zylonite_pxa320.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * linux/arch/arm/mach-pxa/zylonite_pxa320.c
  3. *
  4. * PXA320 specific support code for the
  5. * PXA3xx Development Platform (aka Zylonite)
  6. *
  7. * Copyright (C) 2007 Marvell Internation Ltd.
  8. * 2007-08-21: eric miao <eric.miao@marvell.com>
  9. * initial version
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/module.h>
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <mach/gpio.h>
  19. #include <mach/mfp-pxa320.h>
  20. #include <mach/zylonite.h>
  21. #include "generic.h"
  22. static mfp_cfg_t mfp_cfg[] __initdata = {
  23. /* LCD */
  24. GPIO6_2_LCD_LDD_0,
  25. GPIO7_2_LCD_LDD_1,
  26. GPIO8_2_LCD_LDD_2,
  27. GPIO9_2_LCD_LDD_3,
  28. GPIO10_2_LCD_LDD_4,
  29. GPIO11_2_LCD_LDD_5,
  30. GPIO12_2_LCD_LDD_6,
  31. GPIO13_2_LCD_LDD_7,
  32. GPIO63_LCD_LDD_8,
  33. GPIO64_LCD_LDD_9,
  34. GPIO65_LCD_LDD_10,
  35. GPIO66_LCD_LDD_11,
  36. GPIO67_LCD_LDD_12,
  37. GPIO68_LCD_LDD_13,
  38. GPIO69_LCD_LDD_14,
  39. GPIO70_LCD_LDD_15,
  40. GPIO71_LCD_LDD_16,
  41. GPIO72_LCD_LDD_17,
  42. GPIO73_LCD_CS_N,
  43. GPIO74_LCD_VSYNC,
  44. GPIO14_2_LCD_FCLK,
  45. GPIO15_2_LCD_LCLK,
  46. GPIO16_2_LCD_PCLK,
  47. GPIO17_2_LCD_BIAS,
  48. GPIO14_PWM3_OUT, /* backlight */
  49. /* FFUART */
  50. GPIO41_UART1_RXD | MFP_LPM_EDGE_FALL,
  51. GPIO42_UART1_TXD,
  52. GPIO43_UART1_CTS,
  53. GPIO44_UART1_DCD,
  54. GPIO45_UART1_DSR | MFP_LPM_EDGE_FALL,
  55. GPIO46_UART1_RI,
  56. GPIO47_UART1_DTR,
  57. GPIO48_UART1_RTS,
  58. /* AC97 */
  59. GPIO34_AC97_SYSCLK,
  60. GPIO35_AC97_SDATA_IN_0,
  61. GPIO37_AC97_SDATA_OUT,
  62. GPIO38_AC97_SYNC,
  63. GPIO39_AC97_BITCLK,
  64. GPIO40_AC97_nACRESET,
  65. /* SSP3 */
  66. GPIO89_SSP3_SCLK,
  67. GPIO90_SSP3_FRM,
  68. GPIO91_SSP3_TXD,
  69. GPIO92_SSP3_RXD,
  70. /* WM9713 IRQ */
  71. GPIO15_GPIO,
  72. /* I2C */
  73. GPIO32_I2C_SCL,
  74. GPIO33_I2C_SDA,
  75. /* Keypad */
  76. GPIO105_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
  77. GPIO106_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
  78. GPIO113_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
  79. GPIO114_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
  80. GPIO115_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
  81. GPIO116_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
  82. GPIO117_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
  83. GPIO118_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
  84. GPIO119_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
  85. GPIO120_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
  86. GPIO121_KP_MKOUT_0,
  87. GPIO122_KP_MKOUT_1,
  88. GPIO123_KP_MKOUT_2,
  89. GPIO124_KP_MKOUT_3,
  90. GPIO125_KP_MKOUT_4,
  91. GPIO126_KP_MKOUT_5,
  92. GPIO127_KP_MKOUT_6,
  93. GPIO5_2_KP_MKOUT_7,
  94. /* Ethernet */
  95. GPIO4_nCS3,
  96. GPIO90_GPIO,
  97. /* MMC1 */
  98. GPIO18_MMC1_DAT0,
  99. GPIO19_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
  100. GPIO20_MMC1_DAT2,
  101. GPIO21_MMC1_DAT3,
  102. GPIO22_MMC1_CLK,
  103. GPIO23_MMC1_CMD,/* CMD0 for slot 0 */
  104. GPIO31_GPIO, /* CMD1 default as GPIO for slot 0 */
  105. /* MMC2 */
  106. GPIO24_MMC2_DAT0,
  107. GPIO25_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
  108. GPIO26_MMC2_DAT2,
  109. GPIO27_MMC2_DAT3,
  110. GPIO28_MMC2_CLK,
  111. GPIO29_MMC2_CMD,
  112. /* Debug LEDs */
  113. GPIO1_2_GPIO | MFP_LPM_DRIVE_HIGH,
  114. GPIO4_2_GPIO | MFP_LPM_DRIVE_HIGH,
  115. };
  116. #define NUM_LCD_DETECT_PINS 7
  117. static int lcd_detect_pins[] __initdata = {
  118. MFP_PIN_GPIO72, /* LCD_LDD_17 - ORIENT */
  119. MFP_PIN_GPIO71, /* LCD_LDD_16 - LCDID[5] */
  120. MFP_PIN_GPIO17_2, /* LCD_BIAS - LCDID[4] */
  121. MFP_PIN_GPIO15_2, /* LCD_LCLK - LCDID[3] */
  122. MFP_PIN_GPIO14_2, /* LCD_FCLK - LCDID[2] */
  123. MFP_PIN_GPIO73, /* LCD_CS_N - LCDID[1] */
  124. MFP_PIN_GPIO74, /* LCD_VSYNC - LCDID[0] */
  125. /*
  126. * set the MFP_PIN_GPIO 14/15/17 to alternate function other than
  127. * GPIO to avoid input level confliction with 14_2, 15_2, 17_2
  128. */
  129. MFP_PIN_GPIO14,
  130. MFP_PIN_GPIO15,
  131. MFP_PIN_GPIO17,
  132. };
  133. static int lcd_detect_mfpr[] __initdata = {
  134. /* AF0, DS 1X, Pull Neither, Edge Clear */
  135. 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440,
  136. 0xc442, /* Backlight, Pull-Up, AF2 */
  137. 0x8445, /* AF5 */
  138. 0x8445, /* AF5 */
  139. };
  140. static void __init zylonite_detect_lcd_panel(void)
  141. {
  142. unsigned long mfpr_save[ARRAY_SIZE(lcd_detect_pins)];
  143. int i, gpio, id = 0;
  144. /* save the original MFP settings of these pins and configure them
  145. * as GPIO Input, DS01X, Pull Neither, Edge Clear
  146. */
  147. for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) {
  148. mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
  149. pxa3xx_mfp_write(lcd_detect_pins[i], lcd_detect_mfpr[i]);
  150. }
  151. for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
  152. id = id << 1;
  153. gpio = mfp_to_gpio(lcd_detect_pins[i]);
  154. gpio_direction_input(gpio);
  155. if (gpio_get_value(gpio))
  156. id = id | 0x1;
  157. }
  158. /* lcd id, flush out bit 1 */
  159. lcd_id = id & 0x3d;
  160. /* lcd orientation, portrait or landscape */
  161. lcd_orientation = (id >> 6) & 0x1;
  162. /* restore the original MFP settings */
  163. for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++)
  164. pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
  165. }
  166. void __init zylonite_pxa320_init(void)
  167. {
  168. if (cpu_is_pxa320()) {
  169. /* initialize MFP */
  170. pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg));
  171. /* detect LCD panel */
  172. zylonite_detect_lcd_panel();
  173. /* GPIO pin assignment */
  174. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO9);
  175. gpio_debug_led1 = mfp_to_gpio(MFP_PIN_GPIO1_2);
  176. gpio_debug_led2 = mfp_to_gpio(MFP_PIN_GPIO4_2);
  177. /* MMC card detect & write protect for controller 0 */
  178. zylonite_mmc_slot[0].gpio_cd = mfp_to_gpio(MFP_PIN_GPIO1);
  179. zylonite_mmc_slot[0].gpio_wp = mfp_to_gpio(MFP_PIN_GPIO5);
  180. /* WM9713 IRQ */
  181. wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO15);
  182. }
  183. }