board-da850-evm.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. /*
  2. * TI DA850/OMAP-L138 EVM board
  3. *
  4. * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * Derived from: arch/arm/mach-davinci/board-da830-evm.c
  7. * Original Copyrights follow:
  8. *
  9. * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
  10. * the terms of the GNU General Public License version 2. This program
  11. * is licensed "as is" without any warranty of any kind, whether express
  12. * or implied.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/init.h>
  17. #include <linux/console.h>
  18. #include <linux/i2c.h>
  19. #include <linux/i2c/at24.h>
  20. #include <linux/gpio.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/mtd/mtd.h>
  23. #include <linux/mtd/nand.h>
  24. #include <linux/mtd/partitions.h>
  25. #include <linux/mtd/physmap.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <mach/common.h>
  29. #include <mach/irqs.h>
  30. #include <mach/cp_intc.h>
  31. #include <mach/da8xx.h>
  32. #include <mach/nand.h>
  33. #define DA850_EVM_PHY_MASK 0x1
  34. #define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
  35. #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
  36. #define DA850_LCD_PWR_PIN GPIO_TO_PIN(8, 10)
  37. #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
  38. #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
  39. static struct mtd_partition da850_evm_norflash_partition[] = {
  40. {
  41. .name = "NOR filesystem",
  42. .offset = 0,
  43. .size = MTDPART_SIZ_FULL,
  44. .mask_flags = 0,
  45. },
  46. };
  47. static struct physmap_flash_data da850_evm_norflash_data = {
  48. .width = 2,
  49. .parts = da850_evm_norflash_partition,
  50. .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
  51. };
  52. static struct resource da850_evm_norflash_resource[] = {
  53. {
  54. .start = DA8XX_AEMIF_CS2_BASE,
  55. .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
  56. .flags = IORESOURCE_MEM,
  57. },
  58. };
  59. static struct platform_device da850_evm_norflash_device = {
  60. .name = "physmap-flash",
  61. .id = 0,
  62. .dev = {
  63. .platform_data = &da850_evm_norflash_data,
  64. },
  65. .num_resources = 1,
  66. .resource = da850_evm_norflash_resource,
  67. };
  68. /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  69. * (128K blocks). It may be used instead of the (default) SPI flash
  70. * to boot, using TI's tools to install the secondary boot loader
  71. * (UBL) and U-Boot.
  72. */
  73. struct mtd_partition da850_evm_nandflash_partition[] = {
  74. {
  75. .name = "u-boot env",
  76. .offset = 0,
  77. .size = SZ_128K,
  78. .mask_flags = MTD_WRITEABLE,
  79. },
  80. {
  81. .name = "UBL",
  82. .offset = MTDPART_OFS_APPEND,
  83. .size = SZ_128K,
  84. .mask_flags = MTD_WRITEABLE,
  85. },
  86. {
  87. .name = "u-boot",
  88. .offset = MTDPART_OFS_APPEND,
  89. .size = 4 * SZ_128K,
  90. .mask_flags = MTD_WRITEABLE,
  91. },
  92. {
  93. .name = "kernel",
  94. .offset = 0x200000,
  95. .size = SZ_2M,
  96. .mask_flags = 0,
  97. },
  98. {
  99. .name = "filesystem",
  100. .offset = MTDPART_OFS_APPEND,
  101. .size = MTDPART_SIZ_FULL,
  102. .mask_flags = 0,
  103. },
  104. };
  105. static struct davinci_nand_pdata da850_evm_nandflash_data = {
  106. .parts = da850_evm_nandflash_partition,
  107. .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
  108. .ecc_mode = NAND_ECC_HW,
  109. .options = NAND_USE_FLASH_BBT,
  110. };
  111. static struct resource da850_evm_nandflash_resource[] = {
  112. {
  113. .start = DA8XX_AEMIF_CS3_BASE,
  114. .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
  115. .flags = IORESOURCE_MEM,
  116. },
  117. {
  118. .start = DA8XX_AEMIF_CTL_BASE,
  119. .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
  120. .flags = IORESOURCE_MEM,
  121. },
  122. };
  123. static struct platform_device da850_evm_nandflash_device = {
  124. .name = "davinci_nand",
  125. .id = 1,
  126. .dev = {
  127. .platform_data = &da850_evm_nandflash_data,
  128. },
  129. .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
  130. .resource = da850_evm_nandflash_resource,
  131. };
  132. static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
  133. .bus_freq = 100, /* kHz */
  134. .bus_delay = 0, /* usec */
  135. };
  136. static struct davinci_uart_config da850_evm_uart_config __initdata = {
  137. .enabled_uarts = 0x7,
  138. };
  139. static struct platform_device *da850_evm_devices[] __initdata = {
  140. &da850_evm_nandflash_device,
  141. &da850_evm_norflash_device,
  142. };
  143. /* davinci da850 evm audio machine driver */
  144. static u8 da850_iis_serializer_direction[] = {
  145. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  146. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  147. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  148. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  149. };
  150. static struct snd_platform_data da850_evm_snd_data = {
  151. .tx_dma_offset = 0x2000,
  152. .rx_dma_offset = 0x2000,
  153. .op_mode = DAVINCI_MCASP_IIS_MODE,
  154. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  155. .tdm_slots = 2,
  156. .serial_dir = da850_iis_serializer_direction,
  157. .eventq_no = EVENTQ_1,
  158. .version = MCASP_VERSION_2,
  159. .txnumevt = 1,
  160. .rxnumevt = 1,
  161. };
  162. static int da850_evm_mmc_get_ro(int index)
  163. {
  164. return gpio_get_value(DA850_MMCSD_WP_PIN);
  165. }
  166. static int da850_evm_mmc_get_cd(int index)
  167. {
  168. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  169. }
  170. static struct davinci_mmc_config da850_mmc_config = {
  171. .get_ro = da850_evm_mmc_get_ro,
  172. .get_cd = da850_evm_mmc_get_cd,
  173. .wires = 4,
  174. .version = MMC_CTLR_VERSION_2,
  175. };
  176. static int da850_lcd_hw_init(void)
  177. {
  178. int status;
  179. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  180. if (status < 0)
  181. return status;
  182. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  183. if (status < 0) {
  184. gpio_free(DA850_LCD_BL_PIN);
  185. return status;
  186. }
  187. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  188. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  189. /* disable lcd backlight */
  190. gpio_set_value(DA850_LCD_BL_PIN, 0);
  191. /* disable lcd power */
  192. gpio_set_value(DA850_LCD_PWR_PIN, 0);
  193. /* enable lcd power */
  194. gpio_set_value(DA850_LCD_PWR_PIN, 1);
  195. /* enable lcd backlight */
  196. gpio_set_value(DA850_LCD_BL_PIN, 1);
  197. return 0;
  198. }
  199. #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
  200. #define DA8XX_AEMIF_ASIZE_16BIT 0x1
  201. static void __init da850_evm_init_nor(void)
  202. {
  203. void __iomem *aemif_addr;
  204. aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
  205. /* Configure data bus width of CS2 to 16 bit */
  206. writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
  207. DA8XX_AEMIF_ASIZE_16BIT,
  208. aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
  209. iounmap(aemif_addr);
  210. }
  211. static __init void da850_evm_init(void)
  212. {
  213. struct davinci_soc_info *soc_info = &davinci_soc_info;
  214. int ret;
  215. ret = da8xx_pinmux_setup(da850_nand_pins);
  216. if (ret)
  217. pr_warning("da850_evm_init: nand mux setup failed: %d\n",
  218. ret);
  219. ret = da8xx_pinmux_setup(da850_nor_pins);
  220. if (ret)
  221. pr_warning("da850_evm_init: nor mux setup failed: %d\n",
  222. ret);
  223. da850_evm_init_nor();
  224. platform_add_devices(da850_evm_devices,
  225. ARRAY_SIZE(da850_evm_devices));
  226. ret = da8xx_register_edma();
  227. if (ret)
  228. pr_warning("da850_evm_init: edma registration failed: %d\n",
  229. ret);
  230. ret = da8xx_pinmux_setup(da850_i2c0_pins);
  231. if (ret)
  232. pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
  233. ret);
  234. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  235. if (ret)
  236. pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
  237. ret);
  238. soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
  239. soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
  240. soc_info->emac_pdata->rmii_en = 0;
  241. ret = da8xx_pinmux_setup(da850_cpgmac_pins);
  242. if (ret)
  243. pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
  244. ret);
  245. ret = da8xx_register_emac();
  246. if (ret)
  247. pr_warning("da850_evm_init: emac registration failed: %d\n",
  248. ret);
  249. ret = da8xx_register_watchdog();
  250. if (ret)
  251. pr_warning("da830_evm_init: watchdog registration failed: %d\n",
  252. ret);
  253. ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
  254. if (ret)
  255. pr_warning("da850_evm_init: mmcsd0 mux setup failed: %d\n",
  256. ret);
  257. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  258. if (ret)
  259. pr_warning("da850_evm_init: can not open GPIO %d\n",
  260. DA850_MMCSD_CD_PIN);
  261. gpio_direction_input(DA850_MMCSD_CD_PIN);
  262. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  263. if (ret)
  264. pr_warning("da850_evm_init: can not open GPIO %d\n",
  265. DA850_MMCSD_WP_PIN);
  266. gpio_direction_input(DA850_MMCSD_WP_PIN);
  267. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  268. if (ret)
  269. pr_warning("da850_evm_init: mmcsd0 registration failed: %d\n",
  270. ret);
  271. davinci_serial_init(&da850_evm_uart_config);
  272. /*
  273. * shut down uart 0 and 1; they are not used on the board and
  274. * accessing them causes endless "too much work in irq53" messages
  275. * with arago fs
  276. */
  277. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  278. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  279. ret = da8xx_pinmux_setup(da850_mcasp_pins);
  280. if (ret)
  281. pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
  282. ret);
  283. da8xx_init_mcasp(0, &da850_evm_snd_data);
  284. ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
  285. if (ret)
  286. pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
  287. ret);
  288. ret = da850_lcd_hw_init();
  289. if (ret)
  290. pr_warning("da850_evm_init: lcd initialization failed: %d\n",
  291. ret);
  292. ret = da8xx_register_lcdc();
  293. if (ret)
  294. pr_warning("da850_evm_init: lcdc registration failed: %d\n",
  295. ret);
  296. }
  297. #ifdef CONFIG_SERIAL_8250_CONSOLE
  298. static int __init da850_evm_console_init(void)
  299. {
  300. return add_preferred_console("ttyS", 2, "115200");
  301. }
  302. console_initcall(da850_evm_console_init);
  303. #endif
  304. static __init void da850_evm_irq_init(void)
  305. {
  306. struct davinci_soc_info *soc_info = &davinci_soc_info;
  307. cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
  308. soc_info->intc_irq_prios);
  309. }
  310. static void __init da850_evm_map_io(void)
  311. {
  312. da850_init();
  313. }
  314. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
  315. .phys_io = IO_PHYS,
  316. .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
  317. .boot_params = (DA8XX_DDR_BASE + 0x100),
  318. .map_io = da850_evm_map_io,
  319. .init_irq = da850_evm_irq_init,
  320. .timer = &davinci_timer,
  321. .init_machine = da850_evm_init,
  322. MACHINE_END