blob: 0abe379c6f33f10e93cda7a30dd5b607211d4e2d [file] [log] [blame]
Grant Likely9d24c882009-10-15 10:57:44 -06001#include <linux/of.h> /* linux/of.h gets to determine #include ordering */
Paul Mackerras9b6b5632005-10-06 12:06:20 +10002#ifndef _POWERPC_PROM_H
3#define _POWERPC_PROM_H
4#ifdef __KERNEL__
5
6/*
7 * Definitions for talking to the Open Firmware PROM on
8 * Power Macintosh computers.
9 *
10 * Copyright (C) 1996-2005 Paul Mackerras.
11 *
12 * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19#include <linux/types.h>
Grant Likelyd8678b52009-10-15 10:57:53 -060020#include <linux/of_fdt.h>
Grant Likely6b884a82010-06-08 07:48:09 -060021#include <linux/of_address.h>
Grant Likelye3873442010-06-18 11:09:59 -060022#include <linux/of_irq.h>
Paul Mackerras9b6b5632005-10-06 12:06:20 +100023#include <linux/proc_fs.h>
Andy Fleminga9b14972006-10-19 19:52:26 -050024#include <linux/platform_device.h>
Andrew Morton99ddef92007-02-17 18:17:16 -070025#include <asm/irq.h>
Paul Mackerras9b6b5632005-10-06 12:06:20 +100026#include <asm/atomic.h>
27
Paul Mackerras9b6b5632005-10-06 12:06:20 +100028#define HAVE_ARCH_DEVTREE_FIXUPS
29
Paul Mackerras40ef8cb2005-10-10 22:50:37 +100030#ifdef CONFIG_PPC32
Paul Mackerras9b6b5632005-10-06 12:06:20 +100031/*
32 * PCI <-> OF matching functions
33 * (XXX should these be here?)
34 */
35struct pci_bus;
36struct pci_dev;
37extern int pci_device_from_OF_node(struct device_node *node,
38 u8* bus, u8* devfn);
39extern struct device_node* pci_busdev_to_OF_node(struct pci_bus *, int);
40extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
41extern void pci_create_OF_bus_map(void);
Paul Mackerras40ef8cb2005-10-10 22:50:37 +100042#endif
43
Benjamin Herrenschmidtd1405b82005-11-23 17:53:42 +110044/*
Benjamin Herrenschmidtd2dd4822005-11-30 16:57:28 +110045 * OF address retreival & translation
46 */
47
Benjamin Herrenschmidtd2dd4822005-11-30 16:57:28 +110048/* Translate an OF address block into a CPU physical address
Benjamin Herrenschmidtd1405b82005-11-23 17:53:42 +110049 */
Jeremy Kerra7f67bd2006-07-12 15:35:54 +100050extern u64 of_translate_address(struct device_node *np, const u32 *addr);
Benjamin Herrenschmidtd1405b82005-11-23 17:53:42 +110051
Benjamin Herrenschmidt837c54d2007-12-11 14:48:22 +110052/* Translate a DMA address from device space to CPU space */
53extern u64 of_translate_dma_address(struct device_node *dev,
54 const u32 *in_addr);
55
Benjamin Herrenschmidtd2dd4822005-11-30 16:57:28 +110056/* Extract an address from a device, returns the region size and
57 * the address space flags too. The PCI version uses a BAR number
58 * instead of an absolute index
59 */
Jeremy Kerra7f67bd2006-07-12 15:35:54 +100060extern const u32 *of_get_address(struct device_node *dev, int index,
Benjamin Herrenschmidtd2dd4822005-11-30 16:57:28 +110061 u64 *size, unsigned int *flags);
Anton Vorontsovff1f4ee2008-06-11 08:31:00 +100062#ifdef CONFIG_PCI
Jeremy Kerra7f67bd2006-07-12 15:35:54 +100063extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
Benjamin Herrenschmidtd2dd4822005-11-30 16:57:28 +110064 u64 *size, unsigned int *flags);
Anton Vorontsovff1f4ee2008-06-11 08:31:00 +100065#else
66static inline const u32 *of_get_pci_address(struct device_node *dev,
67 int bar_no, u64 *size, unsigned int *flags)
68{
69 return NULL;
70}
71#endif /* CONFIG_PCI */
Benjamin Herrenschmidtd2dd4822005-11-30 16:57:28 +110072
73/* Get an address as a resource. Note that if your address is
74 * a PIO address, the conversion will fail if the physical address
75 * can't be internally converted to an IO token with
76 * pci_address_to_pio(), that is because it's either called to early
77 * or it can't be matched to any host bridge IO space
78 */
79extern int of_address_to_resource(struct device_node *dev, int index,
80 struct resource *r);
Anton Vorontsovff1f4ee2008-06-11 08:31:00 +100081#ifdef CONFIG_PCI
Benjamin Herrenschmidtd2dd4822005-11-30 16:57:28 +110082extern int of_pci_address_to_resource(struct device_node *dev, int bar,
83 struct resource *r);
Anton Vorontsovff1f4ee2008-06-11 08:31:00 +100084#else
85static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
86 struct resource *r)
87{
88 return -ENOSYS;
89}
90#endif /* CONFIG_PCI */
Benjamin Herrenschmidtd1405b82005-11-23 17:53:42 +110091
Jeremy Kerrd4ad66f2006-05-18 18:05:15 +100092/* Parse the ibm,dma-window property of an OF node into the busno, phys and
93 * size parameters.
94 */
Jeremy Kerra7f67bd2006-07-12 15:35:54 +100095void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
Jeremy Kerrd4ad66f2006-05-18 18:05:15 +100096 unsigned long *busno, unsigned long *phys, unsigned long *size);
97
Michael Ellermanb68239e2006-02-03 19:05:47 +110098extern void kdump_move_device_tree(void);
99
Benjamin Herrenschmidtacf7d762006-06-19 20:33:16 +0200100/* CPU OF node matching */
101struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
102
Nathan Lynche523f722008-12-10 14:46:04 +0000103/* cache lookup */
104struct device_node *of_find_next_cache_node(struct device_node *np);
105
Timur Tabi29cfe6f2007-02-16 12:01:29 -0600106/* Get the MAC address */
107extern const void *of_get_mac_address(struct device_node *np);
Benjamin Herrenschmidtcc9fd712006-07-03 19:35:17 +1000108
Michael Ellerman40681b92006-08-02 11:13:50 +1000109/**
Benjamin Herrenschmidtcc9fd712006-07-03 19:35:17 +1000110 * of_irq_map_pci - Resolve the interrupt for a PCI device
111 * @pdev: the device whose interrupt is to be resolved
112 * @out_irq: structure of_irq filled by this function
113 *
114 * This function resolves the PCI interrupt for a given PCI device. If a
115 * device-node exists for a given pci_dev, it will use normal OF tree
116 * walking. If not, it will implement standard swizzling and walk up the
117 * PCI tree until an device-node is found, at which point it will finish
118 * resolving using the OF tree walking.
119 */
120struct pci_dev;
121extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
122
Paul Mackerras9b6b5632005-10-06 12:06:20 +1000123#endif /* __KERNEL__ */
124#endif /* _POWERPC_PROM_H */