Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+31 -20
+31 -20
arch/arm/mach-omap1/board-palmte.c
··· 13 13 * 14 14 * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org> 15 15 */ 16 - #include <linux/gpio.h> 16 + #include <linux/gpio/machine.h> 17 + #include <linux/gpio/consumer.h> 17 18 #include <linux/kernel.h> 18 19 #include <linux/init.h> 19 20 #include <linux/input.h> ··· 188 187 }, 189 188 }; 190 189 191 - static void __init palmte_misc_gpio_setup(void) 192 - { 193 - /* Set TSC2102 PINTDAV pin as input (used by TSC2102 driver) */ 194 - if (gpio_request(PALMTE_PINTDAV_GPIO, "TSC2102 PINTDAV") < 0) { 195 - printk(KERN_ERR "Could not reserve PINTDAV GPIO!\n"); 196 - return; 197 - } 198 - gpio_direction_input(PALMTE_PINTDAV_GPIO); 199 - 200 - /* Set USB-or-DC-IN pin as input (unused) */ 201 - if (gpio_request(PALMTE_USB_OR_DC_GPIO, "USB/DC-IN") < 0) { 202 - printk(KERN_ERR "Could not reserve cable signal GPIO!\n"); 203 - return; 204 - } 205 - gpio_direction_input(PALMTE_USB_OR_DC_GPIO); 206 - } 207 - 208 190 #if IS_ENABLED(CONFIG_MMC_OMAP) 209 191 210 192 static struct omap_mmc_platform_data _palmte_mmc_config = { ··· 215 231 216 232 #endif /* CONFIG_MMC_OMAP */ 217 233 234 + static struct gpiod_lookup_table palmte_irq_gpio_table = { 235 + .dev_id = NULL, 236 + .table = { 237 + /* GPIO used for TSC2102 PINTDAV IRQ */ 238 + GPIO_LOOKUP("gpio-0-15", PALMTE_PINTDAV_GPIO, "tsc2102_irq", 239 + GPIO_ACTIVE_HIGH), 240 + /* GPIO used for USB or DC input detection */ 241 + GPIO_LOOKUP("gpio-0-15", PALMTE_USB_OR_DC_GPIO, "usb_dc_irq", 242 + GPIO_ACTIVE_HIGH), 243 + { } 244 + }, 245 + }; 246 + 218 247 static void __init omap_palmte_init(void) 219 248 { 249 + struct gpio_desc *d; 250 + 220 251 /* mux pins for uarts */ 221 252 omap_cfg_reg(UART1_TX); 222 253 omap_cfg_reg(UART1_RTS); ··· 242 243 243 244 platform_add_devices(palmte_devices, ARRAY_SIZE(palmte_devices)); 244 245 245 - palmte_spi_info[0].irq = gpio_to_irq(PALMTE_PINTDAV_GPIO); 246 + gpiod_add_lookup_table(&palmte_irq_gpio_table); 247 + d = gpiod_get(NULL, "tsc2102_irq", GPIOD_IN); 248 + if (IS_ERR(d)) 249 + pr_err("Unable to get TSC2102 IRQ GPIO descriptor\n"); 250 + else 251 + palmte_spi_info[0].irq = gpiod_to_irq(d); 246 252 spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info)); 247 - palmte_misc_gpio_setup(); 253 + 254 + /* We are getting this just to set it up as input */ 255 + d = gpiod_get(NULL, "usb_dc_irq", GPIOD_IN); 256 + if (IS_ERR(d)) 257 + pr_err("Unable to get USB/DC IRQ GPIO descriptor\n"); 258 + else 259 + gpiod_put(d); 260 + 248 261 omap_serial_init(); 249 262 omap1_usb_init(&palmte_usb_config); 250 263 omap_register_i2c_bus(1, 100, NULL, 0);