board-da850-evm.c 38 KB

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