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: 92bf78b33b ("gpio: omap: use dynamic allocation of base")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Linus Walleij 2023-04-30 17:45:29 +02:00
parent 4c40db6249
commit 480c82daa3

View file

@ -11,7 +11,8 @@
* Maintainters : Vladimir Ananiev (aka Vovan888), Sergge
* oslik.ru
*/
#include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/input.h>
@ -304,8 +305,23 @@ static struct platform_device *sx1_devices[] __initdata = {
/*-----------------------------------------*/
static struct gpiod_lookup_table sx1_gpio_table = {
.dev_id = NULL,
.table = {
GPIO_LOOKUP("gpio-0-15", 1, "irda_off",
GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("gpio-0-15", 11, "switch",
GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("gpio-0-15", 15, "usb_on",
GPIO_ACTIVE_HIGH),
{ }
},
};
static void __init omap_sx1_init(void)
{
struct gpio_desc *d;
/* mux pins for uarts */
omap_cfg_reg(UART1_TX);
omap_cfg_reg(UART1_RTS);
@ -320,15 +336,25 @@ static void __init omap_sx1_init(void)
omap_register_i2c_bus(1, 100, NULL, 0);
omap1_usb_init(&sx1_usb_config);
sx1_mmc_init();
gpiod_add_lookup_table(&sx1_gpio_table);
/* turn on USB power */
/* sx1_setusbpower(1); can't do it here because i2c is not ready */
gpio_request(1, "A_IRDA_OFF");
gpio_request(11, "A_SWITCH");
gpio_request(15, "A_USB_ON");
gpio_direction_output(1, 1); /*A_IRDA_OFF = 1 */
gpio_direction_output(11, 0); /*A_SWITCH = 0 */
gpio_direction_output(15, 0); /*A_USB_ON = 0 */
d = gpiod_get(NULL, "irda_off", GPIOD_OUT_HIGH);
if (IS_ERR(d))
pr_err("Unable to get IRDA OFF GPIO descriptor\n");
else
gpiod_put(d);
d = gpiod_get(NULL, "switch", GPIOD_OUT_LOW);
if (IS_ERR(d))
pr_err("Unable to get SWITCH GPIO descriptor\n");
else
gpiod_put(d);
d = gpiod_get(NULL, "usb_on", GPIOD_OUT_LOW);
if (IS_ERR(d))
pr_err("Unable to get USB ON GPIO descriptor\n");
else
gpiod_put(d);
omapfb_set_lcd_config(&sx1_lcd_config);
}