board-da850-evm.c 37 KB

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