armadillo5x0.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. /*
  2. * armadillo5x0.c
  3. *
  4. * Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
  5. * updates in http://alberdroid.blogspot.com/
  6. *
  7. * Based on Atmark Techno, Inc. armadillo 500 BSP 2008
  8. * Based on mx31ads.c and pcm037.c Great Work!
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23. * MA 02110-1301, USA.
  24. */
  25. #include <linux/types.h>
  26. #include <linux/init.h>
  27. #include <linux/clk.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/gpio.h>
  30. #include <linux/smsc911x.h>
  31. #include <linux/interrupt.h>
  32. #include <linux/irq.h>
  33. #include <linux/mtd/physmap.h>
  34. #include <linux/io.h>
  35. #include <mach/hardware.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/time.h>
  39. #include <asm/memory.h>
  40. #include <asm/mach/map.h>
  41. #include <mach/common.h>
  42. #include <mach/imx-uart.h>
  43. #include <mach/iomux-mx3.h>
  44. #include <mach/board-armadillo5x0.h>
  45. #include <mach/mmc.h>
  46. #include <mach/ipu.h>
  47. #include <mach/mx3fb.h>
  48. #include <mach/mxc_nand.h>
  49. #include "devices.h"
  50. #include "crm_regs.h"
  51. static int armadillo5x0_pins[] = {
  52. /* UART1 */
  53. MX31_PIN_CTS1__CTS1,
  54. MX31_PIN_RTS1__RTS1,
  55. MX31_PIN_TXD1__TXD1,
  56. MX31_PIN_RXD1__RXD1,
  57. /* UART2 */
  58. MX31_PIN_CTS2__CTS2,
  59. MX31_PIN_RTS2__RTS2,
  60. MX31_PIN_TXD2__TXD2,
  61. MX31_PIN_RXD2__RXD2,
  62. /* LAN9118_IRQ */
  63. IOMUX_MODE(MX31_PIN_GPIO1_0, IOMUX_CONFIG_GPIO),
  64. /* SDHC1 */
  65. MX31_PIN_SD1_DATA3__SD1_DATA3,
  66. MX31_PIN_SD1_DATA2__SD1_DATA2,
  67. MX31_PIN_SD1_DATA1__SD1_DATA1,
  68. MX31_PIN_SD1_DATA0__SD1_DATA0,
  69. MX31_PIN_SD1_CLK__SD1_CLK,
  70. MX31_PIN_SD1_CMD__SD1_CMD,
  71. /* Framebuffer */
  72. MX31_PIN_LD0__LD0,
  73. MX31_PIN_LD1__LD1,
  74. MX31_PIN_LD2__LD2,
  75. MX31_PIN_LD3__LD3,
  76. MX31_PIN_LD4__LD4,
  77. MX31_PIN_LD5__LD5,
  78. MX31_PIN_LD6__LD6,
  79. MX31_PIN_LD7__LD7,
  80. MX31_PIN_LD8__LD8,
  81. MX31_PIN_LD9__LD9,
  82. MX31_PIN_LD10__LD10,
  83. MX31_PIN_LD11__LD11,
  84. MX31_PIN_LD12__LD12,
  85. MX31_PIN_LD13__LD13,
  86. MX31_PIN_LD14__LD14,
  87. MX31_PIN_LD15__LD15,
  88. MX31_PIN_LD16__LD16,
  89. MX31_PIN_LD17__LD17,
  90. MX31_PIN_VSYNC3__VSYNC3,
  91. MX31_PIN_HSYNC__HSYNC,
  92. MX31_PIN_FPSHIFT__FPSHIFT,
  93. MX31_PIN_DRDY0__DRDY0,
  94. IOMUX_MODE(MX31_PIN_LCS1, IOMUX_CONFIG_GPIO), /*ADV7125_PSAVE*/
  95. };
  96. /*
  97. * NAND Flash
  98. */
  99. static struct mxc_nand_platform_data armadillo5x0_nand_flash_pdata = {
  100. .width = 1,
  101. .hw_ecc = 1,
  102. };
  103. /*
  104. * MTD NOR Flash
  105. */
  106. static struct mtd_partition armadillo5x0_nor_flash_partitions[] = {
  107. {
  108. .name = "nor.bootloader",
  109. .offset = 0x00000000,
  110. .size = 4*32*1024,
  111. }, {
  112. .name = "nor.kernel",
  113. .offset = MTDPART_OFS_APPEND,
  114. .size = 16*128*1024,
  115. }, {
  116. .name = "nor.userland",
  117. .offset = MTDPART_OFS_APPEND,
  118. .size = 110*128*1024,
  119. }, {
  120. .name = "nor.config",
  121. .offset = MTDPART_OFS_APPEND,
  122. .size = 1*128*1024,
  123. },
  124. };
  125. static struct physmap_flash_data armadillo5x0_nor_flash_pdata = {
  126. .width = 2,
  127. .parts = armadillo5x0_nor_flash_partitions,
  128. .nr_parts = ARRAY_SIZE(armadillo5x0_nor_flash_partitions),
  129. };
  130. static struct resource armadillo5x0_nor_flash_resource = {
  131. .flags = IORESOURCE_MEM,
  132. .start = CS0_BASE_ADDR,
  133. .end = CS0_BASE_ADDR + SZ_64M - 1,
  134. };
  135. static struct platform_device armadillo5x0_nor_flash = {
  136. .name = "physmap-flash",
  137. .id = -1,
  138. .num_resources = 1,
  139. .resource = &armadillo5x0_nor_flash_resource,
  140. };
  141. /*
  142. * FB support
  143. */
  144. static const struct fb_videomode fb_modedb[] = {
  145. { /* 640x480 @ 60 Hz */
  146. .name = "CRT-VGA",
  147. .refresh = 60,
  148. .xres = 640,
  149. .yres = 480,
  150. .pixclock = 39721,
  151. .left_margin = 35,
  152. .right_margin = 115,
  153. .upper_margin = 43,
  154. .lower_margin = 1,
  155. .hsync_len = 10,
  156. .vsync_len = 1,
  157. .sync = FB_SYNC_OE_ACT_HIGH,
  158. .vmode = FB_VMODE_NONINTERLACED,
  159. .flag = 0,
  160. }, {/* 800x600 @ 56 Hz */
  161. .name = "CRT-SVGA",
  162. .refresh = 56,
  163. .xres = 800,
  164. .yres = 600,
  165. .pixclock = 30000,
  166. .left_margin = 30,
  167. .right_margin = 108,
  168. .upper_margin = 13,
  169. .lower_margin = 10,
  170. .hsync_len = 10,
  171. .vsync_len = 1,
  172. .sync = FB_SYNC_OE_ACT_HIGH | FB_SYNC_HOR_HIGH_ACT |
  173. FB_SYNC_VERT_HIGH_ACT,
  174. .vmode = FB_VMODE_NONINTERLACED,
  175. .flag = 0,
  176. },
  177. };
  178. static struct ipu_platform_data mx3_ipu_data = {
  179. .irq_base = MXC_IPU_IRQ_START,
  180. };
  181. static struct mx3fb_platform_data mx3fb_pdata = {
  182. .dma_dev = &mx3_ipu.dev,
  183. .name = "CRT-VGA",
  184. .mode = fb_modedb,
  185. .num_modes = ARRAY_SIZE(fb_modedb),
  186. };
  187. /*
  188. * SDHC 1
  189. * MMC support
  190. */
  191. static int armadillo5x0_sdhc1_get_ro(struct device *dev)
  192. {
  193. return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B));
  194. }
  195. static int armadillo5x0_sdhc1_init(struct device *dev,
  196. irq_handler_t detect_irq, void *data)
  197. {
  198. int ret;
  199. int gpio_det, gpio_wp;
  200. gpio_det = IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK);
  201. gpio_wp = IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B);
  202. ret = gpio_request(gpio_det, "sdhc-card-detect");
  203. if (ret)
  204. return ret;
  205. gpio_direction_input(gpio_det);
  206. ret = gpio_request(gpio_wp, "sdhc-write-protect");
  207. if (ret)
  208. goto err_gpio_free;
  209. gpio_direction_input(gpio_wp);
  210. /* When supported the trigger type have to be BOTH */
  211. ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK), detect_irq,
  212. IRQF_DISABLED | IRQF_TRIGGER_FALLING,
  213. "sdhc-detect", data);
  214. if (ret)
  215. goto err_gpio_free_2;
  216. return 0;
  217. err_gpio_free_2:
  218. gpio_free(gpio_wp);
  219. err_gpio_free:
  220. gpio_free(gpio_det);
  221. return ret;
  222. }
  223. static void armadillo5x0_sdhc1_exit(struct device *dev, void *data)
  224. {
  225. free_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK), data);
  226. gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK));
  227. gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B));
  228. }
  229. static struct imxmmc_platform_data sdhc_pdata = {
  230. .get_ro = armadillo5x0_sdhc1_get_ro,
  231. .init = armadillo5x0_sdhc1_init,
  232. .exit = armadillo5x0_sdhc1_exit,
  233. };
  234. /*
  235. * SMSC 9118
  236. * Network support
  237. */
  238. static struct resource armadillo5x0_smc911x_resources[] = {
  239. {
  240. .start = CS3_BASE_ADDR,
  241. .end = CS3_BASE_ADDR + SZ_32M - 1,
  242. .flags = IORESOURCE_MEM,
  243. }, {
  244. .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
  245. .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
  246. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  247. },
  248. };
  249. static struct smsc911x_platform_config smsc911x_info = {
  250. .flags = SMSC911X_USE_32BIT,
  251. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  252. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  253. };
  254. static struct platform_device armadillo5x0_smc911x_device = {
  255. .name = "smsc911x",
  256. .id = -1,
  257. .num_resources = ARRAY_SIZE(armadillo5x0_smc911x_resources),
  258. .resource = armadillo5x0_smc911x_resources,
  259. .dev = {
  260. .platform_data = &smsc911x_info,
  261. },
  262. };
  263. /* UART device data */
  264. static struct imxuart_platform_data uart_pdata = {
  265. .flags = IMXUART_HAVE_RTSCTS,
  266. };
  267. static struct platform_device *devices[] __initdata = {
  268. &armadillo5x0_smc911x_device,
  269. };
  270. /*
  271. * Perform board specific initializations
  272. */
  273. static void __init armadillo5x0_init(void)
  274. {
  275. mxc_iomux_setup_multiple_pins(armadillo5x0_pins,
  276. ARRAY_SIZE(armadillo5x0_pins), "armadillo5x0");
  277. platform_add_devices(devices, ARRAY_SIZE(devices));
  278. /* Register UART */
  279. mxc_register_device(&mxc_uart_device0, &uart_pdata);
  280. mxc_register_device(&mxc_uart_device1, &uart_pdata);
  281. /* SMSC9118 IRQ pin */
  282. gpio_direction_input(MX31_PIN_GPIO1_0);
  283. /* Register SDHC */
  284. mxc_register_device(&mxcsdhc_device0, &sdhc_pdata);
  285. /* Register FB */
  286. mxc_register_device(&mx3_ipu, &mx3_ipu_data);
  287. mxc_register_device(&mx3_fb, &mx3fb_pdata);
  288. /* Register NOR Flash */
  289. mxc_register_device(&armadillo5x0_nor_flash,
  290. &armadillo5x0_nor_flash_pdata);
  291. /* Register NAND Flash */
  292. mxc_register_device(&mxc_nand_device, &armadillo5x0_nand_flash_pdata);
  293. /* set NAND page size to 2k if not configured via boot mode pins */
  294. __raw_writel(__raw_readl(MXC_CCM_RCSR) | (1 << 30), MXC_CCM_RCSR);
  295. }
  296. static void __init armadillo5x0_timer_init(void)
  297. {
  298. mx31_clocks_init(26000000);
  299. }
  300. static struct sys_timer armadillo5x0_timer = {
  301. .init = armadillo5x0_timer_init,
  302. };
  303. MACHINE_START(ARMADILLO5X0, "Armadillo-500")
  304. /* Maintainer: Alberto Panizzo */
  305. .phys_io = AIPS1_BASE_ADDR,
  306. .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  307. .boot_params = PHYS_OFFSET + 0x00000100,
  308. .map_io = mx31_map_io,
  309. .init_irq = mx31_init_irq,
  310. .timer = &armadillo5x0_timer,
  311. .init_machine = armadillo5x0_init,
  312. MACHINE_END