board-da850-evm.c 38 KB

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