Skip to content

Commit b243018

Browse files
Ondrej Jirmandtor
authored andcommitted
Input: sun4i-lradc-keys - add wakeup support
Allow the driver to wake the system on key press if the "wakeup-source" property is provided in the device tree. Using the LRADC as a wakeup source requires keeping the AVCC domain active during sleep. Since this has a nontrivial impact on power consumption (sometimes doubling it), disable the LRADC wakeup source by default. Signed-off-by: Ondrej Jirman <x@xff.cz> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20220424161328.61103-1-samuel@sholland.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent be8fc02 commit b243018

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

drivers/input/keyboard/sun4i-lradc-keys.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <linux/module.h>
2323
#include <linux/of_platform.h>
2424
#include <linux/platform_device.h>
25+
#include <linux/pm_wakeirq.h>
26+
#include <linux/pm_wakeup.h>
2527
#include <linux/regulator/consumer.h>
2628
#include <linux/slab.h>
2729

@@ -226,8 +228,7 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
226228
{
227229
struct sun4i_lradc_data *lradc;
228230
struct device *dev = &pdev->dev;
229-
int i;
230-
int error;
231+
int error, i, irq;
231232

232233
lradc = devm_kzalloc(dev, sizeof(struct sun4i_lradc_data), GFP_KERNEL);
233234
if (!lradc)
@@ -272,8 +273,11 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
272273
if (IS_ERR(lradc->base))
273274
return PTR_ERR(lradc->base);
274275

275-
error = devm_request_irq(dev, platform_get_irq(pdev, 0),
276-
sun4i_lradc_irq, 0,
276+
irq = platform_get_irq(pdev, 0);
277+
if (irq < 0)
278+
return irq;
279+
280+
error = devm_request_irq(dev, irq, sun4i_lradc_irq, 0,
277281
"sun4i-a10-lradc-keys", lradc);
278282
if (error)
279283
return error;
@@ -282,6 +286,16 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
282286
if (error)
283287
return error;
284288

289+
if (device_property_read_bool(dev, "wakeup-source")) {
290+
error = dev_pm_set_wake_irq(dev, irq);
291+
if (error)
292+
dev_warn(dev,
293+
"Failed to set IRQ %d as a wake IRQ: %d\n",
294+
irq, error);
295+
else
296+
device_set_wakeup_capable(dev, true);
297+
}
298+
285299
return 0;
286300
}
287301

0 commit comments

Comments
 (0)