[Skiboot] [PATCH 09/12] FSP/LED: Get SAI location code from device tree

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Mon Apr 6 17:06:23 AEST 2015


SAI information is available in device tree. This patch parses
device tree to get SAI location code information.

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 hw/fsp/fsp-leds.c  |   70 ++++++++++++++++++++++++++++++++++++++++++++--------
 include/fsp-leds.h |    6 ++++
 2 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c
index 1637000..5aa6f20 100644
--- a/hw/fsp/fsp-leds.c
+++ b/hw/fsp/fsp-leds.c
@@ -77,6 +77,13 @@ static bool spcn_cmd_complete = true;	/* SPCN command complete */
 static u32 last_spcn_cmd;
 static int replay = 0;
 
+/*
+ * FSP controls System Attention Indicator. But it expects hypervisor
+ * keep track of the status and serve get LED state request (both from
+ * Linux and FSP itself)!
+ */
+static struct sai_data sai_data;
+
 /* Forward declaration */
 static void fsp_read_leds_data_complete(struct fsp_msg *msg);
 static int process_led_state_change(void);
@@ -1273,6 +1280,53 @@ success:
 	return rc;
 }
 
+/* Get LED node from device tree */
+static struct dt_node *dt_get_led_node(void)
+{
+	struct dt_node *pled;
+
+	if (!opal_node) {
+		prlog(PR_WARNING, PREFIX
+		      "OPAL parent device node not available\n");
+		return NULL;
+	}
+
+	pled = dt_find_by_path(opal_node, DT_PROPERTY_LED_NODE);
+	if (!pled)
+		prlog(PR_WARNING, PREFIX
+		      "Parent device node not available\n");
+
+	return pled;
+}
+
+/* Get System attention indicator location code from device tree */
+static void dt_get_sai_loc_code(void)
+{
+	struct dt_node *pled, *child;
+	const char *led_type = NULL;
+
+	memset(sai_data.loc_code, 0, LOC_CODE_SIZE);
+
+	pled = dt_get_led_node();
+	if (!pled)
+		return;
+
+	list_for_each(&pled->children, child, list) {
+		led_type = dt_prop_get(child, DT_PROPERTY_LED_TYPES);
+		if (!led_type)
+			continue;
+
+		if (strcmp(led_type, LED_TYPE_ATTENTION))
+			continue;
+
+		memcpy(sai_data.loc_code, child->name, LOC_CODE_SIZE - 1);
+
+		prlog(PR_TRACE, PREFIX "SAI Location code = %s\n",
+		      sai_data.loc_code);
+		return;
+	}
+}
+
 /*
  * create_led_device_node
  *
@@ -1301,19 +1355,10 @@ void create_led_device_nodes(void)
 		return;
 	}
 
-	if (!opal_node) {
-		prlog(PR_WARNING, PREFIX
-		      "OPAL parent device node not available\n");
-		return;
-	}
-
 	/* Get LED node */
-	pled = dt_find_by_path(opal_node, DT_PROPERTY_LED_NODE);
-	if (!pled) {
-		prlog(PR_WARNING, PREFIX
-		      "Parent device node not available\n");
+	pled = dt_get_led_node();
+	if (!pled)
 		return;
-	}
 
 	dt_add_property_strings(pled, "compatible", DT_PROPERTY_LED_COMPATIBLE);
 
@@ -1672,6 +1717,9 @@ void fsp_led_init(void)
 	fsp_leds_query_spcn();
 	prlog(PR_TRACE, PREFIX "Init completed\n");
 
+	/* Get System attention indicator state */
+	dt_get_sai_loc_code();
+
 	/* Handle FSP initiated async LED commands */
 	fsp_register_client(&fsp_indicator_client, FSP_MCLASS_INDICATOR);
 	prlog(PR_TRACE, PREFIX "FSP async command client registered\n");
diff --git a/include/fsp-leds.h b/include/fsp-leds.h
index 2b8ed98..1b99ffc 100644
--- a/include/fsp-leds.h
+++ b/include/fsp-leds.h
@@ -126,6 +126,12 @@ struct led_set_cmd {
 	struct	list_node link;
 };
 
+/* System Attention Indicator */
+struct sai_data {
+	uint8_t	state;
+	char	loc_code[LOC_CODE_SIZE];
+};
+
 /* LED commands and state */
 #define LED_COMMAND_FAULT		1
 #define LED_COMMAND_IDENTIFY		0



More information about the Skiboot mailing list