aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanusz Krzysztofik <jmkrzyszt@gmail.com>2018-09-09 19:44:18 -0400
committerTony Lindgren <tony@atomide.com>2018-09-20 17:13:43 -0400
commit1464d031c45da44da6988623c0978b63241df40b (patch)
treec1b262314cbec52e9f1eab8e9ada1c2ecc1057d3
parent0812db94374867324a7811b733f95d5aa06e28b5 (diff)
ARM: OMAP1: ams-delta: initialize latch2 pins to safe values
Latch2 pins control a number of on-board devices, namely LCD, NAND, MODEM and CODEC. Those pins used to be initialized with safe values from init_machine before that operation was: 1) moved to late_initcall in preparation for conversion of latch2 to GPIO device - see commit f7519d8c8290 ("ARM: OMAP1: ams-delta: register latch dependent devices later"), 2) replaced with non-atomic initialization performed by means of gpio_request_array() - see commit 937eb4bb0058 ("ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio"), 3) made completely asynchronous by delegation of GPIO request operations performed on subsets of pins to respective device drivers in subsequent commits. One visible negative result of that disintegration was corrupt keyboard data reported by serio driver, recently fixed by commit 41f8fee385a0 ("ARM: OMAP1: ams-delta: Hog "keybrd_dataout" GPIO pin"). Moreover, initialization of LATCH2_PIN_MODEM_CODEC still performed with ams_delta_latch2_write() wrapper from late_init() is now done on not requested GPIO pin. Reintroduce atomic initialization of latch2 pins at machine_init to prevent from random values potentially corrupting NAND data or maybe even destroing other hardware. Also take care of MODEM/CODEC related pins so MODEM device probe succeeds even if latch2 GPIO device or dependent regulator is not ready and CODEC can be reached over the MODEM even if audio driver doesn't take control over LATCH2_PIN_MODEM_CODEC. Once done, remove the no longer needed GPIO based implementation of ams_delta_latch_write() and its frontend macro. Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> [tony@atomide.com: updated for the header location to remove dependency] Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c52
-rw-r--r--arch/arm/mach-omap1/include/mach/board-ams-delta.h7
2 files changed, 35 insertions, 24 deletions
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 4ff3551d93d3..fda402c837d9 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -321,20 +321,6 @@ struct modem_private_data {
321 321
322static struct modem_private_data modem_priv; 322static struct modem_private_data modem_priv;
323 323
324void 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}
336EXPORT_SYMBOL(ams_delta_latch_write);
337
338static struct resource ams_delta_nand_resources[] = { 324static struct resource ams_delta_nand_resources[] = {
339 [0] = { 325 [0] = {
340 .start = OMAP1_MPUIO_BASE, 326 .start = OMAP1_MPUIO_BASE,
@@ -680,6 +666,40 @@ static void __init omap_gpio_deps_init(void)
680 modem_assign_irq(chip); 666 modem_assign_irq(chip);
681} 667}
682 668
669/*
670 * Initialize latch2 pins with values which are safe for dependent on-board
671 * devices or useful for their successull initialization even before GPIO
672 * driver takes control over the latch pins:
673 * - LATCH2_PIN_LCD_VBLEN = 0
674 * - LATCH2_PIN_LCD_NDISP = 0 Keep LCD device powered off before its
675 * driver takes control over it.
676 * - LATCH2_PIN_NAND_NCE = 0
677 * - LATCH2_PIN_NAND_NWP = 0 Keep NAND device down and write-
678 * protected before its driver takes
679 * control over it.
680 * - LATCH2_PIN_KEYBRD_PWR = 0 Keep keyboard powered off before serio
681 * driver takes control over it.
682 * - LATCH2_PIN_KEYBRD_DATAOUT = 0 Keep low to avoid corruption of first
683 * byte of data received from attached
684 * keyboard when serio device is probed;
685 * the pin is also hogged low by the latch2
686 * GPIO driver as soon as it is ready.
687 * - LATCH2_PIN_MODEM_NRESET = 1 Enable voice MODEM device, allowing for
688 * its successful probe even before a
689 * regulator it depends on, which in turn
690 * takes control over the pin, is set up.
691 * - LATCH2_PIN_MODEM_CODEC = 1 Attach voice MODEM CODEC data port
692 * to the MODEM so the CODEC is under
693 * control even if audio driver doesn't
694 * take it over.
695 */
696static void __init ams_delta_latch2_init(void)
697{
698 u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC;
699
700 __raw_writew(latch2, LATCH2_VIRT);
701}
702
683static void __init ams_delta_init(void) 703static void __init ams_delta_init(void)
684{ 704{
685 /* mux pins for uarts */ 705 /* mux pins for uarts */
@@ -701,6 +721,7 @@ static void __init ams_delta_init(void)
701 omap_cfg_reg(J18_1610_CAM_D7); 721 omap_cfg_reg(J18_1610_CAM_D7);
702 722
703 omap_gpio_deps_init(); 723 omap_gpio_deps_init();
724 ams_delta_latch2_init();
704 gpiod_add_hogs(ams_delta_gpio_hogs); 725 gpiod_add_hogs(ams_delta_gpio_hogs);
705 726
706 omap_serial_init(); 727 omap_serial_init();
@@ -888,9 +909,6 @@ static int __init ams_delta_modem_init(void)
888 /* Initialize the modem_nreset regulator consumer before use */ 909 /* Initialize the modem_nreset regulator consumer before use */
889 modem_priv.regulator = ERR_PTR(-ENODEV); 910 modem_priv.regulator = ERR_PTR(-ENODEV);
890 911
891 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
892 AMS_DELTA_LATCH2_MODEM_CODEC);
893
894 err = platform_device_register(&ams_delta_modem_device); 912 err = platform_device_register(&ams_delta_modem_device);
895 913
896 return err; 914 return err;
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__
63void 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 */