board-da850-evm.c 38 KB

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