diff mbox

[15/15] FSP/LED: Handle SA indicator update notification

Message ID 20150320121110.29915.29061.stgit@localhost.localdomain
State Superseded
Headers show

Commit Message

Vasant Hegde March 20, 2015, 12:11 p.m. UTC
FSP sends SA indicator update notification via sys param update.
Use that info to update cached indicator state.

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
---
 hw/fsp/fsp-leds.c      |   24 ++++++++++++++++++++++++
 include/fsp-sysparam.h |    1 +
 2 files changed, 25 insertions(+)
diff mbox

Patch

diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c
index 1438ea7..8e15459 100644
--- a/hw/fsp/fsp-leds.c
+++ b/hw/fsp/fsp-leds.c
@@ -28,6 +28,8 @@ 
 #include <opal.h>
 #include <opal-msg.h>
 #include <fsp-leds.h>
+#include <fsp-sysparam.h>
+
 
 /* LED prefix */
 #define PREFIX		"FSPLED: "
@@ -324,6 +326,24 @@  static void fsp_get_sai(void)
 	}
 }
 
+static void sai_update_notification(uint32_t param_id, int len, void *data)
+{
+	uint32_t *state = data;
+
+	if (param_id != SYS_PARAM_SAI_STATE || len != 4)
+		return;
+
+	if (*state != LED_STATE_ON && *state != LED_STATE_OFF)
+		return;
+
+	/* Update SAI state */
+	lock(&sai_lock);
+	sai_data.state = *state;
+	unlock(&sai_lock);
+
+	prlog(PR_TRACE, PREFIX "SAI updated. New state = 0x%x\n", *state);
+}
+
 
 /*
  * Update both the local LED lists to reflect upon led state changes
@@ -1889,6 +1909,10 @@  void fsp_led_init(void)
 	fsp_register_client(&fsp_indicator_client, FSP_MCLASS_INDICATOR);
 	prlog(PR_TRACE, PREFIX "FSP async command client registered\n");
 
+	/* Register for SAI update notification */
+	sysparam_add_update_notifier(sai_update_notification,
+				     SYS_PARAM_SAI_STATE);
+
 	opal_register(OPAL_LEDS_GET_INDICATOR, fsp_opal_leds_get_ind, 4);
 	opal_register(OPAL_LEDS_SET_INDICATOR, fsp_opal_leds_set_ind, 5);
 	prlog(PR_TRACE, PREFIX "LED OPAL interface registered\n");
diff --git a/include/fsp-sysparam.h b/include/fsp-sysparam.h
index 899e772..e0276cd 100644
--- a/include/fsp-sysparam.h
+++ b/include/fsp-sysparam.h
@@ -24,6 +24,7 @@ 
 #define SYS_PARAM_HMC_MANAGED		0xf0000003
 #define SYS_PARAM_FLASH_POLICY		0xf0000012
 #define SYS_PARAM_NEED_HMC		0xf0000016
+#define SYS_PARAM_SAI_STATE		0xf0000019
 #define SYS_PARAM_FW_LICENSE		0xf000001d
 #define SYS_PARAM_WWPN			0xf0000023
 #define SYS_PARAM_DEF_BOOT_DEV		0xf0000024