board-da850-evm.c 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625
  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/platform_data/at24.h>
  22. #include <linux/platform_data/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/gpio-davinci.h>
  32. #include <linux/platform_data/mtd-davinci.h>
  33. #include <linux/platform_data/mtd-davinci-aemif.h>
  34. #include <linux/platform_data/spi-davinci.h>
  35. #include <linux/platform_data/uio_pruss.h>
  36. #include <linux/regulator/machine.h>
  37. #include <linux/regulator/tps6507x.h>
  38. #include <linux/regulator/fixed.h>
  39. #include <linux/spi/spi.h>
  40. #include <linux/spi/flash.h>
  41. #include <linux/wl12xx.h>
  42. #include <mach/common.h>
  43. #include <mach/cp_intc.h>
  44. #include <mach/da8xx.h>
  45. #include <mach/mux.h>
  46. #include <mach/sram.h>
  47. #include <asm/mach-types.h>
  48. #include <asm/mach/arch.h>
  49. #include <asm/system_info.h>
  50. #include <media/tvp514x.h>
  51. #include <media/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_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
  56. #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
  57. #define DA850_WLAN_EN GPIO_TO_PIN(6, 9)
  58. #define DA850_WLAN_IRQ GPIO_TO_PIN(6, 10)
  59. #define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
  60. static struct mtd_partition da850evm_spiflash_part[] = {
  61. [0] = {
  62. .name = "UBL",
  63. .offset = 0,
  64. .size = SZ_64K,
  65. .mask_flags = MTD_WRITEABLE,
  66. },
  67. [1] = {
  68. .name = "U-Boot",
  69. .offset = MTDPART_OFS_APPEND,
  70. .size = SZ_512K,
  71. .mask_flags = MTD_WRITEABLE,
  72. },
  73. [2] = {
  74. .name = "U-Boot-Env",
  75. .offset = MTDPART_OFS_APPEND,
  76. .size = SZ_64K,
  77. .mask_flags = MTD_WRITEABLE,
  78. },
  79. [3] = {
  80. .name = "Kernel",
  81. .offset = MTDPART_OFS_APPEND,
  82. .size = SZ_2M + SZ_512K,
  83. .mask_flags = 0,
  84. },
  85. [4] = {
  86. .name = "Filesystem",
  87. .offset = MTDPART_OFS_APPEND,
  88. .size = SZ_4M,
  89. .mask_flags = 0,
  90. },
  91. [5] = {
  92. .name = "MAC-Address",
  93. .offset = SZ_8M - SZ_64K,
  94. .size = SZ_64K,
  95. .mask_flags = MTD_WRITEABLE,
  96. },
  97. };
  98. static struct flash_platform_data da850evm_spiflash_data = {
  99. .name = "m25p80",
  100. .parts = da850evm_spiflash_part,
  101. .nr_parts = ARRAY_SIZE(da850evm_spiflash_part),
  102. .type = "m25p64",
  103. };
  104. static struct davinci_spi_config da850evm_spiflash_cfg = {
  105. .io_type = SPI_IO_TYPE_DMA,
  106. .c2tdelay = 8,
  107. .t2cdelay = 8,
  108. };
  109. static struct spi_board_info da850evm_spi_info[] = {
  110. {
  111. .modalias = "m25p80",
  112. .platform_data = &da850evm_spiflash_data,
  113. .controller_data = &da850evm_spiflash_cfg,
  114. .mode = SPI_MODE_0,
  115. .max_speed_hz = 30000000,
  116. .bus_num = 1,
  117. .chip_select = 0,
  118. },
  119. };
  120. #ifdef CONFIG_MTD
  121. static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
  122. {
  123. char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
  124. size_t retlen;
  125. if (!strcmp(mtd->name, "MAC-Address")) {
  126. mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
  127. if (retlen == ETH_ALEN)
  128. pr_info("Read MAC addr from SPI Flash: %pM\n",
  129. mac_addr);
  130. }
  131. }
  132. static struct mtd_notifier da850evm_spi_notifier = {
  133. .add = da850_evm_m25p80_notify_add,
  134. };
  135. static void da850_evm_setup_mac_addr(void)
  136. {
  137. register_mtd_user(&da850evm_spi_notifier);
  138. }
  139. #else
  140. static void da850_evm_setup_mac_addr(void) { }
  141. #endif
  142. static struct mtd_partition da850_evm_norflash_partition[] = {
  143. {
  144. .name = "bootloaders + env",
  145. .offset = 0,
  146. .size = SZ_512K,
  147. .mask_flags = MTD_WRITEABLE,
  148. },
  149. {
  150. .name = "kernel",
  151. .offset = MTDPART_OFS_APPEND,
  152. .size = SZ_2M,
  153. .mask_flags = 0,
  154. },
  155. {
  156. .name = "filesystem",
  157. .offset = MTDPART_OFS_APPEND,
  158. .size = MTDPART_SIZ_FULL,
  159. .mask_flags = 0,
  160. },
  161. };
  162. static struct physmap_flash_data da850_evm_norflash_data = {
  163. .width = 2,
  164. .parts = da850_evm_norflash_partition,
  165. .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
  166. };
  167. static struct resource da850_evm_norflash_resource[] = {
  168. {
  169. .start = DA8XX_AEMIF_CS2_BASE,
  170. .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
  171. .flags = IORESOURCE_MEM,
  172. },
  173. };
  174. static struct platform_device da850_evm_norflash_device = {
  175. .name = "physmap-flash",
  176. .id = 0,
  177. .dev = {
  178. .platform_data = &da850_evm_norflash_data,
  179. },
  180. .num_resources = 1,
  181. .resource = da850_evm_norflash_resource,
  182. };
  183. static struct davinci_pm_config da850_pm_pdata = {
  184. .sleepcount = 128,
  185. };
  186. static struct platform_device da850_pm_device = {
  187. .name = "pm-davinci",
  188. .dev = {
  189. .platform_data = &da850_pm_pdata,
  190. },
  191. .id = -1,
  192. };
  193. /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  194. * (128K blocks). It may be used instead of the (default) SPI flash
  195. * to boot, using TI's tools to install the secondary boot loader
  196. * (UBL) and U-Boot.
  197. */
  198. static struct mtd_partition da850_evm_nandflash_partition[] = {
  199. {
  200. .name = "u-boot env",
  201. .offset = 0,
  202. .size = SZ_128K,
  203. .mask_flags = MTD_WRITEABLE,
  204. },
  205. {
  206. .name = "UBL",
  207. .offset = MTDPART_OFS_APPEND,
  208. .size = SZ_128K,
  209. .mask_flags = MTD_WRITEABLE,
  210. },
  211. {
  212. .name = "u-boot",
  213. .offset = MTDPART_OFS_APPEND,
  214. .size = 4 * SZ_128K,
  215. .mask_flags = MTD_WRITEABLE,
  216. },
  217. {
  218. .name = "kernel",
  219. .offset = 0x200000,
  220. .size = SZ_2M,
  221. .mask_flags = 0,
  222. },
  223. {
  224. .name = "filesystem",
  225. .offset = MTDPART_OFS_APPEND,
  226. .size = MTDPART_SIZ_FULL,
  227. .mask_flags = 0,
  228. },
  229. };
  230. static struct davinci_aemif_timing da850_evm_nandflash_timing = {
  231. .wsetup = 24,
  232. .wstrobe = 21,
  233. .whold = 14,
  234. .rsetup = 19,
  235. .rstrobe = 50,
  236. .rhold = 0,
  237. .ta = 20,
  238. };
  239. static struct davinci_nand_pdata da850_evm_nandflash_data = {
  240. .parts = da850_evm_nandflash_partition,
  241. .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
  242. .ecc_mode = NAND_ECC_HW,
  243. .ecc_bits = 4,
  244. .bbt_options = NAND_BBT_USE_FLASH,
  245. .timing = &da850_evm_nandflash_timing,
  246. };
  247. static struct resource da850_evm_nandflash_resource[] = {
  248. {
  249. .start = DA8XX_AEMIF_CS3_BASE,
  250. .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
  251. .flags = IORESOURCE_MEM,
  252. },
  253. {
  254. .start = DA8XX_AEMIF_CTL_BASE,
  255. .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
  256. .flags = IORESOURCE_MEM,
  257. },
  258. };
  259. static struct platform_device da850_evm_nandflash_device = {
  260. .name = "davinci_nand",
  261. .id = 1,
  262. .dev = {
  263. .platform_data = &da850_evm_nandflash_data,
  264. },
  265. .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
  266. .resource = da850_evm_nandflash_resource,
  267. };
  268. static struct platform_device *da850_evm_devices[] = {
  269. &da850_evm_nandflash_device,
  270. &da850_evm_norflash_device,
  271. };
  272. #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
  273. #define DA8XX_AEMIF_ASIZE_16BIT 0x1
  274. static void __init da850_evm_init_nor(void)
  275. {
  276. void __iomem *aemif_addr;
  277. aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
  278. /* Configure data bus width of CS2 to 16 bit */
  279. writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
  280. DA8XX_AEMIF_ASIZE_16BIT,
  281. aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
  282. iounmap(aemif_addr);
  283. }
  284. static const short da850_evm_nand_pins[] = {
  285. DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
  286. DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
  287. DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
  288. DA850_NEMA_WE, DA850_NEMA_OE,
  289. -1
  290. };
  291. static const short da850_evm_nor_pins[] = {
  292. DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
  293. DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
  294. DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
  295. DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
  296. DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
  297. DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
  298. DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
  299. DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
  300. DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
  301. DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
  302. DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
  303. DA850_EMA_A_22, DA850_EMA_A_23,
  304. -1
  305. };
  306. #define HAS_MMC IS_ENABLED(CONFIG_MMC_DAVINCI)
  307. static inline void da850_evm_setup_nor_nand(void)
  308. {
  309. int ret = 0;
  310. if (!HAS_MMC) {
  311. ret = davinci_cfg_reg_list(da850_evm_nand_pins);
  312. if (ret)
  313. pr_warn("%s: NAND mux setup failed: %d\n",
  314. __func__, ret);
  315. ret = davinci_cfg_reg_list(da850_evm_nor_pins);
  316. if (ret)
  317. pr_warn("%s: NOR mux setup failed: %d\n",
  318. __func__, ret);
  319. da850_evm_init_nor();
  320. platform_add_devices(da850_evm_devices,
  321. ARRAY_SIZE(da850_evm_devices));
  322. if (davinci_aemif_setup(&da850_evm_nandflash_device))
  323. pr_warn("%s: Cannot configure AEMIF.\n", __func__);
  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. /* davinci da850 evm audio machine driver */
  656. static u8 da850_iis_serializer_direction[] = {
  657. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  658. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  659. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  660. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  661. };
  662. static struct snd_platform_data da850_evm_snd_data = {
  663. .tx_dma_offset = 0x2000,
  664. .rx_dma_offset = 0x2000,
  665. .op_mode = DAVINCI_MCASP_IIS_MODE,
  666. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  667. .tdm_slots = 2,
  668. .serial_dir = da850_iis_serializer_direction,
  669. .asp_chan_q = EVENTQ_0,
  670. .ram_chan_q = EVENTQ_1,
  671. .version = MCASP_VERSION_2,
  672. .txnumevt = 1,
  673. .rxnumevt = 1,
  674. .sram_size_playback = SZ_8K,
  675. .sram_size_capture = SZ_8K,
  676. };
  677. static const short da850_evm_mcasp_pins[] __initconst = {
  678. DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
  679. DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
  680. DA850_AXR_11, DA850_AXR_12,
  681. -1
  682. };
  683. static int da850_evm_mmc_get_ro(int index)
  684. {
  685. return gpio_get_value(DA850_MMCSD_WP_PIN);
  686. }
  687. static int da850_evm_mmc_get_cd(int index)
  688. {
  689. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  690. }
  691. static struct davinci_mmc_config da850_mmc_config = {
  692. .get_ro = da850_evm_mmc_get_ro,
  693. .get_cd = da850_evm_mmc_get_cd,
  694. .wires = 4,
  695. .max_freq = 50000000,
  696. .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
  697. };
  698. static const short da850_evm_mmcsd0_pins[] __initconst = {
  699. DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
  700. DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
  701. DA850_GPIO4_0, DA850_GPIO4_1,
  702. -1
  703. };
  704. static void da850_panel_power_ctrl(int val)
  705. {
  706. /* lcd backlight */
  707. gpio_set_value(DA850_LCD_BL_PIN, val);
  708. /* lcd power */
  709. gpio_set_value(DA850_LCD_PWR_PIN, val);
  710. }
  711. static int da850_lcd_hw_init(void)
  712. {
  713. int status;
  714. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  715. if (status < 0)
  716. return status;
  717. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  718. if (status < 0) {
  719. gpio_free(DA850_LCD_BL_PIN);
  720. return status;
  721. }
  722. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  723. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  724. /* Switch off panel power and backlight */
  725. da850_panel_power_ctrl(0);
  726. /* Switch on panel power and backlight */
  727. da850_panel_power_ctrl(1);
  728. return 0;
  729. }
  730. /* Fixed regulator support */
  731. static struct regulator_consumer_supply fixed_supplies[] = {
  732. /* Baseboard 3.3V: 5V -> TPS73701DCQ -> 3.3V */
  733. REGULATOR_SUPPLY("AVDD", "1-0018"),
  734. REGULATOR_SUPPLY("DRVDD", "1-0018"),
  735. /* Baseboard 1.8V: 5V -> TPS73701DCQ -> 1.8V */
  736. REGULATOR_SUPPLY("DVDD", "1-0018"),
  737. };
  738. /* TPS65070 voltage regulator support */
  739. /* 3.3V */
  740. static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
  741. {
  742. .supply = "usb0_vdda33",
  743. },
  744. {
  745. .supply = "usb1_vdda33",
  746. },
  747. };
  748. /* 3.3V or 1.8V */
  749. static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
  750. {
  751. .supply = "dvdd3318_a",
  752. },
  753. {
  754. .supply = "dvdd3318_b",
  755. },
  756. {
  757. .supply = "dvdd3318_c",
  758. },
  759. REGULATOR_SUPPLY("IOVDD", "1-0018"),
  760. };
  761. /* 1.2V */
  762. static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
  763. {
  764. .supply = "cvdd",
  765. },
  766. };
  767. /* 1.8V LDO */
  768. static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
  769. {
  770. .supply = "sata_vddr",
  771. },
  772. {
  773. .supply = "usb0_vdda18",
  774. },
  775. {
  776. .supply = "usb1_vdda18",
  777. },
  778. {
  779. .supply = "ddr_dvdd18",
  780. },
  781. };
  782. /* 1.2V LDO */
  783. static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
  784. {
  785. .supply = "sata_vdd",
  786. },
  787. {
  788. .supply = "pll0_vdda",
  789. },
  790. {
  791. .supply = "pll1_vdda",
  792. },
  793. {
  794. .supply = "usbs_cvdd",
  795. },
  796. {
  797. .supply = "vddarnwa1",
  798. },
  799. };
  800. /* We take advantage of the fact that both defdcdc{2,3} are tied high */
  801. static struct tps6507x_reg_platform_data tps6507x_platform_data = {
  802. .defdcdc_default = true,
  803. };
  804. static struct regulator_init_data tps65070_regulator_data[] = {
  805. /* dcdc1 */
  806. {
  807. .constraints = {
  808. .min_uV = 3150000,
  809. .max_uV = 3450000,
  810. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  811. REGULATOR_CHANGE_STATUS),
  812. .boot_on = 1,
  813. },
  814. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
  815. .consumer_supplies = tps65070_dcdc1_consumers,
  816. },
  817. /* dcdc2 */
  818. {
  819. .constraints = {
  820. .min_uV = 1710000,
  821. .max_uV = 3450000,
  822. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  823. REGULATOR_CHANGE_STATUS),
  824. .boot_on = 1,
  825. .always_on = 1,
  826. },
  827. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
  828. .consumer_supplies = tps65070_dcdc2_consumers,
  829. .driver_data = &tps6507x_platform_data,
  830. },
  831. /* dcdc3 */
  832. {
  833. .constraints = {
  834. .min_uV = 950000,
  835. .max_uV = 1350000,
  836. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  837. REGULATOR_CHANGE_STATUS),
  838. .boot_on = 1,
  839. },
  840. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
  841. .consumer_supplies = tps65070_dcdc3_consumers,
  842. .driver_data = &tps6507x_platform_data,
  843. },
  844. /* ldo1 */
  845. {
  846. .constraints = {
  847. .min_uV = 1710000,
  848. .max_uV = 1890000,
  849. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  850. REGULATOR_CHANGE_STATUS),
  851. .boot_on = 1,
  852. },
  853. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
  854. .consumer_supplies = tps65070_ldo1_consumers,
  855. },
  856. /* ldo2 */
  857. {
  858. .constraints = {
  859. .min_uV = 1140000,
  860. .max_uV = 1320000,
  861. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  862. REGULATOR_CHANGE_STATUS),
  863. .boot_on = 1,
  864. },
  865. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
  866. .consumer_supplies = tps65070_ldo2_consumers,
  867. },
  868. };
  869. static struct touchscreen_init_data tps6507x_touchscreen_data = {
  870. .poll_period = 30, /* ms between touch samples */
  871. .min_pressure = 0x30, /* minimum pressure to trigger touch */
  872. .vendor = 0, /* /sys/class/input/input?/id/vendor */
  873. .product = 65070, /* /sys/class/input/input?/id/product */
  874. .version = 0x100, /* /sys/class/input/input?/id/version */
  875. };
  876. static struct tps6507x_board tps_board = {
  877. .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
  878. .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
  879. };
  880. static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
  881. {
  882. I2C_BOARD_INFO("tps6507x", 0x48),
  883. .platform_data = &tps_board,
  884. },
  885. };
  886. static int __init pmic_tps65070_init(void)
  887. {
  888. return i2c_register_board_info(1, da850_evm_tps65070_info,
  889. ARRAY_SIZE(da850_evm_tps65070_info));
  890. }
  891. static const short da850_evm_lcdc_pins[] = {
  892. DA850_GPIO2_8, DA850_GPIO2_15,
  893. -1
  894. };
  895. static const short da850_evm_mii_pins[] = {
  896. DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
  897. DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
  898. DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
  899. DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
  900. DA850_MDIO_D,
  901. -1
  902. };
  903. static const short da850_evm_rmii_pins[] = {
  904. DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
  905. DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
  906. DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
  907. DA850_MDIO_D,
  908. -1
  909. };
  910. static int __init da850_evm_config_emac(void)
  911. {
  912. void __iomem *cfg_chip3_base;
  913. int ret;
  914. u32 val;
  915. struct davinci_soc_info *soc_info = &davinci_soc_info;
  916. u8 rmii_en = soc_info->emac_pdata->rmii_en;
  917. if (!machine_is_davinci_da850_evm())
  918. return 0;
  919. cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
  920. val = __raw_readl(cfg_chip3_base);
  921. if (rmii_en) {
  922. val |= BIT(8);
  923. ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
  924. pr_info("EMAC: RMII PHY configured, MII PHY will not be"
  925. " functional\n");
  926. } else {
  927. val &= ~BIT(8);
  928. ret = davinci_cfg_reg_list(da850_evm_mii_pins);
  929. pr_info("EMAC: MII PHY configured, RMII PHY will not be"
  930. " functional\n");
  931. }
  932. if (ret)
  933. pr_warn("%s: CPGMAC/RMII mux setup failed: %d\n",
  934. __func__, ret);
  935. /* configure the CFGCHIP3 register for RMII or MII */
  936. __raw_writel(val, cfg_chip3_base);
  937. ret = davinci_cfg_reg(DA850_GPIO2_6);
  938. if (ret)
  939. pr_warn("%s:GPIO(2,6) mux setup failed\n", __func__);
  940. ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
  941. if (ret) {
  942. pr_warn("Cannot open GPIO %d\n", DA850_MII_MDIO_CLKEN_PIN);
  943. return ret;
  944. }
  945. /* Enable/Disable MII MDIO clock */
  946. gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
  947. soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
  948. ret = da8xx_register_emac();
  949. if (ret)
  950. pr_warn("%s: EMAC registration failed: %d\n", __func__, ret);
  951. return 0;
  952. }
  953. device_initcall(da850_evm_config_emac);
  954. /*
  955. * The following EDMA channels/slots are not being used by drivers (for
  956. * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
  957. * they are being reserved for codecs on the DSP side.
  958. */
  959. static const s16 da850_dma0_rsv_chans[][2] = {
  960. /* (offset, number) */
  961. { 8, 6},
  962. {24, 4},
  963. {30, 2},
  964. {-1, -1}
  965. };
  966. static const s16 da850_dma0_rsv_slots[][2] = {
  967. /* (offset, number) */
  968. { 8, 6},
  969. {24, 4},
  970. {30, 50},
  971. {-1, -1}
  972. };
  973. static const s16 da850_dma1_rsv_chans[][2] = {
  974. /* (offset, number) */
  975. { 0, 28},
  976. {30, 2},
  977. {-1, -1}
  978. };
  979. static const s16 da850_dma1_rsv_slots[][2] = {
  980. /* (offset, number) */
  981. { 0, 28},
  982. {30, 90},
  983. {-1, -1}
  984. };
  985. static struct edma_rsv_info da850_edma_cc0_rsv = {
  986. .rsv_chans = da850_dma0_rsv_chans,
  987. .rsv_slots = da850_dma0_rsv_slots,
  988. };
  989. static struct edma_rsv_info da850_edma_cc1_rsv = {
  990. .rsv_chans = da850_dma1_rsv_chans,
  991. .rsv_slots = da850_dma1_rsv_slots,
  992. };
  993. static struct edma_rsv_info *da850_edma_rsv[2] = {
  994. &da850_edma_cc0_rsv,
  995. &da850_edma_cc1_rsv,
  996. };
  997. #ifdef CONFIG_CPU_FREQ
  998. static __init int da850_evm_init_cpufreq(void)
  999. {
  1000. switch (system_rev & 0xF) {
  1001. case 3:
  1002. da850_max_speed = 456000;
  1003. break;
  1004. case 2:
  1005. da850_max_speed = 408000;
  1006. break;
  1007. case 1:
  1008. da850_max_speed = 372000;
  1009. break;
  1010. }
  1011. return da850_register_cpufreq("pll0_sysclk3");
  1012. }
  1013. #else
  1014. static __init int da850_evm_init_cpufreq(void) { return 0; }
  1015. #endif
  1016. #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
  1017. #define TVP5147_CH0 "tvp514x-0"
  1018. #define TVP5147_CH1 "tvp514x-1"
  1019. /* VPIF capture configuration */
  1020. static struct tvp514x_platform_data tvp5146_pdata = {
  1021. .clk_polarity = 0,
  1022. .hs_polarity = 1,
  1023. .vs_polarity = 1,
  1024. };
  1025. #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
  1026. static const struct vpif_input da850_ch0_inputs[] = {
  1027. {
  1028. .input = {
  1029. .index = 0,
  1030. .name = "Composite",
  1031. .type = V4L2_INPUT_TYPE_CAMERA,
  1032. .capabilities = V4L2_IN_CAP_STD,
  1033. .std = TVP514X_STD_ALL,
  1034. },
  1035. .input_route = INPUT_CVBS_VI2B,
  1036. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  1037. .subdev_name = TVP5147_CH0,
  1038. },
  1039. };
  1040. static const struct vpif_input da850_ch1_inputs[] = {
  1041. {
  1042. .input = {
  1043. .index = 0,
  1044. .name = "S-Video",
  1045. .type = V4L2_INPUT_TYPE_CAMERA,
  1046. .capabilities = V4L2_IN_CAP_STD,
  1047. .std = TVP514X_STD_ALL,
  1048. },
  1049. .input_route = INPUT_SVIDEO_VI2C_VI1C,
  1050. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  1051. .subdev_name = TVP5147_CH1,
  1052. },
  1053. };
  1054. static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
  1055. {
  1056. .name = TVP5147_CH0,
  1057. .board_info = {
  1058. I2C_BOARD_INFO("tvp5146", 0x5d),
  1059. .platform_data = &tvp5146_pdata,
  1060. },
  1061. },
  1062. {
  1063. .name = TVP5147_CH1,
  1064. .board_info = {
  1065. I2C_BOARD_INFO("tvp5146", 0x5c),
  1066. .platform_data = &tvp5146_pdata,
  1067. },
  1068. },
  1069. };
  1070. static struct vpif_capture_config da850_vpif_capture_config = {
  1071. .subdev_info = da850_vpif_capture_sdev_info,
  1072. .subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
  1073. .chan_config[0] = {
  1074. .inputs = da850_ch0_inputs,
  1075. .input_count = ARRAY_SIZE(da850_ch0_inputs),
  1076. .vpif_if = {
  1077. .if_type = VPIF_IF_BT656,
  1078. .hd_pol = 1,
  1079. .vd_pol = 1,
  1080. .fid_pol = 0,
  1081. },
  1082. },
  1083. .chan_config[1] = {
  1084. .inputs = da850_ch1_inputs,
  1085. .input_count = ARRAY_SIZE(da850_ch1_inputs),
  1086. .vpif_if = {
  1087. .if_type = VPIF_IF_BT656,
  1088. .hd_pol = 1,
  1089. .vd_pol = 1,
  1090. .fid_pol = 0,
  1091. },
  1092. },
  1093. .card_name = "DA850/OMAP-L138 Video Capture",
  1094. };
  1095. /* VPIF display configuration */
  1096. static struct adv7343_platform_data adv7343_pdata = {
  1097. .mode_config = {
  1098. .dac = { 1, 1, 1 },
  1099. },
  1100. .sd_config = {
  1101. .sd_dac_out = { 1 },
  1102. },
  1103. };
  1104. static struct vpif_subdev_info da850_vpif_subdev[] = {
  1105. {
  1106. .name = "adv7343",
  1107. .board_info = {
  1108. I2C_BOARD_INFO("adv7343", 0x2a),
  1109. .platform_data = &adv7343_pdata,
  1110. },
  1111. },
  1112. };
  1113. static const struct vpif_output da850_ch0_outputs[] = {
  1114. {
  1115. .output = {
  1116. .index = 0,
  1117. .name = "Composite",
  1118. .type = V4L2_OUTPUT_TYPE_ANALOG,
  1119. .capabilities = V4L2_OUT_CAP_STD,
  1120. .std = V4L2_STD_ALL,
  1121. },
  1122. .subdev_name = "adv7343",
  1123. .output_route = ADV7343_COMPOSITE_ID,
  1124. },
  1125. {
  1126. .output = {
  1127. .index = 1,
  1128. .name = "S-Video",
  1129. .type = V4L2_OUTPUT_TYPE_ANALOG,
  1130. .capabilities = V4L2_OUT_CAP_STD,
  1131. .std = V4L2_STD_ALL,
  1132. },
  1133. .subdev_name = "adv7343",
  1134. .output_route = ADV7343_SVIDEO_ID,
  1135. },
  1136. };
  1137. static struct vpif_display_config da850_vpif_display_config = {
  1138. .subdevinfo = da850_vpif_subdev,
  1139. .subdev_count = ARRAY_SIZE(da850_vpif_subdev),
  1140. .chan_config[0] = {
  1141. .outputs = da850_ch0_outputs,
  1142. .output_count = ARRAY_SIZE(da850_ch0_outputs),
  1143. },
  1144. .card_name = "DA850/OMAP-L138 Video Display",
  1145. };
  1146. static __init void da850_vpif_init(void)
  1147. {
  1148. int ret;
  1149. ret = da850_register_vpif();
  1150. if (ret)
  1151. pr_warn("da850_evm_init: VPIF setup failed: %d\n", ret);
  1152. ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
  1153. if (ret)
  1154. pr_warn("da850_evm_init: VPIF capture mux setup failed: %d\n",
  1155. ret);
  1156. ret = da850_register_vpif_capture(&da850_vpif_capture_config);
  1157. if (ret)
  1158. pr_warn("da850_evm_init: VPIF capture setup failed: %d\n", ret);
  1159. ret = davinci_cfg_reg_list(da850_vpif_display_pins);
  1160. if (ret)
  1161. pr_warn("da850_evm_init: VPIF display mux setup failed: %d\n",
  1162. ret);
  1163. ret = da850_register_vpif_display(&da850_vpif_display_config);
  1164. if (ret)
  1165. pr_warn("da850_evm_init: VPIF display setup failed: %d\n", ret);
  1166. }
  1167. #else
  1168. static __init void da850_vpif_init(void) {}
  1169. #endif
  1170. #ifdef CONFIG_DA850_WL12XX
  1171. static void wl12xx_set_power(int index, bool power_on)
  1172. {
  1173. static bool power_state;
  1174. pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
  1175. if (power_on == power_state)
  1176. return;
  1177. power_state = power_on;
  1178. if (power_on) {
  1179. /* Power up sequence required for wl127x devices */
  1180. gpio_set_value(DA850_WLAN_EN, 1);
  1181. usleep_range(15000, 15000);
  1182. gpio_set_value(DA850_WLAN_EN, 0);
  1183. usleep_range(1000, 1000);
  1184. gpio_set_value(DA850_WLAN_EN, 1);
  1185. msleep(70);
  1186. } else {
  1187. gpio_set_value(DA850_WLAN_EN, 0);
  1188. }
  1189. }
  1190. static struct davinci_mmc_config da850_wl12xx_mmc_config = {
  1191. .set_power = wl12xx_set_power,
  1192. .wires = 4,
  1193. .max_freq = 25000000,
  1194. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
  1195. MMC_CAP_POWER_OFF_CARD,
  1196. };
  1197. static const short da850_wl12xx_pins[] __initconst = {
  1198. DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
  1199. DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
  1200. DA850_GPIO6_9, DA850_GPIO6_10,
  1201. -1
  1202. };
  1203. static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
  1204. .irq = -1,
  1205. .board_ref_clock = WL12XX_REFCLOCK_38,
  1206. .platform_quirks = WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
  1207. };
  1208. static __init int da850_wl12xx_init(void)
  1209. {
  1210. int ret;
  1211. ret = davinci_cfg_reg_list(da850_wl12xx_pins);
  1212. if (ret) {
  1213. pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
  1214. goto exit;
  1215. }
  1216. ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
  1217. if (ret) {
  1218. pr_err("wl12xx/mmc registration failed: %d\n", ret);
  1219. goto exit;
  1220. }
  1221. ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
  1222. if (ret) {
  1223. pr_err("Could not request wl12xx enable gpio: %d\n", ret);
  1224. goto exit;
  1225. }
  1226. ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
  1227. if (ret) {
  1228. pr_err("Could not request wl12xx irq gpio: %d\n", ret);
  1229. goto free_wlan_en;
  1230. }
  1231. da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
  1232. ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
  1233. if (ret) {
  1234. pr_err("Could not set wl12xx data: %d\n", ret);
  1235. goto free_wlan_irq;
  1236. }
  1237. return 0;
  1238. free_wlan_irq:
  1239. gpio_free(DA850_WLAN_IRQ);
  1240. free_wlan_en:
  1241. gpio_free(DA850_WLAN_EN);
  1242. exit:
  1243. return ret;
  1244. }
  1245. #else /* CONFIG_DA850_WL12XX */
  1246. static __init int da850_wl12xx_init(void)
  1247. {
  1248. return 0;
  1249. }
  1250. #endif /* CONFIG_DA850_WL12XX */
  1251. #define DA850EVM_SATA_REFCLKPN_RATE (100 * 1000 * 1000)
  1252. static __init void da850_evm_init(void)
  1253. {
  1254. int ret;
  1255. ret = da850_register_gpio();
  1256. if (ret)
  1257. pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
  1258. regulator_register_fixed(0, fixed_supplies, ARRAY_SIZE(fixed_supplies));
  1259. ret = pmic_tps65070_init();
  1260. if (ret)
  1261. pr_warn("%s: TPS65070 PMIC init failed: %d\n", __func__, ret);
  1262. ret = da850_register_edma(da850_edma_rsv);
  1263. if (ret)
  1264. pr_warn("%s: EDMA registration failed: %d\n", __func__, ret);
  1265. ret = davinci_cfg_reg_list(da850_i2c0_pins);
  1266. if (ret)
  1267. pr_warn("%s: I2C0 mux setup failed: %d\n", __func__, ret);
  1268. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  1269. if (ret)
  1270. pr_warn("%s: I2C0 registration failed: %d\n", __func__, ret);
  1271. ret = da8xx_register_watchdog();
  1272. if (ret)
  1273. pr_warn("%s: watchdog registration failed: %d\n",
  1274. __func__, ret);
  1275. if (HAS_MMC) {
  1276. ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
  1277. if (ret)
  1278. pr_warn("%s: MMCSD0 mux setup failed: %d\n",
  1279. __func__, ret);
  1280. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  1281. if (ret)
  1282. pr_warn("%s: can not open GPIO %d\n",
  1283. __func__, DA850_MMCSD_CD_PIN);
  1284. gpio_direction_input(DA850_MMCSD_CD_PIN);
  1285. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  1286. if (ret)
  1287. pr_warn("%s: can not open GPIO %d\n",
  1288. __func__, DA850_MMCSD_WP_PIN);
  1289. gpio_direction_input(DA850_MMCSD_WP_PIN);
  1290. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  1291. if (ret)
  1292. pr_warn("%s: MMCSD0 registration failed: %d\n",
  1293. __func__, ret);
  1294. ret = da850_wl12xx_init();
  1295. if (ret)
  1296. pr_warn("%s: WL12xx initialization failed: %d\n",
  1297. __func__, ret);
  1298. }
  1299. davinci_serial_init(da8xx_serial_device);
  1300. i2c_register_board_info(1, da850_evm_i2c_devices,
  1301. ARRAY_SIZE(da850_evm_i2c_devices));
  1302. /*
  1303. * shut down uart 0 and 1; they are not used on the board and
  1304. * accessing them causes endless "too much work in irq53" messages
  1305. * with arago fs
  1306. */
  1307. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  1308. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  1309. ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
  1310. if (ret)
  1311. pr_warn("%s: McASP mux setup failed: %d\n", __func__, ret);
  1312. da850_evm_snd_data.sram_pool = sram_get_gen_pool();
  1313. da8xx_register_mcasp(0, &da850_evm_snd_data);
  1314. ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
  1315. if (ret)
  1316. pr_warn("%s: LCDC mux setup failed: %d\n", __func__, ret);
  1317. ret = da8xx_register_uio_pruss();
  1318. if (ret)
  1319. pr_warn("da850_evm_init: pruss initialization failed: %d\n",
  1320. ret);
  1321. /* Handle board specific muxing for LCD here */
  1322. ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
  1323. if (ret)
  1324. pr_warn("%s: EVM specific LCD mux setup failed: %d\n",
  1325. __func__, ret);
  1326. ret = da850_lcd_hw_init();
  1327. if (ret)
  1328. pr_warn("%s: LCD initialization failed: %d\n", __func__, ret);
  1329. sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
  1330. ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
  1331. if (ret)
  1332. pr_warn("%s: LCDC registration failed: %d\n", __func__, ret);
  1333. ret = da8xx_register_rtc();
  1334. if (ret)
  1335. pr_warn("%s: RTC setup failed: %d\n", __func__, ret);
  1336. ret = da850_evm_init_cpufreq();
  1337. if (ret)
  1338. pr_warn("%s: cpufreq registration failed: %d\n", __func__, ret);
  1339. ret = da8xx_register_cpuidle();
  1340. if (ret)
  1341. pr_warn("%s: cpuidle registration failed: %d\n", __func__, ret);
  1342. ret = da850_register_pm(&da850_pm_device);
  1343. if (ret)
  1344. pr_warn("%s: suspend registration failed: %d\n", __func__, ret);
  1345. da850_vpif_init();
  1346. ret = spi_register_board_info(da850evm_spi_info,
  1347. ARRAY_SIZE(da850evm_spi_info));
  1348. if (ret)
  1349. pr_warn("%s: spi info registration failed: %d\n", __func__,
  1350. ret);
  1351. ret = da8xx_register_spi_bus(1, ARRAY_SIZE(da850evm_spi_info));
  1352. if (ret)
  1353. pr_warn("%s: SPI 1 registration failed: %d\n", __func__, ret);
  1354. ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
  1355. if (ret)
  1356. pr_warn("%s: SATA registration failed: %d\n", __func__, ret);
  1357. da850_evm_setup_mac_addr();
  1358. ret = da8xx_register_rproc();
  1359. if (ret)
  1360. pr_warn("%s: dsp/rproc registration failed: %d\n",
  1361. __func__, ret);
  1362. }
  1363. #ifdef CONFIG_SERIAL_8250_CONSOLE
  1364. static int __init da850_evm_console_init(void)
  1365. {
  1366. if (!machine_is_davinci_da850_evm())
  1367. return 0;
  1368. return add_preferred_console("ttyS", 2, "115200");
  1369. }
  1370. console_initcall(da850_evm_console_init);
  1371. #endif
  1372. static void __init da850_evm_map_io(void)
  1373. {
  1374. da850_init();
  1375. }
  1376. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
  1377. .atag_offset = 0x100,
  1378. .map_io = da850_evm_map_io,
  1379. .init_irq = cp_intc_init,
  1380. .init_time = davinci_timer_init,
  1381. .init_machine = da850_evm_init,
  1382. .init_late = davinci_init_late,
  1383. .dma_zone_size = SZ_128M,
  1384. .restart = da8xx_restart,
  1385. .reserve = da8xx_rproc_reserve_cma,
  1386. MACHINE_END