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 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 #ifdef CONFIG_PCI 74b8b572e1SStephen Rothwell extern int of_pci_address_to_resource(struct device_node *dev, int bar, 75b8b572e1SStephen Rothwell struct resource *r); 76b8b572e1SStephen Rothwell #else 77b8b572e1SStephen Rothwell static inline int of_pci_address_to_resource(struct device_node *dev, int bar, 78b8b572e1SStephen Rothwell struct resource *r) 79b8b572e1SStephen Rothwell { 80b8b572e1SStephen Rothwell return -ENOSYS; 81b8b572e1SStephen Rothwell } 82b8b572e1SStephen Rothwell #endif /* CONFIG_PCI */ 83b8b572e1SStephen Rothwell 84*1f5bef30SGrant Likely #ifdef CONFIG_PCI 85*1f5bef30SGrant Likely extern unsigned long pci_address_to_pio(phys_addr_t address); 86*1f5bef30SGrant Likely #else 87*1f5bef30SGrant Likely static inline unsigned long pci_address_to_pio(phys_addr_t address) 88*1f5bef30SGrant Likely { 89*1f5bef30SGrant Likely return (unsigned long)-1; 90*1f5bef30SGrant Likely } 91*1f5bef30SGrant Likely #endif /* CONFIG_PCI */ 92*1f5bef30SGrant Likely 93b8b572e1SStephen Rothwell /* Parse the ibm,dma-window property of an OF node into the busno, phys and 94b8b572e1SStephen Rothwell * size parameters. 95b8b572e1SStephen Rothwell */ 96b8b572e1SStephen Rothwell void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, 97b8b572e1SStephen Rothwell unsigned long *busno, unsigned long *phys, unsigned long *size); 98b8b572e1SStephen Rothwell 99b8b572e1SStephen Rothwell extern void kdump_move_device_tree(void); 100b8b572e1SStephen Rothwell 101b8b572e1SStephen Rothwell /* CPU OF node matching */ 102b8b572e1SStephen Rothwell struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); 103b8b572e1SStephen Rothwell 104e523f723SNathan Lynch /* cache lookup */ 105e523f723SNathan Lynch struct device_node *of_find_next_cache_node(struct device_node *np); 106e523f723SNathan Lynch 107b8b572e1SStephen Rothwell /* Get the MAC address */ 108b8b572e1SStephen Rothwell extern const void *of_get_mac_address(struct device_node *np); 109b8b572e1SStephen Rothwell 110b8b572e1SStephen Rothwell /** 111b8b572e1SStephen Rothwell * of_irq_map_pci - Resolve the interrupt for a PCI device 112b8b572e1SStephen Rothwell * @pdev: the device whose interrupt is to be resolved 113b8b572e1SStephen Rothwell * @out_irq: structure of_irq filled by this function 114b8b572e1SStephen Rothwell * 115b8b572e1SStephen Rothwell * This function resolves the PCI interrupt for a given PCI device. If a 116b8b572e1SStephen Rothwell * device-node exists for a given pci_dev, it will use normal OF tree 117b8b572e1SStephen Rothwell * walking. If not, it will implement standard swizzling and walk up the 118b8b572e1SStephen Rothwell * PCI tree until an device-node is found, at which point it will finish 119b8b572e1SStephen Rothwell * resolving using the OF tree walking. 120b8b572e1SStephen Rothwell */ 121b8b572e1SStephen Rothwell struct pci_dev; 122b8b572e1SStephen Rothwell extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); 123b8b572e1SStephen Rothwell 124b8b572e1SStephen Rothwell #endif /* __KERNEL__ */ 125b8b572e1SStephen Rothwell #endif /* _POWERPC_PROM_H */ 126