mxt_td60.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/platform_device.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/map.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <linux/mtd/physmap.h>
  25. #include <linux/i2c.h>
  26. #include <linux/irq.h>
  27. #include <mach/common.h>
  28. #include <mach/hardware.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/time.h>
  32. #include <asm/mach/map.h>
  33. #include <linux/gpio.h>
  34. #include <mach/imx-uart.h>
  35. #include <mach/iomux.h>
  36. #include <mach/mxc_nand.h>
  37. #include <mach/i2c.h>
  38. #include <linux/i2c/pca953x.h>
  39. #include <mach/imxfb.h>
  40. #include <mach/mmc.h>
  41. #include "devices.h"
  42. static unsigned int mxt_td60_pins[] __initdata = {
  43. /* UART0 */
  44. PE12_PF_UART1_TXD,
  45. PE13_PF_UART1_RXD,
  46. PE14_PF_UART1_CTS,
  47. PE15_PF_UART1_RTS,
  48. /* UART1 */
  49. PE3_PF_UART2_CTS,
  50. PE4_PF_UART2_RTS,
  51. PE6_PF_UART2_TXD,
  52. PE7_PF_UART2_RXD,
  53. /* UART2 */
  54. PE8_PF_UART3_TXD,
  55. PE9_PF_UART3_RXD,
  56. PE10_PF_UART3_CTS,
  57. PE11_PF_UART3_RTS,
  58. /* FEC */
  59. PD0_AIN_FEC_TXD0,
  60. PD1_AIN_FEC_TXD1,
  61. PD2_AIN_FEC_TXD2,
  62. PD3_AIN_FEC_TXD3,
  63. PD4_AOUT_FEC_RX_ER,
  64. PD5_AOUT_FEC_RXD1,
  65. PD6_AOUT_FEC_RXD2,
  66. PD7_AOUT_FEC_RXD3,
  67. PD8_AF_FEC_MDIO,
  68. PD9_AIN_FEC_MDC,
  69. PD10_AOUT_FEC_CRS,
  70. PD11_AOUT_FEC_TX_CLK,
  71. PD12_AOUT_FEC_RXD0,
  72. PD13_AOUT_FEC_RX_DV,
  73. PD14_AOUT_FEC_RX_CLK,
  74. PD15_AOUT_FEC_COL,
  75. PD16_AIN_FEC_TX_ER,
  76. PF23_AIN_FEC_TX_EN,
  77. /* I2C1 */
  78. PD17_PF_I2C_DATA,
  79. PD18_PF_I2C_CLK,
  80. /* I2C2 */
  81. PC5_PF_I2C2_SDA,
  82. PC6_PF_I2C2_SCL,
  83. /* FB */
  84. PA5_PF_LSCLK,
  85. PA6_PF_LD0,
  86. PA7_PF_LD1,
  87. PA8_PF_LD2,
  88. PA9_PF_LD3,
  89. PA10_PF_LD4,
  90. PA11_PF_LD5,
  91. PA12_PF_LD6,
  92. PA13_PF_LD7,
  93. PA14_PF_LD8,
  94. PA15_PF_LD9,
  95. PA16_PF_LD10,
  96. PA17_PF_LD11,
  97. PA18_PF_LD12,
  98. PA19_PF_LD13,
  99. PA20_PF_LD14,
  100. PA21_PF_LD15,
  101. PA22_PF_LD16,
  102. PA23_PF_LD17,
  103. PA25_PF_CLS,
  104. PA27_PF_SPL_SPR,
  105. PA28_PF_HSYNC,
  106. PA29_PF_VSYNC,
  107. PA30_PF_CONTRAST,
  108. PA31_PF_OE_ACD,
  109. /* OWIRE */
  110. PE16_AF_OWIRE,
  111. /* SDHC1*/
  112. PE18_PF_SD1_D0,
  113. PE19_PF_SD1_D1,
  114. PE20_PF_SD1_D2,
  115. PE21_PF_SD1_D3,
  116. PE22_PF_SD1_CMD,
  117. PE23_PF_SD1_CLK,
  118. PF8_AF_ATA_IORDY,
  119. /* SDHC2*/
  120. PB4_PF_SD2_D0,
  121. PB5_PF_SD2_D1,
  122. PB6_PF_SD2_D2,
  123. PB7_PF_SD2_D3,
  124. PB8_PF_SD2_CMD,
  125. PB9_PF_SD2_CLK,
  126. };
  127. static struct mxc_nand_platform_data mxt_td60_nand_board_info = {
  128. .width = 1,
  129. .hw_ecc = 1,
  130. };
  131. static struct imxi2c_platform_data mxt_td60_i2c_data = {
  132. .bitrate = 100000,
  133. };
  134. /* PCA9557 */
  135. static int mxt_td60_pca9557_setup(struct i2c_client *client,
  136. unsigned gpio_base, unsigned ngpio,
  137. void *context)
  138. {
  139. static int mxt_td60_gpio_value[] = {
  140. -1, -1, -1, -1, -1, -1, -1, 1
  141. };
  142. int n;
  143. for (n = 0; n < ARRAY_SIZE(mxt_td60_gpio_value); ++n) {
  144. gpio_request(gpio_base + n, "MXT_TD60 GPIO Exp");
  145. if (mxt_td60_gpio_value[n] < 0)
  146. gpio_direction_input(gpio_base + n);
  147. else
  148. gpio_direction_output(gpio_base + n,
  149. mxt_td60_gpio_value[n]);
  150. gpio_export(gpio_base + n, 0);
  151. }
  152. return 0;
  153. }
  154. static struct pca953x_platform_data mxt_td60_pca9557_pdata = {
  155. .gpio_base = 240, /* place PCA9557 after all MX27 gpio pins */
  156. .invert = 0, /* Do not invert */
  157. .setup = mxt_td60_pca9557_setup,
  158. };
  159. static struct i2c_board_info mxt_td60_i2c_devices[] = {
  160. {
  161. I2C_BOARD_INFO("pca9557", 0x18),
  162. .platform_data = &mxt_td60_pca9557_pdata,
  163. },
  164. };
  165. static struct imxi2c_platform_data mxt_td60_i2c2_data = {
  166. .bitrate = 100000,
  167. };
  168. static struct i2c_board_info mxt_td60_i2c2_devices[] = {
  169. };
  170. static struct imx_fb_videomode mxt_td60_modes[] = {
  171. {
  172. .mode = {
  173. .name = "Chimei LW700AT9003",
  174. .refresh = 60,
  175. .xres = 800,
  176. .yres = 480,
  177. .pixclock = 30303,
  178. .hsync_len = 64,
  179. .left_margin = 0x67,
  180. .right_margin = 0x68,
  181. .vsync_len = 16,
  182. .upper_margin = 0x0f,
  183. .lower_margin = 0x0f,
  184. },
  185. .bpp = 16,
  186. .pcr = 0xFA208B83,
  187. },
  188. };
  189. static struct imx_fb_platform_data mxt_td60_fb_data = {
  190. .mode = mxt_td60_modes,
  191. .num_modes = ARRAY_SIZE(mxt_td60_modes),
  192. /*
  193. * - HSYNC active high
  194. * - VSYNC active high
  195. * - clk notenabled while idle
  196. * - clock inverted
  197. * - data not inverted
  198. * - data enable low active
  199. * - enable sharp mode
  200. */
  201. .pwmr = 0x00A903FF,
  202. .lscr1 = 0x00120300,
  203. .dmacr = 0x00020010,
  204. };
  205. static int mxt_td60_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
  206. void *data)
  207. {
  208. return request_irq(IRQ_GPIOF(8), detect_irq, IRQF_TRIGGER_FALLING,
  209. "sdhc1-card-detect", data);
  210. }
  211. static void mxt_td60_sdhc1_exit(struct device *dev, void *data)
  212. {
  213. free_irq(IRQ_GPIOF(8), data);
  214. }
  215. static struct imxmmc_platform_data sdhc1_pdata = {
  216. .init = mxt_td60_sdhc1_init,
  217. .exit = mxt_td60_sdhc1_exit,
  218. };
  219. static struct platform_device *platform_devices[] __initdata = {
  220. &mxc_fec_device,
  221. };
  222. static struct imxuart_platform_data uart_pdata[] = {
  223. {
  224. .flags = IMXUART_HAVE_RTSCTS,
  225. }, {
  226. .flags = IMXUART_HAVE_RTSCTS,
  227. }, {
  228. .flags = IMXUART_HAVE_RTSCTS,
  229. },
  230. };
  231. static void __init mxt_td60_board_init(void)
  232. {
  233. mxc_gpio_setup_multiple_pins(mxt_td60_pins, ARRAY_SIZE(mxt_td60_pins),
  234. "MXT_TD60");
  235. mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
  236. mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
  237. mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
  238. mxc_register_device(&mxc_nand_device, &mxt_td60_nand_board_info);
  239. i2c_register_board_info(0, mxt_td60_i2c_devices,
  240. ARRAY_SIZE(mxt_td60_i2c_devices));
  241. i2c_register_board_info(1, mxt_td60_i2c2_devices,
  242. ARRAY_SIZE(mxt_td60_i2c2_devices));
  243. mxc_register_device(&mxc_i2c_device0, &mxt_td60_i2c_data);
  244. mxc_register_device(&mxc_i2c_device1, &mxt_td60_i2c2_data);
  245. mxc_register_device(&mxc_fb_device, &mxt_td60_fb_data);
  246. mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata);
  247. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  248. }
  249. static void __init mxt_td60_timer_init(void)
  250. {
  251. mx27_clocks_init(26000000);
  252. }
  253. static struct sys_timer mxt_td60_timer = {
  254. .init = mxt_td60_timer_init,
  255. };
  256. MACHINE_START(MXT_TD60, "Maxtrack i-MXT TD60")
  257. /* maintainer: Maxtrack Industrial */
  258. .phys_io = AIPI_BASE_ADDR,
  259. .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  260. .boot_params = PHYS_OFFSET + 0x100,
  261. .map_io = mx27_map_io,
  262. .init_irq = mx27_init_irq,
  263. .init_machine = mxt_td60_board_init,
  264. .timer = &mxt_td60_timer,
  265. MACHINE_END