board-mityomapl138.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. /*
  2. * Critical Link MityOMAP-L138 SoM
  3. *
  4. * Copyright (C) 2010 Critical Link LLC - http://www.criticallink.com
  5. *
  6. * This file is licensed under the terms of the GNU General Public License
  7. * version 2. This program is licensed "as is" without any warranty of
  8. * any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/console.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <linux/regulator/machine.h>
  16. #include <linux/i2c.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/mach/arch.h>
  19. #include <mach/common.h>
  20. #include <mach/cp_intc.h>
  21. #include <mach/da8xx.h>
  22. #include <mach/nand.h>
  23. #include <mach/mux.h>
  24. #define MITYOMAPL138_PHY_ID "0:03"
  25. static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = {
  26. .bus_freq = 100, /* kHz */
  27. .bus_delay = 0, /* usec */
  28. };
  29. /* TPS65023 voltage regulator support */
  30. /* 1.2V Core */
  31. struct regulator_consumer_supply tps65023_dcdc1_consumers[] = {
  32. {
  33. .supply = "cvdd",
  34. },
  35. };
  36. /* 1.8V */
  37. struct regulator_consumer_supply tps65023_dcdc2_consumers[] = {
  38. {
  39. .supply = "usb0_vdda18",
  40. },
  41. {
  42. .supply = "usb1_vdda18",
  43. },
  44. {
  45. .supply = "ddr_dvdd18",
  46. },
  47. {
  48. .supply = "sata_vddr",
  49. },
  50. };
  51. /* 1.2V */
  52. struct regulator_consumer_supply tps65023_dcdc3_consumers[] = {
  53. {
  54. .supply = "sata_vdd",
  55. },
  56. {
  57. .supply = "usb_cvdd",
  58. },
  59. {
  60. .supply = "pll0_vdda",
  61. },
  62. {
  63. .supply = "pll1_vdda",
  64. },
  65. };
  66. /* 1.8V Aux LDO, not used */
  67. struct regulator_consumer_supply tps65023_ldo1_consumers[] = {
  68. {
  69. .supply = "1.8v_aux",
  70. },
  71. };
  72. /* FPGA VCC Aux (2.5 or 3.3) LDO */
  73. struct regulator_consumer_supply tps65023_ldo2_consumers[] = {
  74. {
  75. .supply = "vccaux",
  76. },
  77. };
  78. struct regulator_init_data tps65023_regulator_data[] = {
  79. /* dcdc1 */
  80. {
  81. .constraints = {
  82. .min_uV = 1150000,
  83. .max_uV = 1350000,
  84. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  85. REGULATOR_CHANGE_STATUS,
  86. .boot_on = 1,
  87. },
  88. .num_consumer_supplies = ARRAY_SIZE(tps65023_dcdc1_consumers),
  89. .consumer_supplies = tps65023_dcdc1_consumers,
  90. },
  91. /* dcdc2 */
  92. {
  93. .constraints = {
  94. .min_uV = 1800000,
  95. .max_uV = 1800000,
  96. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  97. .boot_on = 1,
  98. },
  99. .num_consumer_supplies = ARRAY_SIZE(tps65023_dcdc2_consumers),
  100. .consumer_supplies = tps65023_dcdc2_consumers,
  101. },
  102. /* dcdc3 */
  103. {
  104. .constraints = {
  105. .min_uV = 1200000,
  106. .max_uV = 1200000,
  107. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  108. .boot_on = 1,
  109. },
  110. .num_consumer_supplies = ARRAY_SIZE(tps65023_dcdc3_consumers),
  111. .consumer_supplies = tps65023_dcdc3_consumers,
  112. },
  113. /* ldo1 */
  114. {
  115. .constraints = {
  116. .min_uV = 1800000,
  117. .max_uV = 1800000,
  118. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  119. .boot_on = 1,
  120. },
  121. .num_consumer_supplies = ARRAY_SIZE(tps65023_ldo1_consumers),
  122. .consumer_supplies = tps65023_ldo1_consumers,
  123. },
  124. /* ldo2 */
  125. {
  126. .constraints = {
  127. .min_uV = 2500000,
  128. .max_uV = 3300000,
  129. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  130. REGULATOR_CHANGE_STATUS,
  131. .boot_on = 1,
  132. },
  133. .num_consumer_supplies = ARRAY_SIZE(tps65023_ldo2_consumers),
  134. .consumer_supplies = tps65023_ldo2_consumers,
  135. },
  136. };
  137. static struct i2c_board_info __initdata mityomap_tps65023_info[] = {
  138. {
  139. I2C_BOARD_INFO("tps65023", 0x48),
  140. .platform_data = &tps65023_regulator_data[0],
  141. },
  142. {
  143. I2C_BOARD_INFO("24c02", 0x50),
  144. },
  145. };
  146. static int __init pmic_tps65023_init(void)
  147. {
  148. return i2c_register_board_info(1, mityomap_tps65023_info,
  149. ARRAY_SIZE(mityomap_tps65023_info));
  150. }
  151. /*
  152. * MityDSP-L138 includes a 256 MByte large-page NAND flash
  153. * (128K blocks).
  154. */
  155. struct mtd_partition mityomapl138_nandflash_partition[] = {
  156. {
  157. .name = "rootfs",
  158. .offset = 0,
  159. .size = SZ_128M,
  160. .mask_flags = 0, /* MTD_WRITEABLE, */
  161. },
  162. {
  163. .name = "homefs",
  164. .offset = MTDPART_OFS_APPEND,
  165. .size = MTDPART_SIZ_FULL,
  166. .mask_flags = 0,
  167. },
  168. };
  169. static struct davinci_nand_pdata mityomapl138_nandflash_data = {
  170. .parts = mityomapl138_nandflash_partition,
  171. .nr_parts = ARRAY_SIZE(mityomapl138_nandflash_partition),
  172. .ecc_mode = NAND_ECC_HW,
  173. .options = NAND_USE_FLASH_BBT | NAND_BUSWIDTH_16,
  174. .ecc_bits = 1, /* 4 bit mode is not supported with 16 bit NAND */
  175. };
  176. static struct resource mityomapl138_nandflash_resource[] = {
  177. {
  178. .start = DA8XX_AEMIF_CS3_BASE,
  179. .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
  180. .flags = IORESOURCE_MEM,
  181. },
  182. {
  183. .start = DA8XX_AEMIF_CTL_BASE,
  184. .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
  185. .flags = IORESOURCE_MEM,
  186. },
  187. };
  188. static struct platform_device mityomapl138_nandflash_device = {
  189. .name = "davinci_nand",
  190. .id = 0,
  191. .dev = {
  192. .platform_data = &mityomapl138_nandflash_data,
  193. },
  194. .num_resources = ARRAY_SIZE(mityomapl138_nandflash_resource),
  195. .resource = mityomapl138_nandflash_resource,
  196. };
  197. static struct platform_device *mityomapl138_devices[] __initdata = {
  198. &mityomapl138_nandflash_device,
  199. };
  200. static void __init mityomapl138_setup_nand(void)
  201. {
  202. platform_add_devices(mityomapl138_devices,
  203. ARRAY_SIZE(mityomapl138_devices));
  204. }
  205. static struct davinci_uart_config mityomapl138_uart_config __initdata = {
  206. .enabled_uarts = 0x7,
  207. };
  208. static const short mityomap_mii_pins[] = {
  209. DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
  210. DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
  211. DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
  212. DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
  213. DA850_MDIO_D,
  214. -1
  215. };
  216. static const short mityomap_rmii_pins[] = {
  217. DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
  218. DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
  219. DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
  220. DA850_MDIO_D,
  221. -1
  222. };
  223. static void __init mityomapl138_config_emac(void)
  224. {
  225. void __iomem *cfg_chip3_base;
  226. int ret;
  227. u32 val;
  228. struct davinci_soc_info *soc_info = &davinci_soc_info;
  229. soc_info->emac_pdata->rmii_en = 0; /* hardcoded for now */
  230. cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
  231. val = __raw_readl(cfg_chip3_base);
  232. if (soc_info->emac_pdata->rmii_en) {
  233. val |= BIT(8);
  234. ret = davinci_cfg_reg_list(mityomap_rmii_pins);
  235. pr_info("RMII PHY configured\n");
  236. } else {
  237. val &= ~BIT(8);
  238. ret = davinci_cfg_reg_list(mityomap_mii_pins);
  239. pr_info("MII PHY configured\n");
  240. }
  241. if (ret) {
  242. pr_warning("mii/rmii mux setup failed: %d\n", ret);
  243. return;
  244. }
  245. /* configure the CFGCHIP3 register for RMII or MII */
  246. __raw_writel(val, cfg_chip3_base);
  247. soc_info->emac_pdata->phy_id = MITYOMAPL138_PHY_ID;
  248. ret = da8xx_register_emac();
  249. if (ret)
  250. pr_warning("emac registration failed: %d\n", ret);
  251. }
  252. static struct davinci_pm_config da850_pm_pdata = {
  253. .sleepcount = 128,
  254. };
  255. static struct platform_device da850_pm_device = {
  256. .name = "pm-davinci",
  257. .dev = {
  258. .platform_data = &da850_pm_pdata,
  259. },
  260. .id = -1,
  261. };
  262. static void __init mityomapl138_init(void)
  263. {
  264. int ret;
  265. /* for now, no special EDMA channels are reserved */
  266. ret = da850_register_edma(NULL);
  267. if (ret)
  268. pr_warning("edma registration failed: %d\n", ret);
  269. ret = da8xx_register_watchdog();
  270. if (ret)
  271. pr_warning("watchdog registration failed: %d\n", ret);
  272. davinci_serial_init(&mityomapl138_uart_config);
  273. ret = da8xx_register_i2c(0, &mityomap_i2c_0_pdata);
  274. if (ret)
  275. pr_warning("i2c0 registration failed: %d\n", ret);
  276. ret = pmic_tps65023_init();
  277. if (ret)
  278. pr_warning("TPS65023 PMIC init failed: %d\n", ret);
  279. mityomapl138_setup_nand();
  280. mityomapl138_config_emac();
  281. ret = da8xx_register_rtc();
  282. if (ret)
  283. pr_warning("rtc setup failed: %d\n", ret);
  284. ret = da850_register_cpufreq("pll0_sysclk3");
  285. if (ret)
  286. pr_warning("cpufreq registration failed: %d\n", ret);
  287. ret = da8xx_register_cpuidle();
  288. if (ret)
  289. pr_warning("cpuidle registration failed: %d\n", ret);
  290. ret = da850_register_pm(&da850_pm_device);
  291. if (ret)
  292. pr_warning("da850_evm_init: suspend registration failed: %d\n",
  293. ret);
  294. }
  295. #ifdef CONFIG_SERIAL_8250_CONSOLE
  296. static int __init mityomapl138_console_init(void)
  297. {
  298. if (!machine_is_mityomapl138())
  299. return 0;
  300. return add_preferred_console("ttyS", 1, "115200");
  301. }
  302. console_initcall(mityomapl138_console_init);
  303. #endif
  304. static void __init mityomapl138_map_io(void)
  305. {
  306. da850_init();
  307. }
  308. MACHINE_START(MITYOMAPL138, "MityDSP-L138/MityARM-1808")
  309. .phys_io = IO_PHYS,
  310. .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
  311. .boot_params = (DA8XX_DDR_BASE + 0x100),
  312. .map_io = mityomapl138_map_io,
  313. .init_irq = cp_intc_init,
  314. .timer = &davinci_timer,
  315. .init_machine = mityomapl138_init,
  316. MACHINE_END