mach-mx21ads.c 7.9 KB

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