board-da850-evm.c 31 KB

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