lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <912e86a9-63cf-9d22-2259-193e7212ad7b@linaro.org>
Date:   Wed, 8 Jun 2022 09:05:16 +0200
From:   Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To:     cy_huang <u0084500@...il.com>, robh+dt@...nel.org,
        krzysztof.kozlowski+dt@...aro.org, lee.jones@...aro.org,
        broonie@...nel.org, dmitry.torokhov@...il.com
Cc:     lgirdwood@...il.com, cy_huang@...htek.com,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-input@...r.kernel.org
Subject: Re: [PATCH 4/4] input: misc: rt5120: Add power key support

On 08/06/2022 09:03, Krzysztof Kozlowski wrote:
> On 07/06/2022 07:52, cy_huang wrote:
>> From: ChiYuan Huang <cy_huang@...htek.com>
>>
>> Add RT5120 PMIC power key support.
>>
>> Signed-off-by: ChiYuan Huang <cy_huang@...htek.com>
>> ---
>>  drivers/input/misc/Kconfig         |   9 +++
>>  drivers/input/misc/Makefile        |   1 +
>>  drivers/input/misc/rt5120-pwrkey.c | 115 +++++++++++++++++++++++++++++++++++++
>>  3 files changed, 125 insertions(+)
>>  create mode 100644 drivers/input/misc/rt5120-pwrkey.c
>>
>> diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
>> index dd5227c..9c0d814 100644
>> --- a/drivers/input/misc/Kconfig
>> +++ b/drivers/input/misc/Kconfig
>> @@ -881,6 +881,15 @@ config INPUT_SC27XX_VIBRA
>>  	  To compile this driver as a module, choose M here. The module will
>>  	  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 will
>> +	  be called rt5120-pwerkey.
>> +
>>  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 b92c53a..164ea20 100644
>> --- a/drivers/input/misc/Makefile
>> +++ b/drivers/input/misc/Makefile
>> @@ -68,6 +68,7 @@ obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON)	+= rave-sp-pwrbutton.o
>>  obj-$(CONFIG_INPUT_RB532_BUTTON)	+= rb532_button.o
>>  obj-$(CONFIG_INPUT_REGULATOR_HAPTIC)	+= regulator-haptic.o
>>  obj-$(CONFIG_INPUT_RETU_PWRBUTTON)	+= retu-pwrbutton.o
>> +obj-$(CONFIG_INPUT_RT5120_PWRKEY)	+= rt5120-pwrkey.o
>>  obj-$(CONFIG_INPUT_AXP20X_PEK)		+= axp20x-pek.o
>>  obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)	+= rotary_encoder.o
>>  obj-$(CONFIG_INPUT_RK805_PWRKEY)	+= rk805-pwrkey.o
>> diff --git a/drivers/input/misc/rt5120-pwrkey.c b/drivers/input/misc/rt5120-pwrkey.c
>> new file mode 100644
>> index 00000000..42bd2f3
>> --- /dev/null
>> +++ b/drivers/input/misc/rt5120-pwrkey.c
>> @@ -0,0 +1,115 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +
>> +#include <linux/bits.h>
>> +#include <linux/input.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/mod_devicetable.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/regmap.h>
>> +
>> +#define RT5120_REG_INTSTAT	0x1E
>> +#define RT5120_PWRKEYSTAT_MASK	BIT(7)
>> +
>> +struct rt5120_priv {
>> +	struct regmap *regmap;
>> +	struct input_dev *input;
>> +	int press_irq;
>> +	int release_irq;
>> +};
>> +
>> +static irqreturn_t rt5120_pwrkey_handler(int irq, void *devid)
>> +{
>> +	struct rt5120_priv *priv = devid;
>> +	unsigned int stat;
>> +	bool is_pressed;
>> +	int ret;
>> +
>> +	ret = regmap_read(priv->regmap, RT5120_REG_INTSTAT, &stat);
>> +	if (ret)
>> +		return IRQ_NONE;
>> +
>> +	is_pressed = !(stat & RT5120_PWRKEYSTAT_MASK);
>> +
>> +	if ((is_pressed && irq == priv->press_irq) ||
>> +	    (!is_pressed  && irq == priv->release_irq)) {
>> +		input_report_key(priv->input, KEY_POWER, is_pressed);
>> +		input_sync(priv->input);
>> +	}
>> +
>> +	return IRQ_HANDLED;
>> +}
>> +
>> +static int rt5120_pwrkey_probe(struct platform_device *pdev)
>> +{
>> +	struct rt5120_priv *priv;
>> +	int ret;
>> +
>> +	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
>> +	if (!priv)
>> +		return -ENOMEM;
>> +
>> +	priv->regmap = dev_get_regmap(pdev->dev.parent, NULL);
>> +	if (!priv->regmap) {
>> +		dev_err(&pdev->dev, "Failed to init regmap\n");
>> +		return -ENODEV;
>> +	}
>> +
>> +	priv->press_irq = platform_get_irq_byname(pdev, "pwrkey-press");
>> +	if (priv->press_irq < 0)
>> +		return priv->press_irq;
>> +
>> +	priv->release_irq = platform_get_irq_byname(pdev, "pwrkey-release");
>> +	if (priv->release_irq < 0)
>> +		return priv->release_irq;
> 
> Not described in the bindings. All properties need to be documented.

Hm, it seems it is coming from the parent device, dynamically, so looks ok.


Best regards,
Krzysztof

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ