board-da850-evm.c 34 KB

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