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