Skip to content

Commit 0a0d628

Browse files
Igor Grinbergdtor
authored andcommitted
ARM - OMAP: ads7846: fix pendown debounce setting
Commit 97ee9f0 (ARM: OMAP: fix the ads7846 init code) have enabled the pendown GPIO debounce time setting by the below sequence: gpio_request_one() gpio_set_debounce() gpio_free() It also revealed a bug in the OMAP GPIO handling code which prevented the GPIO debounce clock to be disabled and CORE transition to low power states. Commit c9c55d9 (gpio/omap: fix off-mode bug: clear debounce settings on free/reset) fixes the OMAP GPIO handling code by making sure that the GPIO debounce clock gets disabled if no GPIO is requested from current bank. While fixing the OMAP GPIO handling code (in the right way), the above commit makes the gpio_request->set_debounce->free sequence invalid as after freeing the GPIO, the debounce settings are lost. Fix the debounce settings by moving the debounce initialization to the actual GPIO requesting code - the ads7846 driver. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent c4f4925 commit 0a0d628

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

arch/arm/mach-omap2/common-board-devices.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,36 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
6464
struct spi_board_info *spi_bi = &ads7846_spi_board_info;
6565
int err;
6666

67-
err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
68-
if (err) {
69-
pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
70-
return;
71-
}
67+
/*
68+
* If a board defines get_pendown_state() function, request the pendown
69+
* GPIO and set the GPIO debounce time.
70+
* If a board does not define the get_pendown_state() function, then
71+
* the ads7846 driver will setup the pendown GPIO itself.
72+
*/
73+
if (board_pdata && board_pdata->get_pendown_state) {
74+
err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
75+
if (err) {
76+
pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
77+
return;
78+
}
7279

73-
if (gpio_debounce)
74-
gpio_set_debounce(gpio_pendown, gpio_debounce);
80+
if (gpio_debounce)
81+
gpio_set_debounce(gpio_pendown, gpio_debounce);
82+
83+
gpio_export(gpio_pendown, 0);
84+
}
7585

7686
spi_bi->bus_num = bus_num;
7787
spi_bi->irq = gpio_to_irq(gpio_pendown);
7888

89+
ads7846_config.gpio_pendown = gpio_pendown;
90+
7991
if (board_pdata) {
8092
board_pdata->gpio_pendown = gpio_pendown;
93+
board_pdata->gpio_pendown_debounce = gpio_debounce;
8194
spi_bi->platform_data = board_pdata;
82-
if (board_pdata->get_pendown_state)
83-
gpio_export(gpio_pendown, 0);
84-
} else {
85-
ads7846_config.gpio_pendown = gpio_pendown;
8695
}
8796

88-
if (!board_pdata || (board_pdata && !board_pdata->get_pendown_state))
89-
gpio_free(gpio_pendown);
90-
9197
spi_register_board_info(&ads7846_spi_board_info, 1);
9298
}
9399
#else

0 commit comments

Comments
 (0)