zylonite_pxa300.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * linux/arch/arm/mach-pxa/zylonite_pxa300.c
  3. *
  4. * PXA300/PXA310 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 <asm/gpio.h>
  19. #include <asm/arch/mfp-pxa300.h>
  20. #include <asm/arch/zylonite.h>
  21. #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
  22. /* PXA300/PXA310 common configurations */
  23. static mfp_cfg_t common_mfp_cfg[] __initdata = {
  24. /* LCD */
  25. GPIO54_LCD_LDD_0,
  26. GPIO55_LCD_LDD_1,
  27. GPIO56_LCD_LDD_2,
  28. GPIO57_LCD_LDD_3,
  29. GPIO58_LCD_LDD_4,
  30. GPIO59_LCD_LDD_5,
  31. GPIO60_LCD_LDD_6,
  32. GPIO61_LCD_LDD_7,
  33. GPIO62_LCD_LDD_8,
  34. GPIO63_LCD_LDD_9,
  35. GPIO64_LCD_LDD_10,
  36. GPIO65_LCD_LDD_11,
  37. GPIO66_LCD_LDD_12,
  38. GPIO67_LCD_LDD_13,
  39. GPIO68_LCD_LDD_14,
  40. GPIO69_LCD_LDD_15,
  41. GPIO70_LCD_LDD_16,
  42. GPIO71_LCD_LDD_17,
  43. GPIO72_LCD_FCLK,
  44. GPIO73_LCD_LCLK,
  45. GPIO74_LCD_PCLK,
  46. GPIO75_LCD_BIAS,
  47. GPIO76_LCD_VSYNC,
  48. GPIO127_LCD_CS_N,
  49. /* BTUART */
  50. GPIO111_UART2_RTS,
  51. GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
  52. GPIO113_UART2_TXD,
  53. GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
  54. /* STUART */
  55. GPIO109_UART3_TXD,
  56. GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
  57. /* AC97 */
  58. GPIO23_AC97_nACRESET,
  59. GPIO24_AC97_SYSCLK,
  60. GPIO29_AC97_BITCLK,
  61. GPIO25_AC97_SDATA_IN_0,
  62. GPIO27_AC97_SDATA_OUT,
  63. GPIO28_AC97_SYNC,
  64. /* Keypad */
  65. GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
  66. GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
  67. GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
  68. GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
  69. GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
  70. GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
  71. GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
  72. GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
  73. GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
  74. GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
  75. GPIO121_KP_MKOUT_0,
  76. GPIO122_KP_MKOUT_1,
  77. GPIO123_KP_MKOUT_2,
  78. GPIO124_KP_MKOUT_3,
  79. GPIO125_KP_MKOUT_4,
  80. GPIO4_2_KP_MKOUT_5,
  81. GPIO5_2_KP_MKOUT_6,
  82. GPIO6_2_KP_MKOUT_7,
  83. /* MMC1 */
  84. GPIO3_MMC1_DAT0,
  85. GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
  86. GPIO5_MMC1_DAT2,
  87. GPIO6_MMC1_DAT3,
  88. GPIO7_MMC1_CLK,
  89. GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
  90. GPIO15_GPIO, /* CMD1 default as GPIO for slot 0 */
  91. /* MMC2 */
  92. GPIO9_MMC2_DAT0,
  93. GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
  94. GPIO11_MMC2_DAT2,
  95. GPIO12_MMC2_DAT3,
  96. GPIO13_MMC2_CLK,
  97. GPIO14_MMC2_CMD,
  98. };
  99. static mfp_cfg_t pxa300_mfp_cfg[] __initdata = {
  100. /* FFUART */
  101. GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
  102. GPIO31_UART1_TXD,
  103. GPIO32_UART1_CTS,
  104. GPIO37_UART1_RTS,
  105. GPIO33_UART1_DCD,
  106. GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
  107. GPIO35_UART1_RI,
  108. GPIO36_UART1_DTR,
  109. /* Ethernet */
  110. GPIO2_nCS3,
  111. GPIO99_GPIO,
  112. };
  113. static mfp_cfg_t pxa310_mfp_cfg[] __initdata = {
  114. /* FFUART */
  115. GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL,
  116. GPIO100_UART1_TXD,
  117. GPIO101_UART1_CTS,
  118. GPIO106_UART1_RTS,
  119. /* Ethernet */
  120. GPIO2_nCS3,
  121. GPIO102_GPIO,
  122. /* MMC3 */
  123. GPIO7_2_MMC3_DAT0,
  124. GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH,
  125. GPIO9_2_MMC3_DAT2,
  126. GPIO10_2_MMC3_DAT3,
  127. GPIO103_MMC3_CLK,
  128. GPIO105_MMC3_CMD,
  129. };
  130. #define NUM_LCD_DETECT_PINS 7
  131. static int lcd_detect_pins[] __initdata = {
  132. MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */
  133. MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */
  134. MFP_PIN_GPIO75, /* LCD_BIAS - LCDID[4] */
  135. MFP_PIN_GPIO73, /* LCD_LCLK - LCDID[3] */
  136. MFP_PIN_GPIO72, /* LCD_FCLK - LCDID[2] */
  137. MFP_PIN_GPIO127,/* LCD_CS_N - LCDID[1] */
  138. MFP_PIN_GPIO76, /* LCD_VSYNC - LCDID[0] */
  139. };
  140. static void __init zylonite_detect_lcd_panel(void)
  141. {
  142. unsigned long mfpr_save[NUM_LCD_DETECT_PINS];
  143. int i, gpio, id = 0;
  144. /* save the original MFP settings of these pins and configure
  145. * them as GPIO Input, DS01X, Pull Neither, Edge Clear
  146. */
  147. for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
  148. mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
  149. pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440);
  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 < NUM_LCD_DETECT_PINS; i++)
  164. pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
  165. }
  166. void __init zylonite_pxa300_init(void)
  167. {
  168. if (cpu_is_pxa300() || cpu_is_pxa310()) {
  169. /* initialize MFP */
  170. pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg));
  171. /* detect LCD panel */
  172. zylonite_detect_lcd_panel();
  173. /* GPIO pin assignment */
  174. gpio_backlight = mfp_to_gpio(MFP_PIN_GPIO20);
  175. /* MMC card detect & write protect for controller 0 */
  176. zylonite_mmc_slot[0].gpio_cd = EXT_GPIO(0);
  177. zylonite_mmc_slot[0].gpio_wp = EXT_GPIO(2);
  178. }
  179. if (cpu_is_pxa300()) {
  180. pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg));
  181. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99);
  182. }
  183. if (cpu_is_pxa310()) {
  184. pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg));
  185. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102);
  186. /* MMC card detect & write protect for controller 2 */
  187. zylonite_mmc_slot[2].gpio_cd = EXT_GPIO(30);
  188. zylonite_mmc_slot[2].gpio_wp = EXT_GPIO(31);
  189. }
  190. }