Skip to content

Commit 0812db9

Browse files
jkrzyszttmlind
authored andcommitted
ARM: OMAP1: ams-delta: assign MODEM IRQ from GPIO descriptor
Don't request MODEM IRQ GPIO by its global number in ams_delta_modem_init(). Instead, obtain its GPIO descriptor and assign related IRQ to the MODEM. Do that from omap_gpio_deps_init(), where the chip is already looked up. Then, in ams_delta_modem_init(), just check for the IRQ number having been already assigned. Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Tony Lindgren <tony@atomide.com>
1 parent 5b394b2 commit 0812db9

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

arch/arm/mach-omap1/board-ams-delta.c

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,28 @@ static struct gpiod_hog ams_delta_gpio_hogs[] = {
630630
{},
631631
};
632632

633+
static struct plat_serial8250_port ams_delta_modem_ports[];
634+
635+
/*
636+
* Obtain MODEM IRQ GPIO descriptor using its hardware pin
637+
* number and assign related IRQ number to the MODEM port.
638+
* Keep the GPIO descriptor open so nobody steps in.
639+
*/
640+
static void __init modem_assign_irq(struct gpio_chip *chip)
641+
{
642+
struct gpio_desc *gpiod;
643+
644+
gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ,
645+
"modem_irq");
646+
if (IS_ERR(gpiod)) {
647+
pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__,
648+
PTR_ERR(gpiod));
649+
} else {
650+
gpiod_direction_input(gpiod);
651+
ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod);
652+
}
653+
}
654+
633655
/*
634656
* The purpose of this function is to take care of proper initialization of
635657
* devices and data structures which depend on GPIO lines provided by OMAP GPIO
@@ -649,7 +671,13 @@ static void __init omap_gpio_deps_init(void)
649671
return;
650672
}
651673

674+
/*
675+
* Start with FIQ initialization as it may have to request
676+
* and release successfully each OMAP GPIO pin in turn.
677+
*/
652678
ams_delta_init_fiq(chip, &ams_delta_serio_device);
679+
680+
modem_assign_irq(chip);
653681
}
654682

655683
static void __init ams_delta_init(void)
@@ -844,20 +872,18 @@ static int __init modem_nreset_init(void)
844872
}
845873

846874

875+
/*
876+
* This function expects MODEM IRQ number already assigned to the port
877+
* and fails if it's not.
878+
*/
847879
static int __init ams_delta_modem_init(void)
848880
{
849881
int err;
850882

851-
omap_cfg_reg(M14_1510_GPIO2);
852-
ams_delta_modem_ports[0].irq =
853-
gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
883+
if (ams_delta_modem_ports[0].irq < 0)
884+
return ams_delta_modem_ports[0].irq;
854885

855-
err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem");
856-
if (err) {
857-
pr_err("Couldn't request gpio pin for modem\n");
858-
return err;
859-
}
860-
gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
886+
omap_cfg_reg(M14_1510_GPIO2);
861887

862888
/* Initialize the modem_nreset regulator consumer before use */
863889
modem_priv.regulator = ERR_PTR(-ENODEV);
@@ -866,8 +892,6 @@ static int __init ams_delta_modem_init(void)
866892
AMS_DELTA_LATCH2_MODEM_CODEC);
867893

868894
err = platform_device_register(&ams_delta_modem_device);
869-
if (err)
870-
gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
871895

872896
return err;
873897
}
@@ -898,7 +922,6 @@ static int __init late_init(void)
898922

899923
unregister:
900924
platform_device_unregister(&ams_delta_modem_device);
901-
gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
902925
return err;
903926
}
904927

0 commit comments

Comments
 (0)