zylonite_pxa300.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 <linux/i2c.h>
  19. #include <linux/i2c/pca953x.h>
  20. #include <asm/gpio.h>
  21. #include <mach/mfp-pxa300.h>
  22. #include <mach/i2c.h>
  23. #include <mach/zylonite.h>
  24. #include "generic.h"
  25. /* PXA300/PXA310 common configurations */
  26. static mfp_cfg_t common_mfp_cfg[] __initdata = {
  27. /* LCD */
  28. GPIO54_LCD_LDD_0,
  29. GPIO55_LCD_LDD_1,
  30. GPIO56_LCD_LDD_2,
  31. GPIO57_LCD_LDD_3,
  32. GPIO58_LCD_LDD_4,
  33. GPIO59_LCD_LDD_5,
  34. GPIO60_LCD_LDD_6,
  35. GPIO61_LCD_LDD_7,
  36. GPIO62_LCD_LDD_8,
  37. GPIO63_LCD_LDD_9,
  38. GPIO64_LCD_LDD_10,
  39. GPIO65_LCD_LDD_11,
  40. GPIO66_LCD_LDD_12,
  41. GPIO67_LCD_LDD_13,
  42. GPIO68_LCD_LDD_14,
  43. GPIO69_LCD_LDD_15,
  44. GPIO70_LCD_LDD_16,
  45. GPIO71_LCD_LDD_17,
  46. GPIO72_LCD_FCLK,
  47. GPIO73_LCD_LCLK,
  48. GPIO74_LCD_PCLK,
  49. GPIO75_LCD_BIAS,
  50. GPIO76_LCD_VSYNC,
  51. GPIO127_LCD_CS_N,
  52. GPIO20_PWM3_OUT, /* backlight */
  53. /* BTUART */
  54. GPIO111_UART2_RTS,
  55. GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
  56. GPIO113_UART2_TXD,
  57. GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
  58. /* STUART */
  59. GPIO109_UART3_TXD,
  60. GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
  61. /* AC97 */
  62. GPIO23_AC97_nACRESET,
  63. GPIO24_AC97_SYSCLK,
  64. GPIO29_AC97_BITCLK,
  65. GPIO25_AC97_SDATA_IN_0,
  66. GPIO27_AC97_SDATA_OUT,
  67. GPIO28_AC97_SYNC,
  68. /* SSP3 */
  69. GPIO91_SSP3_SCLK,
  70. GPIO92_SSP3_FRM,
  71. GPIO93_SSP3_TXD,
  72. GPIO94_SSP3_RXD,
  73. /* WM9713 IRQ */
  74. GPIO26_GPIO,
  75. /* Keypad */
  76. GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
  77. GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
  78. GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
  79. GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
  80. GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
  81. GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
  82. GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
  83. GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
  84. GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
  85. GPIO3_2_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. GPIO4_2_KP_MKOUT_5,
  92. GPIO5_2_KP_MKOUT_6,
  93. GPIO6_2_KP_MKOUT_7,
  94. /* MMC1 */
  95. GPIO3_MMC1_DAT0,
  96. GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
  97. GPIO5_MMC1_DAT2,
  98. GPIO6_MMC1_DAT3,
  99. GPIO7_MMC1_CLK,
  100. GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
  101. GPIO15_GPIO, /* CMD1 default as GPIO for slot 0 */
  102. /* MMC2 */
  103. GPIO9_MMC2_DAT0,
  104. GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
  105. GPIO11_MMC2_DAT2,
  106. GPIO12_MMC2_DAT3,
  107. GPIO13_MMC2_CLK,
  108. GPIO14_MMC2_CMD,
  109. /* USB Host */
  110. GPIO0_2_USBH_PEN,
  111. GPIO1_2_USBH_PWR,
  112. /* Standard I2C */
  113. GPIO21_I2C_SCL,
  114. GPIO22_I2C_SDA,
  115. };
  116. static mfp_cfg_t pxa300_mfp_cfg[] __initdata = {
  117. /* FFUART */
  118. GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
  119. GPIO31_UART1_TXD,
  120. GPIO32_UART1_CTS,
  121. GPIO37_UART1_RTS,
  122. GPIO33_UART1_DCD,
  123. GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
  124. GPIO35_UART1_RI,
  125. GPIO36_UART1_DTR,
  126. /* Ethernet */
  127. GPIO2_nCS3,
  128. GPIO99_GPIO,
  129. };
  130. static mfp_cfg_t pxa310_mfp_cfg[] __initdata = {
  131. /* FFUART */
  132. GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL,
  133. GPIO100_UART1_TXD,
  134. GPIO101_UART1_CTS,
  135. GPIO106_UART1_RTS,
  136. /* Ethernet */
  137. GPIO2_nCS3,
  138. GPIO102_GPIO,
  139. /* MMC3 */
  140. GPIO7_2_MMC3_DAT0,
  141. GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH,
  142. GPIO9_2_MMC3_DAT2,
  143. GPIO10_2_MMC3_DAT3,
  144. GPIO103_MMC3_CLK,
  145. GPIO105_MMC3_CMD,
  146. };
  147. #define NUM_LCD_DETECT_PINS 7
  148. static int lcd_detect_pins[] __initdata = {
  149. MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */
  150. MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */
  151. MFP_PIN_GPIO75, /* LCD_BIAS - LCDID[4] */
  152. MFP_PIN_GPIO73, /* LCD_LCLK - LCDID[3] */
  153. MFP_PIN_GPIO72, /* LCD_FCLK - LCDID[2] */
  154. MFP_PIN_GPIO127,/* LCD_CS_N - LCDID[1] */
  155. MFP_PIN_GPIO76, /* LCD_VSYNC - LCDID[0] */
  156. };
  157. static void __init zylonite_detect_lcd_panel(void)
  158. {
  159. unsigned long mfpr_save[NUM_LCD_DETECT_PINS];
  160. int i, gpio, id = 0;
  161. /* save the original MFP settings of these pins and configure
  162. * them as GPIO Input, DS01X, Pull Neither, Edge Clear
  163. */
  164. for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
  165. mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
  166. pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440);
  167. }
  168. for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
  169. id = id << 1;
  170. gpio = mfp_to_gpio(lcd_detect_pins[i]);
  171. gpio_direction_input(gpio);
  172. if (gpio_get_value(gpio))
  173. id = id | 0x1;
  174. }
  175. /* lcd id, flush out bit 1 */
  176. lcd_id = id & 0x3d;
  177. /* lcd orientation, portrait or landscape */
  178. lcd_orientation = (id >> 6) & 0x1;
  179. /* restore the original MFP settings */
  180. for (i = 0; i < NUM_LCD_DETECT_PINS; i++)
  181. pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
  182. }
  183. #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
  184. static struct pca953x_platform_data gpio_exp[] = {
  185. [0] = {
  186. .gpio_base = 128,
  187. },
  188. [1] = {
  189. .gpio_base = 144,
  190. },
  191. };
  192. static struct i2c_board_info zylonite_i2c_board_info[] = {
  193. {
  194. .type = "pca9539",
  195. .addr = 0x74,
  196. .platform_data = &gpio_exp[0],
  197. .irq = IRQ_GPIO(18),
  198. }, {
  199. .type = "pca9539",
  200. .addr = 0x75,
  201. .platform_data = &gpio_exp[1],
  202. .irq = IRQ_GPIO(19),
  203. },
  204. };
  205. static void __init zylonite_init_i2c(void)
  206. {
  207. pxa_set_i2c_info(NULL);
  208. i2c_register_board_info(0, ARRAY_AND_SIZE(zylonite_i2c_board_info));
  209. }
  210. #else
  211. static inline void zylonite_init_i2c(void) {}
  212. #endif
  213. void __init zylonite_pxa300_init(void)
  214. {
  215. if (cpu_is_pxa300() || cpu_is_pxa310()) {
  216. /* initialize MFP */
  217. pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg));
  218. /* detect LCD panel */
  219. zylonite_detect_lcd_panel();
  220. /* MMC card detect & write protect for controller 0 */
  221. zylonite_mmc_slot[0].gpio_cd = EXT_GPIO(0);
  222. zylonite_mmc_slot[0].gpio_wp = EXT_GPIO(2);
  223. /* WM9713 IRQ */
  224. wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO26);
  225. zylonite_init_i2c();
  226. }
  227. if (cpu_is_pxa300()) {
  228. pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg));
  229. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99);
  230. }
  231. if (cpu_is_pxa310()) {
  232. pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg));
  233. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102);
  234. /* MMC card detect & write protect for controller 2 */
  235. zylonite_mmc_slot[2].gpio_cd = EXT_GPIO(30);
  236. zylonite_mmc_slot[2].gpio_wp = EXT_GPIO(31);
  237. }
  238. /* GPIOs for Debug LEDs */
  239. gpio_debug_led1 = EXT_GPIO(25);
  240. gpio_debug_led2 = EXT_GPIO(26);
  241. }