From patchwork Thu Aug 24 08:11:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 9919391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C909F603FF for ; Thu, 24 Aug 2017 08:15:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9EC928B48 for ; Thu, 24 Aug 2017 08:15:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEF1228BAB; Thu, 24 Aug 2017 08:15:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27D4228BB6 for ; Thu, 24 Aug 2017 08:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751290AbdHXIMK (ORCPT ); Thu, 24 Aug 2017 04:12:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:48093 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751276AbdHXIL7 (ORCPT ); Thu, 24 Aug 2017 04:11:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4E047ADAA; Thu, 24 Aug 2017 08:11:57 +0000 (UTC) From: Takashi Iwai To: linux-kernel@vger.kernel.org Cc: Lee Jones , Darren Hart , Andy Shevchenko , "Rafael J . Wysocki" , Mika Westerberg , Johannes Stezenbach , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH v2 2/3] platform/x86: Add support for Dollar Cove TI power button Date: Thu, 24 Aug 2017 10:11:40 +0200 Message-Id: <20170824081141.5018-3-tiwai@suse.de> X-Mailer: git-send-email 2.14.0 In-Reply-To: <20170824081141.5018-1-tiwai@suse.de> References: <20170824081141.5018-1-tiwai@suse.de> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This provides a new input driver for supporting the power button on Dollar Cove TI PMIC, found on Cherrytrail-based devices. The patch is based on the original work by Intel, found at: https://github.com/01org/ProductionKernelQuilts Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891 Signed-off-by: Takashi Iwai Reviewed-by: Mika Westerberg Acked-by: Andy Shevchenko --- v1->v2: * Move power-button driver to platform/x86, driver renames accordingly * Add missing wake-irq cleanup to power-button driver drivers/platform/x86/Kconfig | 8 +++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel_dc_ti_pwrbtn.c | 96 +++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 drivers/platform/x86/intel_dc_ti_pwrbtn.c diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 80b87954f6dd..25ab9f6ba533 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1139,6 +1139,14 @@ config SILEAD_DMI with the OS-image for the device. This option supplies the missing information. Enable this for x86 tablets with Silead touchscreens. +config INTEL_DC_TI_PWRBTN + tristate "Dollar Cove TI power button driver" + depends on INTEL_SOC_PMIC_DC_TI + depends on INPUT + help + Say Y here fi you want to have a power button driver for + Dollar Cove TI PMIC. + endif # X86_PLATFORM_DEVICES config PMC_ATOM diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 91cec1751461..1ce5c18d249e 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -83,3 +83,4 @@ obj-$(CONFIG_PMC_ATOM) += pmc_atom.o obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o obj-$(CONFIG_MLX_CPLD_PLATFORM) += mlxcpld-hotplug.o obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o +obj-$(CONFIG_INTEL_DC_TI_PWRBTN) += intel_dc_ti_pwrbtn.o diff --git a/drivers/platform/x86/intel_dc_ti_pwrbtn.c b/drivers/platform/x86/intel_dc_ti_pwrbtn.c new file mode 100644 index 000000000000..1a40f55699fb --- /dev/null +++ b/drivers/platform/x86/intel_dc_ti_pwrbtn.c @@ -0,0 +1,96 @@ +/* + * Power-button driver for Dollar Cove TI PMIC + * Copyright (C) 2014 Intel Corp + * Copyright (c) 2017 Takashi Iwai + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DC_TI_SIRQ_REG 0x3 +#define SIRQ_PWRBTN_REL (1 << 0) + +static irqreturn_t dc_ti_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); + int state; + + if (!regmap_read(regmap, DC_TI_SIRQ_REG, &state)) { + dev_dbg(dev, "SIRQ_REG=0x%x\n", state); + state &= SIRQ_PWRBTN_REL; + input_event(input, EV_KEY, KEY_POWER, !state); + input_sync(input); + } + + return IRQ_HANDLED; +} + +static int dc_ti_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; + int ret; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return -EINVAL; + 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, dc_ti_pwrbtn_interrupt, + 0, KBUILD_MODNAME, input); + if (ret) + return ret; + + device_init_wakeup(dev, true); + dev_pm_set_wake_irq(dev, irq); + return 0; +} + +static int dc_ti_pwrbtn_remove(struct platform_device *pdev) +{ + dev_pm_clear_wake_irq(&pdev->dev); + device_init_wakeup(&pdev->dev, false); + return 0; +} + +static struct platform_device_id dc_ti_pwrbtn_id_table[] = { + { .name = "dc_ti_pwrbtn" }, + {}, +}; +MODULE_DEVICE_TABLE(platform, dc_ti_pwrbtn_id_table); + +static struct platform_driver dc_ti_pwrbtn_driver = { + .driver = { + .name = KBUILD_MODNAME, + }, + .probe = dc_ti_pwrbtn_probe, + .remove = dc_ti_pwrbtn_remove, + .id_table = dc_ti_pwrbtn_id_table, +}; +module_platform_driver(dc_ti_pwrbtn_driver); + +MODULE_DESCRIPTION("Power-button driver for Dollar Cove TI PMIC"); +MODULE_LICENSE("GPL v2");