Skip to contentSkip to conversation

input: imx_sc_key: Enable wakeup according to dts property wakeup-source

PATCH In review Frank Li 2 participants 3 messages Jul 19, 2024 – Jul 24, 2024

Subsystems (3)
lore
Share & tools
lore

Frank Li

author maintainer
#0 lore raw

PATCH v2 1/1 input: imx_sc_key: Enable wakeup according to dts property wakeup-source

From: Abel Vesa <[email protected]>

Enable default wakeup according to dts property 'wakeup-source'.

---
Change from v1 to v2
- change int to bool
- move of_property_read_bool() just before device_init_wakeup()
- drop !!

---
 drivers/input/keyboard/imx_sc_key.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/input/keyboard/imx_sc_key.c +5 -0
index d18839f1f4f60..fc1492088b645 100644
@@ -110,8 +110,10 @@ static void imx_sc_key_action(void *data)
 
 static int imx_sc_key_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
 	struct imx_key_drv_data *priv;
 	struct input_dev *input;
+	bool wakeup;
 	int error;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -151,6 +153,9 @@ static int imx_sc_key_probe(struct platform_device *pdev)
 	priv->input = input;
 	platform_set_drvdata(pdev, priv);
 
+	wakeup = of_property_read_bool(np, "wakeup-source");
+	device_init_wakeup(&pdev->dev, wakeup);
+
 	error = imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON,
 					 true);
 	if (error) {
Signature · 1 line
2.34.1
maintainer
#1 lore raw

Hi Frank,

Quoted 32 lines · Frank Li

From: Abel Vesa <[email protected]>

Enable default wakeup according to dts property 'wakeup-source'.

---
Change from v1 to v2
- change int to bool
- move of_property_read_bool() just before device_init_wakeup()
- drop !!

---
 drivers/input/keyboard/imx_sc_key.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/input/keyboard/imx_sc_key.c +2 -0
index d18839f1f4f60..fc1492088b645 100644
@@ -110,8 +110,10 @@ static void imx_sc_key_action(void *data)
 
 static int imx_sc_key_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
 	struct imx_key_drv_data *priv;
 	struct input_dev *input;
+	bool wakeup;
 	int error;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);

drivers/input/keyboard/imx_sc_key.c static int imx_sc_key_probe(struct platform_device *pdev) · line 156

Quoted 4 lines
drivers/input/keyboard/imx_sc_key.c +1 -0
@@ -151,6 +153,9 @@ static int imx_sc_key_probe(struct platform_device *pdev)
 	priv->input = input;
 	platform_set_drvdata(pdev, priv);
 
+	wakeup = of_property_read_bool(np, "wakeup-source");

The driver uses generic device properties, why do you use OF-specific variant here?

drivers/input/keyboard/imx_sc_key.c static int imx_sc_key_probe(struct platform_device *pdev) · line 158

Quoted 2 lines
drivers/input/keyboard/imx_sc_key.c +2 -0
+	device_init_wakeup(&pdev->dev, wakeup);
+

How does this actually work? Doesn't the call directly below unconditionally configures button as a wakeup source?

drivers/input/keyboard/imx_sc_key.c static int imx_sc_key_probe(struct platform_device *pdev) · line 161

Quoted 3 lines
drivers/input/keyboard/imx_sc_key.c +0 -0
 	error = imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON,
 					 true);
 	if (error) {

Thanks.

Signature · 1 line
Dmitry
author maintainer
#2 lore raw
Quoted 38 lines · Dmitry Torokhov

Hi Frank,

Quoted 35 lines · Frank Li

From: Abel Vesa <[email protected]>

Enable default wakeup according to dts property 'wakeup-source'.

---
Change from v1 to v2
- change int to bool
- move of_property_read_bool() just before device_init_wakeup()
- drop !!

---
 drivers/input/keyboard/imx_sc_key.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/input/keyboard/imx_sc_key.c +2 -0
index d18839f1f4f60..fc1492088b645 100644
@@ -110,8 +110,10 @@ static void imx_sc_key_action(void *data)
 
 static int imx_sc_key_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
 	struct imx_key_drv_data *priv;
 	struct input_dev *input;
+	bool wakeup;
 	int error;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -151,6 +153,9 @@ static int imx_sc_key_probe(struct platform_device *pdev)
 	priv->input = input;
 	platform_set_drvdata(pdev, priv);
 
Quoted 4 lines

drivers/input/keyboard/imx_sc_key.c static int imx_sc_key_probe(struct platform_device *pdev) · line 156

Quoted 1 line
drivers/input/keyboard/imx_sc_key.c +1 -0
+	wakeup = of_property_read_bool(np, "wakeup-source");

The driver uses generic device properties, why do you use OF-specific variant here?

I think it just show default if it is wakeup source.

Do you think we just need call device_init_wakeup(&pdev->dev, wakeup) to maintance consisent between software wakeup enable status with SCU wakeup enable status?

Since most case power-key should be wakeup source.

Quoted 6 lines

drivers/input/keyboard/imx_sc_key.c static int imx_sc_key_probe(struct platform_device *pdev) · line 158

Quoted 3 lines
drivers/input/keyboard/imx_sc_key.c +2 -0
+	device_init_wakeup(&pdev->dev, wakeup);
+

How does this actually work? Doesn't the call directly below unconditionally configures button as a wakeup source?

Good capture, I am also strange why it can wakeup even dts have not set wakeup-source.

Frank

Quoted 9 lines

drivers/input/keyboard/imx_sc_key.c static int imx_sc_key_probe(struct platform_device *pdev) · line 161

Quoted 4 lines
drivers/input/keyboard/imx_sc_key.c +0 -0
 	error = imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON,
 					 true);
 	if (error) {

Thanks.

Signature · 1 line
Dmitry