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> 21*6b884a8dSGrant 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 an OF address block into a CPU physical address 49b8b572e1SStephen Rothwell */ 50b8b572e1SStephen Rothwell extern u64 of_translate_address(struct device_node *np, const u32 *addr); 51b8b572e1SStephen Rothwell 52b8b572e1SStephen Rothwell /* Translate a DMA address from device space to CPU space */ 53b8b572e1SStephen Rothwell extern u64 of_translate_dma_address(struct device_node *dev, 54b8b572e1SStephen Rothwell const u32 *in_addr); 55b8b572e1SStephen Rothwell 56b8b572e1SStephen Rothwell /* Extract an address from a device, returns the region size and 57b8b572e1SStephen Rothwell * the address space flags too. The PCI version uses a BAR number 58b8b572e1SStephen Rothwell * instead of an absolute index 59b8b572e1SStephen Rothwell */ 60b8b572e1SStephen Rothwell extern const u32 *of_get_address(struct device_node *dev, int index, 61b8b572e1SStephen Rothwell u64 *size, unsigned int *flags); 62b8b572e1SStephen Rothwell #ifdef CONFIG_PCI 63b8b572e1SStephen Rothwell extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no, 64b8b572e1SStephen Rothwell u64 *size, unsigned int *flags); 65b8b572e1SStephen Rothwell #else 66b8b572e1SStephen Rothwell static inline const u32 *of_get_pci_address(struct device_node *dev, 67b8b572e1SStephen Rothwell int bar_no, u64 *size, unsigned int *flags) 68b8b572e1SStephen Rothwell { 69b8b572e1SStephen Rothwell return NULL; 70b8b572e1SStephen Rothwell } 71b8b572e1SStephen Rothwell #endif /* CONFIG_PCI */ 72b8b572e1SStephen Rothwell 73b8b572e1SStephen Rothwell /* Get an address as a resource. Note that if your address is 74b8b572e1SStephen Rothwell * a PIO address, the conversion will fail if the physical address 75b8b572e1SStephen Rothwell * can't be internally converted to an IO token with 76b8b572e1SStephen Rothwell * pci_address_to_pio(), that is because it's either called to early 77b8b572e1SStephen Rothwell * or it can't be matched to any host bridge IO space 78b8b572e1SStephen Rothwell */ 79b8b572e1SStephen Rothwell extern int of_address_to_resource(struct device_node *dev, int index, 80b8b572e1SStephen Rothwell struct resource *r); 81b8b572e1SStephen Rothwell #ifdef CONFIG_PCI 82b8b572e1SStephen Rothwell extern int of_pci_address_to_resource(struct device_node *dev, int bar, 83b8b572e1SStephen Rothwell struct resource *r); 84b8b572e1SStephen Rothwell #else 85b8b572e1SStephen Rothwell static inline int of_pci_address_to_resource(struct device_node *dev, int bar, 86b8b572e1SStephen Rothwell struct resource *r) 87b8b572e1SStephen Rothwell { 88b8b572e1SStephen Rothwell return -ENOSYS; 89b8b572e1SStephen Rothwell } 90b8b572e1SStephen Rothwell #endif /* CONFIG_PCI */ 91b8b572e1SStephen Rothwell 92b8b572e1SStephen Rothwell /* Parse the ibm,dma-window property of an OF node into the busno, phys and 93b8b572e1SStephen Rothwell * size parameters. 94b8b572e1SStephen Rothwell */ 95b8b572e1SStephen Rothwell void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, 96b8b572e1SStephen Rothwell unsigned long *busno, unsigned long *phys, unsigned long *size); 97b8b572e1SStephen Rothwell 98b8b572e1SStephen Rothwell extern void kdump_move_device_tree(void); 99b8b572e1SStephen Rothwell 100b8b572e1SStephen Rothwell /* CPU OF node matching */ 101b8b572e1SStephen Rothwell struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); 102b8b572e1SStephen Rothwell 103e523f723SNathan Lynch /* cache lookup */ 104e523f723SNathan Lynch struct device_node *of_find_next_cache_node(struct device_node *np); 105e523f723SNathan Lynch 106b8b572e1SStephen Rothwell /* Get the MAC address */ 107b8b572e1SStephen Rothwell extern const void *of_get_mac_address(struct device_node *np); 108b8b572e1SStephen Rothwell 109b8b572e1SStephen Rothwell /** 110b8b572e1SStephen Rothwell * of_irq_map_pci - Resolve the interrupt for a PCI device 111b8b572e1SStephen Rothwell * @pdev: the device whose interrupt is to be resolved 112b8b572e1SStephen Rothwell * @out_irq: structure of_irq filled by this function 113b8b572e1SStephen Rothwell * 114b8b572e1SStephen Rothwell * This function resolves the PCI interrupt for a given PCI device. If a 115b8b572e1SStephen Rothwell * device-node exists for a given pci_dev, it will use normal OF tree 116b8b572e1SStephen Rothwell * walking. If not, it will implement standard swizzling and walk up the 117b8b572e1SStephen Rothwell * PCI tree until an device-node is found, at which point it will finish 118b8b572e1SStephen Rothwell * resolving using the OF tree walking. 119b8b572e1SStephen Rothwell */ 120b8b572e1SStephen Rothwell struct pci_dev; 121b8b572e1SStephen Rothwell extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); 122b8b572e1SStephen Rothwell 123b8b572e1SStephen Rothwell #endif /* __KERNEL__ */ 124b8b572e1SStephen Rothwell #endif /* _POWERPC_PROM_H */ 125