board-da850-evm.c 38 KB

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