[Skiboot] [PATCH v7 5/9] Create device tree for each nest unit

Madhavan Srinivasan maddy at linux.vnet.ibm.com
Tue Mar 1 21:40:29 AEDT 2016


Code to loop all the supported nest units and
create device tree nodes for each.

Also empty dt_create_nest_unit() added which
will be used in subsequent patches.

Signed-off-by: Madhavan Srinivasan <maddy at linux.vnet.ibm.com>
---
 hw/nest.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/hw/nest.c b/hw/nest.c
index 71ef52211db5..6802b50f7690 100644
--- a/hw/nest.c
+++ b/hw/nest.c
@@ -58,6 +58,36 @@ struct catalog_grp_to_dt_node dev_grp_map[NEST_DT_DEVICE_MAX];
  */
 struct nest_catalog_page_0 *page0_desc;
 
+static struct dt_node *
+dt_add_device_node(struct dt_node *ptr, const char *name)
+{
+	struct dt_node *type=NULL;
+
+	type = dt_new(ptr, name);
+	if (!type) {
+		prlog(PR_ERR, "nest_counters: %s type creation failed\n", name);
+		return type;
+	}
+
+	dt_add_property_strings(type, "compatible", "ibm,nest-counters-chip");
+	dt_add_property_cells(type, "#address-cells", 1);
+	dt_add_property_cells(type, "#size-cells", 1);
+	dt_add_property(type, "ranges", NULL, 0);
+
+	return type;
+}
+
+/*
+ * Wrapper function to call corresponding nest unit functions
+ * for event dt creation. Not all the chip groups in the catalog are
+ * supported at this point.
+ */
+static int
+dt_create_nest_unit(struct dt_node *ima,
+				struct nest_catalog_group_data *gptr, int id)
+{
+}
+
 static void add_grp_to_nest_unit_table(struct nest_catalog_group_data *gptr)
 {
 	int i, rc, unit, cnt;
@@ -90,6 +120,7 @@ static int detect_nest_units(struct dt_node *ima)
 	struct nest_catalog_group_data *group;
 	char *marker;
 	int rc = 0;
+	int i,j;
 
 	/*
 	 * Scan all available groups in the chip domain from
@@ -109,6 +140,24 @@ static int detect_nest_units(struct dt_node *ima)
 		group = (struct nest_catalog_group_data *)marker;
 	};
 
+	for (i=0; i<NEST_DT_DEVICE_MAX; i++) {
+		for (j=0; j<dev_grp_map[i].grp_count; j++) {
+			group = (struct nest_catalog_group_data *)
+						dev_grp_map[i].groups[j];
+
+			/*
+			 * Check whether dt node has been created for this
+			 *  nest unit, if not do it.
+			 */
+			if (!dev_grp_map[i].dt_node)
+				dev_grp_map[i].dt_node = dt_add_device_node(ima,
+							dev_grp_map[i].nest_unit_name);
+			rc = dt_create_nest_unit(dev_grp_map[i].dt_node, group, i);
+			if (rc)
+				return rc;
+		}
+	}
+
 	return rc;
 }
 
-- 
1.9.1



More information about the Skiboot mailing list