aboutsummaryrefslogtreecommitdiff
path: root/core/chip.c
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2017-06-08 22:54:17 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-06-14 17:25:25 +1000
commitcbccfaf929264c84dc021e456844eca9446677e7 (patch)
tree83b7ef192d779e92b295d38fe22197b31273e22d /core/chip.c
parent4a271498d99540eeea7602b94ad4a08f60e222a5 (diff)
downloadskiboot-cbccfaf929264c84dc021e456844eca9446677e7.zip
skiboot-cbccfaf929264c84dc021e456844eca9446677e7.tar.gz
skiboot-cbccfaf929264c84dc021e456844eca9446677e7.tar.bz2
chip: Factor out chip inititialisation
Move the chip initialisation logic into a function, so we can call it from elsewhere in future. Only change to the logic is that we don't insert the chip into chips[] until we've finished initialising it. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/chip.c')
-rw-r--r--core/chip.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/core/chip.c b/core/chip.c
index 7765545..3550804 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -71,9 +71,35 @@ struct proc_chip *get_chip(uint32_t chip_id)
return chips[chip_id];
}
-void init_chips(void)
+static void init_chip(struct dt_node *dn)
{
struct proc_chip *chip;
+ uint32_t id;
+
+ id = dt_get_chip_id(dn);
+ assert(id < MAX_CHIPS);
+
+ chip = zalloc(sizeof(struct proc_chip));
+ assert(chip);
+
+ chip->id = id;
+ chip->devnode = dn;
+
+ chip->dbob_id = dt_prop_get_u32_def(dn, "ibm,dbob-id", 0xffffffff);
+ chip->pcid = dt_prop_get_u32_def(dn, "ibm,proc-chip-id", 0xffffffff);
+
+ if (dt_prop_get_u32_def(dn, "ibm,occ-functional-state", 0))
+ chip->occ_functional = true;
+ else
+ chip->occ_functional = false;
+
+ list_head_init(&chip->i2cms);
+
+ chips[id] = chip;
+}
+
+void init_chips(void)
+{
struct dt_node *xn;
/* Detect mambo chip */
@@ -106,24 +132,6 @@ void init_chips(void)
/* We walk the chips based on xscom nodes in the tree */
dt_for_each_compatible(dt_root, xn, "ibm,xscom") {
- uint32_t id = dt_get_chip_id(xn);
-
- assert(id < MAX_CHIPS);
-
- chip = zalloc(sizeof(struct proc_chip));
- assert(chip);
- chip->id = id;
- chip->devnode = xn;
- chips[id] = chip;
- chip->dbob_id = dt_prop_get_u32_def(xn, "ibm,dbob-id",
- 0xffffffff);
- chip->pcid = dt_prop_get_u32_def(xn, "ibm,proc-chip-id",
- 0xffffffff);
- if (dt_prop_get_u32_def(xn, "ibm,occ-functional-state", 0))
- chip->occ_functional = true;
- else
- chip->occ_functional = false;
-
- list_head_init(&chip->i2cms);
- };
+ init_chip(xn);
+ }
}