diff mbox

[v1,08/11] ibm-fsp/firenze: Nest Alink unit support

Message ID 1433123610-12456-9-git-send-email-maddy@linux.vnet.ibm.com
State Superseded
Headers show

Commit Message

maddy June 1, 2015, 1:53 a.m. UTC
Patch adds support for Nest Alink unit. Alinks connects sockets.

Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
 hw/nest.c      | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 include/nest.h |  3 +++
 2 files changed, 50 insertions(+)
diff mbox

Patch

diff --git a/hw/nest.c b/hw/nest.c
index bc87ec0..df93601 100644
--- a/hw/nest.c
+++ b/hw/nest.c
@@ -151,6 +151,49 @@  int dt_create_ima_chip_powerbus_type( struct dt_node *ima,
 	return 0;
 }
 
+int dt_create_ima_chip_alink_event(struct dt_node *ima,
+					int idx, u32 offset)
+{
+	char ev_name[MAX_NAME_SIZE];
+	const char *unit = "MiB", *scale = "7.629e-6";
+
+	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
+	snprintf(ev_name, MAX_NAME_SIZE, "Alink%d", idx);
+	dt_add_property_cells(ima, ev_name, offset);
+
+	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
+	snprintf(ev_name, MAX_NAME_SIZE, "unit.Alink%d.unit", idx);
+	dt_add_property_string(ima, ev_name, unit);
+
+	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
+	snprintf(ev_name, MAX_NAME_SIZE, "scale.Alink%d.scale", idx);
+	dt_add_property_string(ima, ev_name, scale);
+
+	return 0;
+}
+
+int dt_create_ima_chip_alink_type( struct dt_node *ima,
+			struct ima_catalogue_group_data *gptr, char *name)
+{
+	struct dt_node *type;
+	int idx;
+	u32 offset;
+
+	type = dt_new(ima, name);
+	if (!type) {
+		prlog(PR_DEBUG, "ima %s type creation failed \n", name);
+		return -1;
+	}
+
+	dt_add_property_string(type, "device_type", "nest-ima-unit");
+	for(idx=0;idx < 3; idx++) {
+		offset = get_chip_event_offset(gptr->event_index[idx]);
+		dt_create_ima_chip_alink_event(type, idx, offset);
+	}
+
+	return 0;
+}
+
 /*
  * Wrapper Function to call Corresponding Nest unit functions
  * for event dt creation. Not all the Chip Groups in the Catalog are
@@ -161,6 +204,7 @@  int dt_create_ima_chip_type (struct dt_node *ima,
 {
 	char *name;
 	int rc = -EINVAL;
+	char al[]="Alink_BW";
 
 	name = (char *)malloc(gptr->group_name_len);
 	if (!name)
@@ -173,6 +217,9 @@  int dt_create_ima_chip_type (struct dt_node *ima,
 	} else if (strstr(name, "PowerBus_BW")) {
 		if (dt_create_ima_chip_powerbus_type(ima, gptr,name))
 			goto out;
+	} else if (strstr(name, "A-link_data")) {
+		if (dt_create_ima_chip_alink_type(ima, gptr,al))
+			goto out;
 	} else
 		goto out;
 
diff --git a/include/nest.h b/include/nest.h
index f569998..9a5669c 100644
--- a/include/nest.h
+++ b/include/nest.h
@@ -233,6 +233,9 @@  int dt_create_ima_chip_mcs_event(struct dt_node *,int,u32);
 int dt_create_ima_chip_powerbus_type(struct dt_node *,
 				struct ima_catalogue_group_data *,char *);
 int dt_create_ima_chip_powerbus_event(struct dt_node *,u32, const char *);
+int dt_create_ima_chip_alink_type(struct dt_node *,
+				struct ima_catalogue_group_data *,char *);
+int dt_create_ima_chip_alink_event(struct dt_node *,int,u32);
 void nest_ima_init(void);
 
 #endif	/* __NEST_H__ */