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 SX1

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>

+33 -7
+33 -7
arch/arm/mach-omap1/board-sx1.c
··· 11 11 * Maintainters : Vladimir Ananiev (aka Vovan888), Sergge 12 12 * oslik.ru 13 13 */ 14 - #include <linux/gpio.h> 14 + #include <linux/gpio/machine.h> 15 + #include <linux/gpio/consumer.h> 15 16 #include <linux/kernel.h> 16 17 #include <linux/init.h> 17 18 #include <linux/input.h> ··· 305 304 306 305 /*-----------------------------------------*/ 307 306 307 + static struct gpiod_lookup_table sx1_gpio_table = { 308 + .dev_id = NULL, 309 + .table = { 310 + GPIO_LOOKUP("gpio-0-15", 1, "irda_off", 311 + GPIO_ACTIVE_HIGH), 312 + GPIO_LOOKUP("gpio-0-15", 11, "switch", 313 + GPIO_ACTIVE_HIGH), 314 + GPIO_LOOKUP("gpio-0-15", 15, "usb_on", 315 + GPIO_ACTIVE_HIGH), 316 + { } 317 + }, 318 + }; 319 + 308 320 static void __init omap_sx1_init(void) 309 321 { 322 + struct gpio_desc *d; 323 + 310 324 /* mux pins for uarts */ 311 325 omap_cfg_reg(UART1_TX); 312 326 omap_cfg_reg(UART1_RTS); ··· 336 320 omap_register_i2c_bus(1, 100, NULL, 0); 337 321 omap1_usb_init(&sx1_usb_config); 338 322 sx1_mmc_init(); 323 + gpiod_add_lookup_table(&sx1_gpio_table); 339 324 340 325 /* turn on USB power */ 341 326 /* sx1_setusbpower(1); can't do it here because i2c is not ready */ 342 - gpio_request(1, "A_IRDA_OFF"); 343 - gpio_request(11, "A_SWITCH"); 344 - gpio_request(15, "A_USB_ON"); 345 - gpio_direction_output(1, 1); /*A_IRDA_OFF = 1 */ 346 - gpio_direction_output(11, 0); /*A_SWITCH = 0 */ 347 - gpio_direction_output(15, 0); /*A_USB_ON = 0 */ 327 + d = gpiod_get(NULL, "irda_off", GPIOD_OUT_HIGH); 328 + if (IS_ERR(d)) 329 + pr_err("Unable to get IRDA OFF GPIO descriptor\n"); 330 + else 331 + gpiod_put(d); 332 + d = gpiod_get(NULL, "switch", GPIOD_OUT_LOW); 333 + if (IS_ERR(d)) 334 + pr_err("Unable to get SWITCH GPIO descriptor\n"); 335 + else 336 + gpiod_put(d); 337 + d = gpiod_get(NULL, "usb_on", GPIOD_OUT_LOW); 338 + if (IS_ERR(d)) 339 + pr_err("Unable to get USB ON GPIO descriptor\n"); 340 + else 341 + gpiod_put(d); 348 342 349 343 omapfb_set_lcd_config(&sx1_lcd_config); 350 344 }