aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver O'Halloran <oohall@gmail.com>2017-09-15 15:40:56 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-09-15 02:49:27 -0500
commit26c19bb8967b9d5b95181e1e615fc23574dad431 (patch)
treecdf8df18f9d6aa6b8f5aa2062c4bf30d4ddd45c2
parent0abc3af7e8f607aa2fe6bffda9bc072e86126bc9 (diff)
downloadskiboot-26c19bb8967b9d5b95181e1e615fc23574dad431.zip
skiboot-26c19bb8967b9d5b95181e1e615fc23574dad431.tar.gz
skiboot-26c19bb8967b9d5b95181e1e615fc23574dad431.tar.bz2
hdata: Add xscom_to_pcrd()
Iterating the SPPCRD structures (per chip data) is a fairly common operation in the HDAT parser. Iterating the tuples directly is somewhat irritating since we need to check for disabled chips, etc on every pass. A better way to handle this is to iterate throught he xscom nodes (generated from the SPPCRD data) and map from the xscom node to the originating structure. This patch adds a function to do that. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--hdata/spira.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/hdata/spira.c b/hdata/spira.c
index b58be7c..240f344 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -290,6 +290,42 @@ static struct dt_node *add_xscom_node(uint64_t base, uint32_t hw_id,
return node;
}
+/*
+ * Given a xscom@ node this will return a pointer into the SPPCRD
+ * structure corresponding to that node
+ */
+#define GET_HDIF_HDR -1
+static const void *xscom_to_pcrd(struct dt_node *xscom, int idata_index)
+{
+ struct spira_ntuple *t = &spira.ntuples.proc_chip;
+ const struct HDIF_common_hdr *hdif;
+ const void *idata;
+ unsigned int size;
+ uint32_t i;
+ void *base;
+
+ i = dt_prop_get_u32_def(xscom, DT_PRIVATE "sppcrd-index", 0xffffffff);
+ if (i == 0xffffffff)
+ return NULL;
+
+ base = get_hdif(t, "SPPCRD");
+ assert(base);
+ assert(i < be16_to_cpu(t->act_cnt));
+
+ hdif = base + i * be32_to_cpu(t->alloc_len);
+ if (!hdif)
+ return NULL;
+
+ if (idata_index == GET_HDIF_HDR)
+ return hdif;
+
+ idata = HDIF_get_idata(hdif, idata_index, &size);
+ if (!idata || !size)
+ return NULL;
+
+ return idata;
+}
+
struct dt_node *find_xscom_for_chip(uint32_t chip_id)
{
struct dt_node *node;
@@ -447,6 +483,9 @@ static bool add_xscom_sppcrd(uint64_t xscom_base)
if (!np)
continue;
+
+ dt_add_property_cells(np, DT_PRIVATE "sppcrd-index", i);
+
version = be16_to_cpu(hdif->version);
/* Version 0A has additional OCC related stuff */