board-da850-evm.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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 i2c_board_info __initdata da850_evm_i2c_devices[] = {
  133. {
  134. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  135. }
  136. };
  137. static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
  138. .bus_freq = 100, /* kHz */
  139. .bus_delay = 0, /* usec */
  140. };
  141. static struct davinci_uart_config da850_evm_uart_config __initdata = {
  142. .enabled_uarts = 0x7,
  143. };
  144. static struct platform_device *da850_evm_devices[] __initdata = {
  145. &da850_evm_nandflash_device,
  146. &da850_evm_norflash_device,
  147. };
  148. /* davinci da850 evm audio machine driver */
  149. static u8 da850_iis_serializer_direction[] = {
  150. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  151. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  152. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  153. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  154. };
  155. static struct snd_platform_data da850_evm_snd_data = {
  156. .tx_dma_offset = 0x2000,
  157. .rx_dma_offset = 0x2000,
  158. .op_mode = DAVINCI_MCASP_IIS_MODE,
  159. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  160. .tdm_slots = 2,
  161. .serial_dir = da850_iis_serializer_direction,
  162. .eventq_no = EVENTQ_1,
  163. .version = MCASP_VERSION_2,
  164. .txnumevt = 1,
  165. .rxnumevt = 1,
  166. };
  167. static int da850_evm_mmc_get_ro(int index)
  168. {
  169. return gpio_get_value(DA850_MMCSD_WP_PIN);
  170. }
  171. static int da850_evm_mmc_get_cd(int index)
  172. {
  173. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  174. }
  175. static struct davinci_mmc_config da850_mmc_config = {
  176. .get_ro = da850_evm_mmc_get_ro,
  177. .get_cd = da850_evm_mmc_get_cd,
  178. .wires = 4,
  179. .version = MMC_CTLR_VERSION_2,
  180. };
  181. static int da850_lcd_hw_init(void)
  182. {
  183. int status;
  184. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  185. if (status < 0)
  186. return status;
  187. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  188. if (status < 0) {
  189. gpio_free(DA850_LCD_BL_PIN);
  190. return status;
  191. }
  192. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  193. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  194. /* disable lcd backlight */
  195. gpio_set_value(DA850_LCD_BL_PIN, 0);
  196. /* disable lcd power */
  197. gpio_set_value(DA850_LCD_PWR_PIN, 0);
  198. /* enable lcd power */
  199. gpio_set_value(DA850_LCD_PWR_PIN, 1);
  200. /* enable lcd backlight */
  201. gpio_set_value(DA850_LCD_BL_PIN, 1);
  202. return 0;
  203. }
  204. #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
  205. #define DA8XX_AEMIF_ASIZE_16BIT 0x1
  206. static void __init da850_evm_init_nor(void)
  207. {
  208. void __iomem *aemif_addr;
  209. aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
  210. /* Configure data bus width of CS2 to 16 bit */
  211. writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
  212. DA8XX_AEMIF_ASIZE_16BIT,
  213. aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
  214. iounmap(aemif_addr);
  215. }
  216. #if defined(CONFIG_MTD_PHYSMAP) || \
  217. defined(CONFIG_MTD_PHYSMAP_MODULE)
  218. #define HAS_NOR 1
  219. #else
  220. #define HAS_NOR 0
  221. #endif
  222. #if defined(CONFIG_MMC_DAVINCI) || \
  223. defined(CONFIG_MMC_DAVINCI_MODULE)
  224. #define HAS_MMC 1
  225. #else
  226. #define HAS_MMC 0
  227. #endif
  228. static __init void da850_evm_init(void)
  229. {
  230. struct davinci_soc_info *soc_info = &davinci_soc_info;
  231. int ret;
  232. ret = da8xx_pinmux_setup(da850_nand_pins);
  233. if (ret)
  234. pr_warning("da850_evm_init: nand mux setup failed: %d\n",
  235. ret);
  236. ret = da8xx_pinmux_setup(da850_nor_pins);
  237. if (ret)
  238. pr_warning("da850_evm_init: nor mux setup failed: %d\n",
  239. ret);
  240. da850_evm_init_nor();
  241. platform_add_devices(da850_evm_devices,
  242. ARRAY_SIZE(da850_evm_devices));
  243. ret = da8xx_register_edma();
  244. if (ret)
  245. pr_warning("da850_evm_init: edma registration failed: %d\n",
  246. ret);
  247. ret = da8xx_pinmux_setup(da850_i2c0_pins);
  248. if (ret)
  249. pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
  250. ret);
  251. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  252. if (ret)
  253. pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
  254. ret);
  255. soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
  256. soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
  257. soc_info->emac_pdata->rmii_en = 0;
  258. ret = da8xx_pinmux_setup(da850_cpgmac_pins);
  259. if (ret)
  260. pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
  261. ret);
  262. ret = da8xx_register_emac();
  263. if (ret)
  264. pr_warning("da850_evm_init: emac registration failed: %d\n",
  265. ret);
  266. ret = da8xx_register_watchdog();
  267. if (ret)
  268. pr_warning("da830_evm_init: watchdog registration failed: %d\n",
  269. ret);
  270. if (HAS_MMC) {
  271. if (HAS_NOR)
  272. pr_warning("WARNING: both NOR Flash and MMC/SD are "
  273. "enabled, but they share AEMIF pins.\n"
  274. "\tDisable one of them.\n");
  275. ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
  276. if (ret)
  277. pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
  278. " %d\n", ret);
  279. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  280. if (ret)
  281. pr_warning("da850_evm_init: can not open GPIO %d\n",
  282. DA850_MMCSD_CD_PIN);
  283. gpio_direction_input(DA850_MMCSD_CD_PIN);
  284. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  285. if (ret)
  286. pr_warning("da850_evm_init: can not open GPIO %d\n",
  287. DA850_MMCSD_WP_PIN);
  288. gpio_direction_input(DA850_MMCSD_WP_PIN);
  289. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  290. if (ret)
  291. pr_warning("da850_evm_init: mmcsd0 registration failed:"
  292. " %d\n", ret);
  293. }
  294. davinci_serial_init(&da850_evm_uart_config);
  295. i2c_register_board_info(1, da850_evm_i2c_devices,
  296. ARRAY_SIZE(da850_evm_i2c_devices));
  297. /*
  298. * shut down uart 0 and 1; they are not used on the board and
  299. * accessing them causes endless "too much work in irq53" messages
  300. * with arago fs
  301. */
  302. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  303. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  304. ret = da8xx_pinmux_setup(da850_mcasp_pins);
  305. if (ret)
  306. pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
  307. ret);
  308. da8xx_init_mcasp(0, &da850_evm_snd_data);
  309. ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
  310. if (ret)
  311. pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
  312. ret);
  313. ret = da850_lcd_hw_init();
  314. if (ret)
  315. pr_warning("da850_evm_init: lcd initialization failed: %d\n",
  316. ret);
  317. ret = da8xx_register_lcdc();
  318. if (ret)
  319. pr_warning("da850_evm_init: lcdc registration failed: %d\n",
  320. ret);
  321. }
  322. #ifdef CONFIG_SERIAL_8250_CONSOLE
  323. static int __init da850_evm_console_init(void)
  324. {
  325. return add_preferred_console("ttyS", 2, "115200");
  326. }
  327. console_initcall(da850_evm_console_init);
  328. #endif
  329. static __init void da850_evm_irq_init(void)
  330. {
  331. struct davinci_soc_info *soc_info = &davinci_soc_info;
  332. cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
  333. soc_info->intc_irq_prios);
  334. }
  335. static void __init da850_evm_map_io(void)
  336. {
  337. da850_init();
  338. }
  339. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
  340. .phys_io = IO_PHYS,
  341. .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
  342. .boot_params = (DA8XX_DDR_BASE + 0x100),
  343. .map_io = da850_evm_map_io,
  344. .init_irq = da850_evm_irq_init,
  345. .timer = &davinci_timer,
  346. .init_machine = da850_evm_init,
  347. MACHINE_END