aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorOliver O'Halloran <oohall@gmail.com>2017-09-15 15:40:48 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-09-15 02:49:27 -0500
commit6d67361b59b70d930144b47f6fbbef956ca2fb40 (patch)
treeeb23994b060466d15686286a8447449534a8470c /core
parentcc41ce944b978395366177a29340facde3f1150b (diff)
downloadskiboot-6d67361b59b70d930144b47f6fbbef956ca2fb40.zip
skiboot-6d67361b59b70d930144b47f6fbbef956ca2fb40.tar.gz
skiboot-6d67361b59b70d930144b47f6fbbef956ca2fb40.tar.bz2
core/pci-slots: Move slot-label construction to a helper
Move this out of the astbmc specific part into a generic helper. This allows us to use it more commonly. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r--core/pci-slot.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/pci-slot.c b/core/pci-slot.c
index 69bdb86..6d3ed6c 100644
--- a/core/pci-slot.c
+++ b/core/pci-slot.c
@@ -212,3 +212,33 @@ struct pci_slot *pci_slot_find(uint64_t id)
slot = pd ? pd->slot : NULL;
return slot;
}
+
+void pci_slot_add_loc(struct pci_slot *slot,
+ struct dt_node *np, const char *label)
+{
+ char tmp[8], loc_code[LOC_CODE_SIZE];
+ struct pci_device *pd = slot->pd;
+ struct phb *phb = slot->phb;
+
+ if (!np)
+ return;
+
+ /* didn't get a real slot label? generate one! */
+ if (!label) {
+ snprintf(tmp, sizeof(tmp), "S%04x%02x", phb->opal_id,
+ pd->secondary_bus);
+ label = tmp;
+ }
+
+ /* Make a <PHB_LOC_CODE>-<LABEL> pair if we have a PHB loc code */
+ if (phb->base_loc_code) {
+ snprintf(loc_code, sizeof(loc_code), "%s-%s",
+ phb->base_loc_code, label);
+ } else {
+ strncpy(loc_code, label, sizeof(loc_code));
+ }
+
+ dt_add_property_string(np, "ibm,slot-label", label);
+ dt_add_property_nstr(np, "ibm,slot-location-code", loc_code,
+ sizeof(loc_code));
+}