board-da850-evm.c 37 KB

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