[Skiboot] [PATCH 04/14] astbmc: Add methods for handing DT based slots
Oliver O'Halloran
oohall at gmail.com
Fri Sep 15 15:40:49 AEST 2017
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
platforms/astbmc/astbmc.h | 1 +
platforms/astbmc/slots.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/platforms/astbmc/astbmc.h b/platforms/astbmc/astbmc.h
index d538f97538dc..88eb43f1f111 100644
--- a/platforms/astbmc/astbmc.h
+++ b/platforms/astbmc/astbmc.h
@@ -54,5 +54,6 @@ extern void check_all_slot_table(void);
extern void slot_table_init(const struct slot_table_entry *top_table);
extern void slot_table_get_slot_info(struct phb *phb, struct pci_device * pd);
+void dt_slot_get_slot_info(struct phb *phb, struct pci_device *pd);
#endif /* __ASTBMC_H */
diff --git a/platforms/astbmc/slots.c b/platforms/astbmc/slots.c
index 5de51209ed59..a5bd50ee8212 100644
--- a/platforms/astbmc/slots.c
+++ b/platforms/astbmc/slots.c
@@ -124,6 +124,54 @@ void slot_table_get_slot_info(struct phb *phb, struct pci_device *pd)
slot->data = (void *)ent;
}
+static void dt_slot_add_properties(struct pci_slot *slot,
+ struct dt_node *np)
+{
+ struct dt_node *slot_np = slot->data;
+ const char *label = NULL;
+
+ if (slot_np)
+ label = dt_prop_get_def(slot_np, "ibm,slot-label", NULL);
+
+ pci_slot_add_loc(slot, np, label);
+}
+
+void dt_slot_get_slot_info(struct phb *phb, struct pci_device *pd)
+{
+ struct dt_node *slot_np;
+ struct pci_slot *slot;
+ const char *name = NULL;
+ bool pluggable = false;
+
+ if (!pd || pd->slot)
+ return;
+
+ slot_np = map_pci_dev_to_slot(phb, pd);
+ if (slot_np) {
+ pluggable = dt_has_node_property(slot_np,
+ "ibm,pluggable", NULL);
+ name = dt_prop_get_def(slot_np, "ibm,slot-label", NULL);
+ }
+
+ if (!slot_np || !name) {
+ slot = pcie_slot_create_dynamic(phb, pd);
+ if (slot) {
+ slot->ops.add_properties = dt_slot_add_properties;
+ slot->pluggable = true;
+ slot->data = (void *)slot_np;
+ }
+
+ return;
+ }
+
+ slot = pcie_slot_create(phb, pd);
+ assert(slot);
+
+ slot->ops.add_properties = dt_slot_add_properties;
+ slot->pluggable = pluggable;
+ slot->data = (void *)slot_np;
+}
+
static int __pci_find_dev_by_location(struct phb *phb,
struct pci_device *pd, void *userdata)
{
--
2.9.5
More information about the Skiboot
mailing list