aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-02-20 22:53:55 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-20 22:53:55 -0500
commit2ef2d7477549c85b84b24b155baa798650cbf90b (patch)
tree49b9f1521ff078eabb328288afb72ad6bb592c37 /arch/sparc
parent198d2f63a6096fe575b696b13ba61b62c620266f (diff)
sparc64: If 'slot-names' property exist, create sysfs PCI slot information.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/kernel/pci.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 592b03d85167..d7e1cf01dd28 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -1094,3 +1094,78 @@ static int __init pcibios_init(void)
1094 return 0; 1094 return 0;
1095} 1095}
1096subsys_initcall(pcibios_init); 1096subsys_initcall(pcibios_init);
1097
1098#ifdef CONFIG_SYSFS
1099static void __devinit pci_bus_slot_names(struct device_node *node,
1100 struct pci_bus *bus)
1101{
1102 const struct pci_slot_names {
1103 u32 slot_mask;
1104 char names[0];
1105 } *prop;
1106 const char *sp;
1107 int len, i;
1108 u32 mask;
1109
1110 prop = of_get_property(node, "slot-names", &len);
1111 if (!prop)
1112 return;
1113
1114 mask = prop->slot_mask;
1115 sp = prop->names;
1116
1117 if (ofpci_verbose)
1118 printk("PCI: Making slots for [%s] mask[0x%02x]\n",
1119 node->full_name, mask);
1120
1121 i = 0;
1122 while (mask) {
1123 struct pci_slot *pci_slot;
1124 u32 this_bit = 1 << i;
1125
1126 if (!(mask & this_bit)) {
1127 i++;
1128 continue;
1129 }
1130
1131 if (ofpci_verbose)
1132 printk("PCI: Making slot [%s]\n", sp);
1133
1134 pci_slot = pci_create_slot(bus, i, sp, NULL);
1135 if (IS_ERR(pci_slot))
1136 printk(KERN_ERR "PCI: pci_create_slot returned %ld\n",
1137 PTR_ERR(pci_slot));
1138
1139 sp += strlen(sp) + 1;
1140 mask &= ~this_bit;
1141 i++;
1142 }
1143}
1144
1145static int __init of_pci_slot_init(void)
1146{
1147 struct pci_bus *pbus = NULL;
1148
1149 while ((pbus = pci_find_next_bus(pbus)) != NULL) {
1150 struct device_node *node;
1151
1152 if (pbus->self) {
1153 struct dev_archdata *sd = pbus->self->sysdata;
1154
1155 /* PCI->PCI bridge */
1156 node = sd->prom_node;
1157 } else {
1158 struct pci_pbm_info *pbm = pbus->sysdata;
1159
1160 /* Host PCI controller */
1161 node = pbm->op->node;
1162 }
1163
1164 pci_bus_slot_names(node, pbus);
1165 }
1166
1167 return 0;
1168}
1169
1170module_init(of_pci_slot_init);
1171#endif