Skip to content

Commit 42c2544

Browse files
Alan CoxSamuel Ortiz
authored andcommitted
x86, mrst: Some drivers need to known when an SCU is available
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. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 1f5a371 commit 42c2544

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎arch/x86/include/asm/intel_scu_ipc.h‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef _ASM_X86_INTEL_SCU_IPC_H_
22
#define _ASM_X86_INTEL_SCU_IPC_H_
33

4+
#include <linux/notifier.h>
5+
46
#define IPCMSG_VRTC 0xFA /* Set vRTC device */
57

68
/* Command id associated with message IPCMSG_VRTC */
@@ -44,4 +46,24 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data);
4446
/* Update FW version */
4547
int intel_scu_ipc_fw_update(u8 *buffer, u32 length);
4648

49+
extern struct blocking_notifier_head intel_scu_notifier;
50+
51+
static inline void intel_scu_notifier_add(struct notifier_block *nb)
52+
{
53+
blocking_notifier_chain_register(&intel_scu_notifier, nb);
54+
}
55+
56+
static inline void intel_scu_notifier_remove(struct notifier_block *nb)
57+
{
58+
blocking_notifier_chain_unregister(&intel_scu_notifier, nb);
59+
}
60+
61+
static inline int intel_scu_notifier_post(unsigned long v, void *p)
62+
{
63+
return blocking_notifier_call_chain(&intel_scu_notifier, v, p);
64+
}
65+
66+
#define SCU_AVAILABLE 1
67+
#define SCU_DOWN 2
68+
4769
#endif

‎arch/x86/platform/mrst/mrst.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/platform_device.h>
2525
#include <linux/irq.h>
2626
#include <linux/module.h>
27+
#include <linux/notifier.h>
2728

2829
#include <asm/setup.h>
2930
#include <asm/mpspec_def.h>
@@ -555,6 +556,9 @@ static void __init intel_scu_i2c_device_register(int bus,
555556
i2c_devs[i2c_next_dev++] = new_dev;
556557
}
557558

559+
BLOCKING_NOTIFIER_HEAD(intel_scu_notifier);
560+
EXPORT_SYMBOL_GPL(intel_scu_notifier);
561+
558562
/* Called by IPC driver */
559563
void intel_scu_devices_create(void)
560564
{
@@ -579,6 +583,7 @@ void intel_scu_devices_create(void)
579583
} else
580584
i2c_register_board_info(i2c_bus[i], i2c_devs[i], 1);
581585
}
586+
intel_scu_notifier_post(SCU_AVAILABLE, 0L);
582587
}
583588
EXPORT_SYMBOL_GPL(intel_scu_devices_create);
584589

@@ -587,6 +592,8 @@ void intel_scu_devices_destroy(void)
587592
{
588593
int i;
589594

595+
intel_scu_notifier_post(SCU_DOWN, 0L);
596+
590597
for (i = 0; i < ipc_next_dev; i++)
591598
platform_device_del(ipc_devs[i]);
592599
}

0 commit comments

Comments
 (0)