From af3ad15398b72407954bccca0d9952527e42da05 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Mon, 9 Feb 2004 16:11:44 -0800 Subject: [PATCH] [PATCH] Export OF device path for PCI devices Here's a new version of the patch according to our discussion. This allows the platform to add its own platform files to the sysfs PCI device node through a "pcibios_add_platform_entries()" call. I added an empty pcibios_add_platform_entries() inline to all archs that apparently have PCI and implemented the OF stuff for ppc and ppc64. The name is still "devspec" for now, I doubt it will conflict and that's consistent with our use of the "devspec" name in other places. --- arch/ppc/kernel/pci.c | 23 +++++++++++++++++++++++ arch/ppc64/kernel/pci.c | 22 ++++++++++++++++++++++ drivers/pci/pci-sysfs.c | 3 +++ include/asm-alpha/pci.h | 4 ++++ include/asm-arm/pci.h | 4 ++++ include/asm-h8300/pci.h | 4 ++++ include/asm-i386/pci.h | 5 +++++ include/asm-ia64/pci.h | 4 ++++ include/asm-m68k/pci.h | 4 ++++ include/asm-m68knommu/pci.h | 4 ++++ include/asm-mips/pci.h | 4 ++++ include/asm-parisc/pci.h | 4 ++++ include/asm-ppc/pci.h | 2 ++ include/asm-ppc64/pci.h | 2 ++ include/asm-sh/pci.h | 4 ++++ include/asm-sparc/pci.h | 4 ++++ include/asm-sparc64/pci.h | 4 ++++ include/asm-v850/pci.h | 4 ++++ include/asm-x86_64/pci.h | 4 ++++ 19 files changed, 109 insertions(+) diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c index bb1a292013306..3c57648569d8f 100644 --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c @@ -1022,8 +1022,31 @@ pci_create_OF_bus_map(void) prom_add_property(find_path_device("/"), of_prop); } } + +static ssize_t pci_show_devspec(struct device *dev, char *buf) +{ + struct pci_dev *pdev; + struct device_node *np; + + pdev = to_pci_dev (dev); + np = pci_device_to_OF_node(pdev); + if (np == NULL || np->full_name == NULL) + return 0; + return sprintf(buf, "%s", np->full_name); +} +static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL); + #endif /* CONFIG_PPC_OF */ +/* Add sysfs properties */ +void pcibios_add_platform_entries(struct pci_dev *dev) +{ +#ifdef CONFIG_PPC_OF + device_create_file(&pdev->dev, &dev_attr_devspec); +#endif /* CONFIG_PPC_OF */ +} + + #ifdef CONFIG_PPC_PMAC /* * This set of routines checks for PCI<->PCI bridges that have closed diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c index 2dc7b69b84265..f37fc0aa3f2f0 100644 --- a/arch/ppc64/kernel/pci.c +++ b/arch/ppc64/kernel/pci.c @@ -540,3 +540,25 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, return ret; } + +#ifdef CONFIG_PPC_PSERIES +static ssize_t pci_show_devspec(struct device *dev, char *buf) +{ + struct pci_dev *pdev; + struct device_node *np; + + pdev = to_pci_dev (dev); + np = pci_device_to_OF_node(pdev); + if (np == NULL || np->full_name == NULL) + return 0; + return sprintf(buf, "%s", np->full_name); +} +static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL); +#endif /* CONFIG_PPC_PSERIES */ + +void pcibios_add_platform_entries(struct pci_dev *pdev) +{ +#ifdef CONFIG_PPC_PSERIES + device_create_file(&pdev->dev, &dev_attr_devspec); +#endif /* CONFIG_PPC_PSERIES */ +} diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index fd94569cd9104..bffe34b22a6af 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -180,4 +180,7 @@ void pci_create_sysfs_dev_files (struct pci_dev *pdev) device_create_file (dev, &dev_attr_irq); device_create_file (dev, &dev_attr_resource); sysfs_create_bin_file(&dev->kobj, &pci_config_attr); + + /* add platform-specific attributes */ + pcibios_add_platform_entries(pdev); } diff --git a/include/asm-alpha/pci.h b/include/asm-alpha/pci.h index faeee03035188..8eba57310ad24 100644 --- a/include/asm-alpha/pci.h +++ b/include/asm-alpha/pci.h @@ -208,6 +208,10 @@ static inline int pci_name_bus(char *name, struct pci_bus *bus) return 0; } +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __KERNEL__ */ /* Values for the `which' argument to sys_pciconfig_iobase. */ diff --git a/include/asm-arm/pci.h b/include/asm-arm/pci.h index 5280c8fa574dc..6456092a5ab8d 100644 --- a/include/asm-arm/pci.h +++ b/include/asm-arm/pci.h @@ -186,6 +186,10 @@ extern void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, struct resource *res); +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __KERNEL__ */ #endif diff --git a/include/asm-h8300/pci.h b/include/asm-h8300/pci.h index f4813f0a9021d..d032729b19df4 100644 --- a/include/asm-h8300/pci.h +++ b/include/asm-h8300/pci.h @@ -22,4 +22,8 @@ extern inline void pcibios_penalize_isa_irq(int irq) #define PCI_DMA_BUS_IS_PHYS (1) +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* _ASM_H8300_PCI_H */ diff --git a/include/asm-i386/pci.h b/include/asm-i386/pci.h index 83aede6ce5952..909a2c1528625 100644 --- a/include/asm-i386/pci.h +++ b/include/asm-i386/pci.h @@ -89,6 +89,11 @@ pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, enum pci_mmap_state mmap_state, int write_combine); + +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __KERNEL__ */ /* implement the pci_ DMA API in terms of the generic device dma_ one */ diff --git a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h index 42f66dda432bb..cbf5c0d9529cd 100644 --- a/include/asm-ia64/pci.h +++ b/include/asm-ia64/pci.h @@ -112,6 +112,10 @@ static inline int pci_name_bus(char *name, struct pci_bus *bus) return 0; } +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + /* generic pci stuff */ #include diff --git a/include/asm-m68k/pci.h b/include/asm-m68k/pci.h index 57e1487bac3f3..9e7d79ab5d13c 100644 --- a/include/asm-m68k/pci.h +++ b/include/asm-m68k/pci.h @@ -54,4 +54,8 @@ static inline void pcibios_penalize_isa_irq(int irq) */ #define PCI_DMA_BUS_IS_PHYS (1) +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* _ASM_M68K_PCI_H */ diff --git a/include/asm-m68knommu/pci.h b/include/asm-m68knommu/pci.h index a99ce768f4a68..e04c77e1184da 100644 --- a/include/asm-m68knommu/pci.h +++ b/include/asm-m68knommu/pci.h @@ -30,6 +30,10 @@ static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask) */ #define pci_dac_dma_supported(pci_dev, mask) (0) +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* CONFIG_COMEMPCI */ #endif /* M68KNOMMU_PCI_H */ diff --git a/include/asm-mips/pci.h b/include/asm-mips/pci.h index 3943c111647ea..75a2b5536bb03 100644 --- a/include/asm-mips/pci.h +++ b/include/asm-mips/pci.h @@ -120,6 +120,10 @@ static inline void pci_dac_dma_sync_single(struct pci_dev *pdev, dma_cache_wback_inv(addr, len); } +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __KERNEL__ */ /* implement the pci_ DMA API in terms of the generic device dma_ one */ diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h index d5dca01282f09..6d803a9e8967f 100644 --- a/include/asm-parisc/pci.h +++ b/include/asm-parisc/pci.h @@ -196,4 +196,8 @@ extern void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, struct resource *res); +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __ASM_PARISC_PCI_H */ diff --git a/include/asm-ppc/pci.h b/include/asm-ppc/pci.h index 16d6175082426..0228e6e40e05c 100644 --- a/include/asm-ppc/pci.h +++ b/include/asm-ppc/pci.h @@ -282,6 +282,8 @@ extern void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, struct resource *res); +extern void pcibios_add_platform_entries(struct pci_dev *dev); + #endif /* __KERNEL__ */ #endif /* __PPC_PCI_H */ diff --git a/include/asm-ppc64/pci.h b/include/asm-ppc64/pci.h index 60d3832dd9344..835b882fb18dc 100644 --- a/include/asm-ppc64/pci.h +++ b/include/asm-ppc64/pci.h @@ -152,6 +152,8 @@ pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus); extern int pci_read_irq_line(struct pci_dev *dev); +extern void pcibios_add_platform_entries(struct pci_dev *dev); + #endif /* __KERNEL__ */ #endif /* __PPC64_PCI_H */ diff --git a/include/asm-sh/pci.h b/include/asm-sh/pci.h index fe2c08b2e7cdf..b16a62e61771d 100644 --- a/include/asm-sh/pci.h +++ b/include/asm-sh/pci.h @@ -256,6 +256,10 @@ extern void pcibios_fixup_irqs(void); extern int pciauto_assign_resources(int busno, struct pci_channel *hose); #endif +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __KERNEL__ */ /* generic pci stuff */ diff --git a/include/asm-sparc/pci.h b/include/asm-sparc/pci.h index e97afc5a44db5..e78d2cbf04268 100644 --- a/include/asm-sparc/pci.h +++ b/include/asm-sparc/pci.h @@ -141,6 +141,10 @@ extern inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask) #define pci_dac_dma_supported(dev, mask) (0) +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __KERNEL__ */ /* generic pci stuff */ diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h index ea722dcb49d83..e64c30c45b107 100644 --- a/include/asm-sparc64/pci.h +++ b/include/asm-sparc64/pci.h @@ -215,6 +215,10 @@ extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, struct pci_bus_region *region); +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __KERNEL__ */ #endif /* __SPARC64_PCI_H */ diff --git a/include/asm-v850/pci.h b/include/asm-v850/pci.h index 81addb7df017e..e3a33920e6932 100644 --- a/include/asm-v850/pci.h +++ b/include/asm-v850/pci.h @@ -76,4 +76,8 @@ extern void pci_free_consistent (struct pci_dev *pdev, size_t size, void *cpu_addr, dma_addr_t dma_addr); +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __V850_PCI_H__ */ diff --git a/include/asm-x86_64/pci.h b/include/asm-x86_64/pci.h index 6feb36107d64f..1ba95e06f32f2 100644 --- a/include/asm-x86_64/pci.h +++ b/include/asm-x86_64/pci.h @@ -263,6 +263,10 @@ pci_dac_dma_sync_single(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, enum pci_mmap_state mmap_state, int write_combine); +static inline void pcibios_add_platform_entries(struct pci_dev *dev) +{ +} + #endif /* __KERNEL__ */ /* generic pci stuff */ -- 2.53.0