2 * Intel Merrifield power button support
4 * (C) Copyright 2017 Intel Corporation
6 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; version 2
14 #include <linux/init.h>
15 #include <linux/ioport.h>
16 #include <linux/platform_device.h>
17 #include <linux/sfi.h>
19 #include <asm/intel-mid.h>
20 #include <asm/intel_scu_ipc.h>
22 static struct resource mrfld_power_btn_resources[] = {
24 .flags = IORESOURCE_IRQ,
28 static struct platform_device mrfld_power_btn_dev = {
29 .name = "msic_power_btn",
30 .id = PLATFORM_DEVID_NONE,
31 .num_resources = ARRAY_SIZE(mrfld_power_btn_resources),
32 .resource = mrfld_power_btn_resources,
35 static int mrfld_power_btn_scu_status_change(struct notifier_block *nb,
36 unsigned long code, void *data)
38 if (code == SCU_DOWN) {
39 platform_device_unregister(&mrfld_power_btn_dev);
43 return platform_device_register(&mrfld_power_btn_dev);
46 static struct notifier_block mrfld_power_btn_scu_notifier = {
47 .notifier_call = mrfld_power_btn_scu_status_change,
50 static int __init register_mrfld_power_btn(void)
52 if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
56 * We need to be sure that the SCU IPC is ready before
57 * PMIC power button device can be registered:
59 intel_scu_notifier_add(&mrfld_power_btn_scu_notifier);
63 arch_initcall(register_mrfld_power_btn);
65 static void __init *mrfld_power_btn_platform_data(void *info)
67 struct resource *res = mrfld_power_btn_resources;
68 struct sfi_device_table_entry *pentry = info;
70 res->start = res->end = pentry->irq;
74 static const struct devs_id mrfld_power_btn_dev_id __initconst = {
75 .name = "bcove_power_btn",
76 .type = SFI_DEV_TYPE_IPC,
79 .get_platform_data = &mrfld_power_btn_platform_data,
82 sfi_device(mrfld_power_btn_dev_id);