x86, mrst: Some drivers need to known when an SCU is available
authorAlan Cox <alan@linux.intel.com>
Fri, 15 Jul 2011 13:39:19 +0000 (14:39 +0100)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:36:20 +0000 (12:36 -0800)
Add a notifier so that drivers can hook into SCU availability in order to
take actions post initialisation when/if the SCU becomes available.

In the ideal world we wouldn't need this and we could avoid any init
dependancies of this form, but in practice we can't do it for some cases.

Change-Id: I8504ff8fac5e8f3ac680aaf2f5334a8284af70c2
Signed-off-by: Alan Cox <alan@linux.intel.com>
arch/x86/include/asm/intel_scu_ipc.h
arch/x86/platform/mrst/mrst.c

index 9f21f27..a941516 100644 (file)
@@ -1,7 +1,13 @@
 #ifndef _ASM_X86_INTEL_SCU_IPC_H_
 #define  _ASM_X86_INTEL_SCU_IPC_H_
 
-#define IPCMSG_VRTC    0xFA     /* Set vRTC device */
+#include <linux/notifier.h>
+
+#define IPCMSG_WARM_RESET      0xF0
+#define IPCMSG_COLD_RESET      0xF1
+#define IPCMSG_SOFT_RESET      0xF2
+#define IPCMSG_COLD_BOOT       0xF3
+#define IPCMSG_VRTC            0xFA     /* Set vRTC device */
 
 /* Command id associated with message IPCMSG_VRTC */
 #define IPC_CMD_VRTC_SETTIME      1 /* Set time */
@@ -47,4 +53,24 @@ int intel_scu_ipc_fw_update(u8 *buffer, u32 length);
 /* Upgrade FW version on Medfield */
 int intel_scu_ipc_medfw_upgrade(void __user *arg);
 
+extern struct blocking_notifier_head intel_scu_notifier;
+
+static inline void intel_scu_notifier_add(struct notifier_block *nb)
+{
+       blocking_notifier_chain_register(&intel_scu_notifier, nb);
+}
+
+static inline void intel_scu_notifier_remove(struct notifier_block *nb)
+{
+       blocking_notifier_chain_unregister(&intel_scu_notifier, nb);
+}
+
+static inline int intel_scu_notifier_post(unsigned long v, void *p)
+{
+       return blocking_notifier_call_chain(&intel_scu_notifier, v, p);
+}
+
+#define                SCU_AVAILABLE           1
+#define                SCU_DOWN                2
+
 #endif
index 86f72fd..7b5c950 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/irq.h>
 #include <linux/module.h>
+#include <linux/notifier.h>
 
 #include <asm/setup.h>
 #include <asm/mpspec_def.h>
@@ -556,6 +557,9 @@ static void __init intel_scu_i2c_device_register(int bus,
        i2c_devs[i2c_next_dev++] = new_dev;
 }
 
+BLOCKING_NOTIFIER_HEAD(intel_scu_notifier);
+EXPORT_SYMBOL_GPL(intel_scu_notifier);
+
 /* Called by IPC driver */
 void intel_scu_devices_create(void)
 {
@@ -580,6 +584,7 @@ void intel_scu_devices_create(void)
                } else
                        i2c_register_board_info(i2c_bus[i], i2c_devs[i], 1);
        }
+       intel_scu_notifier_post(SCU_AVAILABLE, 0L);
 }
 EXPORT_SYMBOL_GPL(intel_scu_devices_create);
 
@@ -588,6 +593,8 @@ void intel_scu_devices_destroy(void)
 {
        int i;
 
+       intel_scu_notifier_post(SCU_DOWN, 0L);
+
        for (i = 0; i < ipc_next_dev; i++)
                platform_device_del(ipc_devs[i]);
 }