board-da850-evm.c 36 KB

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