mach-mxt_td60.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /*
  2. * Copyright (C) 2000 Deep Blue Solutions Ltd
  3. * Copyright (C) 2002 Shane Nay (shane@minirl.com)
  4. * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #include <linux/platform_device.h>
  17. #include <linux/mtd/mtd.h>
  18. #include <linux/mtd/map.h>
  19. #include <linux/mtd/partitions.h>
  20. #include <linux/mtd/physmap.h>
  21. #include <linux/i2c.h>
  22. #include <linux/irq.h>
  23. #include <mach/common.h>
  24. #include <mach/hardware.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/time.h>
  28. #include <asm/mach/map.h>
  29. #include <linux/gpio.h>
  30. #include <mach/iomux-mx27.h>
  31. #include <linux/i2c/pca953x.h>
  32. #include "devices-imx27.h"
  33. static const int mxt_td60_pins[] __initconst = {
  34. /* UART0 */
  35. PE12_PF_UART1_TXD,
  36. PE13_PF_UART1_RXD,
  37. PE14_PF_UART1_CTS,
  38. PE15_PF_UART1_RTS,
  39. /* UART1 */
  40. PE3_PF_UART2_CTS,
  41. PE4_PF_UART2_RTS,
  42. PE6_PF_UART2_TXD,
  43. PE7_PF_UART2_RXD,
  44. /* UART2 */
  45. PE8_PF_UART3_TXD,
  46. PE9_PF_UART3_RXD,
  47. PE10_PF_UART3_CTS,
  48. PE11_PF_UART3_RTS,
  49. /* FEC */
  50. PD0_AIN_FEC_TXD0,
  51. PD1_AIN_FEC_TXD1,
  52. PD2_AIN_FEC_TXD2,
  53. PD3_AIN_FEC_TXD3,
  54. PD4_AOUT_FEC_RX_ER,
  55. PD5_AOUT_FEC_RXD1,
  56. PD6_AOUT_FEC_RXD2,
  57. PD7_AOUT_FEC_RXD3,
  58. PD8_AF_FEC_MDIO,
  59. PD9_AIN_FEC_MDC,
  60. PD10_AOUT_FEC_CRS,
  61. PD11_AOUT_FEC_TX_CLK,
  62. PD12_AOUT_FEC_RXD0,
  63. PD13_AOUT_FEC_RX_DV,
  64. PD14_AOUT_FEC_RX_CLK,
  65. PD15_AOUT_FEC_COL,
  66. PD16_AIN_FEC_TX_ER,
  67. PF23_AIN_FEC_TX_EN,
  68. /* I2C1 */
  69. PD17_PF_I2C_DATA,
  70. PD18_PF_I2C_CLK,
  71. /* I2C2 */
  72. PC5_PF_I2C2_SDA,
  73. PC6_PF_I2C2_SCL,
  74. /* FB */
  75. PA5_PF_LSCLK,
  76. PA6_PF_LD0,
  77. PA7_PF_LD1,
  78. PA8_PF_LD2,
  79. PA9_PF_LD3,
  80. PA10_PF_LD4,
  81. PA11_PF_LD5,
  82. PA12_PF_LD6,
  83. PA13_PF_LD7,
  84. PA14_PF_LD8,
  85. PA15_PF_LD9,
  86. PA16_PF_LD10,
  87. PA17_PF_LD11,
  88. PA18_PF_LD12,
  89. PA19_PF_LD13,
  90. PA20_PF_LD14,
  91. PA21_PF_LD15,
  92. PA22_PF_LD16,
  93. PA23_PF_LD17,
  94. PA25_PF_CLS,
  95. PA27_PF_SPL_SPR,
  96. PA28_PF_HSYNC,
  97. PA29_PF_VSYNC,
  98. PA30_PF_CONTRAST,
  99. PA31_PF_OE_ACD,
  100. /* OWIRE */
  101. PE16_AF_OWIRE,
  102. /* SDHC1*/
  103. PE18_PF_SD1_D0,
  104. PE19_PF_SD1_D1,
  105. PE20_PF_SD1_D2,
  106. PE21_PF_SD1_D3,
  107. PE22_PF_SD1_CMD,
  108. PE23_PF_SD1_CLK,
  109. PF8_AF_ATA_IORDY,
  110. /* SDHC2*/
  111. PB4_PF_SD2_D0,
  112. PB5_PF_SD2_D1,
  113. PB6_PF_SD2_D2,
  114. PB7_PF_SD2_D3,
  115. PB8_PF_SD2_CMD,
  116. PB9_PF_SD2_CLK,
  117. };
  118. static const struct mxc_nand_platform_data
  119. mxt_td60_nand_board_info __initconst = {
  120. .width = 1,
  121. .hw_ecc = 1,
  122. };
  123. static const struct imxi2c_platform_data mxt_td60_i2c0_data __initconst = {
  124. .bitrate = 100000,
  125. };
  126. /* PCA9557 */
  127. static int mxt_td60_pca9557_setup(struct i2c_client *client,
  128. unsigned gpio_base, unsigned ngpio,
  129. void *context)
  130. {
  131. static int mxt_td60_gpio_value[] = {
  132. -1, -1, -1, -1, -1, -1, -1, 1
  133. };
  134. int n;
  135. for (n = 0; n < ARRAY_SIZE(mxt_td60_gpio_value); ++n) {
  136. gpio_request(gpio_base + n, "MXT_TD60 GPIO Exp");
  137. if (mxt_td60_gpio_value[n] < 0)
  138. gpio_direction_input(gpio_base + n);
  139. else
  140. gpio_direction_output(gpio_base + n,
  141. mxt_td60_gpio_value[n]);
  142. gpio_export(gpio_base + n, 0);
  143. }
  144. return 0;
  145. }
  146. static struct pca953x_platform_data mxt_td60_pca9557_pdata = {
  147. .gpio_base = 240, /* place PCA9557 after all MX27 gpio pins */
  148. .invert = 0, /* Do not invert */
  149. .setup = mxt_td60_pca9557_setup,
  150. };
  151. static struct i2c_board_info mxt_td60_i2c_devices[] = {
  152. {
  153. I2C_BOARD_INFO("pca9557", 0x18),
  154. .platform_data = &mxt_td60_pca9557_pdata,
  155. },
  156. };
  157. static const struct imxi2c_platform_data mxt_td60_i2c1_data __initconst = {
  158. .bitrate = 100000,
  159. };
  160. static struct i2c_board_info mxt_td60_i2c2_devices[] = {
  161. };
  162. static struct imx_fb_videomode mxt_td60_modes[] = {
  163. {
  164. .mode = {
  165. .name = "Chimei LW700AT9003",
  166. .refresh = 60,
  167. .xres = 800,
  168. .yres = 480,
  169. .pixclock = 30303,
  170. .hsync_len = 64,
  171. .left_margin = 0x67,
  172. .right_margin = 0x68,
  173. .vsync_len = 16,
  174. .upper_margin = 0x0f,
  175. .lower_margin = 0x0f,
  176. },
  177. .bpp = 16,
  178. .pcr = 0xFA208B83,
  179. },
  180. };
  181. static const struct imx_fb_platform_data mxt_td60_fb_data __initconst = {
  182. .mode = mxt_td60_modes,
  183. .num_modes = ARRAY_SIZE(mxt_td60_modes),
  184. /*
  185. * - HSYNC active high
  186. * - VSYNC active high
  187. * - clk notenabled while idle
  188. * - clock inverted
  189. * - data not inverted
  190. * - data enable low active
  191. * - enable sharp mode
  192. */
  193. .pwmr = 0x00A903FF,
  194. .lscr1 = 0x00120300,
  195. .dmacr = 0x00020010,
  196. };
  197. static int mxt_td60_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
  198. void *data)
  199. {
  200. return request_irq(IRQ_GPIOF(8), detect_irq, IRQF_TRIGGER_FALLING,
  201. "sdhc1-card-detect", data);
  202. }
  203. static void mxt_td60_sdhc1_exit(struct device *dev, void *data)
  204. {
  205. free_irq(IRQ_GPIOF(8), data);
  206. }
  207. static const struct imxmmc_platform_data sdhc1_pdata __initconst = {
  208. .init = mxt_td60_sdhc1_init,
  209. .exit = mxt_td60_sdhc1_exit,
  210. };
  211. static const struct imxuart_platform_data uart_pdata __initconst = {
  212. .flags = IMXUART_HAVE_RTSCTS,
  213. };
  214. static void __init mxt_td60_board_init(void)
  215. {
  216. mxc_gpio_setup_multiple_pins(mxt_td60_pins, ARRAY_SIZE(mxt_td60_pins),
  217. "MXT_TD60");
  218. imx27_add_imx_uart0(&uart_pdata);
  219. imx27_add_imx_uart1(&uart_pdata);
  220. imx27_add_imx_uart2(&uart_pdata);
  221. imx27_add_mxc_nand(&mxt_td60_nand_board_info);
  222. i2c_register_board_info(0, mxt_td60_i2c_devices,
  223. ARRAY_SIZE(mxt_td60_i2c_devices));
  224. i2c_register_board_info(1, mxt_td60_i2c2_devices,
  225. ARRAY_SIZE(mxt_td60_i2c2_devices));
  226. imx27_add_imx_i2c(0, &mxt_td60_i2c0_data);
  227. imx27_add_imx_i2c(1, &mxt_td60_i2c1_data);
  228. imx27_add_imx_fb(&mxt_td60_fb_data);
  229. imx27_add_mxc_mmc(0, &sdhc1_pdata);
  230. imx27_add_fec(NULL);
  231. }
  232. static void __init mxt_td60_timer_init(void)
  233. {
  234. mx27_clocks_init(26000000);
  235. }
  236. static struct sys_timer mxt_td60_timer = {
  237. .init = mxt_td60_timer_init,
  238. };
  239. MACHINE_START(MXT_TD60, "Maxtrack i-MXT TD60")
  240. /* maintainer: Maxtrack Industrial */
  241. .boot_params = MX27_PHYS_OFFSET + 0x100,
  242. .map_io = mx27_map_io,
  243. .init_early = imx27_init_early,
  244. .init_irq = mx27_init_irq,
  245. .timer = &mxt_td60_timer,
  246. .init_machine = mxt_td60_board_init,
  247. MACHINE_END