diff options
author | Janusz Krzysztofik <jmkrzyszt@gmail.com> | 2018-09-09 19:44:17 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2018-09-20 17:06:43 -0400 |
commit | 0812db94374867324a7811b733f95d5aa06e28b5 (patch) | |
tree | 0347d8c4e700ef02db940766ae59d7e037618695 | |
parent | 5b394b2ddf0347bef56e50c69a58773c94343ff3 (diff) |
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>
-rw-r--r-- | arch/arm/mach-omap1/board-ams-delta.c | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index dd28d2614d7f..4ff3551d93d3 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c | |||
@@ -630,6 +630,28 @@ static struct gpiod_hog ams_delta_gpio_hogs[] = { | |||
630 | {}, | 630 | {}, |
631 | }; | 631 | }; |
632 | 632 | ||
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 | |||
633 | /* | 655 | /* |
634 | * The purpose of this function is to take care of proper initialization of | 656 | * The purpose of this function is to take care of proper initialization of |
635 | * devices and data structures which depend on GPIO lines provided by OMAP GPIO | 657 | * 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) | |||
649 | return; | 671 | return; |
650 | } | 672 | } |
651 | 673 | ||
674 | /* | ||
675 | * Start with FIQ initialization as it may have to request | ||
676 | * and release successfully each OMAP GPIO pin in turn. | ||
677 | */ | ||
652 | ams_delta_init_fiq(chip, &ams_delta_serio_device); | 678 | ams_delta_init_fiq(chip, &ams_delta_serio_device); |
679 | |||
680 | modem_assign_irq(chip); | ||
653 | } | 681 | } |
654 | 682 | ||
655 | static void __init ams_delta_init(void) | 683 | static void __init ams_delta_init(void) |
@@ -844,20 +872,18 @@ static int __init modem_nreset_init(void) | |||
844 | } | 872 | } |
845 | 873 | ||
846 | 874 | ||
875 | /* | ||
876 | * This function expects MODEM IRQ number already assigned to the port | ||
877 | * and fails if it's not. | ||
878 | */ | ||
847 | static int __init ams_delta_modem_init(void) | 879 | static int __init ams_delta_modem_init(void) |
848 | { | 880 | { |
849 | int err; | 881 | int err; |
850 | 882 | ||
851 | omap_cfg_reg(M14_1510_GPIO2); | 883 | if (ams_delta_modem_ports[0].irq < 0) |
852 | ams_delta_modem_ports[0].irq = | 884 | return ams_delta_modem_ports[0].irq; |
853 | gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); | ||
854 | 885 | ||
855 | err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem"); | 886 | omap_cfg_reg(M14_1510_GPIO2); |
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); | ||
861 | 887 | ||
862 | /* Initialize the modem_nreset regulator consumer before use */ | 888 | /* Initialize the modem_nreset regulator consumer before use */ |
863 | modem_priv.regulator = ERR_PTR(-ENODEV); | 889 | modem_priv.regulator = ERR_PTR(-ENODEV); |
@@ -866,8 +892,6 @@ static int __init ams_delta_modem_init(void) | |||
866 | AMS_DELTA_LATCH2_MODEM_CODEC); | 892 | AMS_DELTA_LATCH2_MODEM_CODEC); |
867 | 893 | ||
868 | err = platform_device_register(&ams_delta_modem_device); | 894 | err = platform_device_register(&ams_delta_modem_device); |
869 | if (err) | ||
870 | gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); | ||
871 | 895 | ||
872 | return err; | 896 | return err; |
873 | } | 897 | } |
@@ -898,7 +922,6 @@ static int __init late_init(void) | |||
898 | 922 | ||
899 | unregister: | 923 | unregister: |
900 | platform_device_unregister(&ams_delta_modem_device); | 924 | platform_device_unregister(&ams_delta_modem_device); |
901 | gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); | ||
902 | return err; | 925 | return err; |
903 | } | 926 | } |
904 | 927 | ||