mach-mx21ads.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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/driver.h>
  20. #include <linux/gpio.h>
  21. #include <linux/regulator/fixed.h>
  22. #include <linux/regulator/machine.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include "common.h"
  26. #include "devices-imx21.h"
  27. #include "hardware.h"
  28. #include "iomux-mx21.h"
  29. #define MX21ADS_CS8900A_REG (MX21_CS1_BASE_ADDR + 0x000000)
  30. #define MX21ADS_ST16C255_IOBASE_REG (MX21_CS1_BASE_ADDR + 0x200000)
  31. #define MX21ADS_VERSION_REG (MX21_CS1_BASE_ADDR + 0x400000)
  32. #define MX21ADS_IO_REG (MX21_CS1_BASE_ADDR + 0x800000)
  33. #define MX21ADS_MMC_CD IMX_GPIO_NR(4, 25)
  34. #define MX21ADS_CS8900A_IRQ_GPIO IMX_GPIO_NR(5, 11)
  35. #define MX21ADS_MMGPIO_BASE (6 * 32)
  36. /* MX21ADS_IO_REG bit definitions */
  37. #define MX21ADS_IO_SD_WP (MX21ADS_MMGPIO_BASE + 0)
  38. #define MX21ADS_IO_TP6 (MX21ADS_IO_SD_WP)
  39. #define MX21ADS_IO_SW_SEL (MX21ADS_MMGPIO_BASE + 1)
  40. #define MX21ADS_IO_TP7 (MX21ADS_IO_SW_SEL)
  41. #define MX21ADS_IO_RESET_E_UART (MX21ADS_MMGPIO_BASE + 2)
  42. #define MX21ADS_IO_RESET_BASE (MX21ADS_MMGPIO_BASE + 3)
  43. #define MX21ADS_IO_CSI_CTL2 (MX21ADS_MMGPIO_BASE + 4)
  44. #define MX21ADS_IO_CSI_CTL1 (MX21ADS_MMGPIO_BASE + 5)
  45. #define MX21ADS_IO_CSI_CTL0 (MX21ADS_MMGPIO_BASE + 6)
  46. #define MX21ADS_IO_UART1_EN (MX21ADS_MMGPIO_BASE + 7)
  47. #define MX21ADS_IO_UART4_EN (MX21ADS_MMGPIO_BASE + 8)
  48. #define MX21ADS_IO_LCDON (MX21ADS_MMGPIO_BASE + 9)
  49. #define MX21ADS_IO_IRDA_EN (MX21ADS_MMGPIO_BASE + 10)
  50. #define MX21ADS_IO_IRDA_FIR_SEL (MX21ADS_MMGPIO_BASE + 11)
  51. #define MX21ADS_IO_IRDA_MD0_B (MX21ADS_MMGPIO_BASE + 12)
  52. #define MX21ADS_IO_IRDA_MD1 (MX21ADS_MMGPIO_BASE + 13)
  53. #define MX21ADS_IO_LED4_ON (MX21ADS_MMGPIO_BASE + 14)
  54. #define MX21ADS_IO_LED3_ON (MX21ADS_MMGPIO_BASE + 15)
  55. static const int mx21ads_pins[] __initconst = {
  56. /* CS8900A */
  57. (GPIO_PORTE | GPIO_GPIO | GPIO_IN | 11),
  58. /* UART1 */
  59. PE12_PF_UART1_TXD,
  60. PE13_PF_UART1_RXD,
  61. PE14_PF_UART1_CTS,
  62. PE15_PF_UART1_RTS,
  63. /* UART3 (IrDA) - only TXD and RXD */
  64. PE8_PF_UART3_TXD,
  65. PE9_PF_UART3_RXD,
  66. /* UART4 */
  67. PB26_AF_UART4_RTS,
  68. PB28_AF_UART4_TXD,
  69. PB29_AF_UART4_CTS,
  70. PB31_AF_UART4_RXD,
  71. /* LCDC */
  72. PA5_PF_LSCLK,
  73. PA6_PF_LD0,
  74. PA7_PF_LD1,
  75. PA8_PF_LD2,
  76. PA9_PF_LD3,
  77. PA10_PF_LD4,
  78. PA11_PF_LD5,
  79. PA12_PF_LD6,
  80. PA13_PF_LD7,
  81. PA14_PF_LD8,
  82. PA15_PF_LD9,
  83. PA16_PF_LD10,
  84. PA17_PF_LD11,
  85. PA18_PF_LD12,
  86. PA19_PF_LD13,
  87. PA20_PF_LD14,
  88. PA21_PF_LD15,
  89. PA22_PF_LD16,
  90. PA24_PF_REV, /* Sharp panel dedicated signal */
  91. PA25_PF_CLS, /* Sharp panel dedicated signal */
  92. PA26_PF_PS, /* Sharp panel dedicated signal */
  93. PA27_PF_SPL_SPR, /* Sharp panel dedicated signal */
  94. PA28_PF_HSYNC,
  95. PA29_PF_VSYNC,
  96. PA30_PF_CONTRAST,
  97. PA31_PF_OE_ACD,
  98. /* MMC/SDHC */
  99. PE18_PF_SD1_D0,
  100. PE19_PF_SD1_D1,
  101. PE20_PF_SD1_D2,
  102. PE21_PF_SD1_D3,
  103. PE22_PF_SD1_CMD,
  104. PE23_PF_SD1_CLK,
  105. /* NFC */
  106. PF0_PF_NRFB,
  107. PF1_PF_NFCE,
  108. PF2_PF_NFWP,
  109. PF3_PF_NFCLE,
  110. PF4_PF_NFALE,
  111. PF5_PF_NFRE,
  112. PF6_PF_NFWE,
  113. PF7_PF_NFIO0,
  114. PF8_PF_NFIO1,
  115. PF9_PF_NFIO2,
  116. PF10_PF_NFIO3,
  117. PF11_PF_NFIO4,
  118. PF12_PF_NFIO5,
  119. PF13_PF_NFIO6,
  120. PF14_PF_NFIO7,
  121. };
  122. /* ADS's NOR flash: 2x AM29BDS128HE9VKI on 32-bit bus */
  123. static struct physmap_flash_data mx21ads_flash_data = {
  124. .width = 4,
  125. };
  126. static struct resource mx21ads_flash_resource =
  127. DEFINE_RES_MEM(MX21_CS0_BASE_ADDR, SZ_32M);
  128. static struct platform_device mx21ads_nor_mtd_device = {
  129. .name = "physmap-flash",
  130. .id = 0,
  131. .dev = {
  132. .platform_data = &mx21ads_flash_data,
  133. },
  134. .num_resources = 1,
  135. .resource = &mx21ads_flash_resource,
  136. };
  137. static struct resource mx21ads_cs8900_resources[] __initdata = {
  138. DEFINE_RES_MEM(MX21ADS_CS8900A_REG, SZ_1K),
  139. /* irq number is run-time assigned */
  140. DEFINE_RES_IRQ(-1),
  141. };
  142. static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
  143. .name = "cs89x0",
  144. .id = 0,
  145. .res = mx21ads_cs8900_resources,
  146. .num_res = ARRAY_SIZE(mx21ads_cs8900_resources),
  147. };
  148. static const struct imxuart_platform_data uart_pdata_rts __initconst = {
  149. .flags = IMXUART_HAVE_RTSCTS,
  150. };
  151. static const struct imxuart_platform_data uart_pdata_norts __initconst = {
  152. };
  153. static struct resource mx21ads_mmgpio_resource =
  154. DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat");
  155. static struct bgpio_pdata mx21ads_mmgpio_pdata = {
  156. .base = MX21ADS_MMGPIO_BASE,
  157. .ngpio = 16,
  158. };
  159. static struct platform_device mx21ads_mmgpio = {
  160. .name = "basic-mmio-gpio",
  161. .id = PLATFORM_DEVID_AUTO,
  162. .resource = &mx21ads_mmgpio_resource,
  163. .num_resources = 1,
  164. .dev = {
  165. .platform_data = &mx21ads_mmgpio_pdata,
  166. },
  167. };
  168. static struct regulator_consumer_supply mx21ads_lcd_regulator_consumer =
  169. REGULATOR_SUPPLY("lcd", "imx-fb.0");
  170. static struct regulator_init_data mx21ads_lcd_regulator_init_data = {
  171. .constraints = {
  172. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  173. },
  174. .consumer_supplies = &mx21ads_lcd_regulator_consumer,
  175. .num_consumer_supplies = 1,
  176. };
  177. static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = {
  178. .supply_name = "LCD",
  179. .microvolts = 3300000,
  180. .gpio = MX21ADS_IO_LCDON,
  181. .enable_high = 1,
  182. .init_data = &mx21ads_lcd_regulator_init_data,
  183. };
  184. static struct platform_device mx21ads_lcd_regulator = {
  185. .name = "reg-fixed-voltage",
  186. .id = PLATFORM_DEVID_AUTO,
  187. .dev = {
  188. .platform_data = &mx21ads_lcd_regulator_pdata,
  189. },
  190. };
  191. /*
  192. * Connected is a portrait Sharp-QVGA display
  193. * of type: LQ035Q7DB02
  194. */
  195. static struct imx_fb_videomode mx21ads_modes[] = {
  196. {
  197. .mode = {
  198. .name = "Sharp-LQ035Q7",
  199. .refresh = 60,
  200. .xres = 240,
  201. .yres = 320,
  202. .pixclock = 188679, /* in ps (5.3MHz) */
  203. .hsync_len = 2,
  204. .left_margin = 6,
  205. .right_margin = 16,
  206. .vsync_len = 1,
  207. .upper_margin = 8,
  208. .lower_margin = 10,
  209. },
  210. .pcr = 0xfb108bc7,
  211. .bpp = 16,
  212. },
  213. };
  214. static const struct imx_fb_platform_data mx21ads_fb_data __initconst = {
  215. .mode = mx21ads_modes,
  216. .num_modes = ARRAY_SIZE(mx21ads_modes),
  217. .pwmr = 0x00a903ff,
  218. .lscr1 = 0x00120300,
  219. .dmacr = 0x00020008,
  220. };
  221. static int mx21ads_sdhc_get_ro(struct device *dev)
  222. {
  223. return gpio_get_value(MX21ADS_IO_SD_WP);
  224. }
  225. static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq,
  226. void *data)
  227. {
  228. int ret;
  229. ret = gpio_request(MX21ADS_IO_SD_WP, "mmc-ro");
  230. if (ret)
  231. return ret;
  232. return request_irq(gpio_to_irq(MX21ADS_MMC_CD), detect_irq,
  233. IRQF_TRIGGER_FALLING, "mmc-detect", data);
  234. }
  235. static void mx21ads_sdhc_exit(struct device *dev, void *data)
  236. {
  237. free_irq(gpio_to_irq(MX21ADS_MMC_CD), data);
  238. gpio_free(MX21ADS_IO_SD_WP);
  239. }
  240. static const struct imxmmc_platform_data mx21ads_sdhc_pdata __initconst = {
  241. .ocr_avail = MMC_VDD_29_30 | MMC_VDD_30_31, /* 3.0V */
  242. .get_ro = mx21ads_sdhc_get_ro,
  243. .init = mx21ads_sdhc_init,
  244. .exit = mx21ads_sdhc_exit,
  245. };
  246. static const struct mxc_nand_platform_data
  247. mx21ads_nand_board_info __initconst = {
  248. .width = 1,
  249. .hw_ecc = 1,
  250. };
  251. static struct platform_device *platform_devices[] __initdata = {
  252. &mx21ads_mmgpio,
  253. &mx21ads_lcd_regulator,
  254. &mx21ads_nor_mtd_device,
  255. };
  256. static void __init mx21ads_board_init(void)
  257. {
  258. imx21_soc_init();
  259. mxc_gpio_setup_multiple_pins(mx21ads_pins, ARRAY_SIZE(mx21ads_pins),
  260. "mx21ads");
  261. imx21_add_imx_uart0(&uart_pdata_rts);
  262. imx21_add_imx_uart2(&uart_pdata_norts);
  263. imx21_add_imx_uart3(&uart_pdata_rts);
  264. imx21_add_mxc_nand(&mx21ads_nand_board_info);
  265. imx21_add_imx_fb(&mx21ads_fb_data);
  266. }
  267. static void __init mx21ads_late_init(void)
  268. {
  269. imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata);
  270. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  271. mx21ads_cs8900_resources[1].start =
  272. gpio_to_irq(MX21ADS_CS8900A_IRQ_GPIO);
  273. mx21ads_cs8900_resources[1].end =
  274. gpio_to_irq(MX21ADS_CS8900A_IRQ_GPIO);
  275. platform_device_register_full(&mx21ads_cs8900_devinfo);
  276. }
  277. static void __init mx21ads_timer_init(void)
  278. {
  279. mx21_clocks_init(32768, 26000000);
  280. }
  281. MACHINE_START(MX21ADS, "Freescale i.MX21ADS")
  282. /* maintainer: Freescale Semiconductor, Inc. */
  283. .atag_offset = 0x100,
  284. .map_io = mx21_map_io,
  285. .init_early = imx21_init_early,
  286. .init_irq = mx21_init_irq,
  287. .init_time = mx21ads_timer_init,
  288. .init_machine = mx21ads_board_init,
  289. .init_late = mx21ads_late_init,
  290. .restart = mxc_restart,
  291. MACHINE_END