Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp1827594rwa; Sun, 21 Aug 2022 18:40:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR7yd+j2XXQ7OrM587xntGGm3qvPc6QRxeVIOqUEx29EuVONoY5gayQTHg/uqpVf4dHleLAF X-Received: by 2002:a05:6402:528d:b0:440:d769:5908 with SMTP id en13-20020a056402528d00b00440d7695908mr14727341edb.52.1661132419020; Sun, 21 Aug 2022 18:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661132419; cv=none; d=google.com; s=arc-20160816; b=f3egO6evIJxqfQTbKJnA/L9uTgJhuDIA9w5aOPh3KvFOlp6UJCHKKuzSAwshKDbkR5 jzk+apH9DWRG2FkaUvgYiawqCSS9QtMPaFMEoP+FQYcvWX9AqVokF5piPFENPbtWyqdZ sKkaJKKxNUkjB57QZMfEAvDJ3S3PAKugc6jfGIp+ABPXxEqT/SVz9QqR22PKMigqNLy4 TlmdlWDOiENaazr936fMVuXhyPb5elTw4DVntZfE6fxxKo0szv6XUvtrCTCGC98qOrZi QB8R4Z/rDWQef0ErdlLMMrJolqkUS8z11dNxneomV/O/gC3uXWPdy7IAu7bAzOu/KZMs vtaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=3AdmndOpd6zIunTecnpi1mLwFVDbJmvpabOXm3DCD78=; b=fVylJ14MCLDF/oaVRva1J0UONKlzBawmsSWgcbSPDOYJK56NC6X7TRCaMxZjiylebt e6s5SK4/INnTndfwXpE3ccgLdDdcBx8WcN3e4KrbP1KhjcsPH/OBhHKTG61bgYHd7ClO sSk7JDfB0nqLP0/Rqawk+OMS7mdK15Xjf78HUoWD/pdUpne1P5lqfnG9KDBgEuKjr9rJ mazMLMyqYv0hKtxbCT1qe/J9ySffUK6w+7Cm4/F+EUbgkexs+Yn6hSTi9rm38xcYFNu2 zAnSW21/HV4UpGvhQT95InxMY2jydnKm6hjPvtzOyVfSmrCP0h57c4E7whze9w4+3AHU CTPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UjA6q8mK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn26-20020a1709070d1a00b0072b3305dbbesi120007ejc.520.2022.08.21.18.39.54; Sun, 21 Aug 2022 18:40:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UjA6q8mK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbiHVBMl (ORCPT + 99 others); Sun, 21 Aug 2022 21:12:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbiHVBMk (ORCPT ); Sun, 21 Aug 2022 21:12:40 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D16831D335; Sun, 21 Aug 2022 18:12:38 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id h24so11377878wrb.8; Sun, 21 Aug 2022 18:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=3AdmndOpd6zIunTecnpi1mLwFVDbJmvpabOXm3DCD78=; b=UjA6q8mKF5sQPoLULzIpKiofAFZY40IWajUeMlzFBkgXRR1L3syXcQQQ2v1DsjJ+vC f5EdgcNNpD0i8LhIyzUnyj+QzwsqoAXMB+h1UMxTgjtwHNCYxphL3DYz+YlWiT/YSh/0 v1M7tkxnWYKhiZ8YiO9yHEP7FnQSETbPeuSHkLjH6x9hGP/kv65OSAj0TtGOnUaNE7oy dA0Y48JGNapJ6tJw18MvN1mZZoSrzS3Nse+Z7nKiD/3hdZaOiN5lGCs2/tnxxoaeDlEc V7YxbB4YwIip0GsTi/p38daD8wOcVuc0K6EgaaE4tx7OlsfUtsKRNtpsvHWkoxuqPBpt k3RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=3AdmndOpd6zIunTecnpi1mLwFVDbJmvpabOXm3DCD78=; b=IcmBzEswe2Kj56tmsMfUhdefNX8YJ69U14WUrqi5IyyGZ69/P6oLhJO6EGlwxD7KZq GKn3d5MShWdLdrbRqSeZ01jXCRf02ue8im23D/5vXNfgm+V4wUHLGUyCPfPuup3SAl6e et6ODVtZ8TV8pQkDSLkRvrx8iLQiSUiTZnrx9NVG83n1/XnNxOjlAN7IgAKlpblQXh8I CddtWJJH8aKs6Dy4DHN6iyawe2e+dK91LNzwO6F16wOhr+dzxnKuQdyeRjIXJEmvigWc MPGqx0C0LznJnr+93Xx7wMmp5xfZAmbN2RQnq6oBsWE6o51IRDkmsLWqAeCSXsFpwBFS e2ug== X-Gm-Message-State: ACgBeo1PsWHQdIwDoGsVaxWcZtqx0PuauY7TuGYWYylyKKlRDpqwLWcW +Ma/8NFIsDkAgE8pVbx5fGVQICZWFJA/qe1kOXY= X-Received: by 2002:a05:6000:1684:b0:220:6e60:768d with SMTP id y4-20020a056000168400b002206e60768dmr9016494wrd.121.1661130757182; Sun, 21 Aug 2022 18:12:37 -0700 (PDT) MIME-Version: 1.0 References: <1660100142-32493-1-git-send-email-u0084500@gmail.com> <1660100142-32493-4-git-send-email-u0084500@gmail.com> In-Reply-To: <1660100142-32493-4-git-send-email-u0084500@gmail.com> From: ChiYuan Huang Date: Mon, 22 Aug 2022 09:12:25 +0800 Message-ID: Subject: Re: [PATCH v4 3/3] input: misc: rt5120: Add power key support To: Rob Herring , Krzysztof Kozlowski , Lee Jones , Dmitry Torokhov Cc: cy_huang , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , lkml , linux-input@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear reviewers: cy_huang =E6=96=BC 2022=E5=B9=B48=E6=9C=8810=E6=97=A5 = =E9=80=B1=E4=B8=89 =E4=B8=8A=E5=8D=8810:55=E5=AF=AB=E9=81=93=EF=BC=9A > > From: ChiYuan Huang > > Add RT5120 PMIC power key support. > > Signed-off-by: ChiYuan Huang > --- > Since v4: > - Add "Copyright" string and refine for GPL version string. > > Since v3: > - Simplify the power key irq handler key report > - Since press and release irq not needed to keep in private data, change = 'press', > 'release' irq as local variable only. > - Fix Kconfig typo for pwrkey. > Since binding/mfd/regulator are all applied, only this one is left. Any update about this pwrkey patch? > --- > drivers/input/misc/Kconfig | 9 +++ > drivers/input/misc/Makefile | 1 + > drivers/input/misc/rt5120-pwrkey.c | 109 +++++++++++++++++++++++++++++++= ++++++ > 3 files changed, 119 insertions(+) > create mode 100644 drivers/input/misc/rt5120-pwrkey.c > > diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig > index a18ab73..92daa4d 100644 > --- a/drivers/input/misc/Kconfig > +++ b/drivers/input/misc/Kconfig > @@ -891,6 +891,15 @@ config INPUT_SC27XX_VIBRA > To compile this driver as a module, choose M here. The module w= ill > be called sc27xx_vibra. > > +config INPUT_RT5120_PWRKEY > + tristate "RT5120 PMIC power key support" > + depends on MFD_RT5120 > + help > + This enables support for RT5120 PMIC power key driver. > + > + To compile this driver as a module, choose M here. the module w= ill > + be called rt5120-pwrkey. > + > config INPUT_STPMIC1_ONKEY > tristate "STPMIC1 PMIC Onkey support" > depends on MFD_STPMIC1 > diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile > index 28dfc44..d1fb00e 100644 > --- a/drivers/input/misc/Makefile > +++ b/drivers/input/misc/Makefile > @@ -69,6 +69,7 @@ obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON) +=3D rave-sp-pwrb= utton.o > obj-$(CONFIG_INPUT_RB532_BUTTON) +=3D rb532_button.o > obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) +=3D regulator-haptic.o > obj-$(CONFIG_INPUT_RETU_PWRBUTTON) +=3D retu-pwrbutton.o > +obj-$(CONFIG_INPUT_RT5120_PWRKEY) +=3D rt5120-pwrkey.o > obj-$(CONFIG_INPUT_AXP20X_PEK) +=3D axp20x-pek.o > obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) +=3D rotary_encoder.o > obj-$(CONFIG_INPUT_RK805_PWRKEY) +=3D rk805-pwrkey.o > diff --git a/drivers/input/misc/rt5120-pwrkey.c b/drivers/input/misc/rt51= 20-pwrkey.c > new file mode 100644 > index 00000000..94d25ba > --- /dev/null > +++ b/drivers/input/misc/rt5120-pwrkey.c > @@ -0,0 +1,109 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) 2022 Richtek Technology Corp. > + * Author: ChiYuan Huang > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define RT5120_REG_INTSTAT 0x1E > +#define RT5120_PWRKEYSTAT_MASK BIT(7) > + > +struct rt5120_priv { > + struct regmap *regmap; > + struct input_dev *input; > +}; > + > +static irqreturn_t rt5120_pwrkey_handler(int irq, void *devid) > +{ > + struct rt5120_priv *priv =3D devid; > + unsigned int stat; > + int ret; > + > + ret =3D regmap_read(priv->regmap, RT5120_REG_INTSTAT, &stat); > + if (ret) > + return IRQ_NONE; > + > + input_report_key(priv->input, KEY_POWER, > + !(stat & RT5120_PWRKEYSTAT_MASK)); > + input_sync(priv->input); > + > + return IRQ_HANDLED; > +} > + > +static int rt5120_pwrkey_probe(struct platform_device *pdev) > +{ > + struct rt5120_priv *priv; > + struct device *dev =3D &pdev->dev; > + int press_irq, release_irq; > + int ret; > + > + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + priv->regmap =3D dev_get_regmap(dev->parent, NULL); > + if (!priv->regmap) > + return dev_err_probe(dev, -ENODEV, "Failed to init regmap= \n"); > + > + press_irq =3D platform_get_irq_byname(pdev, "pwrkey-press"); > + if (press_irq < 0) > + return press_irq; > + > + release_irq =3D platform_get_irq_byname(pdev, "pwrkey-release"); > + if (release_irq < 0) > + return release_irq; > + > + /* Make input device be device resource managed */ > + priv->input =3D devm_input_allocate_device(dev); > + if (!priv->input) > + return dev_err_probe(dev, -ENOMEM, > + "Failed to allocate input device\n")= ; > + > + priv->input->name =3D "rt5120_pwrkey"; > + priv->input->phys =3D "rt5120_pwrkey/input0"; > + priv->input->id.bustype =3D BUS_I2C; > + input_set_capability(priv->input, EV_KEY, KEY_POWER); > + > + ret =3D input_register_device(priv->input); > + if (ret) > + return dev_err_probe(dev, ret, > + "Failed to register input device\n")= ; > + > + ret =3D devm_request_threaded_irq(dev, press_irq, NULL, > + rt5120_pwrkey_handler, 0, > + "pwrkey-press", priv); > + if (ret) > + return dev_err_probe(dev, ret, > + "Failed to register pwrkey press irq= \n"); > + > + return devm_request_threaded_irq(dev, release_irq, NULL, > + rt5120_pwrkey_handler, 0, > + "pwrkey-release", priv); > +} > + > +static const struct of_device_id r5120_pwrkey_match_table[] =3D { > + { .compatible =3D "richtek,rt5120-pwrkey" }, > + {} > +}; > +MODULE_DEVICE_TABLE(of, r5120_pwrkey_match_table); > + > +static struct platform_driver rt5120_pwrkey_driver =3D { > + .driver =3D { > + .name =3D "rt5120-pwrkey", > + .of_match_table =3D r5120_pwrkey_match_table, > + }, > + .probe =3D rt5120_pwrkey_probe, > +}; > +module_platform_driver(rt5120_pwrkey_driver); > + > +MODULE_AUTHOR("ChiYuan Huang "); > +MODULE_DESCRIPTION("Richtek RT5120 power key driver"); > +MODULE_LICENSE("GPL v2"); > -- > 2.7.4 >