From: Kate Hsuan Date: Fri, 20 Aug 2021 11:04:42 +0000 (+0300) Subject: platform/x86: intel_mrfld_pwrbtn: Move to intel sub-directory X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f51c108d361c1f6f738049c3cc5d52734ea74424;p=linux.git platform/x86: intel_mrfld_pwrbtn: Move to intel sub-directory Move Intel Merrifield power button driver to intel sub-directory to improve readability. Signed-off-by: Kate Hsuan Reviewed-by: Hans de Goede Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210820110458.73018-5-andriy.shevchenko@linux.intel.com Signed-off-by: Hans de Goede --- diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index ba0454450335a..2d6723bb64593 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1159,17 +1159,6 @@ config INTEL_UNCORE_FREQ_CONTROL To compile this driver as a module, choose M here: the module will be called intel-uncore-frequency. -config INTEL_MRFLD_PWRBTN - tristate "Intel Merrifield Basin Cove power button driver" - depends on INTEL_SOC_PMIC_MRFLD - depends on INPUT - help - This option adds a power button driver for Basin Cove PMIC - on Intel Merrifield devices. - - To compile this driver as a module, choose M here: the module - will be called intel_mrfld_pwrbtn. - config INTEL_PMC_CORE tristate "Intel PMC Core driver" depends on PCI diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index bf94af0749f5d..f70c0aa30cdd0 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -127,7 +127,6 @@ obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o obj-$(CONFIG_INTEL_UNCORE_FREQ_CONTROL) += intel-uncore-frequency.o # Intel PMIC / PMC / P-Unit devices -obj-$(CONFIG_INTEL_MRFLD_PWRBTN) += intel_mrfld_pwrbtn.o obj-$(CONFIG_INTEL_PMC_CORE) += intel_pmc_core.o intel_pmc_core_pltdrv.o obj-$(CONFIG_INTEL_PUNIT_IPC) += intel_punit_ipc.o obj-$(CONFIG_INTEL_SCU_IPC) += intel_scu_ipc.o diff --git a/drivers/platform/x86/intel/Kconfig b/drivers/platform/x86/intel/Kconfig index 3792a5492a8a1..9e719db8450c1 100644 --- a/drivers/platform/x86/intel/Kconfig +++ b/drivers/platform/x86/intel/Kconfig @@ -42,4 +42,15 @@ config INTEL_CHTDC_TI_PWRBTN To compile this driver as a module, choose M here: the module will be called intel_chtdc_ti_pwrbtn. +config INTEL_MRFLD_PWRBTN + tristate "Intel Merrifield Basin Cove power button driver" + depends on INTEL_SOC_PMIC_MRFLD + depends on INPUT + help + This option adds a power button driver for Basin Cove PMIC + on Intel Merrifield devices. + + To compile this driver as a module, choose M here: the module + will be called intel_mrfld_pwrbtn. + endif # X86_PLATFORM_DRIVERS_INTEL diff --git a/drivers/platform/x86/intel/Makefile b/drivers/platform/x86/intel/Makefile index 52d7bc0948f3e..4ff755a117704 100644 --- a/drivers/platform/x86/intel/Makefile +++ b/drivers/platform/x86/intel/Makefile @@ -14,3 +14,5 @@ intel_bxtwc_tmu-y := bxtwc_tmu.o obj-$(CONFIG_INTEL_BXTWC_PMIC_TMU) += intel_bxtwc_tmu.o intel_chtdc_ti_pwrbtn-y := chtdc_ti_pwrbtn.o obj-$(CONFIG_INTEL_CHTDC_TI_PWRBTN) += intel_chtdc_ti_pwrbtn.o +intel_mrfld_pwrbtn-y := mrfld_pwrbtn.o +obj-$(CONFIG_INTEL_MRFLD_PWRBTN) += intel_mrfld_pwrbtn.o diff --git a/drivers/platform/x86/intel/mrfld_pwrbtn.c b/drivers/platform/x86/intel/mrfld_pwrbtn.c new file mode 100644 index 0000000000000..d58fea51747e9 --- /dev/null +++ b/drivers/platform/x86/intel/mrfld_pwrbtn.c @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Power-button driver for Basin Cove PMIC + * + * Copyright (c) 2019, Intel Corporation. + * Author: Andy Shevchenko + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BCOVE_PBSTATUS 0x27 +#define BCOVE_PBSTATUS_PBLVL BIT(4) /* 1 - release, 0 - press */ + +static irqreturn_t mrfld_pwrbtn_interrupt(int irq, void *dev_id) +{ + struct input_dev *input = dev_id; + struct device *dev = input->dev.parent; + struct regmap *regmap = dev_get_drvdata(dev); + unsigned int state; + int ret; + + ret = regmap_read(regmap, BCOVE_PBSTATUS, &state); + if (ret) + return IRQ_NONE; + + dev_dbg(dev, "PBSTATUS=0x%x\n", state); + input_report_key(input, KEY_POWER, !(state & BCOVE_PBSTATUS_PBLVL)); + input_sync(input); + + regmap_update_bits(regmap, BCOVE_MIRQLVL1, BCOVE_LVL1_PWRBTN, 0); + return IRQ_HANDLED; +} + +static int mrfld_pwrbtn_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct intel_soc_pmic *pmic = dev_get_drvdata(dev->parent); + struct input_dev *input; + int irq, ret; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + input = devm_input_allocate_device(dev); + if (!input) + return -ENOMEM; + input->name = pdev->name; + input->phys = "power-button/input0"; + input->id.bustype = BUS_HOST; + input->dev.parent = dev; + input_set_capability(input, EV_KEY, KEY_POWER); + ret = input_register_device(input); + if (ret) + return ret; + + dev_set_drvdata(dev, pmic->regmap); + + ret = devm_request_threaded_irq(dev, irq, NULL, mrfld_pwrbtn_interrupt, + IRQF_ONESHOT | IRQF_SHARED, pdev->name, + input); + if (ret) + return ret; + + regmap_update_bits(pmic->regmap, BCOVE_MIRQLVL1, BCOVE_LVL1_PWRBTN, 0); + regmap_update_bits(pmic->regmap, BCOVE_MPBIRQ, BCOVE_PBIRQ_PBTN, 0); + + device_init_wakeup(dev, true); + dev_pm_set_wake_irq(dev, irq); + return 0; +} + +static int mrfld_pwrbtn_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); + return 0; +} + +static const struct platform_device_id mrfld_pwrbtn_id_table[] = { + { .name = "mrfld_bcove_pwrbtn" }, + {} +}; +MODULE_DEVICE_TABLE(platform, mrfld_pwrbtn_id_table); + +static struct platform_driver mrfld_pwrbtn_driver = { + .driver = { + .name = "mrfld_bcove_pwrbtn", + }, + .probe = mrfld_pwrbtn_probe, + .remove = mrfld_pwrbtn_remove, + .id_table = mrfld_pwrbtn_id_table, +}; +module_platform_driver(mrfld_pwrbtn_driver); + +MODULE_DESCRIPTION("Power-button driver for Basin Cove PMIC"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/platform/x86/intel_mrfld_pwrbtn.c b/drivers/platform/x86/intel_mrfld_pwrbtn.c deleted file mode 100644 index d58fea51747e9..0000000000000 --- a/drivers/platform/x86/intel_mrfld_pwrbtn.c +++ /dev/null @@ -1,107 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Power-button driver for Basin Cove PMIC - * - * Copyright (c) 2019, Intel Corporation. - * Author: Andy Shevchenko - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BCOVE_PBSTATUS 0x27 -#define BCOVE_PBSTATUS_PBLVL BIT(4) /* 1 - release, 0 - press */ - -static irqreturn_t mrfld_pwrbtn_interrupt(int irq, void *dev_id) -{ - struct input_dev *input = dev_id; - struct device *dev = input->dev.parent; - struct regmap *regmap = dev_get_drvdata(dev); - unsigned int state; - int ret; - - ret = regmap_read(regmap, BCOVE_PBSTATUS, &state); - if (ret) - return IRQ_NONE; - - dev_dbg(dev, "PBSTATUS=0x%x\n", state); - input_report_key(input, KEY_POWER, !(state & BCOVE_PBSTATUS_PBLVL)); - input_sync(input); - - regmap_update_bits(regmap, BCOVE_MIRQLVL1, BCOVE_LVL1_PWRBTN, 0); - return IRQ_HANDLED; -} - -static int mrfld_pwrbtn_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct intel_soc_pmic *pmic = dev_get_drvdata(dev->parent); - struct input_dev *input; - int irq, ret; - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - - input = devm_input_allocate_device(dev); - if (!input) - return -ENOMEM; - input->name = pdev->name; - input->phys = "power-button/input0"; - input->id.bustype = BUS_HOST; - input->dev.parent = dev; - input_set_capability(input, EV_KEY, KEY_POWER); - ret = input_register_device(input); - if (ret) - return ret; - - dev_set_drvdata(dev, pmic->regmap); - - ret = devm_request_threaded_irq(dev, irq, NULL, mrfld_pwrbtn_interrupt, - IRQF_ONESHOT | IRQF_SHARED, pdev->name, - input); - if (ret) - return ret; - - regmap_update_bits(pmic->regmap, BCOVE_MIRQLVL1, BCOVE_LVL1_PWRBTN, 0); - regmap_update_bits(pmic->regmap, BCOVE_MPBIRQ, BCOVE_PBIRQ_PBTN, 0); - - device_init_wakeup(dev, true); - dev_pm_set_wake_irq(dev, irq); - return 0; -} - -static int mrfld_pwrbtn_remove(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - - dev_pm_clear_wake_irq(dev); - device_init_wakeup(dev, false); - return 0; -} - -static const struct platform_device_id mrfld_pwrbtn_id_table[] = { - { .name = "mrfld_bcove_pwrbtn" }, - {} -}; -MODULE_DEVICE_TABLE(platform, mrfld_pwrbtn_id_table); - -static struct platform_driver mrfld_pwrbtn_driver = { - .driver = { - .name = "mrfld_bcove_pwrbtn", - }, - .probe = mrfld_pwrbtn_probe, - .remove = mrfld_pwrbtn_remove, - .id_table = mrfld_pwrbtn_id_table, -}; -module_platform_driver(mrfld_pwrbtn_driver); - -MODULE_DESCRIPTION("Power-button driver for Basin Cove PMIC"); -MODULE_LICENSE("GPL v2");