@@ -346,6 +346,52 @@ static int64_t fsp_opal_set_param(uint64_t async_token, uint32_t param_id,
return OPAL_ASYNC_COMPLETION;
}
+struct sysparam_notify_entry {
+ struct list_node link;
+ sysparam_update_notify notify;
+};
+
+static LIST_HEAD(sysparam_update_notifiers);
+
+/* Add client to notifier chain */
+void sysparam_add_update_notifier(sysparam_update_notify notify)
+{
+ struct sysparam_notify_entry *entry;
+
+ entry = zalloc(sizeof(struct sysparam_notify_entry));
+ assert(entry);
+
+ entry->notify = notify;
+ list_add_tail(&sysparam_update_notifiers, &entry->link);
+}
+
+/* Remove client from notifier chain */
+void sysparam_del_update_notifier(sysparam_update_notify notify)
+{
+ struct sysparam_notify_entry *entry;
+
+ list_for_each(&sysparam_update_notifiers, entry, link) {
+ if (entry->notify == notify) {
+ list_del(&entry->link);
+ free(entry);
+ return;
+ }
+ }
+}
+
+/* Update notification chain */
+static void sysparam_run_update_notifier(struct fsp_msg *msg)
+{
+ bool ret;
+ struct sysparam_notify_entry *entry;
+
+ list_for_each(&sysparam_update_notifiers, entry, link) {
+ ret = entry->notify(msg);
+ if (ret == true)
+ break;
+ }
+}
+
static bool fsp_sysparam_msg(u32 cmd_sub_mod, struct fsp_msg *msg)
{
struct fsp_msg *rsp;
@@ -356,6 +402,9 @@ static bool fsp_sysparam_msg(u32 cmd_sub_mod, struct fsp_msg *msg)
case FSP_CMD_SP_SPARM_UPD_1:
printf("FSP: Got sysparam update, param ID 0x%x\n",
msg->data.words[0]);
+
+ sysparam_run_update_notifier(msg);
+
rsp = fsp_mkmsg((cmd_sub_mod & 0xffff00) | 0x008000, 0);
if (rsp)
rc = fsp_queue_msg(rsp, fsp_freemsg);
@@ -55,4 +55,16 @@ int fsp_get_sys_param(uint32_t param_id, void *buffer, uint32_t length,
void fsp_sysparam_init(void);
+/*
+ * System parameter update notification.
+ * param_id : parameter id
+ * len : length of data
+ * data : pointer to data
+ */
+typedef bool (*sysparam_update_notify)(struct fsp_msg *msg);
+
+/* Register/unregister for system parameter update notifier chain */
+void sysparam_add_update_notifier(sysparam_update_notify notify);
+void sysparam_del_update_notifier(sysparam_update_notify notify);
+
#endif /* __FSP_SYSPARAM_H */
FSP sends update system parameter notification asynchronously. Presently no one is using this notification. We just ACK this notification. This patch adds notifier chain so that if someone (like LED) is interested in this notification, they can register and get notification. Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Changes in v2: - Updated notifier function so that we can pass fsp_msg structure to clients. --- hw/fsp/fsp-sysparam.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ include/fsp-sysparam.h | 12 ++++++++++++ 2 files changed, 61 insertions(+)