board-mityomapl138.c 8.5 KB

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