Skip to content

Commit 480c82d

Browse files
author
Linus Walleij
committed
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: 92bf78b ("gpio: omap: use dynamic allocation of base") Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 4c40db6 commit 480c82d

1 file changed

Lines changed: 33 additions & 7 deletions

File tree

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

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
* Maintainters : Vladimir Ananiev (aka Vovan888), Sergge
1212
* oslik.ru
1313
*/
14-
#include <linux/gpio.h>
14+
#include <linux/gpio/machine.h>
15+
#include <linux/gpio/consumer.h>
1516
#include <linux/kernel.h>
1617
#include <linux/init.h>
1718
#include <linux/input.h>
@@ -304,8 +305,23 @@ static struct platform_device *sx1_devices[] __initdata = {
304305

305306
/*-----------------------------------------*/
306307

308+
static struct gpiod_lookup_table sx1_gpio_table = {
309+
.dev_id = NULL,
310+
.table = {
311+
GPIO_LOOKUP("gpio-0-15", 1, "irda_off",
312+
GPIO_ACTIVE_HIGH),
313+
GPIO_LOOKUP("gpio-0-15", 11, "switch",
314+
GPIO_ACTIVE_HIGH),
315+
GPIO_LOOKUP("gpio-0-15", 15, "usb_on",
316+
GPIO_ACTIVE_HIGH),
317+
{ }
318+
},
319+
};
320+
307321
static void __init omap_sx1_init(void)
308322
{
323+
struct gpio_desc *d;
324+
309325
/* mux pins for uarts */
310326
omap_cfg_reg(UART1_TX);
311327
omap_cfg_reg(UART1_RTS);
@@ -320,15 +336,25 @@ static void __init omap_sx1_init(void)
320336
omap_register_i2c_bus(1, 100, NULL, 0);
321337
omap1_usb_init(&sx1_usb_config);
322338
sx1_mmc_init();
339+
gpiod_add_lookup_table(&sx1_gpio_table);
323340

324341
/* turn on USB power */
325342
/* sx1_setusbpower(1); can't do it here because i2c is not ready */
326-
gpio_request(1, "A_IRDA_OFF");
327-
gpio_request(11, "A_SWITCH");
328-
gpio_request(15, "A_USB_ON");
329-
gpio_direction_output(1, 1); /*A_IRDA_OFF = 1 */
330-
gpio_direction_output(11, 0); /*A_SWITCH = 0 */
331-
gpio_direction_output(15, 0); /*A_USB_ON = 0 */
343+
d = gpiod_get(NULL, "irda_off", GPIOD_OUT_HIGH);
344+
if (IS_ERR(d))
345+
pr_err("Unable to get IRDA OFF GPIO descriptor\n");
346+
else
347+
gpiod_put(d);
348+
d = gpiod_get(NULL, "switch", GPIOD_OUT_LOW);
349+
if (IS_ERR(d))
350+
pr_err("Unable to get SWITCH GPIO descriptor\n");
351+
else
352+
gpiod_put(d);
353+
d = gpiod_get(NULL, "usb_on", GPIOD_OUT_LOW);
354+
if (IS_ERR(d))
355+
pr_err("Unable to get USB ON GPIO descriptor\n");
356+
else
357+
gpiod_put(d);
332358

333359
omapfb_set_lcd_config(&sx1_lcd_config);
334360
}

0 commit comments

Comments
 (0)