mx21ads.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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.h>
  33. #include <mach/mxc_nand.h>
  34. #include <mach/mmc.h>
  35. #include <mach/board-mx21ads.h>
  36. #include "devices.h"
  37. static unsigned int mx21ads_pins[] = {
  38. /* CS8900A */
  39. (GPIO_PORTE | GPIO_GPIO | GPIO_IN | 11),
  40. /* UART1 */
  41. PE12_PF_UART1_TXD,
  42. PE13_PF_UART1_RXD,
  43. PE14_PF_UART1_CTS,
  44. PE15_PF_UART1_RTS,
  45. /* UART3 (IrDA) - only TXD and RXD */
  46. PE8_PF_UART3_TXD,
  47. PE9_PF_UART3_RXD,
  48. /* UART4 */
  49. PB26_AF_UART4_RTS,
  50. PB28_AF_UART4_TXD,
  51. PB29_AF_UART4_CTS,
  52. PB31_AF_UART4_RXD,
  53. /* LCDC */
  54. PA5_PF_LSCLK,
  55. PA6_PF_LD0,
  56. PA7_PF_LD1,
  57. PA8_PF_LD2,
  58. PA9_PF_LD3,
  59. PA10_PF_LD4,
  60. PA11_PF_LD5,
  61. PA12_PF_LD6,
  62. PA13_PF_LD7,
  63. PA14_PF_LD8,
  64. PA15_PF_LD9,
  65. PA16_PF_LD10,
  66. PA17_PF_LD11,
  67. PA18_PF_LD12,
  68. PA19_PF_LD13,
  69. PA20_PF_LD14,
  70. PA21_PF_LD15,
  71. PA22_PF_LD16,
  72. PA24_PF_REV, /* Sharp panel dedicated signal */
  73. PA25_PF_CLS, /* Sharp panel dedicated signal */
  74. PA26_PF_PS, /* Sharp panel dedicated signal */
  75. PA27_PF_SPL_SPR, /* Sharp panel dedicated signal */
  76. PA28_PF_HSYNC,
  77. PA29_PF_VSYNC,
  78. PA30_PF_CONTRAST,
  79. PA31_PF_OE_ACD,
  80. /* MMC/SDHC */
  81. PE18_PF_SD1_D0,
  82. PE19_PF_SD1_D1,
  83. PE20_PF_SD1_D2,
  84. PE21_PF_SD1_D3,
  85. PE22_PF_SD1_CMD,
  86. PE23_PF_SD1_CLK,
  87. /* NFC */
  88. PF0_PF_NRFB,
  89. PF1_PF_NFCE,
  90. PF2_PF_NFWP,
  91. PF3_PF_NFCLE,
  92. PF4_PF_NFALE,
  93. PF5_PF_NFRE,
  94. PF6_PF_NFWE,
  95. PF7_PF_NFIO0,
  96. PF8_PF_NFIO1,
  97. PF9_PF_NFIO2,
  98. PF10_PF_NFIO3,
  99. PF11_PF_NFIO4,
  100. PF12_PF_NFIO5,
  101. PF13_PF_NFIO6,
  102. PF14_PF_NFIO7,
  103. };
  104. /* ADS's NOR flash: 2x AM29BDS128HE9VKI on 32-bit bus */
  105. static struct physmap_flash_data mx21ads_flash_data = {
  106. .width = 4,
  107. };
  108. static struct resource mx21ads_flash_resource = {
  109. .start = CS0_BASE_ADDR,
  110. .end = CS0_BASE_ADDR + 0x02000000 - 1,
  111. .flags = IORESOURCE_MEM,
  112. };
  113. static struct platform_device mx21ads_nor_mtd_device = {
  114. .name = "physmap-flash",
  115. .id = 0,
  116. .dev = {
  117. .platform_data = &mx21ads_flash_data,
  118. },
  119. .num_resources = 1,
  120. .resource = &mx21ads_flash_resource,
  121. };
  122. static struct imxuart_platform_data uart_pdata = {
  123. .flags = IMXUART_HAVE_RTSCTS,
  124. };
  125. static struct imxuart_platform_data uart_norts_pdata = {
  126. };
  127. static int mx21ads_fb_init(struct platform_device *pdev)
  128. {
  129. u16 tmp;
  130. tmp = __raw_readw(MX21ADS_IO_REG);
  131. tmp |= MX21ADS_IO_LCDON;
  132. __raw_writew(tmp, MX21ADS_IO_REG);
  133. return 0;
  134. }
  135. static void mx21ads_fb_exit(struct platform_device *pdev)
  136. {
  137. u16 tmp;
  138. tmp = __raw_readw(MX21ADS_IO_REG);
  139. tmp &= ~MX21ADS_IO_LCDON;
  140. __raw_writew(tmp, MX21ADS_IO_REG);
  141. }
  142. /*
  143. * Connected is a portrait Sharp-QVGA display
  144. * of type: LQ035Q7DB02
  145. */
  146. static struct imx_fb_platform_data mx21ads_fb_data = {
  147. .pixclock = 188679, /* in ps */
  148. .xres = 240,
  149. .yres = 320,
  150. .bpp = 16,
  151. .hsync_len = 2,
  152. .left_margin = 6,
  153. .right_margin = 16,
  154. .vsync_len = 1,
  155. .upper_margin = 8,
  156. .lower_margin = 10,
  157. .fixed_screen_cpu = 0,
  158. .pcr = 0xFB108BC7,
  159. .pwmr = 0x00A901ff,
  160. .lscr1 = 0x00120300,
  161. .dmacr = 0x00020008,
  162. .init = mx21ads_fb_init,
  163. .exit = mx21ads_fb_exit,
  164. };
  165. static int mx21ads_sdhc_get_ro(struct device *dev)
  166. {
  167. return (__raw_readw(MX21ADS_IO_REG) & MX21ADS_IO_SD_WP) ? 1 : 0;
  168. }
  169. static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq,
  170. void *data)
  171. {
  172. int ret;
  173. ret = request_irq(IRQ_GPIOD(25), detect_irq,
  174. IRQF_TRIGGER_FALLING, "mmc-detect", data);
  175. if (ret)
  176. goto out;
  177. return 0;
  178. out:
  179. return ret;
  180. }
  181. static void mx21ads_sdhc_exit(struct device *dev, void *data)
  182. {
  183. free_irq(IRQ_GPIOD(25), data);
  184. }
  185. static struct imxmmc_platform_data mx21ads_sdhc_pdata = {
  186. .ocr_avail = MMC_VDD_29_30 | MMC_VDD_30_31, /* 3.0V */
  187. .get_ro = mx21ads_sdhc_get_ro,
  188. .init = mx21ads_sdhc_init,
  189. .exit = mx21ads_sdhc_exit,
  190. };
  191. static struct mxc_nand_platform_data mx21ads_nand_board_info = {
  192. .width = 1,
  193. .hw_ecc = 1,
  194. };
  195. static struct map_desc mx21ads_io_desc[] __initdata = {
  196. /*
  197. * Memory-mapped I/O on MX21ADS Base board:
  198. * - CS8900A Ethernet controller
  199. * - ST16C2552CJ UART
  200. * - CPU and Base board version
  201. * - Base board I/O register
  202. */
  203. {
  204. .virtual = MX21ADS_MMIO_BASE_ADDR,
  205. .pfn = __phys_to_pfn(CS1_BASE_ADDR),
  206. .length = MX21ADS_MMIO_SIZE,
  207. .type = MT_DEVICE,
  208. },
  209. };
  210. static void __init mx21ads_map_io(void)
  211. {
  212. mx21_map_io();
  213. iotable_init(mx21ads_io_desc, ARRAY_SIZE(mx21ads_io_desc));
  214. }
  215. static struct platform_device *platform_devices[] __initdata = {
  216. &mx21ads_nor_mtd_device,
  217. };
  218. static void __init mx21ads_board_init(void)
  219. {
  220. mxc_gpio_setup_multiple_pins(mx21ads_pins, ARRAY_SIZE(mx21ads_pins),
  221. "mx21ads");
  222. mxc_register_device(&mxc_uart_device0, &uart_pdata);
  223. mxc_register_device(&mxc_uart_device2, &uart_norts_pdata);
  224. mxc_register_device(&mxc_uart_device3, &uart_pdata);
  225. mxc_register_device(&mxc_fb_device, &mx21ads_fb_data);
  226. mxc_register_device(&mxc_sdhc_device0, &mx21ads_sdhc_pdata);
  227. mxc_register_device(&mxc_nand_device, &mx21ads_nand_board_info);
  228. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  229. }
  230. static void __init mx21ads_timer_init(void)
  231. {
  232. mx21_clocks_init(32768, 26000000);
  233. }
  234. static struct sys_timer mx21ads_timer = {
  235. .init = mx21ads_timer_init,
  236. };
  237. MACHINE_START(MX21ADS, "Freescale i.MX21ADS")
  238. /* maintainer: Freescale Semiconductor, Inc. */
  239. .phys_io = AIPI_BASE_ADDR,
  240. .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  241. .boot_params = PHYS_OFFSET + 0x100,
  242. .map_io = mx21ads_map_io,
  243. .init_irq = mxc_init_irq,
  244. .init_machine = mx21ads_board_init,
  245. .timer = &mx21ads_timer,
  246. MACHINE_END