zylonite_pxa300.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. #include "generic.h"
  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. GPIO20_PWM3_OUT, /* backlight */
  50. /* BTUART */
  51. GPIO111_UART2_RTS,
  52. GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
  53. GPIO113_UART2_TXD,
  54. GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
  55. /* STUART */
  56. GPIO109_UART3_TXD,
  57. GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
  58. /* AC97 */
  59. GPIO23_AC97_nACRESET,
  60. GPIO24_AC97_SYSCLK,
  61. GPIO29_AC97_BITCLK,
  62. GPIO25_AC97_SDATA_IN_0,
  63. GPIO27_AC97_SDATA_OUT,
  64. GPIO28_AC97_SYNC,
  65. /* WM9713 IRQ */
  66. GPIO26_GPIO,
  67. /* Keypad */
  68. GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
  69. GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
  70. GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
  71. GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
  72. GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
  73. GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
  74. GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
  75. GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
  76. GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
  77. GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
  78. GPIO121_KP_MKOUT_0,
  79. GPIO122_KP_MKOUT_1,
  80. GPIO123_KP_MKOUT_2,
  81. GPIO124_KP_MKOUT_3,
  82. GPIO125_KP_MKOUT_4,
  83. GPIO4_2_KP_MKOUT_5,
  84. GPIO5_2_KP_MKOUT_6,
  85. GPIO6_2_KP_MKOUT_7,
  86. /* MMC1 */
  87. GPIO3_MMC1_DAT0,
  88. GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
  89. GPIO5_MMC1_DAT2,
  90. GPIO6_MMC1_DAT3,
  91. GPIO7_MMC1_CLK,
  92. GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
  93. GPIO15_GPIO, /* CMD1 default as GPIO for slot 0 */
  94. /* MMC2 */
  95. GPIO9_MMC2_DAT0,
  96. GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
  97. GPIO11_MMC2_DAT2,
  98. GPIO12_MMC2_DAT3,
  99. GPIO13_MMC2_CLK,
  100. GPIO14_MMC2_CMD,
  101. };
  102. static mfp_cfg_t pxa300_mfp_cfg[] __initdata = {
  103. /* FFUART */
  104. GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
  105. GPIO31_UART1_TXD,
  106. GPIO32_UART1_CTS,
  107. GPIO37_UART1_RTS,
  108. GPIO33_UART1_DCD,
  109. GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
  110. GPIO35_UART1_RI,
  111. GPIO36_UART1_DTR,
  112. /* Ethernet */
  113. GPIO2_nCS3,
  114. GPIO99_GPIO,
  115. };
  116. static mfp_cfg_t pxa310_mfp_cfg[] __initdata = {
  117. /* FFUART */
  118. GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL,
  119. GPIO100_UART1_TXD,
  120. GPIO101_UART1_CTS,
  121. GPIO106_UART1_RTS,
  122. /* Ethernet */
  123. GPIO2_nCS3,
  124. GPIO102_GPIO,
  125. /* MMC3 */
  126. GPIO7_2_MMC3_DAT0,
  127. GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH,
  128. GPIO9_2_MMC3_DAT2,
  129. GPIO10_2_MMC3_DAT3,
  130. GPIO103_MMC3_CLK,
  131. GPIO105_MMC3_CMD,
  132. };
  133. #define NUM_LCD_DETECT_PINS 7
  134. static int lcd_detect_pins[] __initdata = {
  135. MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */
  136. MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */
  137. MFP_PIN_GPIO75, /* LCD_BIAS - LCDID[4] */
  138. MFP_PIN_GPIO73, /* LCD_LCLK - LCDID[3] */
  139. MFP_PIN_GPIO72, /* LCD_FCLK - LCDID[2] */
  140. MFP_PIN_GPIO127,/* LCD_CS_N - LCDID[1] */
  141. MFP_PIN_GPIO76, /* LCD_VSYNC - LCDID[0] */
  142. };
  143. static void __init zylonite_detect_lcd_panel(void)
  144. {
  145. unsigned long mfpr_save[NUM_LCD_DETECT_PINS];
  146. int i, gpio, id = 0;
  147. /* save the original MFP settings of these pins and configure
  148. * them as GPIO Input, DS01X, Pull Neither, Edge Clear
  149. */
  150. for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
  151. mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
  152. pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440);
  153. }
  154. for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
  155. id = id << 1;
  156. gpio = mfp_to_gpio(lcd_detect_pins[i]);
  157. gpio_direction_input(gpio);
  158. if (gpio_get_value(gpio))
  159. id = id | 0x1;
  160. }
  161. /* lcd id, flush out bit 1 */
  162. lcd_id = id & 0x3d;
  163. /* lcd orientation, portrait or landscape */
  164. lcd_orientation = (id >> 6) & 0x1;
  165. /* restore the original MFP settings */
  166. for (i = 0; i < NUM_LCD_DETECT_PINS; i++)
  167. pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
  168. }
  169. void __init zylonite_pxa300_init(void)
  170. {
  171. if (cpu_is_pxa300() || cpu_is_pxa310()) {
  172. /* initialize MFP */
  173. pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg));
  174. /* detect LCD panel */
  175. zylonite_detect_lcd_panel();
  176. /* MMC card detect & write protect for controller 0 */
  177. zylonite_mmc_slot[0].gpio_cd = EXT_GPIO(0);
  178. zylonite_mmc_slot[0].gpio_wp = EXT_GPIO(2);
  179. /* WM9713 IRQ */
  180. wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO26);
  181. }
  182. if (cpu_is_pxa300()) {
  183. pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg));
  184. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99);
  185. }
  186. if (cpu_is_pxa310()) {
  187. pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg));
  188. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102);
  189. /* MMC card detect & write protect for controller 2 */
  190. zylonite_mmc_slot[2].gpio_cd = EXT_GPIO(30);
  191. zylonite_mmc_slot[2].gpio_wp = EXT_GPIO(31);
  192. }
  193. }