board-da850-evm.c 21 KB

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