Skip to content

Commit 084b6f2

Browse files
author
Linus Walleij
committed
ARM: omap1: Fix up the Nokia 770 board device IRQs
The platform devices on the Nokia 770 is using some board-specific IRQs that get statically assigned to platform devices in the boardfile. This does not work with dynamic IRQ chip bases. 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 e519f0b commit 084b6f2

1 file changed

Lines changed: 45 additions & 13 deletions

File tree

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

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
#include <linux/clkdev.h>
88
#include <linux/irq.h>
9-
#include <linux/gpio.h>
9+
#include <linux/gpio/consumer.h>
1010
#include <linux/gpio/machine.h>
1111
#include <linux/gpio/property.h>
1212
#include <linux/kernel.h>
@@ -251,19 +251,25 @@ static struct i2c_board_info nokia770_i2c_board_info_2[] __initdata = {
251251

252252
static void __init nokia770_cbus_init(void)
253253
{
254-
const int retu_irq_gpio = 62;
255-
const int tahvo_irq_gpio = 40;
256-
257-
if (gpio_request_one(retu_irq_gpio, GPIOF_IN, "Retu IRQ"))
258-
return;
259-
if (gpio_request_one(tahvo_irq_gpio, GPIOF_IN, "Tahvo IRQ")) {
260-
gpio_free(retu_irq_gpio);
261-
return;
254+
struct gpio_desc *d;
255+
int irq;
256+
257+
d = gpiod_get(NULL, "retu_irq", GPIOD_IN);
258+
if (IS_ERR(d)) {
259+
pr_err("Unable to get CBUS Retu IRQ GPIO descriptor\n");
260+
} else {
261+
irq = gpiod_to_irq(d);
262+
irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
263+
nokia770_i2c_board_info_2[0].irq = irq;
264+
}
265+
d = gpiod_get(NULL, "tahvo_irq", GPIOD_IN);
266+
if (IS_ERR(d)) {
267+
pr_err("Unable to get CBUS Tahvo IRQ GPIO descriptor\n");
268+
} else {
269+
irq = gpiod_to_irq(d);
270+
irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
271+
nokia770_i2c_board_info_2[1].irq = irq;
262272
}
263-
irq_set_irq_type(gpio_to_irq(retu_irq_gpio), IRQ_TYPE_EDGE_RISING);
264-
irq_set_irq_type(gpio_to_irq(tahvo_irq_gpio), IRQ_TYPE_EDGE_RISING);
265-
nokia770_i2c_board_info_2[0].irq = gpio_to_irq(retu_irq_gpio);
266-
nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio);
267273
i2c_register_board_info(2, nokia770_i2c_board_info_2,
268274
ARRAY_SIZE(nokia770_i2c_board_info_2));
269275
device_create_managed_software_node(&nokia770_cbus_device.dev,
@@ -276,8 +282,26 @@ static void __init nokia770_cbus_init(void)
276282
}
277283
#endif /* CONFIG_I2C_CBUS_GPIO */
278284

285+
static struct gpiod_lookup_table nokia770_irq_gpio_table = {
286+
.dev_id = NULL,
287+
.table = {
288+
/* GPIO used by SPI device 1 */
289+
GPIO_LOOKUP("gpio-0-15", 15, "ads7846_irq",
290+
GPIO_ACTIVE_HIGH),
291+
/* GPIO used for retu IRQ */
292+
GPIO_LOOKUP("gpio-48-63", 15, "retu_irq",
293+
GPIO_ACTIVE_HIGH),
294+
/* GPIO used for tahvo IRQ */
295+
GPIO_LOOKUP("gpio-32-47", 8, "tahvo_irq",
296+
GPIO_ACTIVE_HIGH),
297+
{ }
298+
},
299+
};
300+
279301
static void __init omap_nokia770_init(void)
280302
{
303+
struct gpio_desc *d;
304+
281305
/* On Nokia 770, the SleepX signal is masked with an
282306
* MPUIO line by default. It has to be unmasked for it
283307
* to become functional */
@@ -289,6 +313,14 @@ static void __init omap_nokia770_init(void)
289313

290314
software_node_register_node_group(nokia770_gpiochip_nodes);
291315
platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
316+
317+
gpiod_add_lookup_table(&nokia770_irq_gpio_table);
318+
d = gpiod_get(NULL, "ads7846_irq", GPIOD_IN);
319+
if (IS_ERR(d))
320+
pr_err("Unable to get ADS7846 IRQ GPIO descriptor\n");
321+
else
322+
nokia770_spi_board_info[1].irq = gpiod_to_irq(d);
323+
292324
spi_register_board_info(nokia770_spi_board_info,
293325
ARRAY_SIZE(nokia770_spi_board_info));
294326
omap_serial_init();

0 commit comments

Comments
 (0)