board-da850-evm.c 36 KB

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