zylonite_pxa300.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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 <asm/arch/mfp-pxa300.h>
  22. #include <asm/arch/i2c.h>
  23. #include <asm/arch/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. /* WM9713 IRQ */
  69. GPIO26_GPIO,
  70. /* Keypad */
  71. GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
  72. GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
  73. GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
  74. GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
  75. GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
  76. GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
  77. GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
  78. GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
  79. GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
  80. GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
  81. GPIO121_KP_MKOUT_0,
  82. GPIO122_KP_MKOUT_1,
  83. GPIO123_KP_MKOUT_2,
  84. GPIO124_KP_MKOUT_3,
  85. GPIO125_KP_MKOUT_4,
  86. GPIO4_2_KP_MKOUT_5,
  87. GPIO5_2_KP_MKOUT_6,
  88. GPIO6_2_KP_MKOUT_7,
  89. /* MMC1 */
  90. GPIO3_MMC1_DAT0,
  91. GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
  92. GPIO5_MMC1_DAT2,
  93. GPIO6_MMC1_DAT3,
  94. GPIO7_MMC1_CLK,
  95. GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
  96. GPIO15_GPIO, /* CMD1 default as GPIO for slot 0 */
  97. /* MMC2 */
  98. GPIO9_MMC2_DAT0,
  99. GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
  100. GPIO11_MMC2_DAT2,
  101. GPIO12_MMC2_DAT3,
  102. GPIO13_MMC2_CLK,
  103. GPIO14_MMC2_CMD,
  104. /* Standard I2C */
  105. GPIO21_I2C_SCL,
  106. GPIO22_I2C_SDA,
  107. };
  108. static mfp_cfg_t pxa300_mfp_cfg[] __initdata = {
  109. /* FFUART */
  110. GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
  111. GPIO31_UART1_TXD,
  112. GPIO32_UART1_CTS,
  113. GPIO37_UART1_RTS,
  114. GPIO33_UART1_DCD,
  115. GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
  116. GPIO35_UART1_RI,
  117. GPIO36_UART1_DTR,
  118. /* Ethernet */
  119. GPIO2_nCS3,
  120. GPIO99_GPIO,
  121. };
  122. static mfp_cfg_t pxa310_mfp_cfg[] __initdata = {
  123. /* FFUART */
  124. GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL,
  125. GPIO100_UART1_TXD,
  126. GPIO101_UART1_CTS,
  127. GPIO106_UART1_RTS,
  128. /* Ethernet */
  129. GPIO2_nCS3,
  130. GPIO102_GPIO,
  131. /* MMC3 */
  132. GPIO7_2_MMC3_DAT0,
  133. GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH,
  134. GPIO9_2_MMC3_DAT2,
  135. GPIO10_2_MMC3_DAT3,
  136. GPIO103_MMC3_CLK,
  137. GPIO105_MMC3_CMD,
  138. };
  139. #define NUM_LCD_DETECT_PINS 7
  140. static int lcd_detect_pins[] __initdata = {
  141. MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */
  142. MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */
  143. MFP_PIN_GPIO75, /* LCD_BIAS - LCDID[4] */
  144. MFP_PIN_GPIO73, /* LCD_LCLK - LCDID[3] */
  145. MFP_PIN_GPIO72, /* LCD_FCLK - LCDID[2] */
  146. MFP_PIN_GPIO127,/* LCD_CS_N - LCDID[1] */
  147. MFP_PIN_GPIO76, /* LCD_VSYNC - LCDID[0] */
  148. };
  149. static void __init zylonite_detect_lcd_panel(void)
  150. {
  151. unsigned long mfpr_save[NUM_LCD_DETECT_PINS];
  152. int i, gpio, id = 0;
  153. /* save the original MFP settings of these pins and configure
  154. * them as GPIO Input, DS01X, Pull Neither, Edge Clear
  155. */
  156. for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
  157. mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
  158. pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440);
  159. }
  160. for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
  161. id = id << 1;
  162. gpio = mfp_to_gpio(lcd_detect_pins[i]);
  163. gpio_direction_input(gpio);
  164. if (gpio_get_value(gpio))
  165. id = id | 0x1;
  166. }
  167. /* lcd id, flush out bit 1 */
  168. lcd_id = id & 0x3d;
  169. /* lcd orientation, portrait or landscape */
  170. lcd_orientation = (id >> 6) & 0x1;
  171. /* restore the original MFP settings */
  172. for (i = 0; i < NUM_LCD_DETECT_PINS; i++)
  173. pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
  174. }
  175. #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
  176. static struct pca953x_platform_data gpio_exp[] = {
  177. [0] = {
  178. .gpio_base = 128,
  179. },
  180. [1] = {
  181. .gpio_base = 144,
  182. },
  183. };
  184. struct i2c_board_info zylonite_i2c_board_info[] = {
  185. {
  186. .type = "pca9539",
  187. .addr = 0x74,
  188. .platform_data = &gpio_exp[0],
  189. .irq = IRQ_GPIO(18),
  190. }, {
  191. .type = "pca9539",
  192. .addr = 0x75,
  193. .platform_data = &gpio_exp[1],
  194. .irq = IRQ_GPIO(19),
  195. },
  196. };
  197. static void __init zylonite_init_i2c(void)
  198. {
  199. pxa_set_i2c_info(NULL);
  200. i2c_register_board_info(0, ARRAY_AND_SIZE(zylonite_i2c_board_info));
  201. }
  202. #else
  203. static inline void zylonite_init_i2c(void) {}
  204. #endif
  205. void __init zylonite_pxa300_init(void)
  206. {
  207. if (cpu_is_pxa300() || cpu_is_pxa310()) {
  208. /* initialize MFP */
  209. pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg));
  210. /* detect LCD panel */
  211. zylonite_detect_lcd_panel();
  212. /* MMC card detect & write protect for controller 0 */
  213. zylonite_mmc_slot[0].gpio_cd = EXT_GPIO(0);
  214. zylonite_mmc_slot[0].gpio_wp = EXT_GPIO(2);
  215. /* WM9713 IRQ */
  216. wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO26);
  217. zylonite_init_i2c();
  218. }
  219. if (cpu_is_pxa300()) {
  220. pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg));
  221. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99);
  222. }
  223. if (cpu_is_pxa310()) {
  224. pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg));
  225. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102);
  226. /* MMC card detect & write protect for controller 2 */
  227. zylonite_mmc_slot[2].gpio_cd = EXT_GPIO(30);
  228. zylonite_mmc_slot[2].gpio_wp = EXT_GPIO(31);
  229. }
  230. /* GPIOs for Debug LEDs */
  231. gpio_debug_led1 = EXT_GPIO(25);
  232. gpio_debug_led2 = EXT_GPIO(26);
  233. }