Commit 2c33727a62ac07eed3ae423c209f549394c5c4e9

Authored by Mike Dunn
Committed by Haojian Zhuang
1 parent 7d1f9aeff1

ARM: palmtreo: fix lcd initilialization on treo680

This patch gets the LCD working on my Palm Treo680 by adding some code that
manages the three gpios interfaced to the lcd on the Treo 680.  The precise role
of each gpio in the hardware architecture is not entirely clear to me; this
patch is the result of trial-and-error and observing how the PalmOS code
initializes the lcd.

The need for this patch is not evident when Linux is loaded from PalmOS, because
at that point the lcd-related gpios have already been configured.  But when
booting the kernel by other means, this patch is required unless the bootloader
has performed the necessary initialializations.

Signed-off-by: Mike Dunn <mikedunn@newsguy.com>
Acked-by: Tomas Cech <sleep_walker@suse.cz>
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>

Showing 2 changed files with 61 additions and 3 deletions Side-by-side Diff

arch/arm/mach-pxa/include/mach/palmtreo.h
... ... @@ -44,6 +44,9 @@
44 44 #define GPIO_NR_TREO680_VIBRATE_EN 44
45 45 #define GPIO_NR_TREO680_KEYB_BL 24
46 46 #define GPIO_NR_TREO680_BT_EN 43
  47 +#define GPIO_NR_TREO680_LCD_POWER 77
  48 +#define GPIO_NR_TREO680_LCD_EN 86
  49 +#define GPIO_NR_TREO680_LCD_EN_N 25
47 50 #endif /* CONFIG_MACH_TREO680 */
48 51  
49 52 /* Centro685 specific GPIOs */
arch/arm/mach-pxa/palmtreo.c
... ... @@ -98,9 +98,6 @@
98 98 GPIO96_KP_MKOUT_6,
99 99 GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH, /* Hotsync button */
100 100  
101   - /* LCD */
102   - GPIOxx_LCD_TFT_16BPP,
103   -
104 101 /* Quick Capture Interface */
105 102 GPIO84_CIF_FV,
106 103 GPIO85_CIF_LV,
... ... @@ -140,6 +137,12 @@
140 137 /* MATRIX KEYPAD - different wake up source */
141 138 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
142 139 GPIO99_KP_MKIN_5,
  140 +
  141 + /* LCD... L_BIAS alt fn not configured on Treo680; is GPIO instead */
  142 + GPIOxx_LCD_16BPP,
  143 + GPIO74_LCD_FCLK,
  144 + GPIO75_LCD_LCLK,
  145 + GPIO76_LCD_PCLK,
143 146 };
144 147 #endif /* CONFIG_MACH_TREO680 */
145 148  
... ... @@ -155,6 +158,9 @@
155 158 /* MATRIX KEYPAD - different wake up source */
156 159 GPIO100_KP_MKIN_0,
157 160 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
  161 +
  162 + /* LCD */
  163 + GPIOxx_LCD_TFT_16BPP,
158 164 };
159 165 #endif /* CONFIG_MACH_CENTRO */
160 166  
161 167  
... ... @@ -424,10 +430,59 @@
424 430 }
425 431  
426 432 #ifdef CONFIG_MACH_TREO680
  433 +void __init treo680_gpio_init(void)
  434 +{
  435 + unsigned int gpio;
  436 +
  437 + /* drive all three lcd gpios high initially */
  438 + const unsigned long lcd_flags = GPIOF_INIT_HIGH | GPIOF_DIR_OUT;
  439 +
  440 + /*
  441 + * LCD GPIO initialization...
  442 + */
  443 +
  444 + /*
  445 + * This is likely the power to the lcd. Toggling it low/high appears to
  446 + * turn the lcd off/on. Can be toggled after lcd is initialized without
  447 + * any apparent adverse effects to the lcd operation. Note that this
  448 + * gpio line is used by the lcd controller as the L_BIAS signal, but
  449 + * treo680 configures it as gpio.
  450 + */
  451 + gpio = GPIO_NR_TREO680_LCD_POWER;
  452 + if (gpio_request_one(gpio, lcd_flags, "LCD power") < 0)
  453 + goto fail;
  454 +
  455 + /*
  456 + * These two are called "enables", for lack of a better understanding.
  457 + * If either of these are toggled after the lcd is initialized, the
  458 + * image becomes degraded. N.B. The IPL shipped with the treo
  459 + * configures GPIO_NR_TREO680_LCD_EN_N as output and drives it high. If
  460 + * the IPL is ever reprogrammed, this initialization may be need to be
  461 + * revisited.
  462 + */
  463 + gpio = GPIO_NR_TREO680_LCD_EN;
  464 + if (gpio_request_one(gpio, lcd_flags, "LCD enable") < 0)
  465 + goto fail;
  466 + gpio = GPIO_NR_TREO680_LCD_EN_N;
  467 + if (gpio_request_one(gpio, lcd_flags, "LCD enable_n") < 0)
  468 + goto fail;
  469 +
  470 + /* driving this low turns LCD on */
  471 + gpio_set_value(GPIO_NR_TREO680_LCD_EN_N, 0);
  472 +
  473 + return;
  474 + fail:
  475 + pr_err("gpio %d initialization failed\n", gpio);
  476 + gpio_free(GPIO_NR_TREO680_LCD_POWER);
  477 + gpio_free(GPIO_NR_TREO680_LCD_EN);
  478 + gpio_free(GPIO_NR_TREO680_LCD_EN_N);
  479 +}
  480 +
427 481 static void __init treo680_init(void)
428 482 {
429 483 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
430 484 palmphone_common_init();
  485 + treo680_gpio_init();
431 486 palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, GPIO_NR_TREO680_SD_READONLY,
432 487 GPIO_NR_TREO680_SD_POWER, 0);
433 488 }