mach-mx21ads.c 7.5 KB

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