xref: /linux/arch/powerpc/include/asm/prom.h (revision 559e2b7ee7a1c7753d534abcb2742a4775339293)
19d24c888SGrant Likely #include <linux/of.h>	/* linux/of.h gets to determine #include ordering */
2b8b572e1SStephen Rothwell #ifndef _POWERPC_PROM_H
3b8b572e1SStephen Rothwell #define _POWERPC_PROM_H
4b8b572e1SStephen Rothwell #ifdef __KERNEL__
5b8b572e1SStephen Rothwell 
6b8b572e1SStephen Rothwell /*
7b8b572e1SStephen Rothwell  * Definitions for talking to the Open Firmware PROM on
8b8b572e1SStephen Rothwell  * Power Macintosh computers.
9b8b572e1SStephen Rothwell  *
10b8b572e1SStephen Rothwell  * Copyright (C) 1996-2005 Paul Mackerras.
11b8b572e1SStephen Rothwell  *
12b8b572e1SStephen Rothwell  * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
13b8b572e1SStephen Rothwell  *
14b8b572e1SStephen Rothwell  * This program is free software; you can redistribute it and/or
15b8b572e1SStephen Rothwell  * modify it under the terms of the GNU General Public License
16b8b572e1SStephen Rothwell  * as published by the Free Software Foundation; either version
17b8b572e1SStephen Rothwell  * 2 of the License, or (at your option) any later version.
18b8b572e1SStephen Rothwell  */
19b8b572e1SStephen Rothwell #include <linux/types.h>
20d8678b58SGrant Likely #include <linux/of_fdt.h>
216b884a8dSGrant Likely #include <linux/of_address.h>
22e3873444SGrant Likely #include <linux/of_irq.h>
23b8b572e1SStephen Rothwell #include <linux/proc_fs.h>
24b8b572e1SStephen Rothwell #include <linux/platform_device.h>
25b8b572e1SStephen Rothwell #include <asm/irq.h>
26b8b572e1SStephen Rothwell #include <asm/atomic.h>
27b8b572e1SStephen Rothwell 
28b8b572e1SStephen Rothwell #define HAVE_ARCH_DEVTREE_FIXUPS
29b8b572e1SStephen Rothwell 
30b8b572e1SStephen Rothwell #ifdef CONFIG_PPC32
31b8b572e1SStephen Rothwell /*
32b8b572e1SStephen Rothwell  * PCI <-> OF matching functions
33b8b572e1SStephen Rothwell  * (XXX should these be here?)
34b8b572e1SStephen Rothwell  */
35b8b572e1SStephen Rothwell struct pci_bus;
36b8b572e1SStephen Rothwell struct pci_dev;
37b8b572e1SStephen Rothwell extern int pci_device_from_OF_node(struct device_node *node,
38b8b572e1SStephen Rothwell 				   u8* bus, u8* devfn);
39b8b572e1SStephen Rothwell extern struct device_node* pci_busdev_to_OF_node(struct pci_bus *, int);
40b8b572e1SStephen Rothwell extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
41b8b572e1SStephen Rothwell extern void pci_create_OF_bus_map(void);
42b8b572e1SStephen Rothwell #endif
43b8b572e1SStephen Rothwell 
44b8b572e1SStephen Rothwell /*
45b8b572e1SStephen Rothwell  * OF address retreival & translation
46b8b572e1SStephen Rothwell  */
47b8b572e1SStephen Rothwell 
48b8b572e1SStephen Rothwell /* Translate a DMA address from device space to CPU space */
49b8b572e1SStephen Rothwell extern u64 of_translate_dma_address(struct device_node *dev,
50b8b572e1SStephen Rothwell 				    const u32 *in_addr);
51b8b572e1SStephen Rothwell 
52b8b572e1SStephen Rothwell /* Extract an address from a device, returns the region size and
53b8b572e1SStephen Rothwell  * the address space flags too. The PCI version uses a BAR number
54b8b572e1SStephen Rothwell  * instead of an absolute index
55b8b572e1SStephen Rothwell  */
56b8b572e1SStephen Rothwell extern const u32 *of_get_address(struct device_node *dev, int index,
57b8b572e1SStephen Rothwell 			   u64 *size, unsigned int *flags);
58b8b572e1SStephen Rothwell #ifdef CONFIG_PCI
59b8b572e1SStephen Rothwell extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
60b8b572e1SStephen Rothwell 			       u64 *size, unsigned int *flags);
61b8b572e1SStephen Rothwell #else
62b8b572e1SStephen Rothwell static inline const u32 *of_get_pci_address(struct device_node *dev,
63b8b572e1SStephen Rothwell 		int bar_no, u64 *size, unsigned int *flags)
64b8b572e1SStephen Rothwell {
65b8b572e1SStephen Rothwell 	return NULL;
66b8b572e1SStephen Rothwell }
67b8b572e1SStephen Rothwell #endif /* CONFIG_PCI */
68b8b572e1SStephen Rothwell 
69b8b572e1SStephen Rothwell #ifdef CONFIG_PCI
70b8b572e1SStephen Rothwell extern int of_pci_address_to_resource(struct device_node *dev, int bar,
71b8b572e1SStephen Rothwell 				      struct resource *r);
72b8b572e1SStephen Rothwell #else
73b8b572e1SStephen Rothwell static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
74b8b572e1SStephen Rothwell 		struct resource *r)
75b8b572e1SStephen Rothwell {
76b8b572e1SStephen Rothwell 	return -ENOSYS;
77b8b572e1SStephen Rothwell }
78b8b572e1SStephen Rothwell #endif /* CONFIG_PCI */
79b8b572e1SStephen Rothwell 
801f5bef30SGrant Likely #ifdef CONFIG_PCI
811f5bef30SGrant Likely extern unsigned long pci_address_to_pio(phys_addr_t address);
821f5bef30SGrant Likely #else
831f5bef30SGrant Likely static inline unsigned long pci_address_to_pio(phys_addr_t address)
841f5bef30SGrant Likely {
851f5bef30SGrant Likely 	return (unsigned long)-1;
861f5bef30SGrant Likely }
871f5bef30SGrant Likely #endif	/* CONFIG_PCI */
881f5bef30SGrant Likely 
89b8b572e1SStephen Rothwell /* Parse the ibm,dma-window property of an OF node into the busno, phys and
90b8b572e1SStephen Rothwell  * size parameters.
91b8b572e1SStephen Rothwell  */
92b8b572e1SStephen Rothwell void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
93b8b572e1SStephen Rothwell 		unsigned long *busno, unsigned long *phys, unsigned long *size);
94b8b572e1SStephen Rothwell 
95b8b572e1SStephen Rothwell extern void kdump_move_device_tree(void);
96b8b572e1SStephen Rothwell 
97b8b572e1SStephen Rothwell /* CPU OF node matching */
98b8b572e1SStephen Rothwell struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
99b8b572e1SStephen Rothwell 
100e523f723SNathan Lynch /* cache lookup */
101e523f723SNathan Lynch struct device_node *of_find_next_cache_node(struct device_node *np);
102e523f723SNathan Lynch 
103b8b572e1SStephen Rothwell /* Get the MAC address */
104b8b572e1SStephen Rothwell extern const void *of_get_mac_address(struct device_node *np);
105b8b572e1SStephen Rothwell 
106*559e2b7eSGrant Likely #ifdef CONFIG_NUMA
107*559e2b7eSGrant Likely extern int of_node_to_nid(struct device_node *device);
108*559e2b7eSGrant Likely #else
109*559e2b7eSGrant Likely static inline int of_node_to_nid(struct device_node *device) { return 0; }
110*559e2b7eSGrant Likely #endif
111*559e2b7eSGrant Likely #define of_node_to_nid of_node_to_nid
112*559e2b7eSGrant Likely 
113b8b572e1SStephen Rothwell /**
114b8b572e1SStephen Rothwell  * of_irq_map_pci - Resolve the interrupt for a PCI device
115b8b572e1SStephen Rothwell  * @pdev:	the device whose interrupt is to be resolved
116b8b572e1SStephen Rothwell  * @out_irq:	structure of_irq filled by this function
117b8b572e1SStephen Rothwell  *
118b8b572e1SStephen Rothwell  * This function resolves the PCI interrupt for a given PCI device. If a
119b8b572e1SStephen Rothwell  * device-node exists for a given pci_dev, it will use normal OF tree
120b8b572e1SStephen Rothwell  * walking. If not, it will implement standard swizzling and walk up the
121b8b572e1SStephen Rothwell  * PCI tree until an device-node is found, at which point it will finish
122b8b572e1SStephen Rothwell  * resolving using the OF tree walking.
123b8b572e1SStephen Rothwell  */
124b8b572e1SStephen Rothwell struct pci_dev;
125b8b572e1SStephen Rothwell extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
126b8b572e1SStephen Rothwell 
127129ac799SGrant Likely extern void of_instantiate_rtc(void);
128129ac799SGrant Likely 
129b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
130b8b572e1SStephen Rothwell #endif /* _POWERPC_PROM_H */
131