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-next>] [day] [month] [year] [list]
Message-Id: <20240716205612.1502608-1-Frank.Li@nxp.com>
Date: Tue, 16 Jul 2024 16:56:09 -0400
From: Frank Li <Frank.Li@....com>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Joy Zou <joy.zou@....com>,
	Dong Aisheng <aisheng.dong@....com>,
	Robin Gong <yibin.gong@....com>,
	linux-input@...r.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...),
	linux-kernel@...r.kernel.org (open list)
Cc: imx@...ts.linux.dev
Subject: [PATCH 1/2] input: keyboard: snvs_pwrkey: Enable clock when accessing HP* registers

From: Robin Gong <yibin.gong@....com>

SNVS requires two clock sources:
- LP (32k always on): All LP* registers need this clock. No management is
needed as it is always on.
- HP: All HP* registers require this clock to be enabled before accessing
these registers. Some platforms (e.g., i.MX6SX/i.MX6UL) do not have a
separate HP root clock and it is always on.

Add an optional "snvs-pwrkey" clock for the HP clock and enable it only
when accessing HP* registers.

Signed-off-by: Robin Gong <yibin.gong@....com>
Signed-off-by: Joy Zou <joy.zou@....com>
Signed-off-by: Dong Aisheng <aisheng.dong@....com>
Signed-off-by: Frank Li <Frank.Li@....com>
---
- clock name snvs-pwrkey already documented at
Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
---
 drivers/input/keyboard/snvs_pwrkey.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
index ad8660be0127c..b352148a0cfb2 100644
--- a/drivers/input/keyboard/snvs_pwrkey.c
+++ b/drivers/input/keyboard/snvs_pwrkey.c
@@ -37,6 +37,7 @@ struct pwrkey_drv_data {
 	int keycode;
 	int keystate;  /* 1:pressed */
 	int wakeup;
+	struct clk *clk;
 	struct timer_list check_timer;
 	struct input_dev *input;
 	u8 minor_rev;
@@ -48,7 +49,10 @@ static void imx_imx_snvs_check_for_events(struct timer_list *t)
 	struct input_dev *input = pdata->input;
 	u32 state;
 
+	clk_prepare_enable(pdata->clk);
 	regmap_read(pdata->snvs, SNVS_HPSR_REG, &state);
+	clk_disable_unprepare(pdata->clk);
+
 	state = state & SNVS_HPSR_BTN ? 1 : 0;
 
 	/* only report new event if status changed */
@@ -169,7 +173,15 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 	if (pdata->irq < 0)
 		return -EINVAL;
 
+	pdata->clk = devm_clk_get_optional(&pdev->dev, "snvs-pwrkey");
+	if (IS_ERR(pdata->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(pdata->clk),
+				     "Could not get the snvs-pwrkey clock");
+
+	clk_prepare_enable(pdata->clk);
 	regmap_read(pdata->snvs, SNVS_HPVIDR1_REG, &vid);
+	clk_disable_unprepare(pdata->clk);
+
 	pdata->minor_rev = vid & 0xff;
 
 	regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_DEP_EN, SNVS_LPCR_DEP_EN);
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ