board-da850-evm.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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 <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <mach/common.h>
  28. #include <mach/irqs.h>
  29. #include <mach/cp_intc.h>
  30. #include <mach/da8xx.h>
  31. #include <mach/nand.h>
  32. #define DA850_EVM_PHY_MASK 0x1
  33. #define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
  34. #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
  35. #define DA850_LCD_PWR_PIN GPIO_TO_PIN(8, 10)
  36. #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
  37. #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
  38. /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  39. * (128K blocks). It may be used instead of the (default) SPI flash
  40. * to boot, using TI's tools to install the secondary boot loader
  41. * (UBL) and U-Boot.
  42. */
  43. struct mtd_partition da850_evm_nandflash_partition[] = {
  44. {
  45. .name = "u-boot env",
  46. .offset = 0,
  47. .size = SZ_128K,
  48. .mask_flags = MTD_WRITEABLE,
  49. },
  50. {
  51. .name = "UBL",
  52. .offset = MTDPART_OFS_APPEND,
  53. .size = SZ_128K,
  54. .mask_flags = MTD_WRITEABLE,
  55. },
  56. {
  57. .name = "u-boot",
  58. .offset = MTDPART_OFS_APPEND,
  59. .size = 4 * SZ_128K,
  60. .mask_flags = MTD_WRITEABLE,
  61. },
  62. {
  63. .name = "kernel",
  64. .offset = 0x200000,
  65. .size = SZ_2M,
  66. .mask_flags = 0,
  67. },
  68. {
  69. .name = "filesystem",
  70. .offset = MTDPART_OFS_APPEND,
  71. .size = MTDPART_SIZ_FULL,
  72. .mask_flags = 0,
  73. },
  74. };
  75. static struct davinci_nand_pdata da850_evm_nandflash_data = {
  76. .parts = da850_evm_nandflash_partition,
  77. .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
  78. .ecc_mode = NAND_ECC_HW,
  79. .options = NAND_USE_FLASH_BBT,
  80. };
  81. static struct resource da850_evm_nandflash_resource[] = {
  82. {
  83. .start = DA8XX_AEMIF_CS3_BASE,
  84. .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
  85. .flags = IORESOURCE_MEM,
  86. },
  87. {
  88. .start = DA8XX_AEMIF_CTL_BASE,
  89. .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
  90. .flags = IORESOURCE_MEM,
  91. },
  92. };
  93. static struct platform_device da850_evm_nandflash_device = {
  94. .name = "davinci_nand",
  95. .id = 1,
  96. .dev = {
  97. .platform_data = &da850_evm_nandflash_data,
  98. },
  99. .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
  100. .resource = da850_evm_nandflash_resource,
  101. };
  102. static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
  103. .bus_freq = 100, /* kHz */
  104. .bus_delay = 0, /* usec */
  105. };
  106. static struct davinci_uart_config da850_evm_uart_config __initdata = {
  107. .enabled_uarts = 0x7,
  108. };
  109. static struct platform_device *da850_evm_devices[] __initdata = {
  110. &da850_evm_nandflash_device,
  111. };
  112. /* davinci da850 evm audio machine driver */
  113. static u8 da850_iis_serializer_direction[] = {
  114. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  115. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  116. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  117. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  118. };
  119. static struct snd_platform_data da850_evm_snd_data = {
  120. .tx_dma_offset = 0x2000,
  121. .rx_dma_offset = 0x2000,
  122. .op_mode = DAVINCI_MCASP_IIS_MODE,
  123. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  124. .tdm_slots = 2,
  125. .serial_dir = da850_iis_serializer_direction,
  126. .eventq_no = EVENTQ_1,
  127. .version = MCASP_VERSION_2,
  128. .txnumevt = 1,
  129. .rxnumevt = 1,
  130. };
  131. static int da850_evm_mmc_get_ro(int index)
  132. {
  133. return gpio_get_value(DA850_MMCSD_WP_PIN);
  134. }
  135. static int da850_evm_mmc_get_cd(int index)
  136. {
  137. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  138. }
  139. static struct davinci_mmc_config da850_mmc_config = {
  140. .get_ro = da850_evm_mmc_get_ro,
  141. .get_cd = da850_evm_mmc_get_cd,
  142. .wires = 4,
  143. .version = MMC_CTLR_VERSION_2,
  144. };
  145. static int da850_lcd_hw_init(void)
  146. {
  147. int status;
  148. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  149. if (status < 0)
  150. return status;
  151. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  152. if (status < 0) {
  153. gpio_free(DA850_LCD_BL_PIN);
  154. return status;
  155. }
  156. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  157. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  158. /* disable lcd backlight */
  159. gpio_set_value(DA850_LCD_BL_PIN, 0);
  160. /* disable lcd power */
  161. gpio_set_value(DA850_LCD_PWR_PIN, 0);
  162. /* enable lcd power */
  163. gpio_set_value(DA850_LCD_PWR_PIN, 1);
  164. /* enable lcd backlight */
  165. gpio_set_value(DA850_LCD_BL_PIN, 1);
  166. return 0;
  167. }
  168. static __init void da850_evm_init(void)
  169. {
  170. struct davinci_soc_info *soc_info = &davinci_soc_info;
  171. int ret;
  172. ret = da8xx_pinmux_setup(da850_nand_pins);
  173. if (ret)
  174. pr_warning("da850_evm_init: nand mux setup failed: %d\n",
  175. ret);
  176. platform_add_devices(da850_evm_devices,
  177. ARRAY_SIZE(da850_evm_devices));
  178. ret = da8xx_register_edma();
  179. if (ret)
  180. pr_warning("da850_evm_init: edma registration failed: %d\n",
  181. ret);
  182. ret = da8xx_pinmux_setup(da850_i2c0_pins);
  183. if (ret)
  184. pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
  185. ret);
  186. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  187. if (ret)
  188. pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
  189. ret);
  190. soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
  191. soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
  192. soc_info->emac_pdata->rmii_en = 0;
  193. ret = da8xx_pinmux_setup(da850_cpgmac_pins);
  194. if (ret)
  195. pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
  196. ret);
  197. ret = da8xx_register_emac();
  198. if (ret)
  199. pr_warning("da850_evm_init: emac registration failed: %d\n",
  200. ret);
  201. ret = da8xx_register_watchdog();
  202. if (ret)
  203. pr_warning("da830_evm_init: watchdog registration failed: %d\n",
  204. ret);
  205. ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
  206. if (ret)
  207. pr_warning("da850_evm_init: mmcsd0 mux setup failed: %d\n",
  208. ret);
  209. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  210. if (ret)
  211. pr_warning("da850_evm_init: can not open GPIO %d\n",
  212. DA850_MMCSD_CD_PIN);
  213. gpio_direction_input(DA850_MMCSD_CD_PIN);
  214. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  215. if (ret)
  216. pr_warning("da850_evm_init: can not open GPIO %d\n",
  217. DA850_MMCSD_WP_PIN);
  218. gpio_direction_input(DA850_MMCSD_WP_PIN);
  219. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  220. if (ret)
  221. pr_warning("da850_evm_init: mmcsd0 registration failed: %d\n",
  222. ret);
  223. davinci_serial_init(&da850_evm_uart_config);
  224. /*
  225. * shut down uart 0 and 1; they are not used on the board and
  226. * accessing them causes endless "too much work in irq53" messages
  227. * with arago fs
  228. */
  229. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  230. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  231. ret = da8xx_pinmux_setup(da850_mcasp_pins);
  232. if (ret)
  233. pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
  234. ret);
  235. da8xx_init_mcasp(0, &da850_evm_snd_data);
  236. ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
  237. if (ret)
  238. pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
  239. ret);
  240. ret = da850_lcd_hw_init();
  241. if (ret)
  242. pr_warning("da850_evm_init: lcd initialization failed: %d\n",
  243. ret);
  244. ret = da8xx_register_lcdc();
  245. if (ret)
  246. pr_warning("da850_evm_init: lcdc registration failed: %d\n",
  247. ret);
  248. }
  249. #ifdef CONFIG_SERIAL_8250_CONSOLE
  250. static int __init da850_evm_console_init(void)
  251. {
  252. return add_preferred_console("ttyS", 2, "115200");
  253. }
  254. console_initcall(da850_evm_console_init);
  255. #endif
  256. static __init void da850_evm_irq_init(void)
  257. {
  258. struct davinci_soc_info *soc_info = &davinci_soc_info;
  259. cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
  260. soc_info->intc_irq_prios);
  261. }
  262. static void __init da850_evm_map_io(void)
  263. {
  264. da850_init();
  265. }
  266. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
  267. .phys_io = IO_PHYS,
  268. .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
  269. .boot_params = (DA8XX_DDR_BASE + 0x100),
  270. .map_io = da850_evm_map_io,
  271. .init_irq = da850_evm_irq_init,
  272. .timer = &davinci_timer,
  273. .init_machine = da850_evm_init,
  274. MACHINE_END