board-da850-evm.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608
  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 <mach/sram.h>
  44. #include <asm/mach-types.h>
  45. #include <asm/mach/arch.h>
  46. #include <asm/system_info.h>
  47. #include <media/tvp514x.h>
  48. #include <media/adv7343.h>
  49. #define DA850_EVM_PHY_ID "davinci_mdio-0:00"
  50. #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
  51. #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
  52. #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
  53. #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
  54. #define DA850_WLAN_EN GPIO_TO_PIN(6, 9)
  55. #define DA850_WLAN_IRQ GPIO_TO_PIN(6, 10)
  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. }
  320. }
  321. #ifdef CONFIG_DA850_UI_RMII
  322. static inline void da850_evm_setup_emac_rmii(int rmii_sel)
  323. {
  324. struct davinci_soc_info *soc_info = &davinci_soc_info;
  325. soc_info->emac_pdata->rmii_en = 1;
  326. gpio_set_value_cansleep(rmii_sel, 0);
  327. }
  328. #else
  329. static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
  330. #endif
  331. #define DA850_KEYS_DEBOUNCE_MS 10
  332. /*
  333. * At 200ms polling interval it is possible to miss an
  334. * event by tapping very lightly on the push button but most
  335. * pushes do result in an event; longer intervals require the
  336. * user to hold the button whereas shorter intervals require
  337. * more CPU time for polling.
  338. */
  339. #define DA850_GPIO_KEYS_POLL_MS 200
  340. enum da850_evm_ui_exp_pins {
  341. DA850_EVM_UI_EXP_SEL_C = 5,
  342. DA850_EVM_UI_EXP_SEL_B,
  343. DA850_EVM_UI_EXP_SEL_A,
  344. DA850_EVM_UI_EXP_PB8,
  345. DA850_EVM_UI_EXP_PB7,
  346. DA850_EVM_UI_EXP_PB6,
  347. DA850_EVM_UI_EXP_PB5,
  348. DA850_EVM_UI_EXP_PB4,
  349. DA850_EVM_UI_EXP_PB3,
  350. DA850_EVM_UI_EXP_PB2,
  351. DA850_EVM_UI_EXP_PB1,
  352. };
  353. static const char * const da850_evm_ui_exp[] = {
  354. [DA850_EVM_UI_EXP_SEL_C] = "sel_c",
  355. [DA850_EVM_UI_EXP_SEL_B] = "sel_b",
  356. [DA850_EVM_UI_EXP_SEL_A] = "sel_a",
  357. [DA850_EVM_UI_EXP_PB8] = "pb8",
  358. [DA850_EVM_UI_EXP_PB7] = "pb7",
  359. [DA850_EVM_UI_EXP_PB6] = "pb6",
  360. [DA850_EVM_UI_EXP_PB5] = "pb5",
  361. [DA850_EVM_UI_EXP_PB4] = "pb4",
  362. [DA850_EVM_UI_EXP_PB3] = "pb3",
  363. [DA850_EVM_UI_EXP_PB2] = "pb2",
  364. [DA850_EVM_UI_EXP_PB1] = "pb1",
  365. };
  366. #define DA850_N_UI_PB 8
  367. static struct gpio_keys_button da850_evm_ui_keys[] = {
  368. [0 ... DA850_N_UI_PB - 1] = {
  369. .type = EV_KEY,
  370. .active_low = 1,
  371. .wakeup = 0,
  372. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  373. .code = -1, /* assigned at runtime */
  374. .gpio = -1, /* assigned at runtime */
  375. .desc = NULL, /* assigned at runtime */
  376. },
  377. };
  378. static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
  379. .buttons = da850_evm_ui_keys,
  380. .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
  381. .poll_interval = DA850_GPIO_KEYS_POLL_MS,
  382. };
  383. static struct platform_device da850_evm_ui_keys_device = {
  384. .name = "gpio-keys-polled",
  385. .id = 0,
  386. .dev = {
  387. .platform_data = &da850_evm_ui_keys_pdata
  388. },
  389. };
  390. static void da850_evm_ui_keys_init(unsigned gpio)
  391. {
  392. int i;
  393. struct gpio_keys_button *button;
  394. for (i = 0; i < DA850_N_UI_PB; i++) {
  395. button = &da850_evm_ui_keys[i];
  396. button->code = KEY_F8 - i;
  397. button->desc = (char *)
  398. da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
  399. button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
  400. }
  401. }
  402. #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT
  403. static inline void da850_evm_setup_video_port(int video_sel)
  404. {
  405. gpio_set_value_cansleep(video_sel, 0);
  406. }
  407. #else
  408. static inline void da850_evm_setup_video_port(int video_sel) { }
  409. #endif
  410. static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
  411. unsigned ngpio, void *c)
  412. {
  413. int sel_a, sel_b, sel_c, ret;
  414. sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
  415. sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
  416. sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
  417. ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
  418. if (ret) {
  419. pr_warn("Cannot open UI expander pin %d\n", sel_a);
  420. goto exp_setup_sela_fail;
  421. }
  422. ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
  423. if (ret) {
  424. pr_warn("Cannot open UI expander pin %d\n", sel_b);
  425. goto exp_setup_selb_fail;
  426. }
  427. ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
  428. if (ret) {
  429. pr_warn("Cannot open UI expander pin %d\n", sel_c);
  430. goto exp_setup_selc_fail;
  431. }
  432. /* deselect all functionalities */
  433. gpio_direction_output(sel_a, 1);
  434. gpio_direction_output(sel_b, 1);
  435. gpio_direction_output(sel_c, 1);
  436. da850_evm_ui_keys_init(gpio);
  437. ret = platform_device_register(&da850_evm_ui_keys_device);
  438. if (ret) {
  439. pr_warn("Could not register UI GPIO expander push-buttons");
  440. goto exp_setup_keys_fail;
  441. }
  442. pr_info("DA850/OMAP-L138 EVM UI card detected\n");
  443. da850_evm_setup_nor_nand();
  444. da850_evm_setup_emac_rmii(sel_a);
  445. da850_evm_setup_video_port(sel_c);
  446. return 0;
  447. exp_setup_keys_fail:
  448. gpio_free(sel_c);
  449. exp_setup_selc_fail:
  450. gpio_free(sel_b);
  451. exp_setup_selb_fail:
  452. gpio_free(sel_a);
  453. exp_setup_sela_fail:
  454. return ret;
  455. }
  456. static int da850_evm_ui_expander_teardown(struct i2c_client *client,
  457. unsigned gpio, unsigned ngpio, void *c)
  458. {
  459. platform_device_unregister(&da850_evm_ui_keys_device);
  460. /* deselect all functionalities */
  461. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
  462. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
  463. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
  464. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
  465. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
  466. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
  467. return 0;
  468. }
  469. /* assign the baseboard expander's GPIOs after the UI board's */
  470. #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
  471. #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
  472. enum da850_evm_bb_exp_pins {
  473. DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
  474. DA850_EVM_BB_EXP_SW_RST,
  475. DA850_EVM_BB_EXP_TP_23,
  476. DA850_EVM_BB_EXP_TP_22,
  477. DA850_EVM_BB_EXP_TP_21,
  478. DA850_EVM_BB_EXP_USER_PB1,
  479. DA850_EVM_BB_EXP_USER_LED2,
  480. DA850_EVM_BB_EXP_USER_LED1,
  481. DA850_EVM_BB_EXP_USER_SW1,
  482. DA850_EVM_BB_EXP_USER_SW2,
  483. DA850_EVM_BB_EXP_USER_SW3,
  484. DA850_EVM_BB_EXP_USER_SW4,
  485. DA850_EVM_BB_EXP_USER_SW5,
  486. DA850_EVM_BB_EXP_USER_SW6,
  487. DA850_EVM_BB_EXP_USER_SW7,
  488. DA850_EVM_BB_EXP_USER_SW8
  489. };
  490. static const char * const da850_evm_bb_exp[] = {
  491. [DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en",
  492. [DA850_EVM_BB_EXP_SW_RST] = "sw_rst",
  493. [DA850_EVM_BB_EXP_TP_23] = "tp_23",
  494. [DA850_EVM_BB_EXP_TP_22] = "tp_22",
  495. [DA850_EVM_BB_EXP_TP_21] = "tp_21",
  496. [DA850_EVM_BB_EXP_USER_PB1] = "user_pb1",
  497. [DA850_EVM_BB_EXP_USER_LED2] = "user_led2",
  498. [DA850_EVM_BB_EXP_USER_LED1] = "user_led1",
  499. [DA850_EVM_BB_EXP_USER_SW1] = "user_sw1",
  500. [DA850_EVM_BB_EXP_USER_SW2] = "user_sw2",
  501. [DA850_EVM_BB_EXP_USER_SW3] = "user_sw3",
  502. [DA850_EVM_BB_EXP_USER_SW4] = "user_sw4",
  503. [DA850_EVM_BB_EXP_USER_SW5] = "user_sw5",
  504. [DA850_EVM_BB_EXP_USER_SW6] = "user_sw6",
  505. [DA850_EVM_BB_EXP_USER_SW7] = "user_sw7",
  506. [DA850_EVM_BB_EXP_USER_SW8] = "user_sw8",
  507. };
  508. #define DA850_N_BB_USER_SW 8
  509. static struct gpio_keys_button da850_evm_bb_keys[] = {
  510. [0] = {
  511. .type = EV_KEY,
  512. .active_low = 1,
  513. .wakeup = 0,
  514. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  515. .code = KEY_PROG1,
  516. .desc = NULL, /* assigned at runtime */
  517. .gpio = -1, /* assigned at runtime */
  518. },
  519. [1 ... DA850_N_BB_USER_SW] = {
  520. .type = EV_SW,
  521. .active_low = 1,
  522. .wakeup = 0,
  523. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  524. .code = -1, /* assigned at runtime */
  525. .desc = NULL, /* assigned at runtime */
  526. .gpio = -1, /* assigned at runtime */
  527. },
  528. };
  529. static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
  530. .buttons = da850_evm_bb_keys,
  531. .nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
  532. .poll_interval = DA850_GPIO_KEYS_POLL_MS,
  533. };
  534. static struct platform_device da850_evm_bb_keys_device = {
  535. .name = "gpio-keys-polled",
  536. .id = 1,
  537. .dev = {
  538. .platform_data = &da850_evm_bb_keys_pdata
  539. },
  540. };
  541. static void da850_evm_bb_keys_init(unsigned gpio)
  542. {
  543. int i;
  544. struct gpio_keys_button *button;
  545. button = &da850_evm_bb_keys[0];
  546. button->desc = (char *)
  547. 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 = (char *)
  553. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
  554. button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
  555. }
  556. }
  557. #define DA850_N_BB_USER_LED 2
  558. static struct gpio_led da850_evm_bb_leds[] = {
  559. [0 ... DA850_N_BB_USER_LED - 1] = {
  560. .active_low = 1,
  561. .gpio = -1, /* assigned at runtime */
  562. .name = NULL, /* assigned at runtime */
  563. },
  564. };
  565. static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
  566. .leds = da850_evm_bb_leds,
  567. .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
  568. };
  569. static struct platform_device da850_evm_bb_leds_device = {
  570. .name = "leds-gpio",
  571. .id = -1,
  572. .dev = {
  573. .platform_data = &da850_evm_bb_leds_pdata
  574. }
  575. };
  576. static void da850_evm_bb_leds_init(unsigned gpio)
  577. {
  578. int i;
  579. struct gpio_led *led;
  580. for (i = 0; i < DA850_N_BB_USER_LED; i++) {
  581. led = &da850_evm_bb_leds[i];
  582. led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
  583. led->name =
  584. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
  585. }
  586. }
  587. static int da850_evm_bb_expander_setup(struct i2c_client *client,
  588. unsigned gpio, unsigned ngpio,
  589. void *c)
  590. {
  591. int ret;
  592. /*
  593. * Register the switches and pushbutton on the baseboard as a gpio-keys
  594. * device.
  595. */
  596. da850_evm_bb_keys_init(gpio);
  597. ret = platform_device_register(&da850_evm_bb_keys_device);
  598. if (ret) {
  599. pr_warn("Could not register baseboard GPIO expander keys");
  600. goto io_exp_setup_sw_fail;
  601. }
  602. da850_evm_bb_leds_init(gpio);
  603. ret = platform_device_register(&da850_evm_bb_leds_device);
  604. if (ret) {
  605. pr_warn("Could not register baseboard GPIO expander LEDs");
  606. goto io_exp_setup_leds_fail;
  607. }
  608. return 0;
  609. io_exp_setup_leds_fail:
  610. platform_device_unregister(&da850_evm_bb_keys_device);
  611. io_exp_setup_sw_fail:
  612. return ret;
  613. }
  614. static int da850_evm_bb_expander_teardown(struct i2c_client *client,
  615. unsigned gpio, unsigned ngpio, void *c)
  616. {
  617. platform_device_unregister(&da850_evm_bb_leds_device);
  618. platform_device_unregister(&da850_evm_bb_keys_device);
  619. return 0;
  620. }
  621. static struct pca953x_platform_data da850_evm_ui_expander_info = {
  622. .gpio_base = DAVINCI_N_GPIO,
  623. .setup = da850_evm_ui_expander_setup,
  624. .teardown = da850_evm_ui_expander_teardown,
  625. .names = da850_evm_ui_exp,
  626. };
  627. static struct pca953x_platform_data da850_evm_bb_expander_info = {
  628. .gpio_base = DA850_BB_EXPANDER_GPIO_BASE,
  629. .setup = da850_evm_bb_expander_setup,
  630. .teardown = da850_evm_bb_expander_teardown,
  631. .names = da850_evm_bb_exp,
  632. };
  633. static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
  634. {
  635. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  636. },
  637. {
  638. I2C_BOARD_INFO("tca6416", 0x20),
  639. .platform_data = &da850_evm_ui_expander_info,
  640. },
  641. {
  642. I2C_BOARD_INFO("tca6416", 0x21),
  643. .platform_data = &da850_evm_bb_expander_info,
  644. },
  645. };
  646. static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
  647. .bus_freq = 100, /* kHz */
  648. .bus_delay = 0, /* usec */
  649. };
  650. static struct davinci_uart_config da850_evm_uart_config __initdata = {
  651. .enabled_uarts = 0x7,
  652. };
  653. /* davinci da850 evm audio machine driver */
  654. static u8 da850_iis_serializer_direction[] = {
  655. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  656. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  657. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  658. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  659. };
  660. static struct snd_platform_data da850_evm_snd_data = {
  661. .tx_dma_offset = 0x2000,
  662. .rx_dma_offset = 0x2000,
  663. .op_mode = DAVINCI_MCASP_IIS_MODE,
  664. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  665. .tdm_slots = 2,
  666. .serial_dir = da850_iis_serializer_direction,
  667. .asp_chan_q = EVENTQ_0,
  668. .ram_chan_q = EVENTQ_1,
  669. .version = MCASP_VERSION_2,
  670. .txnumevt = 1,
  671. .rxnumevt = 1,
  672. .sram_size_playback = SZ_8K,
  673. .sram_size_capture = SZ_8K,
  674. };
  675. static const short da850_evm_mcasp_pins[] __initconst = {
  676. DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
  677. DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
  678. DA850_AXR_11, DA850_AXR_12,
  679. -1
  680. };
  681. static int da850_evm_mmc_get_ro(int index)
  682. {
  683. return gpio_get_value(DA850_MMCSD_WP_PIN);
  684. }
  685. static int da850_evm_mmc_get_cd(int index)
  686. {
  687. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  688. }
  689. static struct davinci_mmc_config da850_mmc_config = {
  690. .get_ro = da850_evm_mmc_get_ro,
  691. .get_cd = da850_evm_mmc_get_cd,
  692. .wires = 4,
  693. .max_freq = 50000000,
  694. .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
  695. };
  696. static const short da850_evm_mmcsd0_pins[] __initconst = {
  697. DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
  698. DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
  699. DA850_GPIO4_0, DA850_GPIO4_1,
  700. -1
  701. };
  702. static void da850_panel_power_ctrl(int val)
  703. {
  704. /* lcd backlight */
  705. gpio_set_value(DA850_LCD_BL_PIN, val);
  706. /* lcd power */
  707. gpio_set_value(DA850_LCD_PWR_PIN, val);
  708. }
  709. static int da850_lcd_hw_init(void)
  710. {
  711. int status;
  712. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  713. if (status < 0)
  714. return status;
  715. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  716. if (status < 0) {
  717. gpio_free(DA850_LCD_BL_PIN);
  718. return status;
  719. }
  720. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  721. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  722. /* Switch off panel power and backlight */
  723. da850_panel_power_ctrl(0);
  724. /* Switch on panel power and backlight */
  725. da850_panel_power_ctrl(1);
  726. return 0;
  727. }
  728. /* TPS65070 voltage regulator support */
  729. /* 3.3V */
  730. static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
  731. {
  732. .supply = "usb0_vdda33",
  733. },
  734. {
  735. .supply = "usb1_vdda33",
  736. },
  737. };
  738. /* 3.3V or 1.8V */
  739. static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
  740. {
  741. .supply = "dvdd3318_a",
  742. },
  743. {
  744. .supply = "dvdd3318_b",
  745. },
  746. {
  747. .supply = "dvdd3318_c",
  748. },
  749. };
  750. /* 1.2V */
  751. static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
  752. {
  753. .supply = "cvdd",
  754. },
  755. };
  756. /* 1.8V LDO */
  757. static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
  758. {
  759. .supply = "sata_vddr",
  760. },
  761. {
  762. .supply = "usb0_vdda18",
  763. },
  764. {
  765. .supply = "usb1_vdda18",
  766. },
  767. {
  768. .supply = "ddr_dvdd18",
  769. },
  770. };
  771. /* 1.2V LDO */
  772. static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
  773. {
  774. .supply = "sata_vdd",
  775. },
  776. {
  777. .supply = "pll0_vdda",
  778. },
  779. {
  780. .supply = "pll1_vdda",
  781. },
  782. {
  783. .supply = "usbs_cvdd",
  784. },
  785. {
  786. .supply = "vddarnwa1",
  787. },
  788. };
  789. /* We take advantage of the fact that both defdcdc{2,3} are tied high */
  790. static struct tps6507x_reg_platform_data tps6507x_platform_data = {
  791. .defdcdc_default = true,
  792. };
  793. static struct regulator_init_data tps65070_regulator_data[] = {
  794. /* dcdc1 */
  795. {
  796. .constraints = {
  797. .min_uV = 3150000,
  798. .max_uV = 3450000,
  799. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  800. REGULATOR_CHANGE_STATUS),
  801. .boot_on = 1,
  802. },
  803. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
  804. .consumer_supplies = tps65070_dcdc1_consumers,
  805. },
  806. /* dcdc2 */
  807. {
  808. .constraints = {
  809. .min_uV = 1710000,
  810. .max_uV = 3450000,
  811. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  812. REGULATOR_CHANGE_STATUS),
  813. .boot_on = 1,
  814. },
  815. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
  816. .consumer_supplies = tps65070_dcdc2_consumers,
  817. .driver_data = &tps6507x_platform_data,
  818. },
  819. /* dcdc3 */
  820. {
  821. .constraints = {
  822. .min_uV = 950000,
  823. .max_uV = 1350000,
  824. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  825. REGULATOR_CHANGE_STATUS),
  826. .boot_on = 1,
  827. },
  828. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
  829. .consumer_supplies = tps65070_dcdc3_consumers,
  830. .driver_data = &tps6507x_platform_data,
  831. },
  832. /* ldo1 */
  833. {
  834. .constraints = {
  835. .min_uV = 1710000,
  836. .max_uV = 1890000,
  837. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  838. REGULATOR_CHANGE_STATUS),
  839. .boot_on = 1,
  840. },
  841. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
  842. .consumer_supplies = tps65070_ldo1_consumers,
  843. },
  844. /* ldo2 */
  845. {
  846. .constraints = {
  847. .min_uV = 1140000,
  848. .max_uV = 1320000,
  849. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  850. REGULATOR_CHANGE_STATUS),
  851. .boot_on = 1,
  852. },
  853. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
  854. .consumer_supplies = tps65070_ldo2_consumers,
  855. },
  856. };
  857. static struct touchscreen_init_data tps6507x_touchscreen_data = {
  858. .poll_period = 30, /* ms between touch samples */
  859. .min_pressure = 0x30, /* minimum pressure to trigger touch */
  860. .vref = 0, /* turn off vref when not using A/D */
  861. .vendor = 0, /* /sys/class/input/input?/id/vendor */
  862. .product = 65070, /* /sys/class/input/input?/id/product */
  863. .version = 0x100, /* /sys/class/input/input?/id/version */
  864. };
  865. static struct tps6507x_board tps_board = {
  866. .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
  867. .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
  868. };
  869. static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
  870. {
  871. I2C_BOARD_INFO("tps6507x", 0x48),
  872. .platform_data = &tps_board,
  873. },
  874. };
  875. static int __init pmic_tps65070_init(void)
  876. {
  877. return i2c_register_board_info(1, da850_evm_tps65070_info,
  878. ARRAY_SIZE(da850_evm_tps65070_info));
  879. }
  880. static const short da850_evm_lcdc_pins[] = {
  881. DA850_GPIO2_8, DA850_GPIO2_15,
  882. -1
  883. };
  884. static const short da850_evm_mii_pins[] = {
  885. DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
  886. DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
  887. DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
  888. DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
  889. DA850_MDIO_D,
  890. -1
  891. };
  892. static const short da850_evm_rmii_pins[] = {
  893. DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
  894. DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
  895. DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
  896. DA850_MDIO_D,
  897. -1
  898. };
  899. static int __init da850_evm_config_emac(void)
  900. {
  901. void __iomem *cfg_chip3_base;
  902. int ret;
  903. u32 val;
  904. struct davinci_soc_info *soc_info = &davinci_soc_info;
  905. u8 rmii_en = soc_info->emac_pdata->rmii_en;
  906. if (!machine_is_davinci_da850_evm())
  907. return 0;
  908. cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
  909. val = __raw_readl(cfg_chip3_base);
  910. if (rmii_en) {
  911. val |= BIT(8);
  912. ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
  913. pr_info("EMAC: RMII PHY configured, MII PHY will not be"
  914. " functional\n");
  915. } else {
  916. val &= ~BIT(8);
  917. ret = davinci_cfg_reg_list(da850_evm_mii_pins);
  918. pr_info("EMAC: MII PHY configured, RMII PHY will not be"
  919. " functional\n");
  920. }
  921. if (ret)
  922. pr_warn("%s: CPGMAC/RMII mux setup failed: %d\n",
  923. __func__, ret);
  924. /* configure the CFGCHIP3 register for RMII or MII */
  925. __raw_writel(val, cfg_chip3_base);
  926. ret = davinci_cfg_reg(DA850_GPIO2_6);
  927. if (ret)
  928. pr_warn("%s:GPIO(2,6) mux setup failed\n", __func__);
  929. ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
  930. if (ret) {
  931. pr_warn("Cannot open GPIO %d\n", DA850_MII_MDIO_CLKEN_PIN);
  932. return ret;
  933. }
  934. /* Enable/Disable MII MDIO clock */
  935. gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
  936. soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
  937. ret = da8xx_register_emac();
  938. if (ret)
  939. pr_warn("%s: EMAC registration failed: %d\n", __func__, ret);
  940. return 0;
  941. }
  942. device_initcall(da850_evm_config_emac);
  943. /*
  944. * The following EDMA channels/slots are not being used by drivers (for
  945. * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
  946. * they are being reserved for codecs on the DSP side.
  947. */
  948. static const s16 da850_dma0_rsv_chans[][2] = {
  949. /* (offset, number) */
  950. { 8, 6},
  951. {24, 4},
  952. {30, 2},
  953. {-1, -1}
  954. };
  955. static const s16 da850_dma0_rsv_slots[][2] = {
  956. /* (offset, number) */
  957. { 8, 6},
  958. {24, 4},
  959. {30, 50},
  960. {-1, -1}
  961. };
  962. static const s16 da850_dma1_rsv_chans[][2] = {
  963. /* (offset, number) */
  964. { 0, 28},
  965. {30, 2},
  966. {-1, -1}
  967. };
  968. static const s16 da850_dma1_rsv_slots[][2] = {
  969. /* (offset, number) */
  970. { 0, 28},
  971. {30, 90},
  972. {-1, -1}
  973. };
  974. static struct edma_rsv_info da850_edma_cc0_rsv = {
  975. .rsv_chans = da850_dma0_rsv_chans,
  976. .rsv_slots = da850_dma0_rsv_slots,
  977. };
  978. static struct edma_rsv_info da850_edma_cc1_rsv = {
  979. .rsv_chans = da850_dma1_rsv_chans,
  980. .rsv_slots = da850_dma1_rsv_slots,
  981. };
  982. static struct edma_rsv_info *da850_edma_rsv[2] = {
  983. &da850_edma_cc0_rsv,
  984. &da850_edma_cc1_rsv,
  985. };
  986. #ifdef CONFIG_CPU_FREQ
  987. static __init int da850_evm_init_cpufreq(void)
  988. {
  989. switch (system_rev & 0xF) {
  990. case 3:
  991. da850_max_speed = 456000;
  992. break;
  993. case 2:
  994. da850_max_speed = 408000;
  995. break;
  996. case 1:
  997. da850_max_speed = 372000;
  998. break;
  999. }
  1000. return da850_register_cpufreq("pll0_sysclk3");
  1001. }
  1002. #else
  1003. static __init int da850_evm_init_cpufreq(void) { return 0; }
  1004. #endif
  1005. #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
  1006. #define TVP5147_CH0 "tvp514x-0"
  1007. #define TVP5147_CH1 "tvp514x-1"
  1008. /* VPIF capture configuration */
  1009. static struct tvp514x_platform_data tvp5146_pdata = {
  1010. .clk_polarity = 0,
  1011. .hs_polarity = 1,
  1012. .vs_polarity = 1,
  1013. };
  1014. #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
  1015. static const struct vpif_input da850_ch0_inputs[] = {
  1016. {
  1017. .input = {
  1018. .index = 0,
  1019. .name = "Composite",
  1020. .type = V4L2_INPUT_TYPE_CAMERA,
  1021. .capabilities = V4L2_IN_CAP_STD,
  1022. .std = TVP514X_STD_ALL,
  1023. },
  1024. .input_route = INPUT_CVBS_VI2B,
  1025. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  1026. .subdev_name = TVP5147_CH0,
  1027. },
  1028. };
  1029. static const struct vpif_input da850_ch1_inputs[] = {
  1030. {
  1031. .input = {
  1032. .index = 0,
  1033. .name = "S-Video",
  1034. .type = V4L2_INPUT_TYPE_CAMERA,
  1035. .capabilities = V4L2_IN_CAP_STD,
  1036. .std = TVP514X_STD_ALL,
  1037. },
  1038. .input_route = INPUT_SVIDEO_VI2C_VI1C,
  1039. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  1040. .subdev_name = TVP5147_CH1,
  1041. },
  1042. };
  1043. static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
  1044. {
  1045. .name = TVP5147_CH0,
  1046. .board_info = {
  1047. I2C_BOARD_INFO("tvp5146", 0x5d),
  1048. .platform_data = &tvp5146_pdata,
  1049. },
  1050. },
  1051. {
  1052. .name = TVP5147_CH1,
  1053. .board_info = {
  1054. I2C_BOARD_INFO("tvp5146", 0x5c),
  1055. .platform_data = &tvp5146_pdata,
  1056. },
  1057. },
  1058. };
  1059. static struct vpif_capture_config da850_vpif_capture_config = {
  1060. .subdev_info = da850_vpif_capture_sdev_info,
  1061. .subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
  1062. .chan_config[0] = {
  1063. .inputs = da850_ch0_inputs,
  1064. .input_count = ARRAY_SIZE(da850_ch0_inputs),
  1065. .vpif_if = {
  1066. .if_type = VPIF_IF_BT656,
  1067. .hd_pol = 1,
  1068. .vd_pol = 1,
  1069. .fid_pol = 0,
  1070. },
  1071. },
  1072. .chan_config[1] = {
  1073. .inputs = da850_ch1_inputs,
  1074. .input_count = ARRAY_SIZE(da850_ch1_inputs),
  1075. .vpif_if = {
  1076. .if_type = VPIF_IF_BT656,
  1077. .hd_pol = 1,
  1078. .vd_pol = 1,
  1079. .fid_pol = 0,
  1080. },
  1081. },
  1082. .card_name = "DA850/OMAP-L138 Video Capture",
  1083. };
  1084. /* VPIF display configuration */
  1085. static struct adv7343_platform_data adv7343_pdata = {
  1086. .mode_config = {
  1087. .dac_3 = 1,
  1088. .dac_2 = 1,
  1089. .dac_1 = 1,
  1090. },
  1091. .sd_config = {
  1092. .sd_dac_out1 = 1,
  1093. },
  1094. };
  1095. static struct vpif_subdev_info da850_vpif_subdev[] = {
  1096. {
  1097. .name = "adv7343",
  1098. .board_info = {
  1099. I2C_BOARD_INFO("adv7343", 0x2a),
  1100. .platform_data = &adv7343_pdata,
  1101. },
  1102. },
  1103. };
  1104. static const struct vpif_output da850_ch0_outputs[] = {
  1105. {
  1106. .output = {
  1107. .index = 0,
  1108. .name = "Composite",
  1109. .type = V4L2_OUTPUT_TYPE_ANALOG,
  1110. .capabilities = V4L2_OUT_CAP_STD,
  1111. .std = V4L2_STD_ALL,
  1112. },
  1113. .subdev_name = "adv7343",
  1114. .output_route = ADV7343_COMPOSITE_ID,
  1115. },
  1116. {
  1117. .output = {
  1118. .index = 1,
  1119. .name = "S-Video",
  1120. .type = V4L2_OUTPUT_TYPE_ANALOG,
  1121. .capabilities = V4L2_OUT_CAP_STD,
  1122. .std = V4L2_STD_ALL,
  1123. },
  1124. .subdev_name = "adv7343",
  1125. .output_route = ADV7343_SVIDEO_ID,
  1126. },
  1127. };
  1128. static struct vpif_display_config da850_vpif_display_config = {
  1129. .subdevinfo = da850_vpif_subdev,
  1130. .subdev_count = ARRAY_SIZE(da850_vpif_subdev),
  1131. .chan_config[0] = {
  1132. .outputs = da850_ch0_outputs,
  1133. .output_count = ARRAY_SIZE(da850_ch0_outputs),
  1134. },
  1135. .card_name = "DA850/OMAP-L138 Video Display",
  1136. };
  1137. static __init void da850_vpif_init(void)
  1138. {
  1139. int ret;
  1140. ret = da850_register_vpif();
  1141. if (ret)
  1142. pr_warn("da850_evm_init: VPIF setup failed: %d\n", ret);
  1143. ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
  1144. if (ret)
  1145. pr_warn("da850_evm_init: VPIF capture mux setup failed: %d\n",
  1146. ret);
  1147. ret = da850_register_vpif_capture(&da850_vpif_capture_config);
  1148. if (ret)
  1149. pr_warn("da850_evm_init: VPIF capture setup failed: %d\n", ret);
  1150. ret = davinci_cfg_reg_list(da850_vpif_display_pins);
  1151. if (ret)
  1152. pr_warn("da850_evm_init: VPIF display mux setup failed: %d\n",
  1153. ret);
  1154. ret = da850_register_vpif_display(&da850_vpif_display_config);
  1155. if (ret)
  1156. pr_warn("da850_evm_init: VPIF display setup failed: %d\n", ret);
  1157. }
  1158. #else
  1159. static __init void da850_vpif_init(void) {}
  1160. #endif
  1161. #ifdef CONFIG_DA850_WL12XX
  1162. static void wl12xx_set_power(int index, bool power_on)
  1163. {
  1164. static bool power_state;
  1165. pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
  1166. if (power_on == power_state)
  1167. return;
  1168. power_state = power_on;
  1169. if (power_on) {
  1170. /* Power up sequence required for wl127x devices */
  1171. gpio_set_value(DA850_WLAN_EN, 1);
  1172. usleep_range(15000, 15000);
  1173. gpio_set_value(DA850_WLAN_EN, 0);
  1174. usleep_range(1000, 1000);
  1175. gpio_set_value(DA850_WLAN_EN, 1);
  1176. msleep(70);
  1177. } else {
  1178. gpio_set_value(DA850_WLAN_EN, 0);
  1179. }
  1180. }
  1181. static struct davinci_mmc_config da850_wl12xx_mmc_config = {
  1182. .set_power = wl12xx_set_power,
  1183. .wires = 4,
  1184. .max_freq = 25000000,
  1185. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
  1186. MMC_CAP_POWER_OFF_CARD,
  1187. };
  1188. static const short da850_wl12xx_pins[] __initconst = {
  1189. DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
  1190. DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
  1191. DA850_GPIO6_9, DA850_GPIO6_10,
  1192. -1
  1193. };
  1194. static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
  1195. .irq = -1,
  1196. .board_ref_clock = WL12XX_REFCLOCK_38,
  1197. .platform_quirks = WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
  1198. };
  1199. static __init int da850_wl12xx_init(void)
  1200. {
  1201. int ret;
  1202. ret = davinci_cfg_reg_list(da850_wl12xx_pins);
  1203. if (ret) {
  1204. pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
  1205. goto exit;
  1206. }
  1207. ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
  1208. if (ret) {
  1209. pr_err("wl12xx/mmc registration failed: %d\n", ret);
  1210. goto exit;
  1211. }
  1212. ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
  1213. if (ret) {
  1214. pr_err("Could not request wl12xx enable gpio: %d\n", ret);
  1215. goto exit;
  1216. }
  1217. ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
  1218. if (ret) {
  1219. pr_err("Could not request wl12xx irq gpio: %d\n", ret);
  1220. goto free_wlan_en;
  1221. }
  1222. da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
  1223. ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
  1224. if (ret) {
  1225. pr_err("Could not set wl12xx data: %d\n", ret);
  1226. goto free_wlan_irq;
  1227. }
  1228. return 0;
  1229. free_wlan_irq:
  1230. gpio_free(DA850_WLAN_IRQ);
  1231. free_wlan_en:
  1232. gpio_free(DA850_WLAN_EN);
  1233. exit:
  1234. return ret;
  1235. }
  1236. #else /* CONFIG_DA850_WL12XX */
  1237. static __init int da850_wl12xx_init(void)
  1238. {
  1239. return 0;
  1240. }
  1241. #endif /* CONFIG_DA850_WL12XX */
  1242. #define DA850EVM_SATA_REFCLKPN_RATE (100 * 1000 * 1000)
  1243. static __init void da850_evm_init(void)
  1244. {
  1245. int ret;
  1246. ret = pmic_tps65070_init();
  1247. if (ret)
  1248. pr_warn("%s: TPS65070 PMIC init failed: %d\n", __func__, ret);
  1249. ret = da850_register_edma(da850_edma_rsv);
  1250. if (ret)
  1251. pr_warn("%s: EDMA registration failed: %d\n", __func__, ret);
  1252. ret = davinci_cfg_reg_list(da850_i2c0_pins);
  1253. if (ret)
  1254. pr_warn("%s: I2C0 mux setup failed: %d\n", __func__, ret);
  1255. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  1256. if (ret)
  1257. pr_warn("%s: I2C0 registration failed: %d\n", __func__, ret);
  1258. ret = da8xx_register_watchdog();
  1259. if (ret)
  1260. pr_warn("%s: watchdog registration failed: %d\n",
  1261. __func__, ret);
  1262. if (HAS_MMC) {
  1263. ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
  1264. if (ret)
  1265. pr_warn("%s: MMCSD0 mux setup failed: %d\n",
  1266. __func__, ret);
  1267. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  1268. if (ret)
  1269. pr_warn("%s: can not open GPIO %d\n",
  1270. __func__, DA850_MMCSD_CD_PIN);
  1271. gpio_direction_input(DA850_MMCSD_CD_PIN);
  1272. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  1273. if (ret)
  1274. pr_warn("%s: can not open GPIO %d\n",
  1275. __func__, DA850_MMCSD_WP_PIN);
  1276. gpio_direction_input(DA850_MMCSD_WP_PIN);
  1277. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  1278. if (ret)
  1279. pr_warn("%s: MMCSD0 registration failed: %d\n",
  1280. __func__, ret);
  1281. ret = da850_wl12xx_init();
  1282. if (ret)
  1283. pr_warn("%s: WL12xx initialization failed: %d\n",
  1284. __func__, ret);
  1285. }
  1286. davinci_serial_init(&da850_evm_uart_config);
  1287. i2c_register_board_info(1, da850_evm_i2c_devices,
  1288. ARRAY_SIZE(da850_evm_i2c_devices));
  1289. /*
  1290. * shut down uart 0 and 1; they are not used on the board and
  1291. * accessing them causes endless "too much work in irq53" messages
  1292. * with arago fs
  1293. */
  1294. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  1295. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  1296. ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
  1297. if (ret)
  1298. pr_warn("%s: McASP mux setup failed: %d\n", __func__, ret);
  1299. da850_evm_snd_data.sram_pool = sram_get_gen_pool();
  1300. da8xx_register_mcasp(0, &da850_evm_snd_data);
  1301. ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
  1302. if (ret)
  1303. pr_warn("%s: LCDC mux setup failed: %d\n", __func__, 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_warn("%s: EVM specific LCD mux setup failed: %d\n",
  1312. __func__, ret);
  1313. ret = da850_lcd_hw_init();
  1314. if (ret)
  1315. pr_warn("%s: LCD initialization failed: %d\n", __func__, ret);
  1316. sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
  1317. ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
  1318. if (ret)
  1319. pr_warn("%s: LCDC registration failed: %d\n", __func__, ret);
  1320. ret = da8xx_register_rtc();
  1321. if (ret)
  1322. pr_warn("%s: RTC setup failed: %d\n", __func__, ret);
  1323. ret = da850_evm_init_cpufreq();
  1324. if (ret)
  1325. pr_warn("%s: cpufreq registration failed: %d\n", __func__, ret);
  1326. ret = da8xx_register_cpuidle();
  1327. if (ret)
  1328. pr_warn("%s: cpuidle registration failed: %d\n", __func__, ret);
  1329. ret = da850_register_pm(&da850_pm_device);
  1330. if (ret)
  1331. pr_warn("%s: suspend registration failed: %d\n", __func__, ret);
  1332. da850_vpif_init();
  1333. ret = spi_register_board_info(da850evm_spi_info,
  1334. ARRAY_SIZE(da850evm_spi_info));
  1335. if (ret)
  1336. pr_warn("%s: spi info registration failed: %d\n", __func__,
  1337. ret);
  1338. ret = da8xx_register_spi_bus(1, ARRAY_SIZE(da850evm_spi_info));
  1339. if (ret)
  1340. pr_warn("%s: SPI 1 registration failed: %d\n", __func__, ret);
  1341. ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
  1342. if (ret)
  1343. pr_warn("%s: SATA registration failed: %d\n", __func__, ret);
  1344. da850_evm_setup_mac_addr();
  1345. ret = da8xx_register_rproc();
  1346. if (ret)
  1347. pr_warn("%s: dsp/rproc registration failed: %d\n",
  1348. __func__, ret);
  1349. }
  1350. #ifdef CONFIG_SERIAL_8250_CONSOLE
  1351. static int __init da850_evm_console_init(void)
  1352. {
  1353. if (!machine_is_davinci_da850_evm())
  1354. return 0;
  1355. return add_preferred_console("ttyS", 2, "115200");
  1356. }
  1357. console_initcall(da850_evm_console_init);
  1358. #endif
  1359. static void __init da850_evm_map_io(void)
  1360. {
  1361. da850_init();
  1362. }
  1363. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
  1364. .atag_offset = 0x100,
  1365. .map_io = da850_evm_map_io,
  1366. .init_irq = cp_intc_init,
  1367. .init_time = davinci_timer_init,
  1368. .init_machine = da850_evm_init,
  1369. .init_late = davinci_init_late,
  1370. .dma_zone_size = SZ_128M,
  1371. .restart = da8xx_restart,
  1372. .reserve = da8xx_rproc_reserve_cma,
  1373. MACHINE_END