Skip to content

Commit

Permalink
ARM: OMAP: fix the ads7846 init code
Browse files Browse the repository at this point in the history
In case a board provides the gpio_pendown and not board_pdata,
the GPIO debounce is not taken care of.
Fix this by taking care of GPIO debounce in any case.

Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Signed-off-by: Tony Lindgren <tony@atomide.com>
  • Loading branch information
Igor Grinberg authored and Tony Lindgren committed Jun 21, 2012
1 parent 485802a commit 97ee9f0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions arch/arm/mach-omap2/common-board-devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,30 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
struct spi_board_info *spi_bi = &ads7846_spi_board_info;
int err;

if (board_pdata && board_pdata->get_pendown_state) {
err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
if (err) {
pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
return;
}
gpio_export(gpio_pendown, 0);

if (gpio_debounce)
gpio_set_debounce(gpio_pendown, gpio_debounce);
err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
if (err) {
pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
return;
}

if (gpio_debounce)
gpio_set_debounce(gpio_pendown, gpio_debounce);

spi_bi->bus_num = bus_num;
spi_bi->irq = gpio_to_irq(gpio_pendown);

if (board_pdata) {
board_pdata->gpio_pendown = gpio_pendown;
spi_bi->platform_data = board_pdata;
if (board_pdata->get_pendown_state)
gpio_export(gpio_pendown, 0);
} else {
ads7846_config.gpio_pendown = gpio_pendown;
}

if (!board_pdata || (board_pdata && !board_pdata->get_pendown_state))
gpio_free(gpio_pendown);

spi_register_board_info(&ads7846_spi_board_info, 1);
}
#else
Expand Down

0 comments on commit 97ee9f0

Please sign in to comment.