board-da850-evm.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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. #include <mach/mux.h>
  34. #define DA850_EVM_PHY_MASK 0x1
  35. #define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
  36. #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
  37. #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
  38. #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
  39. #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
  40. static struct mtd_partition da850_evm_norflash_partition[] = {
  41. {
  42. .name = "NOR filesystem",
  43. .offset = 0,
  44. .size = MTDPART_SIZ_FULL,
  45. .mask_flags = 0,
  46. },
  47. };
  48. static struct physmap_flash_data da850_evm_norflash_data = {
  49. .width = 2,
  50. .parts = da850_evm_norflash_partition,
  51. .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
  52. };
  53. static struct resource da850_evm_norflash_resource[] = {
  54. {
  55. .start = DA8XX_AEMIF_CS2_BASE,
  56. .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
  57. .flags = IORESOURCE_MEM,
  58. },
  59. };
  60. static struct platform_device da850_evm_norflash_device = {
  61. .name = "physmap-flash",
  62. .id = 0,
  63. .dev = {
  64. .platform_data = &da850_evm_norflash_data,
  65. },
  66. .num_resources = 1,
  67. .resource = da850_evm_norflash_resource,
  68. };
  69. /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  70. * (128K blocks). It may be used instead of the (default) SPI flash
  71. * to boot, using TI's tools to install the secondary boot loader
  72. * (UBL) and U-Boot.
  73. */
  74. struct mtd_partition da850_evm_nandflash_partition[] = {
  75. {
  76. .name = "u-boot env",
  77. .offset = 0,
  78. .size = SZ_128K,
  79. .mask_flags = MTD_WRITEABLE,
  80. },
  81. {
  82. .name = "UBL",
  83. .offset = MTDPART_OFS_APPEND,
  84. .size = SZ_128K,
  85. .mask_flags = MTD_WRITEABLE,
  86. },
  87. {
  88. .name = "u-boot",
  89. .offset = MTDPART_OFS_APPEND,
  90. .size = 4 * SZ_128K,
  91. .mask_flags = MTD_WRITEABLE,
  92. },
  93. {
  94. .name = "kernel",
  95. .offset = 0x200000,
  96. .size = SZ_2M,
  97. .mask_flags = 0,
  98. },
  99. {
  100. .name = "filesystem",
  101. .offset = MTDPART_OFS_APPEND,
  102. .size = MTDPART_SIZ_FULL,
  103. .mask_flags = 0,
  104. },
  105. };
  106. static struct davinci_nand_pdata da850_evm_nandflash_data = {
  107. .parts = da850_evm_nandflash_partition,
  108. .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
  109. .ecc_mode = NAND_ECC_HW,
  110. .options = NAND_USE_FLASH_BBT,
  111. };
  112. static struct resource da850_evm_nandflash_resource[] = {
  113. {
  114. .start = DA8XX_AEMIF_CS3_BASE,
  115. .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
  116. .flags = IORESOURCE_MEM,
  117. },
  118. {
  119. .start = DA8XX_AEMIF_CTL_BASE,
  120. .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. };
  124. static struct platform_device da850_evm_nandflash_device = {
  125. .name = "davinci_nand",
  126. .id = 1,
  127. .dev = {
  128. .platform_data = &da850_evm_nandflash_data,
  129. },
  130. .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
  131. .resource = da850_evm_nandflash_resource,
  132. };
  133. static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
  134. {
  135. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  136. }
  137. };
  138. static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
  139. .bus_freq = 100, /* kHz */
  140. .bus_delay = 0, /* usec */
  141. };
  142. static struct davinci_uart_config da850_evm_uart_config __initdata = {
  143. .enabled_uarts = 0x7,
  144. };
  145. static struct platform_device *da850_evm_devices[] __initdata = {
  146. &da850_evm_nandflash_device,
  147. &da850_evm_norflash_device,
  148. };
  149. /* davinci da850 evm audio machine driver */
  150. static u8 da850_iis_serializer_direction[] = {
  151. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  152. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  153. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  154. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  155. };
  156. static struct snd_platform_data da850_evm_snd_data = {
  157. .tx_dma_offset = 0x2000,
  158. .rx_dma_offset = 0x2000,
  159. .op_mode = DAVINCI_MCASP_IIS_MODE,
  160. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  161. .tdm_slots = 2,
  162. .serial_dir = da850_iis_serializer_direction,
  163. .eventq_no = EVENTQ_1,
  164. .version = MCASP_VERSION_2,
  165. .txnumevt = 1,
  166. .rxnumevt = 1,
  167. };
  168. static int da850_evm_mmc_get_ro(int index)
  169. {
  170. return gpio_get_value(DA850_MMCSD_WP_PIN);
  171. }
  172. static int da850_evm_mmc_get_cd(int index)
  173. {
  174. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  175. }
  176. static struct davinci_mmc_config da850_mmc_config = {
  177. .get_ro = da850_evm_mmc_get_ro,
  178. .get_cd = da850_evm_mmc_get_cd,
  179. .wires = 4,
  180. .version = MMC_CTLR_VERSION_2,
  181. };
  182. static int da850_lcd_hw_init(void)
  183. {
  184. int status;
  185. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  186. if (status < 0)
  187. return status;
  188. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  189. if (status < 0) {
  190. gpio_free(DA850_LCD_BL_PIN);
  191. return status;
  192. }
  193. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  194. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  195. /* disable lcd backlight */
  196. gpio_set_value(DA850_LCD_BL_PIN, 0);
  197. /* disable lcd power */
  198. gpio_set_value(DA850_LCD_PWR_PIN, 0);
  199. /* enable lcd power */
  200. gpio_set_value(DA850_LCD_PWR_PIN, 1);
  201. /* enable lcd backlight */
  202. gpio_set_value(DA850_LCD_BL_PIN, 1);
  203. return 0;
  204. }
  205. #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
  206. #define DA8XX_AEMIF_ASIZE_16BIT 0x1
  207. static void __init da850_evm_init_nor(void)
  208. {
  209. void __iomem *aemif_addr;
  210. aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
  211. /* Configure data bus width of CS2 to 16 bit */
  212. writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
  213. DA8XX_AEMIF_ASIZE_16BIT,
  214. aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
  215. iounmap(aemif_addr);
  216. }
  217. #if defined(CONFIG_MTD_PHYSMAP) || \
  218. defined(CONFIG_MTD_PHYSMAP_MODULE)
  219. #define HAS_NOR 1
  220. #else
  221. #define HAS_NOR 0
  222. #endif
  223. #if defined(CONFIG_MMC_DAVINCI) || \
  224. defined(CONFIG_MMC_DAVINCI_MODULE)
  225. #define HAS_MMC 1
  226. #else
  227. #define HAS_MMC 0
  228. #endif
  229. static const short da850_evm_lcdc_pins[] = {
  230. DA850_GPIO2_8, DA850_GPIO2_15,
  231. -1
  232. };
  233. static __init void da850_evm_init(void)
  234. {
  235. struct davinci_soc_info *soc_info = &davinci_soc_info;
  236. int ret;
  237. ret = da8xx_pinmux_setup(da850_nand_pins);
  238. if (ret)
  239. pr_warning("da850_evm_init: nand mux setup failed: %d\n",
  240. ret);
  241. ret = da8xx_pinmux_setup(da850_nor_pins);
  242. if (ret)
  243. pr_warning("da850_evm_init: nor mux setup failed: %d\n",
  244. ret);
  245. da850_evm_init_nor();
  246. platform_add_devices(da850_evm_devices,
  247. ARRAY_SIZE(da850_evm_devices));
  248. ret = da8xx_register_edma();
  249. if (ret)
  250. pr_warning("da850_evm_init: edma registration failed: %d\n",
  251. ret);
  252. ret = da8xx_pinmux_setup(da850_i2c0_pins);
  253. if (ret)
  254. pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
  255. ret);
  256. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  257. if (ret)
  258. pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
  259. ret);
  260. soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
  261. soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
  262. soc_info->emac_pdata->rmii_en = 0;
  263. ret = da8xx_pinmux_setup(da850_cpgmac_pins);
  264. if (ret)
  265. pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
  266. ret);
  267. ret = da8xx_register_emac();
  268. if (ret)
  269. pr_warning("da850_evm_init: emac registration failed: %d\n",
  270. ret);
  271. ret = da8xx_register_watchdog();
  272. if (ret)
  273. pr_warning("da830_evm_init: watchdog registration failed: %d\n",
  274. ret);
  275. if (HAS_MMC) {
  276. if (HAS_NOR)
  277. pr_warning("WARNING: both NOR Flash and MMC/SD are "
  278. "enabled, but they share AEMIF pins.\n"
  279. "\tDisable one of them.\n");
  280. ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
  281. if (ret)
  282. pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
  283. " %d\n", ret);
  284. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  285. if (ret)
  286. pr_warning("da850_evm_init: can not open GPIO %d\n",
  287. DA850_MMCSD_CD_PIN);
  288. gpio_direction_input(DA850_MMCSD_CD_PIN);
  289. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  290. if (ret)
  291. pr_warning("da850_evm_init: can not open GPIO %d\n",
  292. DA850_MMCSD_WP_PIN);
  293. gpio_direction_input(DA850_MMCSD_WP_PIN);
  294. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  295. if (ret)
  296. pr_warning("da850_evm_init: mmcsd0 registration failed:"
  297. " %d\n", ret);
  298. }
  299. davinci_serial_init(&da850_evm_uart_config);
  300. i2c_register_board_info(1, da850_evm_i2c_devices,
  301. ARRAY_SIZE(da850_evm_i2c_devices));
  302. /*
  303. * shut down uart 0 and 1; they are not used on the board and
  304. * accessing them causes endless "too much work in irq53" messages
  305. * with arago fs
  306. */
  307. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  308. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  309. ret = da8xx_pinmux_setup(da850_mcasp_pins);
  310. if (ret)
  311. pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
  312. ret);
  313. da8xx_register_mcasp(0, &da850_evm_snd_data);
  314. ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
  315. if (ret)
  316. pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
  317. ret);
  318. /* Handle board specific muxing for LCD here */
  319. ret = da8xx_pinmux_setup(da850_evm_lcdc_pins);
  320. if (ret)
  321. pr_warning("da850_evm_init: evm specific lcd mux setup "
  322. "failed: %d\n", ret);
  323. ret = da850_lcd_hw_init();
  324. if (ret)
  325. pr_warning("da850_evm_init: lcd initialization failed: %d\n",
  326. ret);
  327. ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
  328. if (ret)
  329. pr_warning("da850_evm_init: lcdc registration failed: %d\n",
  330. ret);
  331. ret = da8xx_register_rtc();
  332. if (ret)
  333. pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
  334. }
  335. #ifdef CONFIG_SERIAL_8250_CONSOLE
  336. static int __init da850_evm_console_init(void)
  337. {
  338. return add_preferred_console("ttyS", 2, "115200");
  339. }
  340. console_initcall(da850_evm_console_init);
  341. #endif
  342. static __init void da850_evm_irq_init(void)
  343. {
  344. struct davinci_soc_info *soc_info = &davinci_soc_info;
  345. cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
  346. soc_info->intc_irq_prios);
  347. }
  348. static void __init da850_evm_map_io(void)
  349. {
  350. da850_init();
  351. }
  352. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
  353. .phys_io = IO_PHYS,
  354. .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
  355. .boot_params = (DA8XX_DDR_BASE + 0x100),
  356. .map_io = da850_evm_map_io,
  357. .init_irq = da850_evm_irq_init,
  358. .timer = &davinci_timer,
  359. .init_machine = da850_evm_init,
  360. MACHINE_END