board-da850-evm.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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/init.h>
  16. #include <linux/console.h>
  17. #include <linux/i2c.h>
  18. #include <linux/i2c/at24.h>
  19. #include <linux/i2c/pca953x.h>
  20. #include <linux/mfd/tps6507x.h>
  21. #include <linux/gpio.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/nand.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/mtd/physmap.h>
  27. #include <linux/regulator/machine.h>
  28. #include <linux/regulator/tps6507x.h>
  29. #include <linux/input/tps6507x-ts.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <mach/cp_intc.h>
  33. #include <mach/da8xx.h>
  34. #include <mach/nand.h>
  35. #include <mach/mux.h>
  36. #include <mach/aemif.h>
  37. #define DA850_EVM_PHY_ID "0:00"
  38. #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
  39. #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
  40. #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
  41. #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
  42. #define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
  43. static struct mtd_partition da850_evm_norflash_partition[] = {
  44. {
  45. .name = "bootloaders + env",
  46. .offset = 0,
  47. .size = SZ_512K,
  48. .mask_flags = MTD_WRITEABLE,
  49. },
  50. {
  51. .name = "kernel",
  52. .offset = MTDPART_OFS_APPEND,
  53. .size = SZ_2M,
  54. .mask_flags = 0,
  55. },
  56. {
  57. .name = "filesystem",
  58. .offset = MTDPART_OFS_APPEND,
  59. .size = MTDPART_SIZ_FULL,
  60. .mask_flags = 0,
  61. },
  62. };
  63. static struct physmap_flash_data da850_evm_norflash_data = {
  64. .width = 2,
  65. .parts = da850_evm_norflash_partition,
  66. .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
  67. };
  68. static struct resource da850_evm_norflash_resource[] = {
  69. {
  70. .start = DA8XX_AEMIF_CS2_BASE,
  71. .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
  72. .flags = IORESOURCE_MEM,
  73. },
  74. };
  75. static struct platform_device da850_evm_norflash_device = {
  76. .name = "physmap-flash",
  77. .id = 0,
  78. .dev = {
  79. .platform_data = &da850_evm_norflash_data,
  80. },
  81. .num_resources = 1,
  82. .resource = da850_evm_norflash_resource,
  83. };
  84. static struct davinci_pm_config da850_pm_pdata = {
  85. .sleepcount = 128,
  86. };
  87. static struct platform_device da850_pm_device = {
  88. .name = "pm-davinci",
  89. .dev = {
  90. .platform_data = &da850_pm_pdata,
  91. },
  92. .id = -1,
  93. };
  94. /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  95. * (128K blocks). It may be used instead of the (default) SPI flash
  96. * to boot, using TI's tools to install the secondary boot loader
  97. * (UBL) and U-Boot.
  98. */
  99. static struct mtd_partition da850_evm_nandflash_partition[] = {
  100. {
  101. .name = "u-boot env",
  102. .offset = 0,
  103. .size = SZ_128K,
  104. .mask_flags = MTD_WRITEABLE,
  105. },
  106. {
  107. .name = "UBL",
  108. .offset = MTDPART_OFS_APPEND,
  109. .size = SZ_128K,
  110. .mask_flags = MTD_WRITEABLE,
  111. },
  112. {
  113. .name = "u-boot",
  114. .offset = MTDPART_OFS_APPEND,
  115. .size = 4 * SZ_128K,
  116. .mask_flags = MTD_WRITEABLE,
  117. },
  118. {
  119. .name = "kernel",
  120. .offset = 0x200000,
  121. .size = SZ_2M,
  122. .mask_flags = 0,
  123. },
  124. {
  125. .name = "filesystem",
  126. .offset = MTDPART_OFS_APPEND,
  127. .size = MTDPART_SIZ_FULL,
  128. .mask_flags = 0,
  129. },
  130. };
  131. static struct davinci_aemif_timing da850_evm_nandflash_timing = {
  132. .wsetup = 24,
  133. .wstrobe = 21,
  134. .whold = 14,
  135. .rsetup = 19,
  136. .rstrobe = 50,
  137. .rhold = 0,
  138. .ta = 20,
  139. };
  140. static struct davinci_nand_pdata da850_evm_nandflash_data = {
  141. .parts = da850_evm_nandflash_partition,
  142. .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
  143. .ecc_mode = NAND_ECC_HW,
  144. .ecc_bits = 4,
  145. .options = NAND_USE_FLASH_BBT,
  146. .timing = &da850_evm_nandflash_timing,
  147. };
  148. static struct resource da850_evm_nandflash_resource[] = {
  149. {
  150. .start = DA8XX_AEMIF_CS3_BASE,
  151. .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
  152. .flags = IORESOURCE_MEM,
  153. },
  154. {
  155. .start = DA8XX_AEMIF_CTL_BASE,
  156. .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
  157. .flags = IORESOURCE_MEM,
  158. },
  159. };
  160. static struct platform_device da850_evm_nandflash_device = {
  161. .name = "davinci_nand",
  162. .id = 1,
  163. .dev = {
  164. .platform_data = &da850_evm_nandflash_data,
  165. },
  166. .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
  167. .resource = da850_evm_nandflash_resource,
  168. };
  169. static struct platform_device *da850_evm_devices[] __initdata = {
  170. &da850_evm_nandflash_device,
  171. &da850_evm_norflash_device,
  172. };
  173. #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
  174. #define DA8XX_AEMIF_ASIZE_16BIT 0x1
  175. static void __init da850_evm_init_nor(void)
  176. {
  177. void __iomem *aemif_addr;
  178. aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
  179. /* Configure data bus width of CS2 to 16 bit */
  180. writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
  181. DA8XX_AEMIF_ASIZE_16BIT,
  182. aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
  183. iounmap(aemif_addr);
  184. }
  185. static const short da850_evm_nand_pins[] = {
  186. DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
  187. DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
  188. DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
  189. DA850_NEMA_WE, DA850_NEMA_OE,
  190. -1
  191. };
  192. static const short da850_evm_nor_pins[] = {
  193. DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
  194. DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
  195. DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
  196. DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
  197. DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
  198. DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
  199. DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
  200. DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
  201. DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
  202. DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
  203. DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
  204. DA850_EMA_A_22, DA850_EMA_A_23,
  205. -1
  206. };
  207. static u32 ui_card_detected;
  208. #if defined(CONFIG_MMC_DAVINCI) || \
  209. defined(CONFIG_MMC_DAVINCI_MODULE)
  210. #define HAS_MMC 1
  211. #else
  212. #define HAS_MMC 0
  213. #endif
  214. static inline void da850_evm_setup_nor_nand(void)
  215. {
  216. int ret = 0;
  217. if (ui_card_detected & !HAS_MMC) {
  218. ret = davinci_cfg_reg_list(da850_evm_nand_pins);
  219. if (ret)
  220. pr_warning("da850_evm_init: nand mux setup failed: "
  221. "%d\n", ret);
  222. ret = davinci_cfg_reg_list(da850_evm_nor_pins);
  223. if (ret)
  224. pr_warning("da850_evm_init: nor mux setup failed: %d\n",
  225. ret);
  226. da850_evm_init_nor();
  227. platform_add_devices(da850_evm_devices,
  228. ARRAY_SIZE(da850_evm_devices));
  229. }
  230. }
  231. #ifdef CONFIG_DA850_UI_RMII
  232. static inline void da850_evm_setup_emac_rmii(int rmii_sel)
  233. {
  234. struct davinci_soc_info *soc_info = &davinci_soc_info;
  235. soc_info->emac_pdata->rmii_en = 1;
  236. gpio_set_value(rmii_sel, 0);
  237. }
  238. #else
  239. static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
  240. #endif
  241. static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
  242. unsigned ngpio, void *c)
  243. {
  244. int sel_a, sel_b, sel_c, ret;
  245. sel_a = gpio + 7;
  246. sel_b = gpio + 6;
  247. sel_c = gpio + 5;
  248. ret = gpio_request(sel_a, "sel_a");
  249. if (ret) {
  250. pr_warning("Cannot open UI expander pin %d\n", sel_a);
  251. goto exp_setup_sela_fail;
  252. }
  253. ret = gpio_request(sel_b, "sel_b");
  254. if (ret) {
  255. pr_warning("Cannot open UI expander pin %d\n", sel_b);
  256. goto exp_setup_selb_fail;
  257. }
  258. ret = gpio_request(sel_c, "sel_c");
  259. if (ret) {
  260. pr_warning("Cannot open UI expander pin %d\n", sel_c);
  261. goto exp_setup_selc_fail;
  262. }
  263. /* deselect all functionalities */
  264. gpio_direction_output(sel_a, 1);
  265. gpio_direction_output(sel_b, 1);
  266. gpio_direction_output(sel_c, 1);
  267. ui_card_detected = 1;
  268. pr_info("DA850/OMAP-L138 EVM UI card detected\n");
  269. da850_evm_setup_nor_nand();
  270. da850_evm_setup_emac_rmii(sel_a);
  271. return 0;
  272. exp_setup_selc_fail:
  273. gpio_free(sel_b);
  274. exp_setup_selb_fail:
  275. gpio_free(sel_a);
  276. exp_setup_sela_fail:
  277. return ret;
  278. }
  279. static int da850_evm_ui_expander_teardown(struct i2c_client *client,
  280. unsigned gpio, unsigned ngpio, void *c)
  281. {
  282. /* deselect all functionalities */
  283. gpio_set_value(gpio + 5, 1);
  284. gpio_set_value(gpio + 6, 1);
  285. gpio_set_value(gpio + 7, 1);
  286. gpio_free(gpio + 5);
  287. gpio_free(gpio + 6);
  288. gpio_free(gpio + 7);
  289. return 0;
  290. }
  291. static struct pca953x_platform_data da850_evm_ui_expander_info = {
  292. .gpio_base = DAVINCI_N_GPIO,
  293. .setup = da850_evm_ui_expander_setup,
  294. .teardown = da850_evm_ui_expander_teardown,
  295. };
  296. static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
  297. {
  298. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  299. },
  300. {
  301. I2C_BOARD_INFO("tca6416", 0x20),
  302. .platform_data = &da850_evm_ui_expander_info,
  303. },
  304. };
  305. static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
  306. .bus_freq = 100, /* kHz */
  307. .bus_delay = 0, /* usec */
  308. };
  309. static struct davinci_uart_config da850_evm_uart_config __initdata = {
  310. .enabled_uarts = 0x7,
  311. };
  312. /* davinci da850 evm audio machine driver */
  313. static u8 da850_iis_serializer_direction[] = {
  314. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  315. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  316. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  317. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  318. };
  319. static struct snd_platform_data da850_evm_snd_data = {
  320. .tx_dma_offset = 0x2000,
  321. .rx_dma_offset = 0x2000,
  322. .op_mode = DAVINCI_MCASP_IIS_MODE,
  323. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  324. .tdm_slots = 2,
  325. .serial_dir = da850_iis_serializer_direction,
  326. .asp_chan_q = EVENTQ_1,
  327. .version = MCASP_VERSION_2,
  328. .txnumevt = 1,
  329. .rxnumevt = 1,
  330. };
  331. static int da850_evm_mmc_get_ro(int index)
  332. {
  333. return gpio_get_value(DA850_MMCSD_WP_PIN);
  334. }
  335. static int da850_evm_mmc_get_cd(int index)
  336. {
  337. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  338. }
  339. static struct davinci_mmc_config da850_mmc_config = {
  340. .get_ro = da850_evm_mmc_get_ro,
  341. .get_cd = da850_evm_mmc_get_cd,
  342. .wires = 4,
  343. .max_freq = 50000000,
  344. .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
  345. .version = MMC_CTLR_VERSION_2,
  346. };
  347. static void da850_panel_power_ctrl(int val)
  348. {
  349. /* lcd backlight */
  350. gpio_set_value(DA850_LCD_BL_PIN, val);
  351. /* lcd power */
  352. gpio_set_value(DA850_LCD_PWR_PIN, val);
  353. }
  354. static int da850_lcd_hw_init(void)
  355. {
  356. int status;
  357. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  358. if (status < 0)
  359. return status;
  360. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  361. if (status < 0) {
  362. gpio_free(DA850_LCD_BL_PIN);
  363. return status;
  364. }
  365. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  366. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  367. /* Switch off panel power and backlight */
  368. da850_panel_power_ctrl(0);
  369. /* Switch on panel power and backlight */
  370. da850_panel_power_ctrl(1);
  371. return 0;
  372. }
  373. /* TPS65070 voltage regulator support */
  374. /* 3.3V */
  375. static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
  376. {
  377. .supply = "usb0_vdda33",
  378. },
  379. {
  380. .supply = "usb1_vdda33",
  381. },
  382. };
  383. /* 3.3V or 1.8V */
  384. static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
  385. {
  386. .supply = "dvdd3318_a",
  387. },
  388. {
  389. .supply = "dvdd3318_b",
  390. },
  391. {
  392. .supply = "dvdd3318_c",
  393. },
  394. };
  395. /* 1.2V */
  396. static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
  397. {
  398. .supply = "cvdd",
  399. },
  400. };
  401. /* 1.8V LDO */
  402. static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
  403. {
  404. .supply = "sata_vddr",
  405. },
  406. {
  407. .supply = "usb0_vdda18",
  408. },
  409. {
  410. .supply = "usb1_vdda18",
  411. },
  412. {
  413. .supply = "ddr_dvdd18",
  414. },
  415. };
  416. /* 1.2V LDO */
  417. static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
  418. {
  419. .supply = "sata_vdd",
  420. },
  421. {
  422. .supply = "pll0_vdda",
  423. },
  424. {
  425. .supply = "pll1_vdda",
  426. },
  427. {
  428. .supply = "usbs_cvdd",
  429. },
  430. {
  431. .supply = "vddarnwa1",
  432. },
  433. };
  434. /* We take advantage of the fact that both defdcdc{2,3} are tied high */
  435. static struct tps6507x_reg_platform_data tps6507x_platform_data = {
  436. .defdcdc_default = true,
  437. };
  438. static struct regulator_init_data tps65070_regulator_data[] = {
  439. /* dcdc1 */
  440. {
  441. .constraints = {
  442. .min_uV = 3150000,
  443. .max_uV = 3450000,
  444. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  445. REGULATOR_CHANGE_STATUS),
  446. .boot_on = 1,
  447. },
  448. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
  449. .consumer_supplies = tps65070_dcdc1_consumers,
  450. },
  451. /* dcdc2 */
  452. {
  453. .constraints = {
  454. .min_uV = 1710000,
  455. .max_uV = 3450000,
  456. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  457. REGULATOR_CHANGE_STATUS),
  458. .boot_on = 1,
  459. },
  460. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
  461. .consumer_supplies = tps65070_dcdc2_consumers,
  462. .driver_data = &tps6507x_platform_data,
  463. },
  464. /* dcdc3 */
  465. {
  466. .constraints = {
  467. .min_uV = 950000,
  468. .max_uV = 1320000,
  469. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  470. REGULATOR_CHANGE_STATUS),
  471. .boot_on = 1,
  472. },
  473. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
  474. .consumer_supplies = tps65070_dcdc3_consumers,
  475. .driver_data = &tps6507x_platform_data,
  476. },
  477. /* ldo1 */
  478. {
  479. .constraints = {
  480. .min_uV = 1710000,
  481. .max_uV = 1890000,
  482. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  483. REGULATOR_CHANGE_STATUS),
  484. .boot_on = 1,
  485. },
  486. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
  487. .consumer_supplies = tps65070_ldo1_consumers,
  488. },
  489. /* ldo2 */
  490. {
  491. .constraints = {
  492. .min_uV = 1140000,
  493. .max_uV = 1320000,
  494. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  495. REGULATOR_CHANGE_STATUS),
  496. .boot_on = 1,
  497. },
  498. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
  499. .consumer_supplies = tps65070_ldo2_consumers,
  500. },
  501. };
  502. static struct touchscreen_init_data tps6507x_touchscreen_data = {
  503. .poll_period = 30, /* ms between touch samples */
  504. .min_pressure = 0x30, /* minimum pressure to trigger touch */
  505. .vref = 0, /* turn off vref when not using A/D */
  506. .vendor = 0, /* /sys/class/input/input?/id/vendor */
  507. .product = 65070, /* /sys/class/input/input?/id/product */
  508. .version = 0x100, /* /sys/class/input/input?/id/version */
  509. };
  510. static struct tps6507x_board tps_board = {
  511. .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
  512. .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
  513. };
  514. static struct i2c_board_info __initdata da850evm_tps65070_info[] = {
  515. {
  516. I2C_BOARD_INFO("tps6507x", 0x48),
  517. .platform_data = &tps_board,
  518. },
  519. };
  520. static int __init pmic_tps65070_init(void)
  521. {
  522. return i2c_register_board_info(1, da850evm_tps65070_info,
  523. ARRAY_SIZE(da850evm_tps65070_info));
  524. }
  525. static const short da850_evm_lcdc_pins[] = {
  526. DA850_GPIO2_8, DA850_GPIO2_15,
  527. -1
  528. };
  529. static const short da850_evm_mii_pins[] = {
  530. DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
  531. DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
  532. DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
  533. DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
  534. DA850_MDIO_D,
  535. -1
  536. };
  537. static const short da850_evm_rmii_pins[] = {
  538. DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
  539. DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
  540. DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
  541. DA850_MDIO_D,
  542. -1
  543. };
  544. static int __init da850_evm_config_emac(void)
  545. {
  546. void __iomem *cfg_chip3_base;
  547. int ret;
  548. u32 val;
  549. struct davinci_soc_info *soc_info = &davinci_soc_info;
  550. u8 rmii_en = soc_info->emac_pdata->rmii_en;
  551. if (!machine_is_davinci_da850_evm())
  552. return 0;
  553. cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
  554. val = __raw_readl(cfg_chip3_base);
  555. if (rmii_en) {
  556. val |= BIT(8);
  557. ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
  558. pr_info("EMAC: RMII PHY configured, MII PHY will not be"
  559. " functional\n");
  560. } else {
  561. val &= ~BIT(8);
  562. ret = davinci_cfg_reg_list(da850_evm_mii_pins);
  563. pr_info("EMAC: MII PHY configured, RMII PHY will not be"
  564. " functional\n");
  565. }
  566. if (ret)
  567. pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
  568. ret);
  569. /* configure the CFGCHIP3 register for RMII or MII */
  570. __raw_writel(val, cfg_chip3_base);
  571. ret = davinci_cfg_reg(DA850_GPIO2_6);
  572. if (ret)
  573. pr_warning("da850_evm_init:GPIO(2,6) mux setup "
  574. "failed\n");
  575. ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
  576. if (ret) {
  577. pr_warning("Cannot open GPIO %d\n",
  578. DA850_MII_MDIO_CLKEN_PIN);
  579. return ret;
  580. }
  581. /* Enable/Disable MII MDIO clock */
  582. gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
  583. soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
  584. ret = da8xx_register_emac();
  585. if (ret)
  586. pr_warning("da850_evm_init: emac registration failed: %d\n",
  587. ret);
  588. return 0;
  589. }
  590. device_initcall(da850_evm_config_emac);
  591. /*
  592. * The following EDMA channels/slots are not being used by drivers (for
  593. * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
  594. * they are being reserved for codecs on the DSP side.
  595. */
  596. static const s16 da850_dma0_rsv_chans[][2] = {
  597. /* (offset, number) */
  598. { 8, 6},
  599. {24, 4},
  600. {30, 2},
  601. {-1, -1}
  602. };
  603. static const s16 da850_dma0_rsv_slots[][2] = {
  604. /* (offset, number) */
  605. { 8, 6},
  606. {24, 4},
  607. {30, 50},
  608. {-1, -1}
  609. };
  610. static const s16 da850_dma1_rsv_chans[][2] = {
  611. /* (offset, number) */
  612. { 0, 28},
  613. {30, 2},
  614. {-1, -1}
  615. };
  616. static const s16 da850_dma1_rsv_slots[][2] = {
  617. /* (offset, number) */
  618. { 0, 28},
  619. {30, 90},
  620. {-1, -1}
  621. };
  622. static struct edma_rsv_info da850_edma_cc0_rsv = {
  623. .rsv_chans = da850_dma0_rsv_chans,
  624. .rsv_slots = da850_dma0_rsv_slots,
  625. };
  626. static struct edma_rsv_info da850_edma_cc1_rsv = {
  627. .rsv_chans = da850_dma1_rsv_chans,
  628. .rsv_slots = da850_dma1_rsv_slots,
  629. };
  630. static struct edma_rsv_info *da850_edma_rsv[2] = {
  631. &da850_edma_cc0_rsv,
  632. &da850_edma_cc1_rsv,
  633. };
  634. static __init void da850_evm_init(void)
  635. {
  636. int ret;
  637. ret = pmic_tps65070_init();
  638. if (ret)
  639. pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
  640. ret);
  641. ret = da850_register_edma(da850_edma_rsv);
  642. if (ret)
  643. pr_warning("da850_evm_init: edma registration failed: %d\n",
  644. ret);
  645. ret = davinci_cfg_reg_list(da850_i2c0_pins);
  646. if (ret)
  647. pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
  648. ret);
  649. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  650. if (ret)
  651. pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
  652. ret);
  653. ret = da8xx_register_watchdog();
  654. if (ret)
  655. pr_warning("da830_evm_init: watchdog registration failed: %d\n",
  656. ret);
  657. if (HAS_MMC) {
  658. ret = davinci_cfg_reg_list(da850_mmcsd0_pins);
  659. if (ret)
  660. pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
  661. " %d\n", ret);
  662. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  663. if (ret)
  664. pr_warning("da850_evm_init: can not open GPIO %d\n",
  665. DA850_MMCSD_CD_PIN);
  666. gpio_direction_input(DA850_MMCSD_CD_PIN);
  667. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  668. if (ret)
  669. pr_warning("da850_evm_init: can not open GPIO %d\n",
  670. DA850_MMCSD_WP_PIN);
  671. gpio_direction_input(DA850_MMCSD_WP_PIN);
  672. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  673. if (ret)
  674. pr_warning("da850_evm_init: mmcsd0 registration failed:"
  675. " %d\n", ret);
  676. }
  677. davinci_serial_init(&da850_evm_uart_config);
  678. i2c_register_board_info(1, da850_evm_i2c_devices,
  679. ARRAY_SIZE(da850_evm_i2c_devices));
  680. /*
  681. * shut down uart 0 and 1; they are not used on the board and
  682. * accessing them causes endless "too much work in irq53" messages
  683. * with arago fs
  684. */
  685. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  686. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  687. ret = davinci_cfg_reg_list(da850_mcasp_pins);
  688. if (ret)
  689. pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
  690. ret);
  691. da8xx_register_mcasp(0, &da850_evm_snd_data);
  692. ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
  693. if (ret)
  694. pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
  695. ret);
  696. /* Handle board specific muxing for LCD here */
  697. ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
  698. if (ret)
  699. pr_warning("da850_evm_init: evm specific lcd mux setup "
  700. "failed: %d\n", ret);
  701. ret = da850_lcd_hw_init();
  702. if (ret)
  703. pr_warning("da850_evm_init: lcd initialization failed: %d\n",
  704. ret);
  705. sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
  706. ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
  707. if (ret)
  708. pr_warning("da850_evm_init: lcdc registration failed: %d\n",
  709. ret);
  710. ret = da8xx_register_rtc();
  711. if (ret)
  712. pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
  713. ret = da850_register_cpufreq("pll0_sysclk3");
  714. if (ret)
  715. pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
  716. ret);
  717. ret = da8xx_register_cpuidle();
  718. if (ret)
  719. pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
  720. ret);
  721. ret = da850_register_pm(&da850_pm_device);
  722. if (ret)
  723. pr_warning("da850_evm_init: suspend registration failed: %d\n",
  724. ret);
  725. }
  726. #ifdef CONFIG_SERIAL_8250_CONSOLE
  727. static int __init da850_evm_console_init(void)
  728. {
  729. if (!machine_is_davinci_da850_evm())
  730. return 0;
  731. return add_preferred_console("ttyS", 2, "115200");
  732. }
  733. console_initcall(da850_evm_console_init);
  734. #endif
  735. static void __init da850_evm_map_io(void)
  736. {
  737. da850_init();
  738. }
  739. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
  740. .boot_params = (DA8XX_DDR_BASE + 0x100),
  741. .map_io = da850_evm_map_io,
  742. .init_irq = cp_intc_init,
  743. .timer = &davinci_timer,
  744. .init_machine = da850_evm_init,
  745. MACHINE_END