Skip to content

Commit df89de9

Browse files
author
Linus Walleij
committed
ARM: omap1: Make serial wakeup GPIOs use descriptors
The code in serial.c looks up GPIOs corresponding to a line on the UART when muxed in as GPIO to use this as a wakeup on serial activity for OMAP1. Utilize the NULL device to define some board-specific GPIO lookups and use these to immediately look up the same GPIOs, set as input and convert to IRQ numbers, then set these to wakeup IRQs. This is ugly but should work. This is only needed on the OSK1 and Nokia 770 devices that use the OMAP16xx. Fixes: 92bf78b ("gpio: omap: use dynamic allocation of base") Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 084b6f2 commit df89de9

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@ static struct gpiod_lookup_table nokia770_irq_gpio_table = {
294294
/* GPIO used for tahvo IRQ */
295295
GPIO_LOOKUP("gpio-32-47", 8, "tahvo_irq",
296296
GPIO_ACTIVE_HIGH),
297+
/* GPIOs used by serial wakeup IRQs */
298+
GPIO_LOOKUP_IDX("gpio-32-47", 5, "wakeup", 0,
299+
GPIO_ACTIVE_HIGH),
300+
GPIO_LOOKUP_IDX("gpio-16-31", 2, "wakeup", 1,
301+
GPIO_ACTIVE_HIGH),
302+
GPIO_LOOKUP_IDX("gpio-48-63", 1, "wakeup", 2,
303+
GPIO_ACTIVE_HIGH),
297304
{ }
298305
},
299306
};

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,13 @@ static struct gpiod_lookup_table osk_irq_gpio_table = {
364364
/* GPIO used by the TPS65010 chip */
365365
GPIO_LOOKUP("mpuio", 1, "tps65010",
366366
GPIO_ACTIVE_HIGH),
367+
/* GPIOs used for serial wakeup IRQs */
368+
GPIO_LOOKUP_IDX("gpio-32-47", 5, "wakeup", 0,
369+
GPIO_ACTIVE_HIGH),
370+
GPIO_LOOKUP_IDX("gpio-16-31", 2, "wakeup", 1,
371+
GPIO_ACTIVE_HIGH),
372+
GPIO_LOOKUP_IDX("gpio-48-63", 1, "wakeup", 2,
373+
GPIO_ACTIVE_HIGH),
367374
{ }
368375
},
369376
};

arch/arm/mach-omap1/serial.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
*
55
* OMAP1 serial support.
66
*/
7-
#include <linux/gpio.h>
7+
#include <linux/gpio/machine.h>
8+
#include <linux/gpio/consumer.h>
89
#include <linux/module.h>
910
#include <linux/kernel.h>
1011
#include <linux/init.h>
@@ -196,39 +197,38 @@ void omap_serial_wake_trigger(int enable)
196197
}
197198
}
198199

199-
static void __init omap_serial_set_port_wakeup(int gpio_nr)
200+
static void __init omap_serial_set_port_wakeup(int idx)
200201
{
202+
struct gpio_desc *d;
201203
int ret;
202204

203-
ret = gpio_request(gpio_nr, "UART wake");
204-
if (ret < 0) {
205-
printk(KERN_ERR "Could not request UART wake GPIO: %i\n",
206-
gpio_nr);
205+
d = gpiod_get_index(NULL, "wakeup", idx, GPIOD_IN);
206+
if (IS_ERR(d)) {
207+
pr_err("Unable to get UART wakeup GPIO descriptor\n");
207208
return;
208209
}
209-
gpio_direction_input(gpio_nr);
210-
ret = request_irq(gpio_to_irq(gpio_nr), &omap_serial_wake_interrupt,
210+
ret = request_irq(gpiod_to_irq(d), &omap_serial_wake_interrupt,
211211
IRQF_TRIGGER_RISING, "serial wakeup", NULL);
212212
if (ret) {
213-
gpio_free(gpio_nr);
214-
printk(KERN_ERR "No interrupt for UART wake GPIO: %i\n",
215-
gpio_nr);
213+
gpiod_put(d);
214+
pr_err("No interrupt for UART%d wake GPIO\n", idx + 1);
216215
return;
217216
}
218-
enable_irq_wake(gpio_to_irq(gpio_nr));
217+
enable_irq_wake(gpiod_to_irq(d));
219218
}
220219

220+
221221
int __init omap_serial_wakeup_init(void)
222222
{
223223
if (!cpu_is_omap16xx())
224224
return 0;
225225

226226
if (uart1_ck != NULL)
227-
omap_serial_set_port_wakeup(37);
227+
omap_serial_set_port_wakeup(0);
228228
if (uart2_ck != NULL)
229-
omap_serial_set_port_wakeup(18);
229+
omap_serial_set_port_wakeup(1);
230230
if (uart3_ck != NULL)
231-
omap_serial_set_port_wakeup(49);
231+
omap_serial_set_port_wakeup(2);
232232

233233
return 0;
234234
}

0 commit comments

Comments
 (0)