Skip to content

Commit 4c40db6

Browse files
author
Linus Walleij
committed
ARM: omap1: Remove reliance on GPIO numbers from PalmTE
It appears this happens because the OMAP driver now allocates GPIO numbers dynamically, so all that is references by number is a bit up in the air. Utilize the NULL device to define some board-specific GPIO lookups and use these to immediately look up the same GPIOs, convert to IRQ numbers and pass as resources to the devices. This is ugly but should work. Fixes: 92bf78b ("gpio: omap: use dynamic allocation of base") Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent fa1ae0c commit 4c40db6

1 file changed

Lines changed: 31 additions & 20 deletions

File tree

arch/arm/mach-omap1/board-palmte.c

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
*
1414
* Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
1515
*/
16-
#include <linux/gpio.h>
16+
#include <linux/gpio/machine.h>
17+
#include <linux/gpio/consumer.h>
1718
#include <linux/kernel.h>
1819
#include <linux/init.h>
1920
#include <linux/input.h>
@@ -187,23 +188,6 @@ static struct spi_board_info palmte_spi_info[] __initdata = {
187188
},
188189
};
189190

190-
static void __init palmte_misc_gpio_setup(void)
191-
{
192-
/* Set TSC2102 PINTDAV pin as input (used by TSC2102 driver) */
193-
if (gpio_request(PALMTE_PINTDAV_GPIO, "TSC2102 PINTDAV") < 0) {
194-
printk(KERN_ERR "Could not reserve PINTDAV GPIO!\n");
195-
return;
196-
}
197-
gpio_direction_input(PALMTE_PINTDAV_GPIO);
198-
199-
/* Set USB-or-DC-IN pin as input (unused) */
200-
if (gpio_request(PALMTE_USB_OR_DC_GPIO, "USB/DC-IN") < 0) {
201-
printk(KERN_ERR "Could not reserve cable signal GPIO!\n");
202-
return;
203-
}
204-
gpio_direction_input(PALMTE_USB_OR_DC_GPIO);
205-
}
206-
207191
#if IS_ENABLED(CONFIG_MMC_OMAP)
208192

209193
static struct omap_mmc_platform_data _palmte_mmc_config = {
@@ -231,8 +215,23 @@ static void palmte_mmc_init(void)
231215

232216
#endif /* CONFIG_MMC_OMAP */
233217

218+
static struct gpiod_lookup_table palmte_irq_gpio_table = {
219+
.dev_id = NULL,
220+
.table = {
221+
/* GPIO used for TSC2102 PINTDAV IRQ */
222+
GPIO_LOOKUP("gpio-0-15", PALMTE_PINTDAV_GPIO, "tsc2102_irq",
223+
GPIO_ACTIVE_HIGH),
224+
/* GPIO used for USB or DC input detection */
225+
GPIO_LOOKUP("gpio-0-15", PALMTE_USB_OR_DC_GPIO, "usb_dc_irq",
226+
GPIO_ACTIVE_HIGH),
227+
{ }
228+
},
229+
};
230+
234231
static void __init omap_palmte_init(void)
235232
{
233+
struct gpio_desc *d;
234+
236235
/* mux pins for uarts */
237236
omap_cfg_reg(UART1_TX);
238237
omap_cfg_reg(UART1_RTS);
@@ -243,9 +242,21 @@ static void __init omap_palmte_init(void)
243242

244243
platform_add_devices(palmte_devices, ARRAY_SIZE(palmte_devices));
245244

246-
palmte_spi_info[0].irq = gpio_to_irq(PALMTE_PINTDAV_GPIO);
245+
gpiod_add_lookup_table(&palmte_irq_gpio_table);
246+
d = gpiod_get(NULL, "tsc2102_irq", GPIOD_IN);
247+
if (IS_ERR(d))
248+
pr_err("Unable to get TSC2102 IRQ GPIO descriptor\n");
249+
else
250+
palmte_spi_info[0].irq = gpiod_to_irq(d);
247251
spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info));
248-
palmte_misc_gpio_setup();
252+
253+
/* We are getting this just to set it up as input */
254+
d = gpiod_get(NULL, "usb_dc_irq", GPIOD_IN);
255+
if (IS_ERR(d))
256+
pr_err("Unable to get USB/DC IRQ GPIO descriptor\n");
257+
else
258+
gpiod_put(d);
259+
249260
omap_serial_init();
250261
omap1_usb_init(&palmte_usb_config);
251262
omap_register_i2c_bus(1, 100, NULL, 0);

0 commit comments

Comments
 (0)