diff options
-rw-r--r-- | arch/arm/mach-omap1/ams-delta-fiq-handler.S | 12 | ||||
-rw-r--r-- | arch/arm/mach-omap1/board-ams-delta.c | 161 | ||||
-rw-r--r-- | arch/arm/mach-omap1/include/mach/board-ams-delta.h | 7 | ||||
-rw-r--r-- | include/linux/platform_data/gpio-omap.h | 4 |
4 files changed, 96 insertions, 88 deletions
diff --git a/arch/arm/mach-omap1/ams-delta-fiq-handler.S b/arch/arm/mach-omap1/ams-delta-fiq-handler.S index ddc27638ba2a..e3faa0274b56 100644 --- a/arch/arm/mach-omap1/ams-delta-fiq-handler.S +++ b/arch/arm/mach-omap1/ams-delta-fiq-handler.S | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/linkage.h> | 16 | #include <linux/linkage.h> |
17 | #include <linux/platform_data/ams-delta-fiq.h> | 17 | #include <linux/platform_data/ams-delta-fiq.h> |
18 | #include <linux/platform_data/gpio-omap.h> | ||
18 | 19 | ||
19 | #include <asm/assembler.h> | 20 | #include <asm/assembler.h> |
20 | #include <mach/board-ams-delta.h> | 21 | #include <mach/board-ams-delta.h> |
@@ -24,17 +25,10 @@ | |||
24 | #include "soc.h" | 25 | #include "soc.h" |
25 | 26 | ||
26 | /* | 27 | /* |
27 | * GPIO related definitions, copied from arch/arm/plat-omap/gpio.c. | 28 | * OMAP1510 GPIO related symbol copied from arch/arm/mach-omap1/gpio15xx.c. |
28 | * Unfortunately, those were not placed in a separate header file. | 29 | * Unfortunately, it was not placed in a separate header file. |
29 | */ | 30 | */ |
30 | #define OMAP1510_GPIO_BASE 0xFFFCE000 | 31 | #define OMAP1510_GPIO_BASE 0xFFFCE000 |
31 | #define OMAP1510_GPIO_DATA_INPUT 0x00 | ||
32 | #define OMAP1510_GPIO_DATA_OUTPUT 0x04 | ||
33 | #define OMAP1510_GPIO_DIR_CONTROL 0x08 | ||
34 | #define OMAP1510_GPIO_INT_CONTROL 0x0c | ||
35 | #define OMAP1510_GPIO_INT_MASK 0x10 | ||
36 | #define OMAP1510_GPIO_INT_STATUS 0x14 | ||
37 | #define OMAP1510_GPIO_PIN_CONTROL 0x18 | ||
38 | 32 | ||
39 | /* GPIO register bitmasks */ | 33 | /* GPIO register bitmasks */ |
40 | #define KEYBRD_DATA_MASK (0x1 << AMS_DELTA_GPIO_PIN_KEYBRD_DATA) | 34 | #define KEYBRD_DATA_MASK (0x1 << AMS_DELTA_GPIO_PIN_KEYBRD_DATA) |
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index dd28d2614d7f..318925ae3ebe 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c | |||
@@ -250,39 +250,6 @@ static struct platform_device latch2_gpio_device = { | |||
250 | #define LATCH2_PIN_HOOKFLASH1 14 | 250 | #define LATCH2_PIN_HOOKFLASH1 14 |
251 | #define LATCH2_PIN_HOOKFLASH2 15 | 251 | #define LATCH2_PIN_HOOKFLASH2 15 |
252 | 252 | ||
253 | static const struct gpio latch_gpios[] __initconst = { | ||
254 | { | ||
255 | .gpio = LATCH1_GPIO_BASE + 6, | ||
256 | .flags = GPIOF_OUT_INIT_LOW, | ||
257 | .label = "dockit1", | ||
258 | }, | ||
259 | { | ||
260 | .gpio = LATCH1_GPIO_BASE + 7, | ||
261 | .flags = GPIOF_OUT_INIT_LOW, | ||
262 | .label = "dockit2", | ||
263 | }, | ||
264 | { | ||
265 | .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN, | ||
266 | .flags = GPIOF_OUT_INIT_LOW, | ||
267 | .label = "scard_rstin", | ||
268 | }, | ||
269 | { | ||
270 | .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC, | ||
271 | .flags = GPIOF_OUT_INIT_LOW, | ||
272 | .label = "scard_cmdvcc", | ||
273 | }, | ||
274 | { | ||
275 | .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14, | ||
276 | .flags = GPIOF_OUT_INIT_LOW, | ||
277 | .label = "hookflash1", | ||
278 | }, | ||
279 | { | ||
280 | .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15, | ||
281 | .flags = GPIOF_OUT_INIT_LOW, | ||
282 | .label = "hookflash2", | ||
283 | }, | ||
284 | }; | ||
285 | |||
286 | static struct regulator_consumer_supply modem_nreset_consumers[] = { | 253 | static struct regulator_consumer_supply modem_nreset_consumers[] = { |
287 | REGULATOR_SUPPLY("RESET#", "serial8250.1"), | 254 | REGULATOR_SUPPLY("RESET#", "serial8250.1"), |
288 | REGULATOR_SUPPLY("POR", "cx20442-codec"), | 255 | REGULATOR_SUPPLY("POR", "cx20442-codec"), |
@@ -321,20 +288,6 @@ struct modem_private_data { | |||
321 | 288 | ||
322 | static struct modem_private_data modem_priv; | 289 | static struct modem_private_data modem_priv; |
323 | 290 | ||
324 | void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value) | ||
325 | { | ||
326 | int bit = 0; | ||
327 | u16 bitpos = 1 << bit; | ||
328 | |||
329 | for (; bit < ngpio; bit++, bitpos = bitpos << 1) { | ||
330 | if (!(mask & bitpos)) | ||
331 | continue; | ||
332 | else | ||
333 | gpio_set_value(base + bit, (value & bitpos) != 0); | ||
334 | } | ||
335 | } | ||
336 | EXPORT_SYMBOL(ams_delta_latch_write); | ||
337 | |||
338 | static struct resource ams_delta_nand_resources[] = { | 291 | static struct resource ams_delta_nand_resources[] = { |
339 | [0] = { | 292 | [0] = { |
340 | .start = OMAP1_MPUIO_BASE, | 293 | .start = OMAP1_MPUIO_BASE, |
@@ -630,6 +583,28 @@ static struct gpiod_hog ams_delta_gpio_hogs[] = { | |||
630 | {}, | 583 | {}, |
631 | }; | 584 | }; |
632 | 585 | ||
586 | static struct plat_serial8250_port ams_delta_modem_ports[]; | ||
587 | |||
588 | /* | ||
589 | * Obtain MODEM IRQ GPIO descriptor using its hardware pin | ||
590 | * number and assign related IRQ number to the MODEM port. | ||
591 | * Keep the GPIO descriptor open so nobody steps in. | ||
592 | */ | ||
593 | static void __init modem_assign_irq(struct gpio_chip *chip) | ||
594 | { | ||
595 | struct gpio_desc *gpiod; | ||
596 | |||
597 | gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ, | ||
598 | "modem_irq"); | ||
599 | if (IS_ERR(gpiod)) { | ||
600 | pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__, | ||
601 | PTR_ERR(gpiod)); | ||
602 | } else { | ||
603 | gpiod_direction_input(gpiod); | ||
604 | ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod); | ||
605 | } | ||
606 | } | ||
607 | |||
633 | /* | 608 | /* |
634 | * The purpose of this function is to take care of proper initialization of | 609 | * 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 | 610 | * devices and data structures which depend on GPIO lines provided by OMAP GPIO |
@@ -649,7 +624,47 @@ static void __init omap_gpio_deps_init(void) | |||
649 | return; | 624 | return; |
650 | } | 625 | } |
651 | 626 | ||
627 | /* | ||
628 | * Start with FIQ initialization as it may have to request | ||
629 | * and release successfully each OMAP GPIO pin in turn. | ||
630 | */ | ||
652 | ams_delta_init_fiq(chip, &ams_delta_serio_device); | 631 | ams_delta_init_fiq(chip, &ams_delta_serio_device); |
632 | |||
633 | modem_assign_irq(chip); | ||
634 | } | ||
635 | |||
636 | /* | ||
637 | * Initialize latch2 pins with values which are safe for dependent on-board | ||
638 | * devices or useful for their successull initialization even before GPIO | ||
639 | * driver takes control over the latch pins: | ||
640 | * - LATCH2_PIN_LCD_VBLEN = 0 | ||
641 | * - LATCH2_PIN_LCD_NDISP = 0 Keep LCD device powered off before its | ||
642 | * driver takes control over it. | ||
643 | * - LATCH2_PIN_NAND_NCE = 0 | ||
644 | * - LATCH2_PIN_NAND_NWP = 0 Keep NAND device down and write- | ||
645 | * protected before its driver takes | ||
646 | * control over it. | ||
647 | * - LATCH2_PIN_KEYBRD_PWR = 0 Keep keyboard powered off before serio | ||
648 | * driver takes control over it. | ||
649 | * - LATCH2_PIN_KEYBRD_DATAOUT = 0 Keep low to avoid corruption of first | ||
650 | * byte of data received from attached | ||
651 | * keyboard when serio device is probed; | ||
652 | * the pin is also hogged low by the latch2 | ||
653 | * GPIO driver as soon as it is ready. | ||
654 | * - LATCH2_PIN_MODEM_NRESET = 1 Enable voice MODEM device, allowing for | ||
655 | * its successful probe even before a | ||
656 | * regulator it depends on, which in turn | ||
657 | * takes control over the pin, is set up. | ||
658 | * - LATCH2_PIN_MODEM_CODEC = 1 Attach voice MODEM CODEC data port | ||
659 | * to the MODEM so the CODEC is under | ||
660 | * control even if audio driver doesn't | ||
661 | * take it over. | ||
662 | */ | ||
663 | static void __init ams_delta_latch2_init(void) | ||
664 | { | ||
665 | u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC; | ||
666 | |||
667 | __raw_writew(latch2, LATCH2_VIRT); | ||
653 | } | 668 | } |
654 | 669 | ||
655 | static void __init ams_delta_init(void) | 670 | static void __init ams_delta_init(void) |
@@ -673,6 +688,7 @@ static void __init ams_delta_init(void) | |||
673 | omap_cfg_reg(J18_1610_CAM_D7); | 688 | omap_cfg_reg(J18_1610_CAM_D7); |
674 | 689 | ||
675 | omap_gpio_deps_init(); | 690 | omap_gpio_deps_init(); |
691 | ams_delta_latch2_init(); | ||
676 | gpiod_add_hogs(ams_delta_gpio_hogs); | 692 | gpiod_add_hogs(ams_delta_gpio_hogs); |
677 | 693 | ||
678 | omap_serial_init(); | 694 | omap_serial_init(); |
@@ -813,7 +829,6 @@ static void __init ams_delta_led_init(struct gpio_chip *chip) | |||
813 | static int __init ams_delta_gpio_init(void) | 829 | static int __init ams_delta_gpio_init(void) |
814 | { | 830 | { |
815 | struct gpio_chip *chip; | 831 | struct gpio_chip *chip; |
816 | int err; | ||
817 | 832 | ||
818 | if (!machine_is_ams_delta()) | 833 | if (!machine_is_ams_delta()) |
819 | return -ENODEV; | 834 | return -ENODEV; |
@@ -824,11 +839,7 @@ static int __init ams_delta_gpio_init(void) | |||
824 | else | 839 | else |
825 | ams_delta_led_init(chip); | 840 | ams_delta_led_init(chip); |
826 | 841 | ||
827 | err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios)); | 842 | return 0; |
828 | if (err) | ||
829 | pr_err("Couldn't take over latch1/latch2 GPIO pins\n"); | ||
830 | |||
831 | return err; | ||
832 | } | 843 | } |
833 | device_initcall_sync(ams_delta_gpio_init); | 844 | device_initcall_sync(ams_delta_gpio_init); |
834 | 845 | ||
@@ -844,33 +855,44 @@ static int __init modem_nreset_init(void) | |||
844 | } | 855 | } |
845 | 856 | ||
846 | 857 | ||
858 | /* | ||
859 | * This function expects MODEM IRQ number already assigned to the port | ||
860 | * and fails if it's not. | ||
861 | * The MODEM device requires its RESET# pin kept high during probe. | ||
862 | * That requirement can be fulfilled in several ways: | ||
863 | * - with a descriptor of already functional modem_nreset regulator | ||
864 | * assigned to the MODEM private data, | ||
865 | * - with the regulator not yet controlled by modem_pm function but | ||
866 | * already enabled by default on probe, | ||
867 | * - before the modem_nreset regulator is probed, with the pin already | ||
868 | * set high explicitly. | ||
869 | * The last one is already guaranteed by ams_delta_latch2_init() called | ||
870 | * from machine_init. | ||
871 | * In order to avoid taking over ttyS0 device slot, the MODEM device | ||
872 | * should be registered after OMAP serial ports. Since those ports | ||
873 | * are registered at arch_initcall, this function can be called safely | ||
874 | * at arch_initcall_sync earliest. | ||
875 | */ | ||
847 | static int __init ams_delta_modem_init(void) | 876 | static int __init ams_delta_modem_init(void) |
848 | { | 877 | { |
849 | int err; | 878 | int err; |
850 | 879 | ||
851 | omap_cfg_reg(M14_1510_GPIO2); | 880 | if (!machine_is_ams_delta()) |
852 | ams_delta_modem_ports[0].irq = | 881 | return -ENODEV; |
853 | gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); | ||
854 | 882 | ||
855 | err = gpio_request(AMS_DELTA_GPIO_PIN_MODEM_IRQ, "modem"); | 883 | if (ams_delta_modem_ports[0].irq < 0) |
856 | if (err) { | 884 | return ams_delta_modem_ports[0].irq; |
857 | pr_err("Couldn't request gpio pin for modem\n"); | 885 | |
858 | return err; | 886 | omap_cfg_reg(M14_1510_GPIO2); |
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); |
864 | 890 | ||
865 | ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, | ||
866 | AMS_DELTA_LATCH2_MODEM_CODEC); | ||
867 | |||
868 | err = platform_device_register(&ams_delta_modem_device); | 891 | err = platform_device_register(&ams_delta_modem_device); |
869 | if (err) | ||
870 | gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); | ||
871 | 892 | ||
872 | return err; | 893 | return err; |
873 | } | 894 | } |
895 | arch_initcall_sync(ams_delta_modem_init); | ||
874 | 896 | ||
875 | static int __init late_init(void) | 897 | static int __init late_init(void) |
876 | { | 898 | { |
@@ -880,10 +902,6 @@ static int __init late_init(void) | |||
880 | if (err) | 902 | if (err) |
881 | return err; | 903 | return err; |
882 | 904 | ||
883 | err = ams_delta_modem_init(); | ||
884 | if (err) | ||
885 | return err; | ||
886 | |||
887 | /* | 905 | /* |
888 | * Once the modem device is registered, the modem_nreset | 906 | * Once the modem device is registered, the modem_nreset |
889 | * regulator can be requested on behalf of that device. | 907 | * regulator can be requested on behalf of that device. |
@@ -898,7 +916,6 @@ static int __init late_init(void) | |||
898 | 916 | ||
899 | unregister: | 917 | unregister: |
900 | platform_device_unregister(&ams_delta_modem_device); | 918 | platform_device_unregister(&ams_delta_modem_device); |
901 | gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ); | ||
902 | return err; | 919 | return err; |
903 | } | 920 | } |
904 | 921 | ||
diff --git a/arch/arm/mach-omap1/include/mach/board-ams-delta.h b/arch/arm/mach-omap1/include/mach/board-ams-delta.h index ad6f865d1f16..3b2d8019238a 100644 --- a/arch/arm/mach-omap1/include/mach/board-ams-delta.h +++ b/arch/arm/mach-omap1/include/mach/board-ams-delta.h | |||
@@ -59,13 +59,6 @@ | |||
59 | #define AMS_DELTA_LATCH2_GPIO_BASE AMS_DELTA_GPIO_PIN_LCD_VBLEN | 59 | #define AMS_DELTA_LATCH2_GPIO_BASE AMS_DELTA_GPIO_PIN_LCD_VBLEN |
60 | #define AMS_DELTA_LATCH2_NGPIO 16 | 60 | #define AMS_DELTA_LATCH2_NGPIO 16 |
61 | 61 | ||
62 | #ifndef __ASSEMBLY__ | ||
63 | void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value); | ||
64 | #define ams_delta_latch2_write(mask, value) \ | ||
65 | ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \ | ||
66 | AMS_DELTA_LATCH2_NGPIO, (mask), (value)) | ||
67 | #endif | ||
68 | |||
69 | #endif /* CONFIG_MACH_AMS_DELTA */ | 62 | #endif /* CONFIG_MACH_AMS_DELTA */ |
70 | 63 | ||
71 | #endif /* __ASM_ARCH_OMAP_AMS_DELTA_H */ | 64 | #endif /* __ASM_ARCH_OMAP_AMS_DELTA_H */ |
diff --git a/include/linux/platform_data/gpio-omap.h b/include/linux/platform_data/gpio-omap.h index 8612855691b2..ed071f76b642 100644 --- a/include/linux/platform_data/gpio-omap.h +++ b/include/linux/platform_data/gpio-omap.h | |||
@@ -24,8 +24,10 @@ | |||
24 | #ifndef __ASM_ARCH_OMAP_GPIO_H | 24 | #ifndef __ASM_ARCH_OMAP_GPIO_H |
25 | #define __ASM_ARCH_OMAP_GPIO_H | 25 | #define __ASM_ARCH_OMAP_GPIO_H |
26 | 26 | ||
27 | #ifndef __ASSEMBLER__ | ||
27 | #include <linux/io.h> | 28 | #include <linux/io.h> |
28 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
30 | #endif | ||
29 | 31 | ||
30 | #define OMAP1_MPUIO_BASE 0xfffb5000 | 32 | #define OMAP1_MPUIO_BASE 0xfffb5000 |
31 | 33 | ||
@@ -157,6 +159,7 @@ | |||
157 | #define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr)) | 159 | #define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr)) |
158 | #define OMAP_GPIO_IS_MPUIO(nr) ((nr) >= OMAP_MAX_GPIO_LINES) | 160 | #define OMAP_GPIO_IS_MPUIO(nr) ((nr) >= OMAP_MAX_GPIO_LINES) |
159 | 161 | ||
162 | #ifndef __ASSEMBLER__ | ||
160 | struct omap_gpio_reg_offs { | 163 | struct omap_gpio_reg_offs { |
161 | u16 revision; | 164 | u16 revision; |
162 | u16 direction; | 165 | u16 direction; |
@@ -215,5 +218,6 @@ static inline void omap2_gpio_resume_after_idle(void) | |||
215 | { | 218 | { |
216 | } | 219 | } |
217 | #endif | 220 | #endif |
221 | #endif /* __ASSEMBLER__ */ | ||
218 | 222 | ||
219 | #endif | 223 | #endif |