mach-mx21ads.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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/physmap.h>
  19. #include <linux/gpio.h>
  20. #include <mach/common.h>
  21. #include <mach/hardware.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/time.h>
  25. #include <asm/mach/map.h>
  26. #include <mach/iomux-mx21.h>
  27. #include "devices-imx21.h"
  28. /*
  29. * Memory-mapped I/O on MX21ADS base board
  30. */
  31. #define MX21ADS_MMIO_BASE_ADDR 0xf5000000
  32. #define MX21ADS_MMIO_SIZE 0xc00000
  33. #define MX21ADS_REG_ADDR(offset) (void __force __iomem *) \
  34. (MX21ADS_MMIO_BASE_ADDR + (offset))
  35. #define MX21ADS_CS8900A_MMIO_SIZE 0x200000
  36. #define MX21ADS_CS8900A_IRQ IRQ_GPIOE(11)
  37. #define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000)
  38. #define MX21ADS_VERSION_REG MX21ADS_REG_ADDR(0x400000)
  39. #define MX21ADS_IO_REG MX21ADS_REG_ADDR(0x800000)
  40. /* MX21ADS_IO_REG bit definitions */
  41. #define MX21ADS_IO_SD_WP 0x0001 /* read */
  42. #define MX21ADS_IO_TP6 0x0001 /* write */
  43. #define MX21ADS_IO_SW_SEL 0x0002 /* read */
  44. #define MX21ADS_IO_TP7 0x0002 /* write */
  45. #define MX21ADS_IO_RESET_E_UART 0x0004
  46. #define MX21ADS_IO_RESET_BASE 0x0008
  47. #define MX21ADS_IO_CSI_CTL2 0x0010
  48. #define MX21ADS_IO_CSI_CTL1 0x0020
  49. #define MX21ADS_IO_CSI_CTL0 0x0040
  50. #define MX21ADS_IO_UART1_EN 0x0080
  51. #define MX21ADS_IO_UART4_EN 0x0100
  52. #define MX21ADS_IO_LCDON 0x0200
  53. #define MX21ADS_IO_IRDA_EN 0x0400
  54. #define MX21ADS_IO_IRDA_FIR_SEL 0x0800
  55. #define MX21ADS_IO_IRDA_MD0_B 0x1000
  56. #define MX21ADS_IO_IRDA_MD1 0x2000
  57. #define MX21ADS_IO_LED4_ON 0x4000
  58. #define MX21ADS_IO_LED3_ON 0x8000
  59. static const int mx21ads_pins[] __initconst = {
  60. /* CS8900A */
  61. (GPIO_PORTE | GPIO_GPIO | GPIO_IN | 11),
  62. /* UART1 */
  63. PE12_PF_UART1_TXD,
  64. PE13_PF_UART1_RXD,
  65. PE14_PF_UART1_CTS,
  66. PE15_PF_UART1_RTS,
  67. /* UART3 (IrDA) - only TXD and RXD */
  68. PE8_PF_UART3_TXD,
  69. PE9_PF_UART3_RXD,
  70. /* UART4 */
  71. PB26_AF_UART4_RTS,
  72. PB28_AF_UART4_TXD,
  73. PB29_AF_UART4_CTS,
  74. PB31_AF_UART4_RXD,
  75. /* LCDC */
  76. PA5_PF_LSCLK,
  77. PA6_PF_LD0,
  78. PA7_PF_LD1,
  79. PA8_PF_LD2,
  80. PA9_PF_LD3,
  81. PA10_PF_LD4,
  82. PA11_PF_LD5,
  83. PA12_PF_LD6,
  84. PA13_PF_LD7,
  85. PA14_PF_LD8,
  86. PA15_PF_LD9,
  87. PA16_PF_LD10,
  88. PA17_PF_LD11,
  89. PA18_PF_LD12,
  90. PA19_PF_LD13,
  91. PA20_PF_LD14,
  92. PA21_PF_LD15,
  93. PA22_PF_LD16,
  94. PA24_PF_REV, /* Sharp panel dedicated signal */
  95. PA25_PF_CLS, /* Sharp panel dedicated signal */
  96. PA26_PF_PS, /* Sharp panel dedicated signal */
  97. PA27_PF_SPL_SPR, /* Sharp panel dedicated signal */
  98. PA28_PF_HSYNC,
  99. PA29_PF_VSYNC,
  100. PA30_PF_CONTRAST,
  101. PA31_PF_OE_ACD,
  102. /* MMC/SDHC */
  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. /* NFC */
  110. PF0_PF_NRFB,
  111. PF1_PF_NFCE,
  112. PF2_PF_NFWP,
  113. PF3_PF_NFCLE,
  114. PF4_PF_NFALE,
  115. PF5_PF_NFRE,
  116. PF6_PF_NFWE,
  117. PF7_PF_NFIO0,
  118. PF8_PF_NFIO1,
  119. PF9_PF_NFIO2,
  120. PF10_PF_NFIO3,
  121. PF11_PF_NFIO4,
  122. PF12_PF_NFIO5,
  123. PF13_PF_NFIO6,
  124. PF14_PF_NFIO7,
  125. };
  126. /* ADS's NOR flash: 2x AM29BDS128HE9VKI on 32-bit bus */
  127. static struct physmap_flash_data mx21ads_flash_data = {
  128. .width = 4,
  129. };
  130. static struct resource mx21ads_flash_resource = {
  131. .start = MX21_CS0_BASE_ADDR,
  132. .end = MX21_CS0_BASE_ADDR + 0x02000000 - 1,
  133. .flags = IORESOURCE_MEM,
  134. };
  135. static struct platform_device mx21ads_nor_mtd_device = {
  136. .name = "physmap-flash",
  137. .id = 0,
  138. .dev = {
  139. .platform_data = &mx21ads_flash_data,
  140. },
  141. .num_resources = 1,
  142. .resource = &mx21ads_flash_resource,
  143. };
  144. static const struct resource mx21ads_cs8900_resources[] __initconst = {
  145. DEFINE_RES_MEM(MX21_CS1_BASE_ADDR, MX21ADS_CS8900A_MMIO_SIZE),
  146. DEFINE_RES_IRQ(MX21ADS_CS8900A_IRQ),
  147. };
  148. static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
  149. .name = "cs89x0",
  150. .id = 0,
  151. .res = mx21ads_cs8900_resources,
  152. .num_res = ARRAY_SIZE(mx21ads_cs8900_resources),
  153. };
  154. static const struct imxuart_platform_data uart_pdata_rts __initconst = {
  155. .flags = IMXUART_HAVE_RTSCTS,
  156. };
  157. static const struct imxuart_platform_data uart_pdata_norts __initconst = {
  158. };
  159. static int mx21ads_fb_init(struct platform_device *pdev)
  160. {
  161. u16 tmp;
  162. tmp = __raw_readw(MX21ADS_IO_REG);
  163. tmp |= MX21ADS_IO_LCDON;
  164. __raw_writew(tmp, MX21ADS_IO_REG);
  165. return 0;
  166. }
  167. static void mx21ads_fb_exit(struct platform_device *pdev)
  168. {
  169. u16 tmp;
  170. tmp = __raw_readw(MX21ADS_IO_REG);
  171. tmp &= ~MX21ADS_IO_LCDON;
  172. __raw_writew(tmp, MX21ADS_IO_REG);
  173. }
  174. /*
  175. * Connected is a portrait Sharp-QVGA display
  176. * of type: LQ035Q7DB02
  177. */
  178. static struct imx_fb_videomode mx21ads_modes[] = {
  179. {
  180. .mode = {
  181. .name = "Sharp-LQ035Q7",
  182. .refresh = 60,
  183. .xres = 240,
  184. .yres = 320,
  185. .pixclock = 188679, /* in ps (5.3MHz) */
  186. .hsync_len = 2,
  187. .left_margin = 6,
  188. .right_margin = 16,
  189. .vsync_len = 1,
  190. .upper_margin = 8,
  191. .lower_margin = 10,
  192. },
  193. .pcr = 0xfb108bc7,
  194. .bpp = 16,
  195. },
  196. };
  197. static const struct imx_fb_platform_data mx21ads_fb_data __initconst = {
  198. .mode = mx21ads_modes,
  199. .num_modes = ARRAY_SIZE(mx21ads_modes),
  200. .pwmr = 0x00a903ff,
  201. .lscr1 = 0x00120300,
  202. .dmacr = 0x00020008,
  203. .init = mx21ads_fb_init,
  204. .exit = mx21ads_fb_exit,
  205. };
  206. static int mx21ads_sdhc_get_ro(struct device *dev)
  207. {
  208. return (__raw_readw(MX21ADS_IO_REG) & MX21ADS_IO_SD_WP) ? 1 : 0;
  209. }
  210. static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq,
  211. void *data)
  212. {
  213. return request_irq(IRQ_GPIOD(25), detect_irq,
  214. IRQF_TRIGGER_FALLING, "mmc-detect", data);
  215. }
  216. static void mx21ads_sdhc_exit(struct device *dev, void *data)
  217. {
  218. free_irq(IRQ_GPIOD(25), data);
  219. }
  220. static const struct imxmmc_platform_data mx21ads_sdhc_pdata __initconst = {
  221. .ocr_avail = MMC_VDD_29_30 | MMC_VDD_30_31, /* 3.0V */
  222. .get_ro = mx21ads_sdhc_get_ro,
  223. .init = mx21ads_sdhc_init,
  224. .exit = mx21ads_sdhc_exit,
  225. };
  226. static const struct mxc_nand_platform_data
  227. mx21ads_nand_board_info __initconst = {
  228. .width = 1,
  229. .hw_ecc = 1,
  230. };
  231. static struct map_desc mx21ads_io_desc[] __initdata = {
  232. /*
  233. * Memory-mapped I/O on MX21ADS Base board:
  234. * - CS8900A Ethernet controller
  235. * - ST16C2552CJ UART
  236. * - CPU and Base board version
  237. * - Base board I/O register
  238. */
  239. {
  240. .virtual = MX21ADS_MMIO_BASE_ADDR,
  241. .pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR),
  242. .length = MX21ADS_MMIO_SIZE,
  243. .type = MT_DEVICE,
  244. },
  245. };
  246. static void __init mx21ads_map_io(void)
  247. {
  248. mx21_map_io();
  249. iotable_init(mx21ads_io_desc, ARRAY_SIZE(mx21ads_io_desc));
  250. }
  251. static struct platform_device *platform_devices[] __initdata = {
  252. &mx21ads_nor_mtd_device,
  253. };
  254. static void __init mx21ads_board_init(void)
  255. {
  256. imx21_soc_init();
  257. mxc_gpio_setup_multiple_pins(mx21ads_pins, ARRAY_SIZE(mx21ads_pins),
  258. "mx21ads");
  259. imx21_add_imx_uart0(&uart_pdata_rts);
  260. imx21_add_imx_uart2(&uart_pdata_norts);
  261. imx21_add_imx_uart3(&uart_pdata_rts);
  262. imx21_add_imx_fb(&mx21ads_fb_data);
  263. imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata);
  264. imx21_add_mxc_nand(&mx21ads_nand_board_info);
  265. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  266. platform_device_register_full(
  267. (struct platform_device_info *)&mx21ads_cs8900_devinfo);
  268. }
  269. static void __init mx21ads_timer_init(void)
  270. {
  271. mx21_clocks_init(32768, 26000000);
  272. }
  273. static struct sys_timer mx21ads_timer = {
  274. .init = mx21ads_timer_init,
  275. };
  276. MACHINE_START(MX21ADS, "Freescale i.MX21ADS")
  277. /* maintainer: Freescale Semiconductor, Inc. */
  278. .atag_offset = 0x100,
  279. .map_io = mx21ads_map_io,
  280. .init_early = imx21_init_early,
  281. .init_irq = mx21_init_irq,
  282. .handle_irq = imx21_handle_irq,
  283. .timer = &mx21ads_timer,
  284. .init_machine = mx21ads_board_init,
  285. .restart = mxc_restart,
  286. MACHINE_END