board-da850-evm.c 34 KB

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