[Skiboot] [PATCH v2 1/8] FSP/LEDS: Add device tree nodes

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Sun Mar 8 21:42:47 AEDT 2015


This patch creates a parent LED device node called 'led' under the root
'opal' device node. This also creates child device nodes under 'led'
corresponding to all individual LEDs on the system whether it is an enclosure
type or a descendant type with their location code as name. The location code
information will be used by the host to enlist and access all the individual
LEDs present on the system. The child LED device nodes also have the properties
'led-types' and 'led-loc' representing what kind of LEDs present on the same
loation code and whether it is an enclosure type LED or a descendant type LED.

Sample device tree output:
       ibm,opal {
	       ..
	       ..
              led {
                    compatible = "ibm,opal-v3-led";
                    phandle = <0x1000006b>;
                    linux,phandle = <0x1000006b>;

		    U78C9.001.RST0027-P1-C1 {
                         led-types = "identify", "fault";
                         led-loc = "descendent";
			 phandle = <0x1000006f>;
			 linux,phandle = <0x1000006f>;
		    };

		    <snip>
	      };
       };

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
Signed-off-by: Anshuman Khandual <khandual at linux.vnet.ibm.com>

---
Changes in v2:
  - Removed redundant 'compatible' property for each node
  - Added device tree documentation for 'led' node

 core/init.c                      |    6 ++++
 doc/device-tree/ibm,opal/led.txt |   33 +++++++++++++++++++++
 hw/fsp/fsp-leds.c                |   60 ++++++++++++++++++++++++++++++++++++++
 include/fsp.h                    |    1 +
 4 files changed, 100 insertions(+)
 create mode 100644 doc/device-tree/ibm,opal/led.txt

diff --git a/core/init.c b/core/init.c
index 1fd8d2e..ad01ddb 100644
--- a/core/init.c
+++ b/core/init.c
@@ -394,6 +394,12 @@ void __noreturn load_and_boot_kernel(bool is_reboot)
 	 */
 	occ_pstates_init();
 
+	/*
+	 * LED related SPCN commands might take a while to
+	 * complete. Call this as late as possible.
+	 */
+	create_led_device_nodes();
+
 	/* Set kernel command line argument if specified */
 #ifdef KERNEL_COMMAND_LINE
 	dt_add_property_string(dt_chosen, "bootargs", KERNEL_COMMAND_LINE);
diff --git a/doc/device-tree/ibm,opal/led.txt b/doc/device-tree/ibm,opal/led.txt
new file mode 100644
index 0000000..faff1e8
--- /dev/null
+++ b/doc/device-tree/ibm,opal/led.txt
@@ -0,0 +1,33 @@
+Service Indicators (LEDS)
+-------------------------
+
+The 'led' node under 'ibm,opal' lists service indicators available in the
+system and their capabilities.
+
+led {
+	compatible = "ibm,opal-v3-led";
+	phandle = <0x1000006b>;
+	linux,phandle = <0x1000006b>;
+
+	U78C9.001.RST0027-P1-C1 {
+		led-types = "identify", "fault";
+		led-loc = "descendent";
+		phandle = <0x1000006f>;
+		linux,phandle = <0x1000006f>;
+	};
+	...
+	...
+};
+
+'compatible' property describes LEDs compatibility.
+
+Each node under 'led' node describes location code of FRU/Enclosure.
+
+The properties under each node:
+
+  led-types : Supported indicators (attention/identify/fault).
+
+  led-loc   : enclosure/descendent(FRU) location code.
+
+These LEDs can be accessed through OPAL_LEDS_{GET/SET}_INDICATOR interfaces.
+Refer to doc/opal-api/opal-led-get-set-114-115.txt for interface details.
diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c
index a03339e..911f853 100644
--- a/hw/fsp/fsp-leds.c
+++ b/hw/fsp/fsp-leds.c
@@ -24,6 +24,7 @@
 #include <spcn.h>
 #include <lock.h>
 #include <errorlog.h>
+#include <opal-api.h>
 
 #include "fsp-leds.h"
 
@@ -1048,6 +1049,65 @@ static struct fsp_client fsp_indicator_client = {
 };
 
 /*
+ * create_led_device_node
+ *
+ * Creates the system parent LED device node and all individual
+ * child LED device nodes under it. This is called right before
+ * starting the payload (Linux) to ensure that the SPCN command
+ * sequence to fetch the LED location code list has been finished
+ * and to have a better chance of creating the deviced nodes.
+ */
+void create_led_device_nodes(void)
+{
+	struct fsp_led_data *led, *next;
+	struct dt_node *pled, *cled;
+
+	if (!fsp_present())
+		return;
+
+	/* Make sure LED list read is completed */
+	while (led_support == LED_STATE_READING)
+		opal_run_pollers();
+
+	if (led_support == LED_STATE_ABSENT) {
+		prlog(PR_WARNING, PREFIX "LED support not available, \
+		      hence device tree nodes will not be created\n");
+		return;
+	}
+
+	if (!opal_node) {
+		prlog(PR_WARNING, PREFIX
+		      "OPAL parent device node not available\n");
+		return;
+	}
+
+	/* LED parent node */
+	pled = dt_new(opal_node, "led");
+	if (!pled) {
+		prlog(PR_WARNING, PREFIX
+		      "Parent device node creation failed\n");
+		return;
+	}
+	dt_add_property_strings(pled, "compatible", "ibm,opal-v3-led");
+
+	/* LED child nodes */
+	list_for_each_safe(&cec_ledq, led, next, link) {
+		cled = dt_new(pled, led->loc_code);
+		if (!cled) {
+			prlog(PR_WARNING, PREFIX
+			      "Child device node creation failed\n");
+			continue;
+		}
+
+		dt_add_property_strings(cled, "led-types", "identify", "fault");
+		if (is_enclosure_led(led->loc_code))
+			dt_add_property_strings(cled, "led-loc", "enclosure");
+		else
+			dt_add_property_strings(cled, "led-loc", "descendent");
+	}
+}
+
+/*
  * Process the received LED data from SPCN
  *
  * Every LED state data is added into the CEC list. If the location
diff --git a/include/fsp.h b/include/fsp.h
index b796bfb..c960469 100644
--- a/include/fsp.h
+++ b/include/fsp.h
@@ -783,6 +783,7 @@ extern void fsp_init_diag(void);
 
 /* LED */
 extern void fsp_led_init(void);
+extern void create_led_device_nodes(void);
 
 /* EPOW */
 extern void fsp_epow_init(void);



More information about the Skiboot mailing list