From 1bc754579ff17288d7dc69d2c3e38e4e6bf4960e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 5 Aug 2013 09:04:18 -0700 Subject: Input: max7359 - add CONFIG_PM_SLEEP to suspend/resume Add CONFIG_PM_SLEEP to suspend/resume functions to fix the build warnings when CONFIG_PM_SLEEP is not selected. This is because sleep PM callbacks defined by SET_SYSTEM_SLEEP_PM_OPS are only used when the CONFIG_PM_SLEEP is enabled. drivers/input/keyboard/max7359_keypad.c:275:12: warning: 'max7359_suspend' defined but not used [-Wunused-function] drivers/input/keyboard/max7359_keypad.c:287:12: warning: 'max7359_resume' defined but not used [-Wunused-function] Signed-off-by: Jingoo Han Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/max7359_keypad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c index 7c7af2b01e65..bc2cdaf563fd 100644 --- a/drivers/input/keyboard/max7359_keypad.c +++ b/drivers/input/keyboard/max7359_keypad.c @@ -271,7 +271,7 @@ static int max7359_remove(struct i2c_client *client) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int max7359_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); -- cgit From 3719b54bc62318db7dd8ac7c39a09dfb991a208f Mon Sep 17 00:00:00 2001 From: Bo Shen Date: Tue, 13 Aug 2013 09:46:40 -0700 Subject: Input: qt1070 - add power management ops Add power management ops for qt1070, it may be a wakeup source. Signed-off-by: Bo Shen Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/qt1070.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c index 42b773b3125a..6c561ec3cc09 100644 --- a/drivers/input/keyboard/qt1070.c +++ b/drivers/input/keyboard/qt1070.c @@ -243,6 +243,32 @@ static int qt1070_remove(struct i2c_client *client) return 0; } +#ifdef CONFIG_PM_SLEEP +static int qt1070_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct qt1070_data *data = i2c_get_clientdata(client); + + if (device_may_wakeup(dev)) + enable_irq_wake(data->irq); + + return 0; +} + +static int qt1070_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct qt1070_data *data = i2c_get_clientdata(client); + + if (device_may_wakeup(dev)) + disable_irq_wake(data->irq); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(qt1070_pm_ops, qt1070_suspend, qt1070_resume); + static const struct i2c_device_id qt1070_id[] = { { "qt1070", 0 }, { }, @@ -253,6 +279,7 @@ static struct i2c_driver qt1070_driver = { .driver = { .name = "qt1070", .owner = THIS_MODULE, + .pm = &qt1070_pm_ops, }, .id_table = qt1070_id, .probe = qt1070_probe, -- cgit From eacd0c47966b918f10c7ac1a91dd9fccb0f58ddd Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 15 Aug 2013 00:07:43 -0700 Subject: Input: tegra-kbc - simplify use of devm_ioremap_resource Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression pdev,res,n,e,e1; expression ret != 0; identifier l; @@ - res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res - if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res + res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res); // Signed-off-by: Julia Lawall Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/tegra-kbc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index b46142f78ef2..9cd20e6905a0 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c @@ -638,12 +638,6 @@ static int tegra_kbc_probe(struct platform_device *pdev) if (!tegra_kbc_check_pin_cfg(kbc, &num_rows)) return -EINVAL; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "failed to get I/O memory\n"); - return -ENXIO; - } - kbc->irq = platform_get_irq(pdev, 0); if (kbc->irq < 0) { dev_err(&pdev->dev, "failed to get keyboard IRQ\n"); @@ -658,6 +652,7 @@ static int tegra_kbc_probe(struct platform_device *pdev) setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); kbc->mmio = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(kbc->mmio)) return PTR_ERR(kbc->mmio); -- cgit From ef0aca7f2f94a24d82aea0b74ae7a71c611e4895 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 15 Aug 2013 00:08:17 -0700 Subject: Input: keyboard, serio - simplify use of devm_ioremap_resource Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. Move the call to platform_get_resource adjacent to the call to devm_ioremap_resource to make the connection between them more clear. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression pdev,res,n,e,e1; expression ret != 0; identifier l; @@ - res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res - if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res + res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res); // Signed-off-by: Julia Lawall Acked-by: Viresh Kumar Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/imx_keypad.c | 7 +------ drivers/input/keyboard/nspire-keypad.c | 7 +------ drivers/input/keyboard/spear-keyboard.c | 7 +------ 3 files changed, 3 insertions(+), 18 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c index 03c8cc5cb6c1..328cfc1eed95 100644 --- a/drivers/input/keyboard/imx_keypad.c +++ b/drivers/input/keyboard/imx_keypad.c @@ -442,12 +442,6 @@ static int imx_keypad_probe(struct platform_device *pdev) return -EINVAL; } - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res == NULL) { - dev_err(&pdev->dev, "no I/O memory defined in platform data\n"); - return -EINVAL; - } - input_dev = devm_input_allocate_device(&pdev->dev); if (!input_dev) { dev_err(&pdev->dev, "failed to allocate the input device\n"); @@ -468,6 +462,7 @@ static int imx_keypad_probe(struct platform_device *pdev) setup_timer(&keypad->check_matrix_timer, imx_keypad_check_for_events, (unsigned long) keypad); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(keypad->mmio_base)) return PTR_ERR(keypad->mmio_base); diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c index 20d872d6f603..b3e3edab6d9f 100644 --- a/drivers/input/keyboard/nspire-keypad.c +++ b/drivers/input/keyboard/nspire-keypad.c @@ -171,12 +171,6 @@ static int nspire_keypad_probe(struct platform_device *pdev) return -EINVAL; } - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "missing platform resources\n"); - return -EINVAL; - } - keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad), GFP_KERNEL); if (!keypad) { @@ -208,6 +202,7 @@ static int nspire_keypad_probe(struct platform_device *pdev) return PTR_ERR(keypad->clk); } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); keypad->reg_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(keypad->reg_base)) return PTR_ERR(keypad->reg_base); diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c index 7111124b5362..85ff530d9a91 100644 --- a/drivers/input/keyboard/spear-keyboard.c +++ b/drivers/input/keyboard/spear-keyboard.c @@ -191,12 +191,6 @@ static int spear_kbd_probe(struct platform_device *pdev) int irq; int error; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "no keyboard resource defined\n"); - return -EBUSY; - } - irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "not able to get irq for the device\n"); @@ -228,6 +222,7 @@ static int spear_kbd_probe(struct platform_device *pdev) kbd->suspended_rate = pdata->suspended_rate; } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); kbd->io_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(kbd->io_base)) return PTR_ERR(kbd->io_base); -- cgit From 875ad6966ec6f7c4ddb36cf363bffbffa6961ab5 Mon Sep 17 00:00:00 2001 From: Illia Smyrnov Date: Sun, 25 Aug 2013 23:25:18 -0700 Subject: Input: omap-keypad - use bitfiled instead of hardcoded values Use bitfiled instead of hardcoded values to set KBD_CTRL, use BIT macro, remove unused defines. Signed-off-by: Illia Smyrnov Reviewed-by: Felipe Balbi Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/omap4-keypad.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index f4aa53a1fd69..c7275481a74e 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -53,21 +53,17 @@ #define OMAP4_KBD_FULLCODE63_32 0x48 /* OMAP4 bit definitions */ -#define OMAP4_DEF_IRQENABLE_EVENTEN (1 << 0) -#define OMAP4_DEF_IRQENABLE_LONGKEY (1 << 1) -#define OMAP4_DEF_IRQENABLE_TIMEOUTEN (1 << 2) -#define OMAP4_DEF_WUP_EVENT_ENA (1 << 0) -#define OMAP4_DEF_WUP_LONG_KEY_ENA (1 << 1) -#define OMAP4_DEF_CTRL_NOSOFTMODE (1 << 1) -#define OMAP4_DEF_CTRLPTVVALUE (1 << 2) -#define OMAP4_DEF_CTRLPTV (1 << 1) +#define OMAP4_DEF_IRQENABLE_EVENTEN BIT(0) +#define OMAP4_DEF_IRQENABLE_LONGKEY BIT(1) +#define OMAP4_DEF_WUP_EVENT_ENA BIT(0) +#define OMAP4_DEF_WUP_LONG_KEY_ENA BIT(1) +#define OMAP4_DEF_CTRL_NOSOFTMODE BIT(1) +#define OMAP4_DEF_CTRL_PTV_SHIFT 2 /* OMAP4 values */ -#define OMAP4_VAL_IRQDISABLE 0x00 -#define OMAP4_VAL_DEBOUNCINGTIME 0x07 -#define OMAP4_VAL_FUNCTIONALCFG 0x1E - -#define OMAP4_MASK_IRQSTATUSDISABLE 0xFFFF +#define OMAP4_VAL_IRQDISABLE 0x0 +#define OMAP4_VAL_DEBOUNCINGTIME 0x7 +#define OMAP4_VAL_PVT 0x7 enum { KBD_REVISION_OMAP4 = 0, @@ -175,7 +171,8 @@ static int omap4_keypad_open(struct input_dev *input) disable_irq(keypad_data->irq); kbd_writel(keypad_data, OMAP4_KBD_CTRL, - OMAP4_VAL_FUNCTIONALCFG); + OMAP4_DEF_CTRL_NOSOFTMODE | + (OMAP4_VAL_PVT << OMAP4_DEF_CTRL_PTV_SHIFT)); kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME, OMAP4_VAL_DEBOUNCINGTIME); kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, -- cgit From c683da3ec985bcf0e69890f372cffaba47a1a537 Mon Sep 17 00:00:00 2001 From: Illia Smyrnov Date: Sun, 25 Aug 2013 23:25:50 -0700 Subject: Input: omap-keypad - convert to threaded IRQ Convert to use threaded IRQ. Signed-off-by: Illia Smyrnov Reviewed-by: Felipe Balbi Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/omap4-keypad.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index c7275481a74e..b876a0d8c6be 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -112,8 +112,22 @@ static void kbd_write_irqreg(struct omap4_keypad *keypad_data, } -/* Interrupt handler */ -static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) +/* Interrupt handlers */ +static irqreturn_t omap4_keypad_irq_handler(int irq, void *dev_id) +{ + struct omap4_keypad *keypad_data = dev_id; + + if (kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)) { + /* Disable interrupts */ + kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, + OMAP4_VAL_IRQDISABLE); + return IRQ_WAKE_THREAD; + } + + return IRQ_NONE; +} + +static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id) { struct omap4_keypad *keypad_data = dev_id; struct input_dev *input_dev = keypad_data->input; @@ -121,10 +135,6 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id) unsigned int col, row, code, changed; u32 *new_state = (u32 *) key_state; - /* Disable interrupts */ - kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, - OMAP4_VAL_IRQDISABLE); - *new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0); *(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32); @@ -360,9 +370,10 @@ static int omap4_keypad_probe(struct platform_device *pdev) goto err_free_keymap; } - error = request_irq(keypad_data->irq, omap4_keypad_interrupt, - IRQF_TRIGGER_RISING, - "omap4-keypad", keypad_data); + error = request_threaded_irq(keypad_data->irq, omap4_keypad_irq_handler, + omap4_keypad_irq_thread_fn, + IRQF_TRIGGER_RISING, + "omap4-keypad", keypad_data); if (error) { dev_err(&pdev->dev, "failed to register interrupt\n"); goto err_free_input; -- cgit From afbac60b0c535189a76855a04d85492cf2d992e1 Mon Sep 17 00:00:00 2001 From: Illia Smyrnov Date: Sun, 25 Aug 2013 23:26:16 -0700 Subject: Input: omap-keypad - clear interrupts on open According to TRM, the recommended way for keyboard controller initialization is clear the interrupt-status register, then set up certain keyboard events for generating an interrupt request and set up expected source of wake-up event that generates a wake-up request. Signed-off-by: Illia Smyrnov Reviewed-by: Felipe Balbi Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/omap4-keypad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index b876a0d8c6be..0244262e2600 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -185,8 +185,9 @@ static int omap4_keypad_open(struct input_dev *input) (OMAP4_VAL_PVT << OMAP4_DEF_CTRL_PTV_SHIFT)); kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME, OMAP4_VAL_DEBOUNCINGTIME); + /* clear pending interrupts */ kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, - OMAP4_VAL_IRQDISABLE); + kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE, OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY); -- cgit From 78608a0d940982e926401b4fa5e4a9061e9b53f3 Mon Sep 17 00:00:00 2001 From: Illia Smyrnov Date: Sun, 25 Aug 2013 23:29:30 -0700 Subject: Input: omap-keypad - enable wakeup capability for keypad. Enable/disable IRQ wake in suspend/resume handlers to make the keypad wakeup capable. Signed-off-by: Illia Smyrnov Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/omap4-keypad.c | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index 0244262e2600..cd6b9175179a 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -74,6 +74,7 @@ struct omap4_keypad { struct input_dev *input; void __iomem *base; + bool irq_wake_enabled; unsigned int irq; unsigned int rows; @@ -380,6 +381,7 @@ static int omap4_keypad_probe(struct platform_device *pdev) goto err_free_input; } + device_init_wakeup(&pdev->dev, true); pm_runtime_put_sync(&pdev->dev); error = input_register_device(keypad_data->input); @@ -393,6 +395,7 @@ static int omap4_keypad_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(&pdev->dev); + device_init_wakeup(&pdev->dev, false); free_irq(keypad_data->irq, keypad_data); err_free_keymap: kfree(keypad_data->keymap); @@ -418,6 +421,8 @@ static int omap4_keypad_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); + device_init_wakeup(&pdev->dev, false); + input_unregister_device(keypad_data->input); iounmap(keypad_data->base); @@ -439,12 +444,46 @@ static const struct of_device_id omap_keypad_dt_match[] = { MODULE_DEVICE_TABLE(of, omap_keypad_dt_match); #endif +#ifdef CONFIG_PM_SLEEP +static int omap4_keypad_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); + int error; + + if (device_may_wakeup(&pdev->dev)) { + error = enable_irq_wake(keypad_data->irq); + if (!error) + keypad_data->irq_wake_enabled = true; + } + + return 0; +} + +static int omap4_keypad_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); + + if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) { + disable_irq_wake(keypad_data->irq); + keypad_data->irq_wake_enabled = false; + } + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(omap4_keypad_pm_ops, + omap4_keypad_suspend, omap4_keypad_resume); + static struct platform_driver omap4_keypad_driver = { .probe = omap4_keypad_probe, .remove = omap4_keypad_remove, .driver = { .name = "omap4-keypad", .owner = THIS_MODULE, + .pm = &omap4_keypad_pm_ops, .of_match_table = of_match_ptr(omap_keypad_dt_match), }, }; -- cgit From 50f3c163751f84bd572a712a255cd69903e232e2 Mon Sep 17 00:00:00 2001 From: Illia Smyrnov Date: Sun, 25 Aug 2013 23:32:45 -0700 Subject: Input: omap-keypad - set up irq type from DT OMAP4 is DT only, so read the keypad IRQ type from DT instead hard-coding it in the driver. Signed-off-by: Illia Smyrnov Reviewed-by: Felipe Balbi Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/omap4-keypad.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index cd6b9175179a..30acfd49fa6c 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -373,8 +373,7 @@ static int omap4_keypad_probe(struct platform_device *pdev) } error = request_threaded_irq(keypad_data->irq, omap4_keypad_irq_handler, - omap4_keypad_irq_thread_fn, - IRQF_TRIGGER_RISING, + omap4_keypad_irq_thread_fn, 0, "omap4-keypad", keypad_data); if (error) { dev_err(&pdev->dev, "failed to register interrupt\n"); -- cgit