board-da850-evm.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602
  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/i2c/at24.h>
  22. #include <linux/i2c/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/mtd-davinci.h>
  32. #include <linux/platform_data/mtd-davinci-aemif.h>
  33. #include <linux/platform_data/spi-davinci.h>
  34. #include <linux/platform_data/uio_pruss.h>
  35. #include <linux/regulator/machine.h>
  36. #include <linux/regulator/tps6507x.h>
  37. #include <linux/spi/spi.h>
  38. #include <linux/spi/flash.h>
  39. #include <linux/wl12xx.h>
  40. #include <mach/cp_intc.h>
  41. #include <mach/da8xx.h>
  42. #include <mach/mux.h>
  43. #include <asm/mach-types.h>
  44. #include <asm/mach/arch.h>
  45. #include <asm/system_info.h>
  46. #include <media/tvp514x.h>
  47. #include <media/adv7343.h>
  48. #define DA850_EVM_PHY_ID "davinci_mdio-0:00"
  49. #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
  50. #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
  51. #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
  52. #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
  53. #define DA850_WLAN_EN GPIO_TO_PIN(6, 9)
  54. #define DA850_WLAN_IRQ GPIO_TO_PIN(6, 10)
  55. #define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
  56. static struct mtd_partition da850evm_spiflash_part[] = {
  57. [0] = {
  58. .name = "UBL",
  59. .offset = 0,
  60. .size = SZ_64K,
  61. .mask_flags = MTD_WRITEABLE,
  62. },
  63. [1] = {
  64. .name = "U-Boot",
  65. .offset = MTDPART_OFS_APPEND,
  66. .size = SZ_512K,
  67. .mask_flags = MTD_WRITEABLE,
  68. },
  69. [2] = {
  70. .name = "U-Boot-Env",
  71. .offset = MTDPART_OFS_APPEND,
  72. .size = SZ_64K,
  73. .mask_flags = MTD_WRITEABLE,
  74. },
  75. [3] = {
  76. .name = "Kernel",
  77. .offset = MTDPART_OFS_APPEND,
  78. .size = SZ_2M + SZ_512K,
  79. .mask_flags = 0,
  80. },
  81. [4] = {
  82. .name = "Filesystem",
  83. .offset = MTDPART_OFS_APPEND,
  84. .size = SZ_4M,
  85. .mask_flags = 0,
  86. },
  87. [5] = {
  88. .name = "MAC-Address",
  89. .offset = SZ_8M - SZ_64K,
  90. .size = SZ_64K,
  91. .mask_flags = MTD_WRITEABLE,
  92. },
  93. };
  94. static struct flash_platform_data da850evm_spiflash_data = {
  95. .name = "m25p80",
  96. .parts = da850evm_spiflash_part,
  97. .nr_parts = ARRAY_SIZE(da850evm_spiflash_part),
  98. .type = "m25p64",
  99. };
  100. static struct davinci_spi_config da850evm_spiflash_cfg = {
  101. .io_type = SPI_IO_TYPE_DMA,
  102. .c2tdelay = 8,
  103. .t2cdelay = 8,
  104. };
  105. static struct spi_board_info da850evm_spi_info[] = {
  106. {
  107. .modalias = "m25p80",
  108. .platform_data = &da850evm_spiflash_data,
  109. .controller_data = &da850evm_spiflash_cfg,
  110. .mode = SPI_MODE_0,
  111. .max_speed_hz = 30000000,
  112. .bus_num = 1,
  113. .chip_select = 0,
  114. },
  115. };
  116. #ifdef CONFIG_MTD
  117. static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
  118. {
  119. char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
  120. size_t retlen;
  121. if (!strcmp(mtd->name, "MAC-Address")) {
  122. mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
  123. if (retlen == ETH_ALEN)
  124. pr_info("Read MAC addr from SPI Flash: %pM\n",
  125. mac_addr);
  126. }
  127. }
  128. static struct mtd_notifier da850evm_spi_notifier = {
  129. .add = da850_evm_m25p80_notify_add,
  130. };
  131. static void da850_evm_setup_mac_addr(void)
  132. {
  133. register_mtd_user(&da850evm_spi_notifier);
  134. }
  135. #else
  136. static void da850_evm_setup_mac_addr(void) { }
  137. #endif
  138. static struct mtd_partition da850_evm_norflash_partition[] = {
  139. {
  140. .name = "bootloaders + env",
  141. .offset = 0,
  142. .size = SZ_512K,
  143. .mask_flags = MTD_WRITEABLE,
  144. },
  145. {
  146. .name = "kernel",
  147. .offset = MTDPART_OFS_APPEND,
  148. .size = SZ_2M,
  149. .mask_flags = 0,
  150. },
  151. {
  152. .name = "filesystem",
  153. .offset = MTDPART_OFS_APPEND,
  154. .size = MTDPART_SIZ_FULL,
  155. .mask_flags = 0,
  156. },
  157. };
  158. static struct physmap_flash_data da850_evm_norflash_data = {
  159. .width = 2,
  160. .parts = da850_evm_norflash_partition,
  161. .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
  162. };
  163. static struct resource da850_evm_norflash_resource[] = {
  164. {
  165. .start = DA8XX_AEMIF_CS2_BASE,
  166. .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
  167. .flags = IORESOURCE_MEM,
  168. },
  169. };
  170. static struct platform_device da850_evm_norflash_device = {
  171. .name = "physmap-flash",
  172. .id = 0,
  173. .dev = {
  174. .platform_data = &da850_evm_norflash_data,
  175. },
  176. .num_resources = 1,
  177. .resource = da850_evm_norflash_resource,
  178. };
  179. static struct davinci_pm_config da850_pm_pdata = {
  180. .sleepcount = 128,
  181. };
  182. static struct platform_device da850_pm_device = {
  183. .name = "pm-davinci",
  184. .dev = {
  185. .platform_data = &da850_pm_pdata,
  186. },
  187. .id = -1,
  188. };
  189. /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  190. * (128K blocks). It may be used instead of the (default) SPI flash
  191. * to boot, using TI's tools to install the secondary boot loader
  192. * (UBL) and U-Boot.
  193. */
  194. static struct mtd_partition da850_evm_nandflash_partition[] = {
  195. {
  196. .name = "u-boot env",
  197. .offset = 0,
  198. .size = SZ_128K,
  199. .mask_flags = MTD_WRITEABLE,
  200. },
  201. {
  202. .name = "UBL",
  203. .offset = MTDPART_OFS_APPEND,
  204. .size = SZ_128K,
  205. .mask_flags = MTD_WRITEABLE,
  206. },
  207. {
  208. .name = "u-boot",
  209. .offset = MTDPART_OFS_APPEND,
  210. .size = 4 * SZ_128K,
  211. .mask_flags = MTD_WRITEABLE,
  212. },
  213. {
  214. .name = "kernel",
  215. .offset = 0x200000,
  216. .size = SZ_2M,
  217. .mask_flags = 0,
  218. },
  219. {
  220. .name = "filesystem",
  221. .offset = MTDPART_OFS_APPEND,
  222. .size = MTDPART_SIZ_FULL,
  223. .mask_flags = 0,
  224. },
  225. };
  226. static struct davinci_aemif_timing da850_evm_nandflash_timing = {
  227. .wsetup = 24,
  228. .wstrobe = 21,
  229. .whold = 14,
  230. .rsetup = 19,
  231. .rstrobe = 50,
  232. .rhold = 0,
  233. .ta = 20,
  234. };
  235. static struct davinci_nand_pdata da850_evm_nandflash_data = {
  236. .parts = da850_evm_nandflash_partition,
  237. .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
  238. .ecc_mode = NAND_ECC_HW,
  239. .ecc_bits = 4,
  240. .bbt_options = NAND_BBT_USE_FLASH,
  241. .timing = &da850_evm_nandflash_timing,
  242. };
  243. static struct resource da850_evm_nandflash_resource[] = {
  244. {
  245. .start = DA8XX_AEMIF_CS3_BASE,
  246. .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
  247. .flags = IORESOURCE_MEM,
  248. },
  249. {
  250. .start = DA8XX_AEMIF_CTL_BASE,
  251. .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
  252. .flags = IORESOURCE_MEM,
  253. },
  254. };
  255. static struct platform_device da850_evm_nandflash_device = {
  256. .name = "davinci_nand",
  257. .id = 1,
  258. .dev = {
  259. .platform_data = &da850_evm_nandflash_data,
  260. },
  261. .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
  262. .resource = da850_evm_nandflash_resource,
  263. };
  264. static struct platform_device *da850_evm_devices[] = {
  265. &da850_evm_nandflash_device,
  266. &da850_evm_norflash_device,
  267. };
  268. #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
  269. #define DA8XX_AEMIF_ASIZE_16BIT 0x1
  270. static void __init da850_evm_init_nor(void)
  271. {
  272. void __iomem *aemif_addr;
  273. aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
  274. /* Configure data bus width of CS2 to 16 bit */
  275. writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
  276. DA8XX_AEMIF_ASIZE_16BIT,
  277. aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
  278. iounmap(aemif_addr);
  279. }
  280. static const short da850_evm_nand_pins[] = {
  281. DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
  282. DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
  283. DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
  284. DA850_NEMA_WE, DA850_NEMA_OE,
  285. -1
  286. };
  287. static const short da850_evm_nor_pins[] = {
  288. DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
  289. DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
  290. DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
  291. DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
  292. DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
  293. DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
  294. DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
  295. DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
  296. DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
  297. DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
  298. DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
  299. DA850_EMA_A_22, DA850_EMA_A_23,
  300. -1
  301. };
  302. #if defined(CONFIG_MMC_DAVINCI) || \
  303. defined(CONFIG_MMC_DAVINCI_MODULE)
  304. #define HAS_MMC 1
  305. #else
  306. #define HAS_MMC 0
  307. #endif
  308. static inline void da850_evm_setup_nor_nand(void)
  309. {
  310. int ret = 0;
  311. if (!HAS_MMC) {
  312. ret = davinci_cfg_reg_list(da850_evm_nand_pins);
  313. if (ret)
  314. pr_warning("da850_evm_init: nand mux setup failed: "
  315. "%d\n", ret);
  316. ret = davinci_cfg_reg_list(da850_evm_nor_pins);
  317. if (ret)
  318. pr_warning("da850_evm_init: nor mux setup failed: %d\n",
  319. ret);
  320. da850_evm_init_nor();
  321. platform_add_devices(da850_evm_devices,
  322. ARRAY_SIZE(da850_evm_devices));
  323. }
  324. }
  325. #ifdef CONFIG_DA850_UI_RMII
  326. static inline void da850_evm_setup_emac_rmii(int rmii_sel)
  327. {
  328. struct davinci_soc_info *soc_info = &davinci_soc_info;
  329. soc_info->emac_pdata->rmii_en = 1;
  330. gpio_set_value_cansleep(rmii_sel, 0);
  331. }
  332. #else
  333. static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
  334. #endif
  335. #define DA850_KEYS_DEBOUNCE_MS 10
  336. /*
  337. * At 200ms polling interval it is possible to miss an
  338. * event by tapping very lightly on the push button but most
  339. * pushes do result in an event; longer intervals require the
  340. * user to hold the button whereas shorter intervals require
  341. * more CPU time for polling.
  342. */
  343. #define DA850_GPIO_KEYS_POLL_MS 200
  344. enum da850_evm_ui_exp_pins {
  345. DA850_EVM_UI_EXP_SEL_C = 5,
  346. DA850_EVM_UI_EXP_SEL_B,
  347. DA850_EVM_UI_EXP_SEL_A,
  348. DA850_EVM_UI_EXP_PB8,
  349. DA850_EVM_UI_EXP_PB7,
  350. DA850_EVM_UI_EXP_PB6,
  351. DA850_EVM_UI_EXP_PB5,
  352. DA850_EVM_UI_EXP_PB4,
  353. DA850_EVM_UI_EXP_PB3,
  354. DA850_EVM_UI_EXP_PB2,
  355. DA850_EVM_UI_EXP_PB1,
  356. };
  357. static const char const *da850_evm_ui_exp[] = {
  358. [DA850_EVM_UI_EXP_SEL_C] = "sel_c",
  359. [DA850_EVM_UI_EXP_SEL_B] = "sel_b",
  360. [DA850_EVM_UI_EXP_SEL_A] = "sel_a",
  361. [DA850_EVM_UI_EXP_PB8] = "pb8",
  362. [DA850_EVM_UI_EXP_PB7] = "pb7",
  363. [DA850_EVM_UI_EXP_PB6] = "pb6",
  364. [DA850_EVM_UI_EXP_PB5] = "pb5",
  365. [DA850_EVM_UI_EXP_PB4] = "pb4",
  366. [DA850_EVM_UI_EXP_PB3] = "pb3",
  367. [DA850_EVM_UI_EXP_PB2] = "pb2",
  368. [DA850_EVM_UI_EXP_PB1] = "pb1",
  369. };
  370. #define DA850_N_UI_PB 8
  371. static struct gpio_keys_button da850_evm_ui_keys[] = {
  372. [0 ... DA850_N_UI_PB - 1] = {
  373. .type = EV_KEY,
  374. .active_low = 1,
  375. .wakeup = 0,
  376. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  377. .code = -1, /* assigned at runtime */
  378. .gpio = -1, /* assigned at runtime */
  379. .desc = NULL, /* assigned at runtime */
  380. },
  381. };
  382. static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
  383. .buttons = da850_evm_ui_keys,
  384. .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
  385. .poll_interval = DA850_GPIO_KEYS_POLL_MS,
  386. };
  387. static struct platform_device da850_evm_ui_keys_device = {
  388. .name = "gpio-keys-polled",
  389. .id = 0,
  390. .dev = {
  391. .platform_data = &da850_evm_ui_keys_pdata
  392. },
  393. };
  394. static void da850_evm_ui_keys_init(unsigned gpio)
  395. {
  396. int i;
  397. struct gpio_keys_button *button;
  398. for (i = 0; i < DA850_N_UI_PB; i++) {
  399. button = &da850_evm_ui_keys[i];
  400. button->code = KEY_F8 - i;
  401. button->desc = (char *)
  402. da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
  403. button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
  404. }
  405. }
  406. #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT
  407. static inline void da850_evm_setup_video_port(int video_sel)
  408. {
  409. gpio_set_value_cansleep(video_sel, 0);
  410. }
  411. #else
  412. static inline void da850_evm_setup_video_port(int video_sel) { }
  413. #endif
  414. static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
  415. unsigned ngpio, void *c)
  416. {
  417. int sel_a, sel_b, sel_c, ret;
  418. sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
  419. sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
  420. sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
  421. ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
  422. if (ret) {
  423. pr_warning("Cannot open UI expander pin %d\n", sel_a);
  424. goto exp_setup_sela_fail;
  425. }
  426. ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
  427. if (ret) {
  428. pr_warning("Cannot open UI expander pin %d\n", sel_b);
  429. goto exp_setup_selb_fail;
  430. }
  431. ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
  432. if (ret) {
  433. pr_warning("Cannot open UI expander pin %d\n", sel_c);
  434. goto exp_setup_selc_fail;
  435. }
  436. /* deselect all functionalities */
  437. gpio_direction_output(sel_a, 1);
  438. gpio_direction_output(sel_b, 1);
  439. gpio_direction_output(sel_c, 1);
  440. da850_evm_ui_keys_init(gpio);
  441. ret = platform_device_register(&da850_evm_ui_keys_device);
  442. if (ret) {
  443. pr_warning("Could not register UI GPIO expander push-buttons");
  444. goto exp_setup_keys_fail;
  445. }
  446. pr_info("DA850/OMAP-L138 EVM UI card detected\n");
  447. da850_evm_setup_nor_nand();
  448. da850_evm_setup_emac_rmii(sel_a);
  449. da850_evm_setup_video_port(sel_c);
  450. return 0;
  451. exp_setup_keys_fail:
  452. gpio_free(sel_c);
  453. exp_setup_selc_fail:
  454. gpio_free(sel_b);
  455. exp_setup_selb_fail:
  456. gpio_free(sel_a);
  457. exp_setup_sela_fail:
  458. return ret;
  459. }
  460. static int da850_evm_ui_expander_teardown(struct i2c_client *client,
  461. unsigned gpio, unsigned ngpio, void *c)
  462. {
  463. platform_device_unregister(&da850_evm_ui_keys_device);
  464. /* deselect all functionalities */
  465. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
  466. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
  467. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
  468. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
  469. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
  470. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
  471. return 0;
  472. }
  473. /* assign the baseboard expander's GPIOs after the UI board's */
  474. #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
  475. #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
  476. enum da850_evm_bb_exp_pins {
  477. DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
  478. DA850_EVM_BB_EXP_SW_RST,
  479. DA850_EVM_BB_EXP_TP_23,
  480. DA850_EVM_BB_EXP_TP_22,
  481. DA850_EVM_BB_EXP_TP_21,
  482. DA850_EVM_BB_EXP_USER_PB1,
  483. DA850_EVM_BB_EXP_USER_LED2,
  484. DA850_EVM_BB_EXP_USER_LED1,
  485. DA850_EVM_BB_EXP_USER_SW1,
  486. DA850_EVM_BB_EXP_USER_SW2,
  487. DA850_EVM_BB_EXP_USER_SW3,
  488. DA850_EVM_BB_EXP_USER_SW4,
  489. DA850_EVM_BB_EXP_USER_SW5,
  490. DA850_EVM_BB_EXP_USER_SW6,
  491. DA850_EVM_BB_EXP_USER_SW7,
  492. DA850_EVM_BB_EXP_USER_SW8
  493. };
  494. static const char const *da850_evm_bb_exp[] = {
  495. [DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en",
  496. [DA850_EVM_BB_EXP_SW_RST] = "sw_rst",
  497. [DA850_EVM_BB_EXP_TP_23] = "tp_23",
  498. [DA850_EVM_BB_EXP_TP_22] = "tp_22",
  499. [DA850_EVM_BB_EXP_TP_21] = "tp_21",
  500. [DA850_EVM_BB_EXP_USER_PB1] = "user_pb1",
  501. [DA850_EVM_BB_EXP_USER_LED2] = "user_led2",
  502. [DA850_EVM_BB_EXP_USER_LED1] = "user_led1",
  503. [DA850_EVM_BB_EXP_USER_SW1] = "user_sw1",
  504. [DA850_EVM_BB_EXP_USER_SW2] = "user_sw2",
  505. [DA850_EVM_BB_EXP_USER_SW3] = "user_sw3",
  506. [DA850_EVM_BB_EXP_USER_SW4] = "user_sw4",
  507. [DA850_EVM_BB_EXP_USER_SW5] = "user_sw5",
  508. [DA850_EVM_BB_EXP_USER_SW6] = "user_sw6",
  509. [DA850_EVM_BB_EXP_USER_SW7] = "user_sw7",
  510. [DA850_EVM_BB_EXP_USER_SW8] = "user_sw8",
  511. };
  512. #define DA850_N_BB_USER_SW 8
  513. static struct gpio_keys_button da850_evm_bb_keys[] = {
  514. [0] = {
  515. .type = EV_KEY,
  516. .active_low = 1,
  517. .wakeup = 0,
  518. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  519. .code = KEY_PROG1,
  520. .desc = NULL, /* assigned at runtime */
  521. .gpio = -1, /* assigned at runtime */
  522. },
  523. [1 ... DA850_N_BB_USER_SW] = {
  524. .type = EV_SW,
  525. .active_low = 1,
  526. .wakeup = 0,
  527. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  528. .code = -1, /* assigned at runtime */
  529. .desc = NULL, /* assigned at runtime */
  530. .gpio = -1, /* assigned at runtime */
  531. },
  532. };
  533. static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
  534. .buttons = da850_evm_bb_keys,
  535. .nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
  536. .poll_interval = DA850_GPIO_KEYS_POLL_MS,
  537. };
  538. static struct platform_device da850_evm_bb_keys_device = {
  539. .name = "gpio-keys-polled",
  540. .id = 1,
  541. .dev = {
  542. .platform_data = &da850_evm_bb_keys_pdata
  543. },
  544. };
  545. static void da850_evm_bb_keys_init(unsigned gpio)
  546. {
  547. int i;
  548. struct gpio_keys_button *button;
  549. button = &da850_evm_bb_keys[0];
  550. button->desc = (char *)
  551. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
  552. button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
  553. for (i = 0; i < DA850_N_BB_USER_SW; i++) {
  554. button = &da850_evm_bb_keys[i + 1];
  555. button->code = SW_LID + i;
  556. button->desc = (char *)
  557. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
  558. button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
  559. }
  560. }
  561. #define DA850_N_BB_USER_LED 2
  562. static struct gpio_led da850_evm_bb_leds[] = {
  563. [0 ... DA850_N_BB_USER_LED - 1] = {
  564. .active_low = 1,
  565. .gpio = -1, /* assigned at runtime */
  566. .name = NULL, /* assigned at runtime */
  567. },
  568. };
  569. static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
  570. .leds = da850_evm_bb_leds,
  571. .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
  572. };
  573. static struct platform_device da850_evm_bb_leds_device = {
  574. .name = "leds-gpio",
  575. .id = -1,
  576. .dev = {
  577. .platform_data = &da850_evm_bb_leds_pdata
  578. }
  579. };
  580. static void da850_evm_bb_leds_init(unsigned gpio)
  581. {
  582. int i;
  583. struct gpio_led *led;
  584. for (i = 0; i < DA850_N_BB_USER_LED; i++) {
  585. led = &da850_evm_bb_leds[i];
  586. led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
  587. led->name =
  588. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
  589. }
  590. }
  591. static int da850_evm_bb_expander_setup(struct i2c_client *client,
  592. unsigned gpio, unsigned ngpio,
  593. void *c)
  594. {
  595. int ret;
  596. /*
  597. * Register the switches and pushbutton on the baseboard as a gpio-keys
  598. * device.
  599. */
  600. da850_evm_bb_keys_init(gpio);
  601. ret = platform_device_register(&da850_evm_bb_keys_device);
  602. if (ret) {
  603. pr_warning("Could not register baseboard GPIO expander keys");
  604. goto io_exp_setup_sw_fail;
  605. }
  606. da850_evm_bb_leds_init(gpio);
  607. ret = platform_device_register(&da850_evm_bb_leds_device);
  608. if (ret) {
  609. pr_warning("Could not register baseboard GPIO expander LEDS");
  610. goto io_exp_setup_leds_fail;
  611. }
  612. return 0;
  613. io_exp_setup_leds_fail:
  614. platform_device_unregister(&da850_evm_bb_keys_device);
  615. io_exp_setup_sw_fail:
  616. return ret;
  617. }
  618. static int da850_evm_bb_expander_teardown(struct i2c_client *client,
  619. unsigned gpio, unsigned ngpio, void *c)
  620. {
  621. platform_device_unregister(&da850_evm_bb_leds_device);
  622. platform_device_unregister(&da850_evm_bb_keys_device);
  623. return 0;
  624. }
  625. static struct pca953x_platform_data da850_evm_ui_expander_info = {
  626. .gpio_base = DAVINCI_N_GPIO,
  627. .setup = da850_evm_ui_expander_setup,
  628. .teardown = da850_evm_ui_expander_teardown,
  629. .names = da850_evm_ui_exp,
  630. };
  631. static struct pca953x_platform_data da850_evm_bb_expander_info = {
  632. .gpio_base = DA850_BB_EXPANDER_GPIO_BASE,
  633. .setup = da850_evm_bb_expander_setup,
  634. .teardown = da850_evm_bb_expander_teardown,
  635. .names = da850_evm_bb_exp,
  636. };
  637. static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
  638. {
  639. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  640. },
  641. {
  642. I2C_BOARD_INFO("tca6416", 0x20),
  643. .platform_data = &da850_evm_ui_expander_info,
  644. },
  645. {
  646. I2C_BOARD_INFO("tca6416", 0x21),
  647. .platform_data = &da850_evm_bb_expander_info,
  648. },
  649. };
  650. static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
  651. .bus_freq = 100, /* kHz */
  652. .bus_delay = 0, /* usec */
  653. };
  654. static struct davinci_uart_config da850_evm_uart_config __initdata = {
  655. .enabled_uarts = 0x7,
  656. };
  657. /* davinci da850 evm audio machine driver */
  658. static u8 da850_iis_serializer_direction[] = {
  659. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  660. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  661. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  662. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  663. };
  664. static struct snd_platform_data da850_evm_snd_data = {
  665. .tx_dma_offset = 0x2000,
  666. .rx_dma_offset = 0x2000,
  667. .op_mode = DAVINCI_MCASP_IIS_MODE,
  668. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  669. .tdm_slots = 2,
  670. .serial_dir = da850_iis_serializer_direction,
  671. .asp_chan_q = EVENTQ_0,
  672. .version = MCASP_VERSION_2,
  673. .txnumevt = 1,
  674. .rxnumevt = 1,
  675. };
  676. static const short da850_evm_mcasp_pins[] __initconst = {
  677. DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
  678. DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
  679. DA850_AXR_11, DA850_AXR_12,
  680. -1
  681. };
  682. static int da850_evm_mmc_get_ro(int index)
  683. {
  684. return gpio_get_value(DA850_MMCSD_WP_PIN);
  685. }
  686. static int da850_evm_mmc_get_cd(int index)
  687. {
  688. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  689. }
  690. static struct davinci_mmc_config da850_mmc_config = {
  691. .get_ro = da850_evm_mmc_get_ro,
  692. .get_cd = da850_evm_mmc_get_cd,
  693. .wires = 4,
  694. .max_freq = 50000000,
  695. .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
  696. .version = MMC_CTLR_VERSION_2,
  697. };
  698. static const short da850_evm_mmcsd0_pins[] __initconst = {
  699. DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
  700. DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
  701. DA850_GPIO4_0, DA850_GPIO4_1,
  702. -1
  703. };
  704. static void da850_panel_power_ctrl(int val)
  705. {
  706. /* lcd backlight */
  707. gpio_set_value(DA850_LCD_BL_PIN, val);
  708. /* lcd power */
  709. gpio_set_value(DA850_LCD_PWR_PIN, val);
  710. }
  711. static int da850_lcd_hw_init(void)
  712. {
  713. int status;
  714. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  715. if (status < 0)
  716. return status;
  717. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  718. if (status < 0) {
  719. gpio_free(DA850_LCD_BL_PIN);
  720. return status;
  721. }
  722. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  723. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  724. /* Switch off panel power and backlight */
  725. da850_panel_power_ctrl(0);
  726. /* Switch on panel power and backlight */
  727. da850_panel_power_ctrl(1);
  728. return 0;
  729. }
  730. /* TPS65070 voltage regulator support */
  731. /* 3.3V */
  732. static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
  733. {
  734. .supply = "usb0_vdda33",
  735. },
  736. {
  737. .supply = "usb1_vdda33",
  738. },
  739. };
  740. /* 3.3V or 1.8V */
  741. static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
  742. {
  743. .supply = "dvdd3318_a",
  744. },
  745. {
  746. .supply = "dvdd3318_b",
  747. },
  748. {
  749. .supply = "dvdd3318_c",
  750. },
  751. };
  752. /* 1.2V */
  753. static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
  754. {
  755. .supply = "cvdd",
  756. },
  757. };
  758. /* 1.8V LDO */
  759. static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
  760. {
  761. .supply = "sata_vddr",
  762. },
  763. {
  764. .supply = "usb0_vdda18",
  765. },
  766. {
  767. .supply = "usb1_vdda18",
  768. },
  769. {
  770. .supply = "ddr_dvdd18",
  771. },
  772. };
  773. /* 1.2V LDO */
  774. static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
  775. {
  776. .supply = "sata_vdd",
  777. },
  778. {
  779. .supply = "pll0_vdda",
  780. },
  781. {
  782. .supply = "pll1_vdda",
  783. },
  784. {
  785. .supply = "usbs_cvdd",
  786. },
  787. {
  788. .supply = "vddarnwa1",
  789. },
  790. };
  791. /* We take advantage of the fact that both defdcdc{2,3} are tied high */
  792. static struct tps6507x_reg_platform_data tps6507x_platform_data = {
  793. .defdcdc_default = true,
  794. };
  795. static struct regulator_init_data tps65070_regulator_data[] = {
  796. /* dcdc1 */
  797. {
  798. .constraints = {
  799. .min_uV = 3150000,
  800. .max_uV = 3450000,
  801. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  802. REGULATOR_CHANGE_STATUS),
  803. .boot_on = 1,
  804. },
  805. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
  806. .consumer_supplies = tps65070_dcdc1_consumers,
  807. },
  808. /* dcdc2 */
  809. {
  810. .constraints = {
  811. .min_uV = 1710000,
  812. .max_uV = 3450000,
  813. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  814. REGULATOR_CHANGE_STATUS),
  815. .boot_on = 1,
  816. },
  817. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
  818. .consumer_supplies = tps65070_dcdc2_consumers,
  819. .driver_data = &tps6507x_platform_data,
  820. },
  821. /* dcdc3 */
  822. {
  823. .constraints = {
  824. .min_uV = 950000,
  825. .max_uV = 1350000,
  826. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  827. REGULATOR_CHANGE_STATUS),
  828. .boot_on = 1,
  829. },
  830. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
  831. .consumer_supplies = tps65070_dcdc3_consumers,
  832. .driver_data = &tps6507x_platform_data,
  833. },
  834. /* ldo1 */
  835. {
  836. .constraints = {
  837. .min_uV = 1710000,
  838. .max_uV = 1890000,
  839. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  840. REGULATOR_CHANGE_STATUS),
  841. .boot_on = 1,
  842. },
  843. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
  844. .consumer_supplies = tps65070_ldo1_consumers,
  845. },
  846. /* ldo2 */
  847. {
  848. .constraints = {
  849. .min_uV = 1140000,
  850. .max_uV = 1320000,
  851. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  852. REGULATOR_CHANGE_STATUS),
  853. .boot_on = 1,
  854. },
  855. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
  856. .consumer_supplies = tps65070_ldo2_consumers,
  857. },
  858. };
  859. static struct touchscreen_init_data tps6507x_touchscreen_data = {
  860. .poll_period = 30, /* ms between touch samples */
  861. .min_pressure = 0x30, /* minimum pressure to trigger touch */
  862. .vref = 0, /* turn off vref when not using A/D */
  863. .vendor = 0, /* /sys/class/input/input?/id/vendor */
  864. .product = 65070, /* /sys/class/input/input?/id/product */
  865. .version = 0x100, /* /sys/class/input/input?/id/version */
  866. };
  867. static struct tps6507x_board tps_board = {
  868. .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
  869. .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
  870. };
  871. static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
  872. {
  873. I2C_BOARD_INFO("tps6507x", 0x48),
  874. .platform_data = &tps_board,
  875. },
  876. };
  877. static int __init pmic_tps65070_init(void)
  878. {
  879. return i2c_register_board_info(1, da850_evm_tps65070_info,
  880. ARRAY_SIZE(da850_evm_tps65070_info));
  881. }
  882. static const short da850_evm_lcdc_pins[] = {
  883. DA850_GPIO2_8, DA850_GPIO2_15,
  884. -1
  885. };
  886. static const short da850_evm_mii_pins[] = {
  887. DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
  888. DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
  889. DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
  890. DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
  891. DA850_MDIO_D,
  892. -1
  893. };
  894. static const short da850_evm_rmii_pins[] = {
  895. DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
  896. DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
  897. DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
  898. DA850_MDIO_D,
  899. -1
  900. };
  901. static int __init da850_evm_config_emac(void)
  902. {
  903. void __iomem *cfg_chip3_base;
  904. int ret;
  905. u32 val;
  906. struct davinci_soc_info *soc_info = &davinci_soc_info;
  907. u8 rmii_en = soc_info->emac_pdata->rmii_en;
  908. if (!machine_is_davinci_da850_evm())
  909. return 0;
  910. cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
  911. val = __raw_readl(cfg_chip3_base);
  912. if (rmii_en) {
  913. val |= BIT(8);
  914. ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
  915. pr_info("EMAC: RMII PHY configured, MII PHY will not be"
  916. " functional\n");
  917. } else {
  918. val &= ~BIT(8);
  919. ret = davinci_cfg_reg_list(da850_evm_mii_pins);
  920. pr_info("EMAC: MII PHY configured, RMII PHY will not be"
  921. " functional\n");
  922. }
  923. if (ret)
  924. pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
  925. ret);
  926. /* configure the CFGCHIP3 register for RMII or MII */
  927. __raw_writel(val, cfg_chip3_base);
  928. ret = davinci_cfg_reg(DA850_GPIO2_6);
  929. if (ret)
  930. pr_warning("da850_evm_init:GPIO(2,6) mux setup "
  931. "failed\n");
  932. ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
  933. if (ret) {
  934. pr_warning("Cannot open GPIO %d\n",
  935. DA850_MII_MDIO_CLKEN_PIN);
  936. return ret;
  937. }
  938. /* Enable/Disable MII MDIO clock */
  939. gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
  940. soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
  941. ret = da8xx_register_emac();
  942. if (ret)
  943. pr_warning("da850_evm_init: emac registration failed: %d\n",
  944. 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 vpif_subdev_info da850_vpif_subdev[] = {
  1091. {
  1092. .name = "adv7343",
  1093. .board_info = {
  1094. I2C_BOARD_INFO("adv7343", 0x2a),
  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. };
  1131. static __init void da850_vpif_init(void)
  1132. {
  1133. int ret;
  1134. ret = da850_register_vpif();
  1135. if (ret)
  1136. pr_warn("da850_evm_init: VPIF setup failed: %d\n", ret);
  1137. ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
  1138. if (ret)
  1139. pr_warn("da850_evm_init: VPIF capture mux setup failed: %d\n",
  1140. ret);
  1141. ret = da850_register_vpif_capture(&da850_vpif_capture_config);
  1142. if (ret)
  1143. pr_warn("da850_evm_init: VPIF capture setup failed: %d\n", ret);
  1144. ret = davinci_cfg_reg_list(da850_vpif_display_pins);
  1145. if (ret)
  1146. pr_warn("da850_evm_init: VPIF display mux setup failed: %d\n",
  1147. ret);
  1148. ret = da850_register_vpif_display(&da850_vpif_display_config);
  1149. if (ret)
  1150. pr_warn("da850_evm_init: VPIF display setup failed: %d\n", ret);
  1151. }
  1152. #else
  1153. static __init void da850_vpif_init(void) {}
  1154. #endif
  1155. #ifdef CONFIG_DA850_WL12XX
  1156. static void wl12xx_set_power(int index, bool power_on)
  1157. {
  1158. static bool power_state;
  1159. pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
  1160. if (power_on == power_state)
  1161. return;
  1162. power_state = power_on;
  1163. if (power_on) {
  1164. /* Power up sequence required for wl127x devices */
  1165. gpio_set_value(DA850_WLAN_EN, 1);
  1166. usleep_range(15000, 15000);
  1167. gpio_set_value(DA850_WLAN_EN, 0);
  1168. usleep_range(1000, 1000);
  1169. gpio_set_value(DA850_WLAN_EN, 1);
  1170. msleep(70);
  1171. } else {
  1172. gpio_set_value(DA850_WLAN_EN, 0);
  1173. }
  1174. }
  1175. static struct davinci_mmc_config da850_wl12xx_mmc_config = {
  1176. .set_power = wl12xx_set_power,
  1177. .wires = 4,
  1178. .max_freq = 25000000,
  1179. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
  1180. MMC_CAP_POWER_OFF_CARD,
  1181. .version = MMC_CTLR_VERSION_2,
  1182. };
  1183. static const short da850_wl12xx_pins[] __initconst = {
  1184. DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
  1185. DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
  1186. DA850_GPIO6_9, DA850_GPIO6_10,
  1187. -1
  1188. };
  1189. static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
  1190. .irq = -1,
  1191. .board_ref_clock = WL12XX_REFCLOCK_38,
  1192. .platform_quirks = WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
  1193. };
  1194. static __init int da850_wl12xx_init(void)
  1195. {
  1196. int ret;
  1197. ret = davinci_cfg_reg_list(da850_wl12xx_pins);
  1198. if (ret) {
  1199. pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
  1200. goto exit;
  1201. }
  1202. ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
  1203. if (ret) {
  1204. pr_err("wl12xx/mmc registration failed: %d\n", ret);
  1205. goto exit;
  1206. }
  1207. ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
  1208. if (ret) {
  1209. pr_err("Could not request wl12xx enable gpio: %d\n", ret);
  1210. goto exit;
  1211. }
  1212. ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
  1213. if (ret) {
  1214. pr_err("Could not request wl12xx irq gpio: %d\n", ret);
  1215. goto free_wlan_en;
  1216. }
  1217. da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
  1218. ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
  1219. if (ret) {
  1220. pr_err("Could not set wl12xx data: %d\n", ret);
  1221. goto free_wlan_irq;
  1222. }
  1223. return 0;
  1224. free_wlan_irq:
  1225. gpio_free(DA850_WLAN_IRQ);
  1226. free_wlan_en:
  1227. gpio_free(DA850_WLAN_EN);
  1228. exit:
  1229. return ret;
  1230. }
  1231. #else /* CONFIG_DA850_WL12XX */
  1232. static __init int da850_wl12xx_init(void)
  1233. {
  1234. return 0;
  1235. }
  1236. #endif /* CONFIG_DA850_WL12XX */
  1237. #define DA850EVM_SATA_REFCLKPN_RATE (100 * 1000 * 1000)
  1238. static __init void da850_evm_init(void)
  1239. {
  1240. int ret;
  1241. ret = pmic_tps65070_init();
  1242. if (ret)
  1243. pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
  1244. ret);
  1245. ret = da850_register_edma(da850_edma_rsv);
  1246. if (ret)
  1247. pr_warning("da850_evm_init: edma registration failed: %d\n",
  1248. ret);
  1249. ret = davinci_cfg_reg_list(da850_i2c0_pins);
  1250. if (ret)
  1251. pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
  1252. ret);
  1253. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  1254. if (ret)
  1255. pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
  1256. ret);
  1257. ret = da8xx_register_watchdog();
  1258. if (ret)
  1259. pr_warning("da830_evm_init: watchdog registration failed: %d\n",
  1260. ret);
  1261. if (HAS_MMC) {
  1262. ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
  1263. if (ret)
  1264. pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
  1265. " %d\n", ret);
  1266. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  1267. if (ret)
  1268. pr_warning("da850_evm_init: can not open GPIO %d\n",
  1269. DA850_MMCSD_CD_PIN);
  1270. gpio_direction_input(DA850_MMCSD_CD_PIN);
  1271. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  1272. if (ret)
  1273. pr_warning("da850_evm_init: can not open GPIO %d\n",
  1274. DA850_MMCSD_WP_PIN);
  1275. gpio_direction_input(DA850_MMCSD_WP_PIN);
  1276. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  1277. if (ret)
  1278. pr_warning("da850_evm_init: mmcsd0 registration failed:"
  1279. " %d\n", ret);
  1280. ret = da850_wl12xx_init();
  1281. if (ret)
  1282. pr_warning("da850_evm_init: wl12xx initialization"
  1283. " failed: %d\n", ret);
  1284. }
  1285. davinci_serial_init(&da850_evm_uart_config);
  1286. i2c_register_board_info(1, da850_evm_i2c_devices,
  1287. ARRAY_SIZE(da850_evm_i2c_devices));
  1288. /*
  1289. * shut down uart 0 and 1; they are not used on the board and
  1290. * accessing them causes endless "too much work in irq53" messages
  1291. * with arago fs
  1292. */
  1293. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  1294. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  1295. ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
  1296. if (ret)
  1297. pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
  1298. ret);
  1299. da8xx_register_mcasp(0, &da850_evm_snd_data);
  1300. ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
  1301. if (ret)
  1302. pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
  1303. ret);
  1304. ret = da8xx_register_uio_pruss();
  1305. if (ret)
  1306. pr_warn("da850_evm_init: pruss initialization failed: %d\n",
  1307. ret);
  1308. /* Handle board specific muxing for LCD here */
  1309. ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
  1310. if (ret)
  1311. pr_warning("da850_evm_init: evm specific lcd mux setup "
  1312. "failed: %d\n", ret);
  1313. ret = da850_lcd_hw_init();
  1314. if (ret)
  1315. pr_warning("da850_evm_init: lcd initialization failed: %d\n",
  1316. ret);
  1317. sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
  1318. ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
  1319. if (ret)
  1320. pr_warning("da850_evm_init: lcdc registration failed: %d\n",
  1321. ret);
  1322. ret = da8xx_register_rtc();
  1323. if (ret)
  1324. pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
  1325. ret = da850_evm_init_cpufreq();
  1326. if (ret)
  1327. pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
  1328. ret);
  1329. ret = da8xx_register_cpuidle();
  1330. if (ret)
  1331. pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
  1332. ret);
  1333. ret = da850_register_pm(&da850_pm_device);
  1334. if (ret)
  1335. pr_warning("da850_evm_init: suspend registration failed: %d\n",
  1336. ret);
  1337. da850_vpif_init();
  1338. ret = da8xx_register_spi(1, da850evm_spi_info,
  1339. ARRAY_SIZE(da850evm_spi_info));
  1340. if (ret)
  1341. pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
  1342. ret);
  1343. ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
  1344. if (ret)
  1345. pr_warning("da850_evm_init: sata registration failed: %d\n",
  1346. ret);
  1347. da850_evm_setup_mac_addr();
  1348. }
  1349. #ifdef CONFIG_SERIAL_8250_CONSOLE
  1350. static int __init da850_evm_console_init(void)
  1351. {
  1352. if (!machine_is_davinci_da850_evm())
  1353. return 0;
  1354. return add_preferred_console("ttyS", 2, "115200");
  1355. }
  1356. console_initcall(da850_evm_console_init);
  1357. #endif
  1358. static void __init da850_evm_map_io(void)
  1359. {
  1360. da850_init();
  1361. }
  1362. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
  1363. .atag_offset = 0x100,
  1364. .map_io = da850_evm_map_io,
  1365. .init_irq = cp_intc_init,
  1366. .timer = &davinci_timer,
  1367. .init_machine = da850_evm_init,
  1368. .init_late = davinci_init_late,
  1369. .dma_zone_size = SZ_128M,
  1370. .restart = da8xx_restart,
  1371. MACHINE_END