Skip to content

Commit

Permalink
hdata: Add xscom_to_pcrd()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
oohal authored and stewartsmith committed Sep 15, 2017
1 parent 0abc3af commit 26c19bb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hdata/spira.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 26c19bb

Please sign in to comment.