board-da850-evm.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  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 <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <mach/cp_intc.h>
  37. #include <mach/da8xx.h>
  38. #include <mach/nand.h>
  39. #include <mach/mux.h>
  40. #include <mach/aemif.h>
  41. #include <mach/spi.h>
  42. #define DA850_EVM_PHY_ID "0:00"
  43. #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
  44. #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
  45. #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
  46. #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
  47. #define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
  48. static struct mtd_partition da850evm_spiflash_part[] = {
  49. [0] = {
  50. .name = "UBL",
  51. .offset = 0,
  52. .size = SZ_64K,
  53. .mask_flags = MTD_WRITEABLE,
  54. },
  55. [1] = {
  56. .name = "U-Boot",
  57. .offset = MTDPART_OFS_APPEND,
  58. .size = SZ_512K,
  59. .mask_flags = MTD_WRITEABLE,
  60. },
  61. [2] = {
  62. .name = "U-Boot-Env",
  63. .offset = MTDPART_OFS_APPEND,
  64. .size = SZ_64K,
  65. .mask_flags = MTD_WRITEABLE,
  66. },
  67. [3] = {
  68. .name = "Kernel",
  69. .offset = MTDPART_OFS_APPEND,
  70. .size = SZ_2M + SZ_512K,
  71. .mask_flags = 0,
  72. },
  73. [4] = {
  74. .name = "Filesystem",
  75. .offset = MTDPART_OFS_APPEND,
  76. .size = SZ_4M,
  77. .mask_flags = 0,
  78. },
  79. [5] = {
  80. .name = "MAC-Address",
  81. .offset = SZ_8M - SZ_64K,
  82. .size = SZ_64K,
  83. .mask_flags = MTD_WRITEABLE,
  84. },
  85. };
  86. static struct flash_platform_data da850evm_spiflash_data = {
  87. .name = "m25p80",
  88. .parts = da850evm_spiflash_part,
  89. .nr_parts = ARRAY_SIZE(da850evm_spiflash_part),
  90. .type = "m25p64",
  91. };
  92. static struct davinci_spi_config da850evm_spiflash_cfg = {
  93. .io_type = SPI_IO_TYPE_DMA,
  94. .c2tdelay = 8,
  95. .t2cdelay = 8,
  96. };
  97. static struct spi_board_info da850evm_spi_info[] = {
  98. {
  99. .modalias = "m25p80",
  100. .platform_data = &da850evm_spiflash_data,
  101. .controller_data = &da850evm_spiflash_cfg,
  102. .mode = SPI_MODE_0,
  103. .max_speed_hz = 30000000,
  104. .bus_num = 1,
  105. .chip_select = 0,
  106. },
  107. };
  108. static struct mtd_partition da850_evm_norflash_partition[] = {
  109. {
  110. .name = "bootloaders + env",
  111. .offset = 0,
  112. .size = SZ_512K,
  113. .mask_flags = MTD_WRITEABLE,
  114. },
  115. {
  116. .name = "kernel",
  117. .offset = MTDPART_OFS_APPEND,
  118. .size = SZ_2M,
  119. .mask_flags = 0,
  120. },
  121. {
  122. .name = "filesystem",
  123. .offset = MTDPART_OFS_APPEND,
  124. .size = MTDPART_SIZ_FULL,
  125. .mask_flags = 0,
  126. },
  127. };
  128. static struct physmap_flash_data da850_evm_norflash_data = {
  129. .width = 2,
  130. .parts = da850_evm_norflash_partition,
  131. .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
  132. };
  133. static struct resource da850_evm_norflash_resource[] = {
  134. {
  135. .start = DA8XX_AEMIF_CS2_BASE,
  136. .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
  137. .flags = IORESOURCE_MEM,
  138. },
  139. };
  140. static struct platform_device da850_evm_norflash_device = {
  141. .name = "physmap-flash",
  142. .id = 0,
  143. .dev = {
  144. .platform_data = &da850_evm_norflash_data,
  145. },
  146. .num_resources = 1,
  147. .resource = da850_evm_norflash_resource,
  148. };
  149. static struct davinci_pm_config da850_pm_pdata = {
  150. .sleepcount = 128,
  151. };
  152. static struct platform_device da850_pm_device = {
  153. .name = "pm-davinci",
  154. .dev = {
  155. .platform_data = &da850_pm_pdata,
  156. },
  157. .id = -1,
  158. };
  159. /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
  160. * (128K blocks). It may be used instead of the (default) SPI flash
  161. * to boot, using TI's tools to install the secondary boot loader
  162. * (UBL) and U-Boot.
  163. */
  164. static struct mtd_partition da850_evm_nandflash_partition[] = {
  165. {
  166. .name = "u-boot env",
  167. .offset = 0,
  168. .size = SZ_128K,
  169. .mask_flags = MTD_WRITEABLE,
  170. },
  171. {
  172. .name = "UBL",
  173. .offset = MTDPART_OFS_APPEND,
  174. .size = SZ_128K,
  175. .mask_flags = MTD_WRITEABLE,
  176. },
  177. {
  178. .name = "u-boot",
  179. .offset = MTDPART_OFS_APPEND,
  180. .size = 4 * SZ_128K,
  181. .mask_flags = MTD_WRITEABLE,
  182. },
  183. {
  184. .name = "kernel",
  185. .offset = 0x200000,
  186. .size = SZ_2M,
  187. .mask_flags = 0,
  188. },
  189. {
  190. .name = "filesystem",
  191. .offset = MTDPART_OFS_APPEND,
  192. .size = MTDPART_SIZ_FULL,
  193. .mask_flags = 0,
  194. },
  195. };
  196. static struct davinci_aemif_timing da850_evm_nandflash_timing = {
  197. .wsetup = 24,
  198. .wstrobe = 21,
  199. .whold = 14,
  200. .rsetup = 19,
  201. .rstrobe = 50,
  202. .rhold = 0,
  203. .ta = 20,
  204. };
  205. static struct davinci_nand_pdata da850_evm_nandflash_data = {
  206. .parts = da850_evm_nandflash_partition,
  207. .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
  208. .ecc_mode = NAND_ECC_HW,
  209. .ecc_bits = 4,
  210. .options = NAND_USE_FLASH_BBT,
  211. .timing = &da850_evm_nandflash_timing,
  212. };
  213. static struct resource da850_evm_nandflash_resource[] = {
  214. {
  215. .start = DA8XX_AEMIF_CS3_BASE,
  216. .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. {
  220. .start = DA8XX_AEMIF_CTL_BASE,
  221. .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
  222. .flags = IORESOURCE_MEM,
  223. },
  224. };
  225. static struct platform_device da850_evm_nandflash_device = {
  226. .name = "davinci_nand",
  227. .id = 1,
  228. .dev = {
  229. .platform_data = &da850_evm_nandflash_data,
  230. },
  231. .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
  232. .resource = da850_evm_nandflash_resource,
  233. };
  234. static struct platform_device *da850_evm_devices[] __initdata = {
  235. &da850_evm_nandflash_device,
  236. &da850_evm_norflash_device,
  237. };
  238. #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
  239. #define DA8XX_AEMIF_ASIZE_16BIT 0x1
  240. static void __init da850_evm_init_nor(void)
  241. {
  242. void __iomem *aemif_addr;
  243. aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
  244. /* Configure data bus width of CS2 to 16 bit */
  245. writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
  246. DA8XX_AEMIF_ASIZE_16BIT,
  247. aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
  248. iounmap(aemif_addr);
  249. }
  250. static const short da850_evm_nand_pins[] = {
  251. DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
  252. DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
  253. DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
  254. DA850_NEMA_WE, DA850_NEMA_OE,
  255. -1
  256. };
  257. static const short da850_evm_nor_pins[] = {
  258. DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
  259. DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
  260. DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
  261. DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
  262. DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
  263. DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
  264. DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
  265. DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
  266. DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
  267. DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
  268. DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
  269. DA850_EMA_A_22, DA850_EMA_A_23,
  270. -1
  271. };
  272. #if defined(CONFIG_MMC_DAVINCI) || \
  273. defined(CONFIG_MMC_DAVINCI_MODULE)
  274. #define HAS_MMC 1
  275. #else
  276. #define HAS_MMC 0
  277. #endif
  278. static inline void da850_evm_setup_nor_nand(void)
  279. {
  280. int ret = 0;
  281. if (!HAS_MMC) {
  282. ret = davinci_cfg_reg_list(da850_evm_nand_pins);
  283. if (ret)
  284. pr_warning("da850_evm_init: nand mux setup failed: "
  285. "%d\n", ret);
  286. ret = davinci_cfg_reg_list(da850_evm_nor_pins);
  287. if (ret)
  288. pr_warning("da850_evm_init: nor mux setup failed: %d\n",
  289. ret);
  290. da850_evm_init_nor();
  291. platform_add_devices(da850_evm_devices,
  292. ARRAY_SIZE(da850_evm_devices));
  293. }
  294. }
  295. #ifdef CONFIG_DA850_UI_RMII
  296. static inline void da850_evm_setup_emac_rmii(int rmii_sel)
  297. {
  298. struct davinci_soc_info *soc_info = &davinci_soc_info;
  299. soc_info->emac_pdata->rmii_en = 1;
  300. gpio_set_value_cansleep(rmii_sel, 0);
  301. }
  302. #else
  303. static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
  304. #endif
  305. #define DA850_KEYS_DEBOUNCE_MS 10
  306. /*
  307. * At 200ms polling interval it is possible to miss an
  308. * event by tapping very lightly on the push button but most
  309. * pushes do result in an event; longer intervals require the
  310. * user to hold the button whereas shorter intervals require
  311. * more CPU time for polling.
  312. */
  313. #define DA850_GPIO_KEYS_POLL_MS 200
  314. enum da850_evm_ui_exp_pins {
  315. DA850_EVM_UI_EXP_SEL_C = 5,
  316. DA850_EVM_UI_EXP_SEL_B,
  317. DA850_EVM_UI_EXP_SEL_A,
  318. DA850_EVM_UI_EXP_PB8,
  319. DA850_EVM_UI_EXP_PB7,
  320. DA850_EVM_UI_EXP_PB6,
  321. DA850_EVM_UI_EXP_PB5,
  322. DA850_EVM_UI_EXP_PB4,
  323. DA850_EVM_UI_EXP_PB3,
  324. DA850_EVM_UI_EXP_PB2,
  325. DA850_EVM_UI_EXP_PB1,
  326. };
  327. static const char const *da850_evm_ui_exp[] = {
  328. [DA850_EVM_UI_EXP_SEL_C] = "sel_c",
  329. [DA850_EVM_UI_EXP_SEL_B] = "sel_b",
  330. [DA850_EVM_UI_EXP_SEL_A] = "sel_a",
  331. [DA850_EVM_UI_EXP_PB8] = "pb8",
  332. [DA850_EVM_UI_EXP_PB7] = "pb7",
  333. [DA850_EVM_UI_EXP_PB6] = "pb6",
  334. [DA850_EVM_UI_EXP_PB5] = "pb5",
  335. [DA850_EVM_UI_EXP_PB4] = "pb4",
  336. [DA850_EVM_UI_EXP_PB3] = "pb3",
  337. [DA850_EVM_UI_EXP_PB2] = "pb2",
  338. [DA850_EVM_UI_EXP_PB1] = "pb1",
  339. };
  340. #define DA850_N_UI_PB 8
  341. static struct gpio_keys_button da850_evm_ui_keys[] = {
  342. [0 ... DA850_N_UI_PB - 1] = {
  343. .type = EV_KEY,
  344. .active_low = 1,
  345. .wakeup = 0,
  346. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  347. .code = -1, /* assigned at runtime */
  348. .gpio = -1, /* assigned at runtime */
  349. .desc = NULL, /* assigned at runtime */
  350. },
  351. };
  352. static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
  353. .buttons = da850_evm_ui_keys,
  354. .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
  355. .poll_interval = DA850_GPIO_KEYS_POLL_MS,
  356. };
  357. static struct platform_device da850_evm_ui_keys_device = {
  358. .name = "gpio-keys-polled",
  359. .id = 0,
  360. .dev = {
  361. .platform_data = &da850_evm_ui_keys_pdata
  362. },
  363. };
  364. static void da850_evm_ui_keys_init(unsigned gpio)
  365. {
  366. int i;
  367. struct gpio_keys_button *button;
  368. for (i = 0; i < DA850_N_UI_PB; i++) {
  369. button = &da850_evm_ui_keys[i];
  370. button->code = KEY_F8 - i;
  371. button->desc = (char *)
  372. da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
  373. button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
  374. }
  375. }
  376. static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
  377. unsigned ngpio, void *c)
  378. {
  379. int sel_a, sel_b, sel_c, ret;
  380. sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
  381. sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
  382. sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
  383. ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
  384. if (ret) {
  385. pr_warning("Cannot open UI expander pin %d\n", sel_a);
  386. goto exp_setup_sela_fail;
  387. }
  388. ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
  389. if (ret) {
  390. pr_warning("Cannot open UI expander pin %d\n", sel_b);
  391. goto exp_setup_selb_fail;
  392. }
  393. ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
  394. if (ret) {
  395. pr_warning("Cannot open UI expander pin %d\n", sel_c);
  396. goto exp_setup_selc_fail;
  397. }
  398. /* deselect all functionalities */
  399. gpio_direction_output(sel_a, 1);
  400. gpio_direction_output(sel_b, 1);
  401. gpio_direction_output(sel_c, 1);
  402. da850_evm_ui_keys_init(gpio);
  403. ret = platform_device_register(&da850_evm_ui_keys_device);
  404. if (ret) {
  405. pr_warning("Could not register UI GPIO expander push-buttons");
  406. goto exp_setup_keys_fail;
  407. }
  408. pr_info("DA850/OMAP-L138 EVM UI card detected\n");
  409. da850_evm_setup_nor_nand();
  410. da850_evm_setup_emac_rmii(sel_a);
  411. return 0;
  412. exp_setup_keys_fail:
  413. gpio_free(sel_c);
  414. exp_setup_selc_fail:
  415. gpio_free(sel_b);
  416. exp_setup_selb_fail:
  417. gpio_free(sel_a);
  418. exp_setup_sela_fail:
  419. return ret;
  420. }
  421. static int da850_evm_ui_expander_teardown(struct i2c_client *client,
  422. unsigned gpio, unsigned ngpio, void *c)
  423. {
  424. platform_device_unregister(&da850_evm_ui_keys_device);
  425. /* deselect all functionalities */
  426. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
  427. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
  428. gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
  429. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
  430. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
  431. gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
  432. return 0;
  433. }
  434. /* assign the baseboard expander's GPIOs after the UI board's */
  435. #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
  436. #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
  437. enum da850_evm_bb_exp_pins {
  438. DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
  439. DA850_EVM_BB_EXP_SW_RST,
  440. DA850_EVM_BB_EXP_TP_23,
  441. DA850_EVM_BB_EXP_TP_22,
  442. DA850_EVM_BB_EXP_TP_21,
  443. DA850_EVM_BB_EXP_USER_PB1,
  444. DA850_EVM_BB_EXP_USER_LED2,
  445. DA850_EVM_BB_EXP_USER_LED1,
  446. DA850_EVM_BB_EXP_USER_SW1,
  447. DA850_EVM_BB_EXP_USER_SW2,
  448. DA850_EVM_BB_EXP_USER_SW3,
  449. DA850_EVM_BB_EXP_USER_SW4,
  450. DA850_EVM_BB_EXP_USER_SW5,
  451. DA850_EVM_BB_EXP_USER_SW6,
  452. DA850_EVM_BB_EXP_USER_SW7,
  453. DA850_EVM_BB_EXP_USER_SW8
  454. };
  455. static const char const *da850_evm_bb_exp[] = {
  456. [DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en",
  457. [DA850_EVM_BB_EXP_SW_RST] = "sw_rst",
  458. [DA850_EVM_BB_EXP_TP_23] = "tp_23",
  459. [DA850_EVM_BB_EXP_TP_22] = "tp_22",
  460. [DA850_EVM_BB_EXP_TP_21] = "tp_21",
  461. [DA850_EVM_BB_EXP_USER_PB1] = "user_pb1",
  462. [DA850_EVM_BB_EXP_USER_LED2] = "user_led2",
  463. [DA850_EVM_BB_EXP_USER_LED1] = "user_led1",
  464. [DA850_EVM_BB_EXP_USER_SW1] = "user_sw1",
  465. [DA850_EVM_BB_EXP_USER_SW2] = "user_sw2",
  466. [DA850_EVM_BB_EXP_USER_SW3] = "user_sw3",
  467. [DA850_EVM_BB_EXP_USER_SW4] = "user_sw4",
  468. [DA850_EVM_BB_EXP_USER_SW5] = "user_sw5",
  469. [DA850_EVM_BB_EXP_USER_SW6] = "user_sw6",
  470. [DA850_EVM_BB_EXP_USER_SW7] = "user_sw7",
  471. [DA850_EVM_BB_EXP_USER_SW8] = "user_sw8",
  472. };
  473. #define DA850_N_BB_USER_SW 8
  474. static struct gpio_keys_button da850_evm_bb_keys[] = {
  475. [0] = {
  476. .type = EV_KEY,
  477. .active_low = 1,
  478. .wakeup = 0,
  479. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  480. .code = KEY_PROG1,
  481. .desc = NULL, /* assigned at runtime */
  482. .gpio = -1, /* assigned at runtime */
  483. },
  484. [1 ... DA850_N_BB_USER_SW] = {
  485. .type = EV_SW,
  486. .active_low = 1,
  487. .wakeup = 0,
  488. .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
  489. .code = -1, /* assigned at runtime */
  490. .desc = NULL, /* assigned at runtime */
  491. .gpio = -1, /* assigned at runtime */
  492. },
  493. };
  494. static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
  495. .buttons = da850_evm_bb_keys,
  496. .nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
  497. .poll_interval = DA850_GPIO_KEYS_POLL_MS,
  498. };
  499. static struct platform_device da850_evm_bb_keys_device = {
  500. .name = "gpio-keys-polled",
  501. .id = 1,
  502. .dev = {
  503. .platform_data = &da850_evm_bb_keys_pdata
  504. },
  505. };
  506. static void da850_evm_bb_keys_init(unsigned gpio)
  507. {
  508. int i;
  509. struct gpio_keys_button *button;
  510. button = &da850_evm_bb_keys[0];
  511. button->desc = (char *)
  512. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
  513. button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
  514. for (i = 0; i < DA850_N_BB_USER_SW; i++) {
  515. button = &da850_evm_bb_keys[i + 1];
  516. button->code = SW_LID + i;
  517. button->desc = (char *)
  518. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
  519. button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
  520. }
  521. }
  522. #define DA850_N_BB_USER_LED 2
  523. static struct gpio_led da850_evm_bb_leds[] = {
  524. [0 ... DA850_N_BB_USER_LED - 1] = {
  525. .active_low = 1,
  526. .gpio = -1, /* assigned at runtime */
  527. .name = NULL, /* assigned at runtime */
  528. },
  529. };
  530. static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
  531. .leds = da850_evm_bb_leds,
  532. .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
  533. };
  534. static struct platform_device da850_evm_bb_leds_device = {
  535. .name = "leds-gpio",
  536. .id = -1,
  537. .dev = {
  538. .platform_data = &da850_evm_bb_leds_pdata
  539. }
  540. };
  541. static void da850_evm_bb_leds_init(unsigned gpio)
  542. {
  543. int i;
  544. struct gpio_led *led;
  545. for (i = 0; i < DA850_N_BB_USER_LED; i++) {
  546. led = &da850_evm_bb_leds[i];
  547. led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
  548. led->name =
  549. da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
  550. }
  551. }
  552. static int da850_evm_bb_expander_setup(struct i2c_client *client,
  553. unsigned gpio, unsigned ngpio,
  554. void *c)
  555. {
  556. int ret;
  557. /*
  558. * Register the switches and pushbutton on the baseboard as a gpio-keys
  559. * device.
  560. */
  561. da850_evm_bb_keys_init(gpio);
  562. ret = platform_device_register(&da850_evm_bb_keys_device);
  563. if (ret) {
  564. pr_warning("Could not register baseboard GPIO expander keys");
  565. goto io_exp_setup_sw_fail;
  566. }
  567. da850_evm_bb_leds_init(gpio);
  568. ret = platform_device_register(&da850_evm_bb_leds_device);
  569. if (ret) {
  570. pr_warning("Could not register baseboard GPIO expander LEDS");
  571. goto io_exp_setup_leds_fail;
  572. }
  573. return 0;
  574. io_exp_setup_leds_fail:
  575. platform_device_unregister(&da850_evm_bb_keys_device);
  576. io_exp_setup_sw_fail:
  577. return ret;
  578. }
  579. static int da850_evm_bb_expander_teardown(struct i2c_client *client,
  580. unsigned gpio, unsigned ngpio, void *c)
  581. {
  582. platform_device_unregister(&da850_evm_bb_leds_device);
  583. platform_device_unregister(&da850_evm_bb_keys_device);
  584. return 0;
  585. }
  586. static struct pca953x_platform_data da850_evm_ui_expander_info = {
  587. .gpio_base = DAVINCI_N_GPIO,
  588. .setup = da850_evm_ui_expander_setup,
  589. .teardown = da850_evm_ui_expander_teardown,
  590. .names = da850_evm_ui_exp,
  591. };
  592. static struct pca953x_platform_data da850_evm_bb_expander_info = {
  593. .gpio_base = DA850_BB_EXPANDER_GPIO_BASE,
  594. .setup = da850_evm_bb_expander_setup,
  595. .teardown = da850_evm_bb_expander_teardown,
  596. .names = da850_evm_bb_exp,
  597. };
  598. static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
  599. {
  600. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  601. },
  602. {
  603. I2C_BOARD_INFO("tca6416", 0x20),
  604. .platform_data = &da850_evm_ui_expander_info,
  605. },
  606. {
  607. I2C_BOARD_INFO("tca6416", 0x21),
  608. .platform_data = &da850_evm_bb_expander_info,
  609. },
  610. };
  611. static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
  612. .bus_freq = 100, /* kHz */
  613. .bus_delay = 0, /* usec */
  614. };
  615. static struct davinci_uart_config da850_evm_uart_config __initdata = {
  616. .enabled_uarts = 0x7,
  617. };
  618. /* davinci da850 evm audio machine driver */
  619. static u8 da850_iis_serializer_direction[] = {
  620. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  621. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  622. INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
  623. RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
  624. };
  625. static struct snd_platform_data da850_evm_snd_data = {
  626. .tx_dma_offset = 0x2000,
  627. .rx_dma_offset = 0x2000,
  628. .op_mode = DAVINCI_MCASP_IIS_MODE,
  629. .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
  630. .tdm_slots = 2,
  631. .serial_dir = da850_iis_serializer_direction,
  632. .asp_chan_q = EVENTQ_1,
  633. .version = MCASP_VERSION_2,
  634. .txnumevt = 1,
  635. .rxnumevt = 1,
  636. };
  637. static const short da850_evm_mcasp_pins[] __initconst = {
  638. DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
  639. DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
  640. DA850_AXR_11, DA850_AXR_12,
  641. -1
  642. };
  643. static int da850_evm_mmc_get_ro(int index)
  644. {
  645. return gpio_get_value(DA850_MMCSD_WP_PIN);
  646. }
  647. static int da850_evm_mmc_get_cd(int index)
  648. {
  649. return !gpio_get_value(DA850_MMCSD_CD_PIN);
  650. }
  651. static struct davinci_mmc_config da850_mmc_config = {
  652. .get_ro = da850_evm_mmc_get_ro,
  653. .get_cd = da850_evm_mmc_get_cd,
  654. .wires = 4,
  655. .max_freq = 50000000,
  656. .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
  657. .version = MMC_CTLR_VERSION_2,
  658. };
  659. static const short da850_evm_mmcsd0_pins[] __initconst = {
  660. DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
  661. DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
  662. DA850_GPIO4_0, DA850_GPIO4_1,
  663. -1
  664. };
  665. static void da850_panel_power_ctrl(int val)
  666. {
  667. /* lcd backlight */
  668. gpio_set_value(DA850_LCD_BL_PIN, val);
  669. /* lcd power */
  670. gpio_set_value(DA850_LCD_PWR_PIN, val);
  671. }
  672. static int da850_lcd_hw_init(void)
  673. {
  674. int status;
  675. status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
  676. if (status < 0)
  677. return status;
  678. status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
  679. if (status < 0) {
  680. gpio_free(DA850_LCD_BL_PIN);
  681. return status;
  682. }
  683. gpio_direction_output(DA850_LCD_BL_PIN, 0);
  684. gpio_direction_output(DA850_LCD_PWR_PIN, 0);
  685. /* Switch off panel power and backlight */
  686. da850_panel_power_ctrl(0);
  687. /* Switch on panel power and backlight */
  688. da850_panel_power_ctrl(1);
  689. return 0;
  690. }
  691. /* TPS65070 voltage regulator support */
  692. /* 3.3V */
  693. static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
  694. {
  695. .supply = "usb0_vdda33",
  696. },
  697. {
  698. .supply = "usb1_vdda33",
  699. },
  700. };
  701. /* 3.3V or 1.8V */
  702. static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
  703. {
  704. .supply = "dvdd3318_a",
  705. },
  706. {
  707. .supply = "dvdd3318_b",
  708. },
  709. {
  710. .supply = "dvdd3318_c",
  711. },
  712. };
  713. /* 1.2V */
  714. static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
  715. {
  716. .supply = "cvdd",
  717. },
  718. };
  719. /* 1.8V LDO */
  720. static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
  721. {
  722. .supply = "sata_vddr",
  723. },
  724. {
  725. .supply = "usb0_vdda18",
  726. },
  727. {
  728. .supply = "usb1_vdda18",
  729. },
  730. {
  731. .supply = "ddr_dvdd18",
  732. },
  733. };
  734. /* 1.2V LDO */
  735. static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
  736. {
  737. .supply = "sata_vdd",
  738. },
  739. {
  740. .supply = "pll0_vdda",
  741. },
  742. {
  743. .supply = "pll1_vdda",
  744. },
  745. {
  746. .supply = "usbs_cvdd",
  747. },
  748. {
  749. .supply = "vddarnwa1",
  750. },
  751. };
  752. /* We take advantage of the fact that both defdcdc{2,3} are tied high */
  753. static struct tps6507x_reg_platform_data tps6507x_platform_data = {
  754. .defdcdc_default = true,
  755. };
  756. static struct regulator_init_data tps65070_regulator_data[] = {
  757. /* dcdc1 */
  758. {
  759. .constraints = {
  760. .min_uV = 3150000,
  761. .max_uV = 3450000,
  762. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  763. REGULATOR_CHANGE_STATUS),
  764. .boot_on = 1,
  765. },
  766. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
  767. .consumer_supplies = tps65070_dcdc1_consumers,
  768. },
  769. /* dcdc2 */
  770. {
  771. .constraints = {
  772. .min_uV = 1710000,
  773. .max_uV = 3450000,
  774. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  775. REGULATOR_CHANGE_STATUS),
  776. .boot_on = 1,
  777. },
  778. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
  779. .consumer_supplies = tps65070_dcdc2_consumers,
  780. .driver_data = &tps6507x_platform_data,
  781. },
  782. /* dcdc3 */
  783. {
  784. .constraints = {
  785. .min_uV = 950000,
  786. .max_uV = 1350000,
  787. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  788. REGULATOR_CHANGE_STATUS),
  789. .boot_on = 1,
  790. },
  791. .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
  792. .consumer_supplies = tps65070_dcdc3_consumers,
  793. .driver_data = &tps6507x_platform_data,
  794. },
  795. /* ldo1 */
  796. {
  797. .constraints = {
  798. .min_uV = 1710000,
  799. .max_uV = 1890000,
  800. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  801. REGULATOR_CHANGE_STATUS),
  802. .boot_on = 1,
  803. },
  804. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
  805. .consumer_supplies = tps65070_ldo1_consumers,
  806. },
  807. /* ldo2 */
  808. {
  809. .constraints = {
  810. .min_uV = 1140000,
  811. .max_uV = 1320000,
  812. .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
  813. REGULATOR_CHANGE_STATUS),
  814. .boot_on = 1,
  815. },
  816. .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
  817. .consumer_supplies = tps65070_ldo2_consumers,
  818. },
  819. };
  820. static struct touchscreen_init_data tps6507x_touchscreen_data = {
  821. .poll_period = 30, /* ms between touch samples */
  822. .min_pressure = 0x30, /* minimum pressure to trigger touch */
  823. .vref = 0, /* turn off vref when not using A/D */
  824. .vendor = 0, /* /sys/class/input/input?/id/vendor */
  825. .product = 65070, /* /sys/class/input/input?/id/product */
  826. .version = 0x100, /* /sys/class/input/input?/id/version */
  827. };
  828. static struct tps6507x_board tps_board = {
  829. .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
  830. .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
  831. };
  832. static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
  833. {
  834. I2C_BOARD_INFO("tps6507x", 0x48),
  835. .platform_data = &tps_board,
  836. },
  837. };
  838. static int __init pmic_tps65070_init(void)
  839. {
  840. return i2c_register_board_info(1, da850_evm_tps65070_info,
  841. ARRAY_SIZE(da850_evm_tps65070_info));
  842. }
  843. static const short da850_evm_lcdc_pins[] = {
  844. DA850_GPIO2_8, DA850_GPIO2_15,
  845. -1
  846. };
  847. static const short da850_evm_mii_pins[] = {
  848. DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
  849. DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
  850. DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
  851. DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
  852. DA850_MDIO_D,
  853. -1
  854. };
  855. static const short da850_evm_rmii_pins[] = {
  856. DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
  857. DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
  858. DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
  859. DA850_MDIO_D,
  860. -1
  861. };
  862. static int __init da850_evm_config_emac(void)
  863. {
  864. void __iomem *cfg_chip3_base;
  865. int ret;
  866. u32 val;
  867. struct davinci_soc_info *soc_info = &davinci_soc_info;
  868. u8 rmii_en = soc_info->emac_pdata->rmii_en;
  869. if (!machine_is_davinci_da850_evm())
  870. return 0;
  871. cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
  872. val = __raw_readl(cfg_chip3_base);
  873. if (rmii_en) {
  874. val |= BIT(8);
  875. ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
  876. pr_info("EMAC: RMII PHY configured, MII PHY will not be"
  877. " functional\n");
  878. } else {
  879. val &= ~BIT(8);
  880. ret = davinci_cfg_reg_list(da850_evm_mii_pins);
  881. pr_info("EMAC: MII PHY configured, RMII PHY will not be"
  882. " functional\n");
  883. }
  884. if (ret)
  885. pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
  886. ret);
  887. /* configure the CFGCHIP3 register for RMII or MII */
  888. __raw_writel(val, cfg_chip3_base);
  889. ret = davinci_cfg_reg(DA850_GPIO2_6);
  890. if (ret)
  891. pr_warning("da850_evm_init:GPIO(2,6) mux setup "
  892. "failed\n");
  893. ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
  894. if (ret) {
  895. pr_warning("Cannot open GPIO %d\n",
  896. DA850_MII_MDIO_CLKEN_PIN);
  897. return ret;
  898. }
  899. /* Enable/Disable MII MDIO clock */
  900. gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
  901. soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
  902. ret = da8xx_register_emac();
  903. if (ret)
  904. pr_warning("da850_evm_init: emac registration failed: %d\n",
  905. ret);
  906. return 0;
  907. }
  908. device_initcall(da850_evm_config_emac);
  909. /*
  910. * The following EDMA channels/slots are not being used by drivers (for
  911. * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
  912. * they are being reserved for codecs on the DSP side.
  913. */
  914. static const s16 da850_dma0_rsv_chans[][2] = {
  915. /* (offset, number) */
  916. { 8, 6},
  917. {24, 4},
  918. {30, 2},
  919. {-1, -1}
  920. };
  921. static const s16 da850_dma0_rsv_slots[][2] = {
  922. /* (offset, number) */
  923. { 8, 6},
  924. {24, 4},
  925. {30, 50},
  926. {-1, -1}
  927. };
  928. static const s16 da850_dma1_rsv_chans[][2] = {
  929. /* (offset, number) */
  930. { 0, 28},
  931. {30, 2},
  932. {-1, -1}
  933. };
  934. static const s16 da850_dma1_rsv_slots[][2] = {
  935. /* (offset, number) */
  936. { 0, 28},
  937. {30, 90},
  938. {-1, -1}
  939. };
  940. static struct edma_rsv_info da850_edma_cc0_rsv = {
  941. .rsv_chans = da850_dma0_rsv_chans,
  942. .rsv_slots = da850_dma0_rsv_slots,
  943. };
  944. static struct edma_rsv_info da850_edma_cc1_rsv = {
  945. .rsv_chans = da850_dma1_rsv_chans,
  946. .rsv_slots = da850_dma1_rsv_slots,
  947. };
  948. static struct edma_rsv_info *da850_edma_rsv[2] = {
  949. &da850_edma_cc0_rsv,
  950. &da850_edma_cc1_rsv,
  951. };
  952. #ifdef CONFIG_CPU_FREQ
  953. static __init int da850_evm_init_cpufreq(void)
  954. {
  955. switch (system_rev & 0xF) {
  956. case 3:
  957. da850_max_speed = 456000;
  958. break;
  959. case 2:
  960. da850_max_speed = 408000;
  961. break;
  962. case 1:
  963. da850_max_speed = 372000;
  964. break;
  965. }
  966. return da850_register_cpufreq("pll0_sysclk3");
  967. }
  968. #else
  969. static __init int da850_evm_init_cpufreq(void) { return 0; }
  970. #endif
  971. #define DA850EVM_SATA_REFCLKPN_RATE (100 * 1000 * 1000)
  972. static __init void da850_evm_init(void)
  973. {
  974. int ret;
  975. ret = pmic_tps65070_init();
  976. if (ret)
  977. pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
  978. ret);
  979. ret = da850_register_edma(da850_edma_rsv);
  980. if (ret)
  981. pr_warning("da850_evm_init: edma registration failed: %d\n",
  982. ret);
  983. ret = davinci_cfg_reg_list(da850_i2c0_pins);
  984. if (ret)
  985. pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
  986. ret);
  987. ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
  988. if (ret)
  989. pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
  990. ret);
  991. ret = da8xx_register_watchdog();
  992. if (ret)
  993. pr_warning("da830_evm_init: watchdog registration failed: %d\n",
  994. ret);
  995. if (HAS_MMC) {
  996. ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
  997. if (ret)
  998. pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
  999. " %d\n", ret);
  1000. ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
  1001. if (ret)
  1002. pr_warning("da850_evm_init: can not open GPIO %d\n",
  1003. DA850_MMCSD_CD_PIN);
  1004. gpio_direction_input(DA850_MMCSD_CD_PIN);
  1005. ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
  1006. if (ret)
  1007. pr_warning("da850_evm_init: can not open GPIO %d\n",
  1008. DA850_MMCSD_WP_PIN);
  1009. gpio_direction_input(DA850_MMCSD_WP_PIN);
  1010. ret = da8xx_register_mmcsd0(&da850_mmc_config);
  1011. if (ret)
  1012. pr_warning("da850_evm_init: mmcsd0 registration failed:"
  1013. " %d\n", ret);
  1014. }
  1015. davinci_serial_init(&da850_evm_uart_config);
  1016. i2c_register_board_info(1, da850_evm_i2c_devices,
  1017. ARRAY_SIZE(da850_evm_i2c_devices));
  1018. /*
  1019. * shut down uart 0 and 1; they are not used on the board and
  1020. * accessing them causes endless "too much work in irq53" messages
  1021. * with arago fs
  1022. */
  1023. __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
  1024. __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
  1025. ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
  1026. if (ret)
  1027. pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
  1028. ret);
  1029. da8xx_register_mcasp(0, &da850_evm_snd_data);
  1030. ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
  1031. if (ret)
  1032. pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
  1033. ret);
  1034. /* Handle board specific muxing for LCD here */
  1035. ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
  1036. if (ret)
  1037. pr_warning("da850_evm_init: evm specific lcd mux setup "
  1038. "failed: %d\n", ret);
  1039. ret = da850_lcd_hw_init();
  1040. if (ret)
  1041. pr_warning("da850_evm_init: lcd initialization failed: %d\n",
  1042. ret);
  1043. sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
  1044. ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
  1045. if (ret)
  1046. pr_warning("da850_evm_init: lcdc registration failed: %d\n",
  1047. ret);
  1048. ret = da8xx_register_rtc();
  1049. if (ret)
  1050. pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
  1051. ret = da850_evm_init_cpufreq();
  1052. if (ret)
  1053. pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
  1054. ret);
  1055. ret = da8xx_register_cpuidle();
  1056. if (ret)
  1057. pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
  1058. ret);
  1059. ret = da850_register_pm(&da850_pm_device);
  1060. if (ret)
  1061. pr_warning("da850_evm_init: suspend registration failed: %d\n",
  1062. ret);
  1063. ret = da8xx_register_spi(1, da850evm_spi_info,
  1064. ARRAY_SIZE(da850evm_spi_info));
  1065. if (ret)
  1066. pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
  1067. ret);
  1068. ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
  1069. if (ret)
  1070. pr_warning("da850_evm_init: sata registration failed: %d\n",
  1071. ret);
  1072. }
  1073. #ifdef CONFIG_SERIAL_8250_CONSOLE
  1074. static int __init da850_evm_console_init(void)
  1075. {
  1076. if (!machine_is_davinci_da850_evm())
  1077. return 0;
  1078. return add_preferred_console("ttyS", 2, "115200");
  1079. }
  1080. console_initcall(da850_evm_console_init);
  1081. #endif
  1082. static void __init da850_evm_map_io(void)
  1083. {
  1084. da850_init();
  1085. }
  1086. MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
  1087. .boot_params = (DA8XX_DDR_BASE + 0x100),
  1088. .map_io = da850_evm_map_io,
  1089. .init_irq = cp_intc_init,
  1090. .timer = &davinci_timer,
  1091. .init_machine = da850_evm_init,
  1092. .dma_zone_size = SZ_128M,
  1093. MACHINE_END