board-da850-evm.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  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/input.h>
  21. #include <linux/mfd/tps6507x.h>
  22. #include <linux/gpio.h>
  23. #include <linux/gpio_keys.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/mtd/mtd.h>
  26. #include <linux/mtd/nand.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/mtd/physmap.h>
  29. #include <linux/regulator/machine.h>
  30. #include <linux/regulator/tps6507x.h>
  31. #include <linux/input/tps6507x-ts.h>
  32. #include <linux/spi/spi.h>
  33. #include <linux/spi/flash.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <mach/cp_intc.h>
  37. #include <mach/da8xx.h>
  38. #include <mach/nand.h>
  39. #include <mach/mux.h>
  40. #include <mach/aemif.h>
  41. #include <mach/spi.h>
  42. #define DA850_EVM_PHY_ID "0:00"
  43. #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
  44. #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
  45. #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
  46. #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
  47. #define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
  48. static struct mtd_partition da850evm_spiflash_part[] = {
  49. [0] = {
  50. .name = "UBL",
  51. .offset = 0,
  52. .size = SZ_64K,
  53. .mask_flags = MTD_WRITEABLE,
  54. },
  55. [1] = {
  56. .name = "U-Boot",
  57. .offset = MTDPART_OFS_APPEND,
  58. .size = SZ_512K,
  59. .mask_flags = MTD_WRITEABLE,
  60. },
  61. [2] = {
  62. .name = "U-Boot-Env",
  63. .offset = MTDPART_OFS_APPEND,
  64. .size = SZ_64K,
  65. .mask_flags = MTD_WRITEABLE,
  66. },
  67. [3] = {
  68. .name = "Kernel",
  69. .offset = MTDPART_OFS_APPEND,
  70. .size = SZ_2M + SZ_512K,
  71. .mask_flags = 0,
  72. },
  73. [4] = {
  74. .name = "Filesystem",
  75. .offset = MTDPART_OFS_APPEND,
  76. .size = SZ_4M,
  77. .mask_flags = 0,
  78. },
  79. [5] = {
  80. .name = "MAC-Address",
  81. .offset = SZ_8M - SZ_64K,
  82. .size = SZ_64K,
  83. .mask_flags = MTD_WRITEABLE,
  84. },
  85. };
  86. static struct flash_platform_data da850evm_spiflash_data = {
  87. .name = "m25p80",
  88. .parts = da850evm_spiflash_part,
  89. .nr_parts = ARRAY_SIZE(da850evm_spiflash_part),
  90. .type = "m25p64",
  91. };
  92. static struct davinci_spi_config da850evm_spiflash_cfg = {
  93. .io_type = SPI_IO_TYPE_DMA,
  94. .c2tdelay = 8,
  95. .t2cdelay = 8,
  96. };
  97. static struct spi_board_info da850evm_spi_info[] = {
  98. {
  99. .modalias = "m25p80",
  100. .platform_data = &da850evm_spiflash_data,
  101. .controller_data = &da850evm_spiflash_cfg,
  102. .mode = SPI_MODE_0,
  103. .max_speed_hz = 30000000,
  104. .bus_num = 1,
  105. .chip_select = 0,
  106. },
  107. };
  108. #ifdef CONFIG_MTD
  109. static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
  110. {
  111. char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
  112. size_t retlen;
  113. if (!strcmp(mtd->name, "MAC-Address")) {
  114. mtd->read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
  115. if (retlen == ETH_ALEN)
  116. pr_info("Read MAC addr from SPI Flash: %pM\n",
  117. mac_addr);
  118. }
  119. }
  120. static struct mtd_notifier da850evm_spi_notifier = {
  121. .add = da850_evm_m25p80_notify_add,
  122. };
  123. static void da850_evm_setup_mac_addr(void)
  124. {
  125. register_mtd_user(&da850evm_spi_notifier);
  126. }
  127. #else
  128. static void da850_evm_setup_mac_addr(void) { }
  129. #endif
  130. static struct mtd_partition da850_evm_norflash_partition[] = {
  131. {
  132. .name = "bootloaders + env",
  133. .offset = 0,
  134. .size = SZ_512K,
  135. .mask_flags = MTD_WRITEABLE,
  136. },
  137. {
  138. .name = "kernel",
  139. .offset = MTDPART_OFS_APPEND,
  140. .size = SZ_2M,
  141. .mask_flags = 0,
  142. },
  143. {
  144. .name = "filesystem",
  145. .offset = MTDPART_OFS_APPEND,
  146. .size = MTDPART_SIZ_FULL,
  147. .mask_flags = 0,
  148. },
  149. };
  150. static struct physmap_flash_data da850_evm_norflash_data = {
  151. .width = 2,
  152. .parts = da850_evm_norflash_partition,
  153. .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
  154. };
  155. static struct resource da850_evm_norflash_resource[] = {
  156. {
  157. .start = DA8XX_AEMIF_CS2_BASE,
  158. .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
  159. .flags = IORESOURCE_MEM,
  160. },
  161. };
  162. static struct platform_device da850_evm_norflash_device = {
  163. .name = "physmap-flash",
  164. .id = 0,
  165. .dev = {
  166. .platform_data = &da850_evm_norflash_data,
  167. },
  168. .num_resources = 1,
  169. .resource = da850_evm_norflash_resource,
  170. };
  171. static struct davinci_pm_config da850_pm_pdata = {
  172. .sleepcount = 128,
  173. };
  174. static struct platform_device da850_pm_device = {
  175. .name = "pm-davinci",
  176. .dev = {
  177. .platform_data = &da850_pm_pdata,
  178. },
  179. .id = -1,
  180. };
  181. /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  182. * (128K blocks). It may be used instead of the (default) SPI flash
  183. * to boot, using TI's tools to install the secondary boot loader
  184. * (UBL) and U-Boot.
  185. */
  186. static struct mtd_partition da850_evm_nandflash_partition[] = {
  187. {
  188. .name = "u-boot env",
  189. .offset = 0,
  190. .size = SZ_128K,
  191. .mask_flags = MTD_WRITEABLE,
  192. },
  193. {
  194. .name = "UBL",
  195. .offset = MTDPART_OFS_APPEND,
  196. .size = SZ_128K,
  197. .mask_flags = MTD_WRITEABLE,
  198. },
  199. {
  200. .name = "u-boot",
  201. .offset = MTDPART_OFS_APPEND,
  202. .size = 4 * SZ_128K,
  203. .mask_flags = MTD_WRITEABLE,
  204. },
  205. {
  206. .name = "kernel",
  207. .offset = 0x200000,
  208. .size = SZ_2M,
  209. .mask_flags = 0,
  210. },
  211. {
  212. .name = "filesystem",
  213. .offset = MTDPART_OFS_APPEND,
  214. .size = MTDPART_SIZ_FULL,
  215. .mask_flags = 0,
  216. },
  217. };
  218. static struct davinci_aemif_timing da850_evm_nandflash_timing = {
  219. .wsetup = 24,
  220. .wstrobe = 21,
  221. .whold = 14,
  222. .rsetup = 19,
  223. .rstrobe = 50,
  224. .rhold = 0,
  225. .ta = 20,
  226. };
  227. static struct davinci_nand_pdata da850_evm_nandflash_data = {
  228. .parts = da850_evm_nandflash_partition,
  229. .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
  230. .ecc_mode = NAND_ECC_HW,
  231. .ecc_bits = 4,
  232. .options = NAND_USE_FLASH_BBT,
  233. .timing = &da850_evm_nandflash_timing,
  234. };
  235. static struct resource da850_evm_nandflash_resource[] = {
  236. {
  237. .start = DA8XX_AEMIF_CS3_BASE,
  238. .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
  239. .flags = IORESOURCE_MEM,
  240. },
  241. {
  242. .start = DA8XX_AEMIF_CTL_BASE,
  243. .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
  244. .flags = IORESOURCE_MEM,
  245. },
  246. };
  247. static struct platform_device da850_evm_nandflash_device = {
  248. .name = "davinci_nand",
  249. .id = 1,
  250. .dev = {
  251. .platform_data = &da850_evm_nandflash_data,
  252. },
  253. .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
  254. .resource = da850_evm_nandflash_resource,
  255. };
  256. static struct platform_device *da850_evm_devices[] __initdata = {
  257. &da850_evm_nandflash_device,
  258. &da850_evm_norflash_device,
  259. };
  260. #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
  261. #define DA8XX_AEMIF_ASIZE_16BIT 0x1
  262. static void __init da850_evm_init_nor(void)
  263. {
  264. void __iomem *aemif_addr;
  265. aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
  266. /* Configure data bus width of CS2 to 16 bit */
  267. writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
  268. DA8XX_AEMIF_ASIZE_16BIT,
  269. aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
  270. iounmap(aemif_addr);
  271. }
  272. static const short da850_evm_nand_pins[] = {
  273. DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
  274. DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
  275. DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
  276. DA850_NEMA_WE, DA850_NEMA_OE,
  277. -1
  278. };
  279. static const short da850_evm_nor_pins[] = {
  280. DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
  281. DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
  282. DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
  283. DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
  284. DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
  285. DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
  286. DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
  287. DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
  288. DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
  289. DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
  290. DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
  291. DA850_EMA_A_22, DA850_EMA_A_23,
  292. -1
  293. };
  294. #if defined(CONFIG_MMC_DAVINCI) || \
  295. defined(CONFIG_MMC_DAVINCI_MODULE)
  296. #define HAS_MMC 1
  297. #else
  298. #define HAS_MMC 0
  299. #endif
  300. static inline void da850_evm_setup_nor_nand(void)
  301. {
  302. int ret = 0;
  303. if (!HAS_MMC) {
  304. ret = davinci_cfg_reg_list(da850_evm_nand_pins);
  305. if (ret)
  306. pr_warning("da850_evm_init: nand mux setup failed: "
  307. "%d\n", ret);
  308. ret = davinci_cfg_reg_list(da850_evm_nor_pins);
  309. if (ret)
  310. pr_warning("da850_evm_init: nor mux setup failed: %d\n",
  311. ret);
  312. da850_evm_init_nor();
  313. platform_add_devices(da850_evm_devices,
  314. ARRAY_SIZE(da850_evm_devices));
  315. }
  316. }
  317. #ifdef CONFIG_DA850_UI_RMII
  318. static inline void da850_evm_setup_emac_rmii(int rmii_sel)
  319. {
  320. struct davinci_soc_info *soc_info = &davinci_soc_info;
  321. soc_info->emac_pdata->rmii_en = 1;
  322. gpio_set_value_cansleep(rmii_sel, 0);
  323. }
  324. #else
  325. static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
  326. #endif
  327. #define DA850_KEYS_DEBOUNCE_MS 10
  328. /*
  329. * At 200ms polling interval it is possible to miss an
  330. * event by tapping very lightly on the push button but most
  331. * pushes do result in an event; longer intervals require the
  332. * user to hold the button whereas shorter intervals require
  333. * more CPU time for polling.
  334. */
  335. #define DA850_GPIO_KEYS_POLL_MS 200
  336. enum da850_evm_ui_exp_pins {
  337. DA850_EVM_UI_EXP_SEL_C = 5,
  338. DA850_EVM_UI_EXP_SEL_B,
  339. DA850_EVM_UI_EXP_SEL_A,
  340. DA850_EVM_UI_EXP_PB8,
  341. DA850_EVM_UI_EXP_PB7,
  342. DA850_EVM_UI_EXP_PB6,
  343. DA850_EVM_UI_EXP_PB5,
  344. DA850_EVM_UI_EXP_PB4,
  345. DA850_EVM_UI_EXP_PB3,
  346. DA850_EVM_UI_EXP_PB2,
  347. DA850_EVM_UI_EXP_PB1,
  348. };
  349. static const char const *da850_evm_ui_exp[] = {
  350. [DA850_EVM_UI_EXP_SEL_C] = "sel_c",
  351. [DA850_EVM_UI_EXP_SEL_B] = "sel_b",
  352. [DA850_EVM_UI_EXP_SEL_A] = "sel_a",
  353. [DA850_EVM_UI_EXP_PB8] = "pb8",
  354. [DA850_EVM_UI_EXP_PB7] = "pb7",
  355. [DA850_EVM_UI_EXP_PB6] = "pb6",
  356. [DA850_EVM_UI_EXP_PB5] = "pb5",
  357. [DA850_EVM_UI_EXP_PB4] = "pb4",
  358. [DA850_EVM_UI_EXP_PB3] = "pb3",
  359. [DA850_EVM_UI_EXP_PB2] = "pb2",
  360. [DA850_EVM_UI_EXP_PB1] = "pb1",
  361. };
  362. #define DA850_N_UI_PB 8
  363. static struct gpio_keys_button da850_evm_ui_keys[] = {
  364. [0 ... DA850_N_UI_PB - 1] = {
  365. .type = EV_KEY,
  366. .active_low = 1,
  367. .wakeup = 0,
  368. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  369. .code = -1, /* assigned at runtime */
  370. .gpio = -1, /* assigned at runtime */
  371. .desc = NULL, /* assigned at runtime */
  372. },
  373. };
  374. static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
  375. .buttons = da850_evm_ui_keys,
  376. .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
  377. .poll_interval = DA850_GPIO_KEYS_POLL_MS,
  378. };
  379. static struct platform_device da850_evm_ui_keys_device = {
  380. .name = "gpio-keys-polled",
  381. .id = 0,
  382. .dev = {
  383. .platform_data = &da850_evm_ui_keys_pdata
  384. },
  385. };
  386. static void da850_evm_ui_keys_init(unsigned gpio)
  387. {
  388. int i;
  389. struct gpio_keys_button *button;
  390. for (i = 0; i < DA850_N_UI_PB; i++) {
  391. button = &da850_evm_ui_keys[i];
  392. button->code = KEY_F8 - i;
  393. button->desc = (char *)
  394. da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
  395. button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
  396. }
  397. }
  398. static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
  399. unsigned ngpio, void *c)
  400. {
  401. int sel_a, sel_b, sel_c, ret;
  402. sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
  403. sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
  404. sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
  405. ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
  406. if (ret) {
  407. pr_warning("Cannot open UI expander pin %d\n", sel_a);
  408. goto exp_setup_sela_fail;
  409. }
  410. ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
  411. if (ret) {
  412. pr_warning("Cannot open UI expander pin %d\n", sel_b);
  413. goto exp_setup_selb_fail;
  414. }
  415. ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
  416. if (ret) {
  417. pr_warning("Cannot open UI expander pin %d\n", sel_c);
  418. goto exp_setup_selc_fail;
  419. }
  420. /* deselect all functionalities */
  421. gpio_direction_output(sel_a, 1);
  422. gpio_direction_output(sel_b, 1);
  423. gpio_direction_output(sel_c, 1);
  424. da850_evm_ui_keys_init(gpio);
  425. ret = platform_device_register(&da850_evm_ui_keys_device);
  426. if (ret) {
  427. pr_warning("Could not register UI GPIO expander push-buttons");
  428. goto exp_setup_keys_fail;
  429. }
  430. pr_info("DA850/OMAP-L138 EVM UI card detected\n");
  431. da850_evm_setup_nor_nand();
  432. da850_evm_setup_emac_rmii(sel_a);
  433. return 0;
  434. exp_setup_keys_fail:
  435. gpio_free(sel_c);
  436. exp_setup_selc_fail:
  437. gpio_free(sel_b);
  438. exp_setup_selb_fail:
  439. gpio_free(sel_a);
  440. exp_setup_sela_fail:
  441. return ret;
  442. }
  443. static int da850_evm_ui_expander_teardown(struct i2c_client *client,
  444. unsigned gpio, unsigned ngpio, void *c)
  445. {
  446. platform_device_unregister(&da850_evm_ui_keys_device);
  447. /* deselect all functionalities */
  448. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
  449. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
  450. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
  451. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
  452. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
  453. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
  454. return 0;
  455. }
  456. /* assign the baseboard expander's GPIOs after the UI board's */
  457. #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
  458. #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
  459. enum da850_evm_bb_exp_pins {
  460. DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
  461. DA850_EVM_BB_EXP_SW_RST,
  462. DA850_EVM_BB_EXP_TP_23,
  463. DA850_EVM_BB_EXP_TP_22,
  464. DA850_EVM_BB_EXP_TP_21,
  465. DA850_EVM_BB_EXP_USER_PB1,
  466. DA850_EVM_BB_EXP_USER_LED2,
  467. DA850_EVM_BB_EXP_USER_LED1,
  468. DA850_EVM_BB_EXP_USER_SW1,
  469. DA850_EVM_BB_EXP_USER_SW2,
  470. DA850_EVM_BB_EXP_USER_SW3,
  471. DA850_EVM_BB_EXP_USER_SW4,
  472. DA850_EVM_BB_EXP_USER_SW5,
  473. DA850_EVM_BB_EXP_USER_SW6,
  474. DA850_EVM_BB_EXP_USER_SW7,
  475. DA850_EVM_BB_EXP_USER_SW8
  476. };
  477. static const char const *da850_evm_bb_exp[] = {
  478. [DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en",
  479. [DA850_EVM_BB_EXP_SW_RST] = "sw_rst",
  480. [DA850_EVM_BB_EXP_TP_23] = "tp_23",
  481. [DA850_EVM_BB_EXP_TP_22] = "tp_22",
  482. [DA850_EVM_BB_EXP_TP_21] = "tp_21",
  483. [DA850_EVM_BB_EXP_USER_PB1] = "user_pb1",
  484. [DA850_EVM_BB_EXP_USER_LED2] = "user_led2",
  485. [DA850_EVM_BB_EXP_USER_LED1] = "user_led1",
  486. [DA850_EVM_BB_EXP_USER_SW1] = "user_sw1",
  487. [DA850_EVM_BB_EXP_USER_SW2] = "user_sw2",
  488. [DA850_EVM_BB_EXP_USER_SW3] = "user_sw3",
  489. [DA850_EVM_BB_EXP_USER_SW4] = "user_sw4",
  490. [DA850_EVM_BB_EXP_USER_SW5] = "user_sw5",
  491. [DA850_EVM_BB_EXP_USER_SW6] = "user_sw6",
  492. [DA850_EVM_BB_EXP_USER_SW7] = "user_sw7",
  493. [DA850_EVM_BB_EXP_USER_SW8] = "user_sw8",
  494. };
  495. #define DA850_N_BB_USER_SW 8
  496. static struct gpio_keys_button da850_evm_bb_keys[] = {
  497. [0] = {
  498. .type = EV_KEY,
  499. .active_low = 1,
  500. .wakeup = 0,
  501. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  502. .code = KEY_PROG1,
  503. .desc = NULL, /* assigned at runtime */
  504. .gpio = -1, /* assigned at runtime */
  505. },
  506. [1 ... DA850_N_BB_USER_SW] = {
  507. .type = EV_SW,
  508. .active_low = 1,
  509. .wakeup = 0,
  510. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  511. .code = -1, /* assigned at runtime */
  512. .desc = NULL, /* assigned at runtime */
  513. .gpio = -1, /* assigned at runtime */
  514. },
  515. };
  516. static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
  517. .buttons = da850_evm_bb_keys,
  518. .nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
  519. .poll_interval = DA850_GPIO_KEYS_POLL_MS,
  520. };
  521. static struct platform_device da850_evm_bb_keys_device = {
  522. .name = "gpio-keys-polled",
  523. .id = 1,
  524. .dev = {
  525. .platform_data = &da850_evm_bb_keys_pdata
  526. },
  527. };
  528. static void da850_evm_bb_keys_init(unsigned gpio)
  529. {
  530. int i;
  531. struct gpio_keys_button *button;
  532. button = &da850_evm_bb_keys[0];
  533. button->desc = (char *)
  534. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
  535. button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
  536. for (i = 0; i < DA850_N_BB_USER_SW; i++) {
  537. button = &da850_evm_bb_keys[i + 1];
  538. button->code = SW_LID + i;
  539. button->desc = (char *)
  540. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
  541. button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
  542. }
  543. }
  544. #define DA850_N_BB_USER_LED 2
  545. static struct gpio_led da850_evm_bb_leds[] = {
  546. [0 ... DA850_N_BB_USER_LED - 1] = {
  547. .active_low = 1,
  548. .gpio = -1, /* assigned at runtime */
  549. .name = NULL, /* assigned at runtime */
  550. },
  551. };
  552. static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
  553. .leds = da850_evm_bb_leds,
  554. .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
  555. };
  556. static struct platform_device da850_evm_bb_leds_device = {
  557. .name = "leds-gpio",
  558. .id = -1,
  559. .dev = {
  560. .platform_data = &da850_evm_bb_leds_pdata
  561. }
  562. };
  563. static void da850_evm_bb_leds_init(unsigned gpio)
  564. {
  565. int i;
  566. struct gpio_led *led;
  567. for (i = 0; i < DA850_N_BB_USER_LED; i++) {
  568. led = &da850_evm_bb_leds[i];
  569. led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
  570. led->name =
  571. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
  572. }
  573. }
  574. static int da850_evm_bb_expander_setup(struct i2c_client *client,
  575. unsigned gpio, unsigned ngpio,
  576. void *c)
  577. {
  578. int ret;
  579. /*
  580. * Register the switches and pushbutton on the baseboard as a gpio-keys
  581. * device.
  582. */
  583. da850_evm_bb_keys_init(gpio);
  584. ret = platform_device_register(&da850_evm_bb_keys_device);
  585. if (ret) {
  586. pr_warning("Could not register baseboard GPIO expander keys");
  587. goto io_exp_setup_sw_fail;
  588. }
  589. da850_evm_bb_leds_init(gpio);
  590. ret = platform_device_register(&da850_evm_bb_leds_device);
  591. if (ret) {
  592. pr_warning("Could not register baseboard GPIO expander LEDS");
  593. goto io_exp_setup_leds_fail;
  594. }
  595. return 0;
  596. io_exp_setup_leds_fail:
  597. platform_device_unregister(&da850_evm_bb_keys_device);
  598. io_exp_setup_sw_fail:
  599. return ret;
  600. }
  601. static int da850_evm_bb_expander_teardown(struct i2c_client *client,
  602. unsigned gpio, unsigned ngpio, void *c)
  603. {
  604. platform_device_unregister(&da850_evm_bb_leds_device);
  605. platform_device_unregister(&da850_evm_bb_keys_device);
  606. return 0;
  607. }
  608. static struct pca953x_platform_data da850_evm_ui_expander_info = {
  609. .gpio_base = DAVINCI_N_GPIO,
  610. .setup = da850_evm_ui_expander_setup,
  611. .teardown = da850_evm_ui_expander_teardown,
  612. .names = da850_evm_ui_exp,
  613. };
  614. static struct pca953x_platform_data da850_evm_bb_expander_info = {
  615. .gpio_base = DA850_BB_EXPANDER_GPIO_BASE,
  616. .setup = da850_evm_bb_expander_setup,
  617. .teardown = da850_evm_bb_expander_teardown,
  618. .names = da850_evm_bb_exp,
  619. };
  620. static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
  621. {
  622. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  623. },
  624. {
  625. I2C_BOARD_INFO("tca6416", 0x20),
  626. .platform_data = &da850_evm_ui_expander_info,
  627. },
  628. {
  629. I2C_BOARD_INFO("tca6416", 0x21),
  630. .platform_data = &da850_evm_bb_expander_info,
  631. },
  632. };
  633. static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
  634. .bus_freq = 100, /* kHz */
  635. .bus_delay = 0, /* usec */
  636. };
  637. static struct davinci_uart_config da850_evm_uart_config __initdata = {
  638. .enabled_uarts = 0x7,
  639. };
  640. /* davinci da850 evm audio machine driver */
  641. static u8 da850_iis_serializer_direction[] = {
  642. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  643. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  644. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  645. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  646. };
  647. static struct snd_platform_data da850_evm_snd_data = {
  648. .tx_dma_offset = 0x2000,
  649. .rx_dma_offset = 0x2000,
  650. .op_mode = DAVINCI_MCASP_IIS_MODE,
  651. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  652. .tdm_slots = 2,
  653. .serial_dir = da850_iis_serializer_direction,
  654. .asp_chan_q = EVENTQ_1,
  655. .version = MCASP_VERSION_2,
  656. .txnumevt = 1,
  657. .rxnumevt = 1,
  658. };
  659. static const short da850_evm_mcasp_pins[] __initconst = {
  660. DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
  661. DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
  662. DA850_AXR_11, DA850_AXR_12,
  663. -1
  664. };
  665. static int da850_evm_mmc_get_ro(int index)
  666. {
  667. return gpio_get_value(DA850_MMCSD_WP_PIN);
  668. }
  669. static int da850_evm_mmc_get_cd(int index)
  670. {
  671. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  672. }
  673. static struct davinci_mmc_config da850_mmc_config = {
  674. .get_ro = da850_evm_mmc_get_ro,
  675. .get_cd = da850_evm_mmc_get_cd,
  676. .wires = 4,
  677. .max_freq = 50000000,
  678. .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
  679. .version = MMC_CTLR_VERSION_2,
  680. };
  681. static const short da850_evm_mmcsd0_pins[] __initconst = {
  682. DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
  683. DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
  684. DA850_GPIO4_0, DA850_GPIO4_1,
  685. -1
  686. };
  687. static void da850_panel_power_ctrl(int val)
  688. {
  689. /* lcd backlight */
  690. gpio_set_value(DA850_LCD_BL_PIN, val);
  691. /* lcd power */
  692. gpio_set_value(DA850_LCD_PWR_PIN, val);
  693. }
  694. static int da850_lcd_hw_init(void)
  695. {
  696. int status;
  697. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  698. if (status < 0)
  699. return status;
  700. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  701. if (status < 0) {
  702. gpio_free(DA850_LCD_BL_PIN);
  703. return status;
  704. }
  705. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  706. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  707. /* Switch off panel power and backlight */
  708. da850_panel_power_ctrl(0);
  709. /* Switch on panel power and backlight */
  710. da850_panel_power_ctrl(1);
  711. return 0;
  712. }
  713. /* TPS65070 voltage regulator support */
  714. /* 3.3V */
  715. static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
  716. {
  717. .supply = "usb0_vdda33",
  718. },
  719. {
  720. .supply = "usb1_vdda33",
  721. },
  722. };
  723. /* 3.3V or 1.8V */
  724. static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
  725. {
  726. .supply = "dvdd3318_a",
  727. },
  728. {
  729. .supply = "dvdd3318_b",
  730. },
  731. {
  732. .supply = "dvdd3318_c",
  733. },
  734. };
  735. /* 1.2V */
  736. static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
  737. {
  738. .supply = "cvdd",
  739. },
  740. };
  741. /* 1.8V LDO */
  742. static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
  743. {
  744. .supply = "sata_vddr",
  745. },
  746. {
  747. .supply = "usb0_vdda18",
  748. },
  749. {
  750. .supply = "usb1_vdda18",
  751. },
  752. {
  753. .supply = "ddr_dvdd18",
  754. },
  755. };
  756. /* 1.2V LDO */
  757. static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
  758. {
  759. .supply = "sata_vdd",
  760. },
  761. {
  762. .supply = "pll0_vdda",
  763. },
  764. {
  765. .supply = "pll1_vdda",
  766. },
  767. {
  768. .supply = "usbs_cvdd",
  769. },
  770. {
  771. .supply = "vddarnwa1",
  772. },
  773. };
  774. /* We take advantage of the fact that both defdcdc{2,3} are tied high */
  775. static struct tps6507x_reg_platform_data tps6507x_platform_data = {
  776. .defdcdc_default = true,
  777. };
  778. static struct regulator_init_data tps65070_regulator_data[] = {
  779. /* dcdc1 */
  780. {
  781. .constraints = {
  782. .min_uV = 3150000,
  783. .max_uV = 3450000,
  784. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  785. REGULATOR_CHANGE_STATUS),
  786. .boot_on = 1,
  787. },
  788. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
  789. .consumer_supplies = tps65070_dcdc1_consumers,
  790. },
  791. /* dcdc2 */
  792. {
  793. .constraints = {
  794. .min_uV = 1710000,
  795. .max_uV = 3450000,
  796. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  797. REGULATOR_CHANGE_STATUS),
  798. .boot_on = 1,
  799. },
  800. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
  801. .consumer_supplies = tps65070_dcdc2_consumers,
  802. .driver_data = &tps6507x_platform_data,
  803. },
  804. /* dcdc3 */
  805. {
  806. .constraints = {
  807. .min_uV = 950000,
  808. .max_uV = 1350000,
  809. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  810. REGULATOR_CHANGE_STATUS),
  811. .boot_on = 1,
  812. },
  813. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
  814. .consumer_supplies = tps65070_dcdc3_consumers,
  815. .driver_data = &tps6507x_platform_data,
  816. },
  817. /* ldo1 */
  818. {
  819. .constraints = {
  820. .min_uV = 1710000,
  821. .max_uV = 1890000,
  822. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  823. REGULATOR_CHANGE_STATUS),
  824. .boot_on = 1,
  825. },
  826. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
  827. .consumer_supplies = tps65070_ldo1_consumers,
  828. },
  829. /* ldo2 */
  830. {
  831. .constraints = {
  832. .min_uV = 1140000,
  833. .max_uV = 1320000,
  834. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  835. REGULATOR_CHANGE_STATUS),
  836. .boot_on = 1,
  837. },
  838. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
  839. .consumer_supplies = tps65070_ldo2_consumers,
  840. },
  841. };
  842. static struct touchscreen_init_data tps6507x_touchscreen_data = {
  843. .poll_period = 30, /* ms between touch samples */
  844. .min_pressure = 0x30, /* minimum pressure to trigger touch */
  845. .vref = 0, /* turn off vref when not using A/D */
  846. .vendor = 0, /* /sys/class/input/input?/id/vendor */
  847. .product = 65070, /* /sys/class/input/input?/id/product */
  848. .version = 0x100, /* /sys/class/input/input?/id/version */
  849. };
  850. static struct tps6507x_board tps_board = {
  851. .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
  852. .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
  853. };
  854. static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
  855. {
  856. I2C_BOARD_INFO("tps6507x", 0x48),
  857. .platform_data = &tps_board,
  858. },
  859. };
  860. static int __init pmic_tps65070_init(void)
  861. {
  862. return i2c_register_board_info(1, da850_evm_tps65070_info,
  863. ARRAY_SIZE(da850_evm_tps65070_info));
  864. }
  865. static const short da850_evm_lcdc_pins[] = {
  866. DA850_GPIO2_8, DA850_GPIO2_15,
  867. -1
  868. };
  869. static const short da850_evm_mii_pins[] = {
  870. DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
  871. DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
  872. DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
  873. DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
  874. DA850_MDIO_D,
  875. -1
  876. };
  877. static const short da850_evm_rmii_pins[] = {
  878. DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
  879. DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
  880. DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
  881. DA850_MDIO_D,
  882. -1
  883. };
  884. static int __init da850_evm_config_emac(void)
  885. {
  886. void __iomem *cfg_chip3_base;
  887. int ret;
  888. u32 val;
  889. struct davinci_soc_info *soc_info = &davinci_soc_info;
  890. u8 rmii_en = soc_info->emac_pdata->rmii_en;
  891. if (!machine_is_davinci_da850_evm())
  892. return 0;
  893. cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
  894. val = __raw_readl(cfg_chip3_base);
  895. if (rmii_en) {
  896. val |= BIT(8);
  897. ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
  898. pr_info("EMAC: RMII PHY configured, MII PHY will not be"
  899. " functional\n");
  900. } else {
  901. val &= ~BIT(8);
  902. ret = davinci_cfg_reg_list(da850_evm_mii_pins);
  903. pr_info("EMAC: MII PHY configured, RMII PHY will not be"
  904. " functional\n");
  905. }
  906. if (ret)
  907. pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
  908. ret);
  909. /* configure the CFGCHIP3 register for RMII or MII */
  910. __raw_writel(val, cfg_chip3_base);
  911. ret = davinci_cfg_reg(DA850_GPIO2_6);
  912. if (ret)
  913. pr_warning("da850_evm_init:GPIO(2,6) mux setup "
  914. "failed\n");
  915. ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
  916. if (ret) {
  917. pr_warning("Cannot open GPIO %d\n",
  918. DA850_MII_MDIO_CLKEN_PIN);
  919. return ret;
  920. }
  921. /* Enable/Disable MII MDIO clock */
  922. gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
  923. soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
  924. ret = da8xx_register_emac();
  925. if (ret)
  926. pr_warning("da850_evm_init: emac registration failed: %d\n",
  927. ret);
  928. return 0;
  929. }
  930. device_initcall(da850_evm_config_emac);
  931. /*
  932. * The following EDMA channels/slots are not being used by drivers (for
  933. * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
  934. * they are being reserved for codecs on the DSP side.
  935. */
  936. static const s16 da850_dma0_rsv_chans[][2] = {
  937. /* (offset, number) */
  938. { 8, 6},
  939. {24, 4},
  940. {30, 2},
  941. {-1, -1}
  942. };
  943. static const s16 da850_dma0_rsv_slots[][2] = {
  944. /* (offset, number) */
  945. { 8, 6},
  946. {24, 4},
  947. {30, 50},
  948. {-1, -1}
  949. };
  950. static const s16 da850_dma1_rsv_chans[][2] = {
  951. /* (offset, number) */
  952. { 0, 28},
  953. {30, 2},
  954. {-1, -1}
  955. };
  956. static const s16 da850_dma1_rsv_slots[][2] = {
  957. /* (offset, number) */
  958. { 0, 28},
  959. {30, 90},
  960. {-1, -1}
  961. };
  962. static struct edma_rsv_info da850_edma_cc0_rsv = {
  963. .rsv_chans = da850_dma0_rsv_chans,
  964. .rsv_slots = da850_dma0_rsv_slots,
  965. };
  966. static struct edma_rsv_info da850_edma_cc1_rsv = {
  967. .rsv_chans = da850_dma1_rsv_chans,
  968. .rsv_slots = da850_dma1_rsv_slots,
  969. };
  970. static struct edma_rsv_info *da850_edma_rsv[2] = {
  971. &da850_edma_cc0_rsv,
  972. &da850_edma_cc1_rsv,
  973. };
  974. #ifdef CONFIG_CPU_FREQ
  975. static __init int da850_evm_init_cpufreq(void)
  976. {
  977. switch (system_rev & 0xF) {
  978. case 3:
  979. da850_max_speed = 456000;
  980. break;
  981. case 2:
  982. da850_max_speed = 408000;
  983. break;
  984. case 1:
  985. da850_max_speed = 372000;
  986. break;
  987. }
  988. return da850_register_cpufreq("pll0_sysclk3");
  989. }
  990. #else
  991. static __init int da850_evm_init_cpufreq(void) { return 0; }
  992. #endif
  993. #define DA850EVM_SATA_REFCLKPN_RATE (100 * 1000 * 1000)
  994. static __init void da850_evm_init(void)
  995. {
  996. int ret;
  997. ret = pmic_tps65070_init();
  998. if (ret)
  999. pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
  1000. ret);
  1001. ret = da850_register_edma(da850_edma_rsv);
  1002. if (ret)
  1003. pr_warning("da850_evm_init: edma registration failed: %d\n",
  1004. ret);
  1005. ret = davinci_cfg_reg_list(da850_i2c0_pins);
  1006. if (ret)
  1007. pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
  1008. ret);
  1009. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  1010. if (ret)
  1011. pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
  1012. ret);
  1013. ret = da8xx_register_watchdog();
  1014. if (ret)
  1015. pr_warning("da830_evm_init: watchdog registration failed: %d\n",
  1016. ret);
  1017. if (HAS_MMC) {
  1018. ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
  1019. if (ret)
  1020. pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
  1021. " %d\n", ret);
  1022. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  1023. if (ret)
  1024. pr_warning("da850_evm_init: can not open GPIO %d\n",
  1025. DA850_MMCSD_CD_PIN);
  1026. gpio_direction_input(DA850_MMCSD_CD_PIN);
  1027. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  1028. if (ret)
  1029. pr_warning("da850_evm_init: can not open GPIO %d\n",
  1030. DA850_MMCSD_WP_PIN);
  1031. gpio_direction_input(DA850_MMCSD_WP_PIN);
  1032. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  1033. if (ret)
  1034. pr_warning("da850_evm_init: mmcsd0 registration failed:"
  1035. " %d\n", ret);
  1036. }
  1037. davinci_serial_init(&da850_evm_uart_config);
  1038. i2c_register_board_info(1, da850_evm_i2c_devices,
  1039. ARRAY_SIZE(da850_evm_i2c_devices));
  1040. /*
  1041. * shut down uart 0 and 1; they are not used on the board and
  1042. * accessing them causes endless "too much work in irq53" messages
  1043. * with arago fs
  1044. */
  1045. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  1046. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  1047. ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
  1048. if (ret)
  1049. pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
  1050. ret);
  1051. da8xx_register_mcasp(0, &da850_evm_snd_data);
  1052. ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
  1053. if (ret)
  1054. pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
  1055. ret);
  1056. /* Handle board specific muxing for LCD here */
  1057. ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
  1058. if (ret)
  1059. pr_warning("da850_evm_init: evm specific lcd mux setup "
  1060. "failed: %d\n", ret);
  1061. ret = da850_lcd_hw_init();
  1062. if (ret)
  1063. pr_warning("da850_evm_init: lcd initialization failed: %d\n",
  1064. ret);
  1065. sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
  1066. ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
  1067. if (ret)
  1068. pr_warning("da850_evm_init: lcdc registration failed: %d\n",
  1069. ret);
  1070. ret = da8xx_register_rtc();
  1071. if (ret)
  1072. pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
  1073. ret = da850_evm_init_cpufreq();
  1074. if (ret)
  1075. pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
  1076. ret);
  1077. ret = da8xx_register_cpuidle();
  1078. if (ret)
  1079. pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
  1080. ret);
  1081. ret = da850_register_pm(&da850_pm_device);
  1082. if (ret)
  1083. pr_warning("da850_evm_init: suspend registration failed: %d\n",
  1084. ret);
  1085. ret = da8xx_register_spi(1, da850evm_spi_info,
  1086. ARRAY_SIZE(da850evm_spi_info));
  1087. if (ret)
  1088. pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
  1089. ret);
  1090. ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
  1091. if (ret)
  1092. pr_warning("da850_evm_init: sata registration failed: %d\n",
  1093. ret);
  1094. da850_evm_setup_mac_addr();
  1095. }
  1096. #ifdef CONFIG_SERIAL_8250_CONSOLE
  1097. static int __init da850_evm_console_init(void)
  1098. {
  1099. if (!machine_is_davinci_da850_evm())
  1100. return 0;
  1101. return add_preferred_console("ttyS", 2, "115200");
  1102. }
  1103. console_initcall(da850_evm_console_init);
  1104. #endif
  1105. static void __init da850_evm_map_io(void)
  1106. {
  1107. da850_init();
  1108. }
  1109. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
  1110. .atag_offset = 0x100,
  1111. .map_io = da850_evm_map_io,
  1112. .init_irq = cp_intc_init,
  1113. .timer = &davinci_timer,
  1114. .init_machine = da850_evm_init,
  1115. .dma_zone_size = SZ_128M,
  1116. MACHINE_END