board-da850-evm.c 36 KB

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