devices-da8xx.c 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. /*
  2. * DA8XX/OMAP L1XX platform device data
  3. *
  4. * Copyright (c) 2007-2009, MontaVista Software, Inc. <source@mvista.com>
  5. * Derived from code that was:
  6. * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/dma-contiguous.h>
  16. #include <linux/serial_8250.h>
  17. #include <linux/ahci_platform.h>
  18. #include <linux/clk.h>
  19. #include <linux/reboot.h>
  20. #include <linux/dmaengine.h>
  21. #include <mach/cputype.h>
  22. #include <mach/common.h>
  23. #include <mach/time.h>
  24. #include <mach/da8xx.h>
  25. #include "cpuidle.h"
  26. #include "sram.h"
  27. #include "clock.h"
  28. #include "asp.h"
  29. #define DA8XX_TPCC_BASE 0x01c00000
  30. #define DA8XX_TPTC0_BASE 0x01c08000
  31. #define DA8XX_TPTC1_BASE 0x01c08400
  32. #define DA8XX_WDOG_BASE 0x01c21000 /* DA8XX_TIMER64P1_BASE */
  33. #define DA8XX_I2C0_BASE 0x01c22000
  34. #define DA8XX_RTC_BASE 0x01c23000
  35. #define DA8XX_PRUSS_MEM_BASE 0x01c30000
  36. #define DA8XX_MMCSD0_BASE 0x01c40000
  37. #define DA8XX_SPI0_BASE 0x01c41000
  38. #define DA830_SPI1_BASE 0x01e12000
  39. #define DA8XX_LCD_CNTRL_BASE 0x01e13000
  40. #define DA850_SATA_BASE 0x01e18000
  41. #define DA850_MMCSD1_BASE 0x01e1b000
  42. #define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000
  43. #define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000
  44. #define DA8XX_EMAC_CPGMAC_BASE 0x01e23000
  45. #define DA8XX_EMAC_MDIO_BASE 0x01e24000
  46. #define DA8XX_I2C1_BASE 0x01e28000
  47. #define DA850_TPCC1_BASE 0x01e30000
  48. #define DA850_TPTC2_BASE 0x01e38000
  49. #define DA850_SPI1_BASE 0x01f0e000
  50. #define DA8XX_DDR2_CTL_BASE 0xb0000000
  51. #define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000
  52. #define DA8XX_EMAC_MOD_REG_OFFSET 0x2000
  53. #define DA8XX_EMAC_RAM_OFFSET 0x0000
  54. #define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K
  55. #define DA8XX_DMA_SPI0_RX EDMA_CTLR_CHAN(0, 14)
  56. #define DA8XX_DMA_SPI0_TX EDMA_CTLR_CHAN(0, 15)
  57. #define DA8XX_DMA_MMCSD0_RX EDMA_CTLR_CHAN(0, 16)
  58. #define DA8XX_DMA_MMCSD0_TX EDMA_CTLR_CHAN(0, 17)
  59. #define DA8XX_DMA_SPI1_RX EDMA_CTLR_CHAN(0, 18)
  60. #define DA8XX_DMA_SPI1_TX EDMA_CTLR_CHAN(0, 19)
  61. #define DA850_DMA_MMCSD1_RX EDMA_CTLR_CHAN(1, 28)
  62. #define DA850_DMA_MMCSD1_TX EDMA_CTLR_CHAN(1, 29)
  63. void __iomem *da8xx_syscfg0_base;
  64. void __iomem *da8xx_syscfg1_base;
  65. static struct plat_serial8250_port da8xx_serial0_pdata[] = {
  66. {
  67. .mapbase = DA8XX_UART0_BASE,
  68. .irq = IRQ_DA8XX_UARTINT0,
  69. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  70. UPF_IOREMAP,
  71. .iotype = UPIO_MEM,
  72. .regshift = 2,
  73. },
  74. {
  75. .flags = 0,
  76. }
  77. };
  78. static struct plat_serial8250_port da8xx_serial1_pdata[] = {
  79. {
  80. .mapbase = DA8XX_UART1_BASE,
  81. .irq = IRQ_DA8XX_UARTINT1,
  82. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  83. UPF_IOREMAP,
  84. .iotype = UPIO_MEM,
  85. .regshift = 2,
  86. },
  87. {
  88. .flags = 0,
  89. }
  90. };
  91. static struct plat_serial8250_port da8xx_serial2_pdata[] = {
  92. {
  93. .mapbase = DA8XX_UART2_BASE,
  94. .irq = IRQ_DA8XX_UARTINT2,
  95. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  96. UPF_IOREMAP,
  97. .iotype = UPIO_MEM,
  98. .regshift = 2,
  99. },
  100. {
  101. .flags = 0,
  102. }
  103. };
  104. struct platform_device da8xx_serial_device[] = {
  105. {
  106. .name = "serial8250",
  107. .id = PLAT8250_DEV_PLATFORM,
  108. .dev = {
  109. .platform_data = da8xx_serial0_pdata,
  110. }
  111. },
  112. {
  113. .name = "serial8250",
  114. .id = PLAT8250_DEV_PLATFORM1,
  115. .dev = {
  116. .platform_data = da8xx_serial1_pdata,
  117. }
  118. },
  119. {
  120. .name = "serial8250",
  121. .id = PLAT8250_DEV_PLATFORM2,
  122. .dev = {
  123. .platform_data = da8xx_serial2_pdata,
  124. }
  125. },
  126. {
  127. }
  128. };
  129. static s8 da8xx_queue_priority_mapping[][2] = {
  130. /* {event queue no, Priority} */
  131. {0, 3},
  132. {1, 7},
  133. {-1, -1}
  134. };
  135. static s8 da850_queue_priority_mapping[][2] = {
  136. /* {event queue no, Priority} */
  137. {0, 3},
  138. {-1, -1}
  139. };
  140. static struct edma_soc_info da8xx_edma0_pdata = {
  141. .queue_priority_mapping = da8xx_queue_priority_mapping,
  142. .default_queue = EVENTQ_1,
  143. };
  144. static struct edma_soc_info da850_edma1_pdata = {
  145. .queue_priority_mapping = da850_queue_priority_mapping,
  146. .default_queue = EVENTQ_0,
  147. };
  148. static struct resource da8xx_edma0_resources[] = {
  149. {
  150. .name = "edma3_cc",
  151. .start = DA8XX_TPCC_BASE,
  152. .end = DA8XX_TPCC_BASE + SZ_32K - 1,
  153. .flags = IORESOURCE_MEM,
  154. },
  155. {
  156. .name = "edma3_tc0",
  157. .start = DA8XX_TPTC0_BASE,
  158. .end = DA8XX_TPTC0_BASE + SZ_1K - 1,
  159. .flags = IORESOURCE_MEM,
  160. },
  161. {
  162. .name = "edma3_tc1",
  163. .start = DA8XX_TPTC1_BASE,
  164. .end = DA8XX_TPTC1_BASE + SZ_1K - 1,
  165. .flags = IORESOURCE_MEM,
  166. },
  167. {
  168. .name = "edma3_ccint",
  169. .start = IRQ_DA8XX_CCINT0,
  170. .flags = IORESOURCE_IRQ,
  171. },
  172. {
  173. .name = "edma3_ccerrint",
  174. .start = IRQ_DA8XX_CCERRINT,
  175. .flags = IORESOURCE_IRQ,
  176. },
  177. };
  178. static struct resource da850_edma1_resources[] = {
  179. {
  180. .name = "edma3_cc",
  181. .start = DA850_TPCC1_BASE,
  182. .end = DA850_TPCC1_BASE + SZ_32K - 1,
  183. .flags = IORESOURCE_MEM,
  184. },
  185. {
  186. .name = "edma3_tc0",
  187. .start = DA850_TPTC2_BASE,
  188. .end = DA850_TPTC2_BASE + SZ_1K - 1,
  189. .flags = IORESOURCE_MEM,
  190. },
  191. {
  192. .name = "edma3_ccint",
  193. .start = IRQ_DA850_CCINT1,
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. {
  197. .name = "edma3_ccerrint",
  198. .start = IRQ_DA850_CCERRINT1,
  199. .flags = IORESOURCE_IRQ,
  200. },
  201. };
  202. static const struct platform_device_info da8xx_edma0_device __initconst = {
  203. .name = "edma",
  204. .id = 0,
  205. .dma_mask = DMA_BIT_MASK(32),
  206. .res = da8xx_edma0_resources,
  207. .num_res = ARRAY_SIZE(da8xx_edma0_resources),
  208. .data = &da8xx_edma0_pdata,
  209. .size_data = sizeof(da8xx_edma0_pdata),
  210. };
  211. static const struct platform_device_info da850_edma1_device __initconst = {
  212. .name = "edma",
  213. .id = 1,
  214. .dma_mask = DMA_BIT_MASK(32),
  215. .res = da850_edma1_resources,
  216. .num_res = ARRAY_SIZE(da850_edma1_resources),
  217. .data = &da850_edma1_pdata,
  218. .size_data = sizeof(da850_edma1_pdata),
  219. };
  220. static const struct dma_slave_map da830_edma_map[] = {
  221. { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 0) },
  222. { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 1) },
  223. { "davinci-mcasp.1", "rx", EDMA_FILTER_PARAM(0, 2) },
  224. { "davinci-mcasp.1", "tx", EDMA_FILTER_PARAM(0, 3) },
  225. { "davinci-mcasp.2", "rx", EDMA_FILTER_PARAM(0, 4) },
  226. { "davinci-mcasp.2", "tx", EDMA_FILTER_PARAM(0, 5) },
  227. { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 14) },
  228. { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 15) },
  229. { "da830-mmc.0", "rx", EDMA_FILTER_PARAM(0, 16) },
  230. { "da830-mmc.0", "tx", EDMA_FILTER_PARAM(0, 17) },
  231. { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 18) },
  232. { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 19) },
  233. };
  234. int __init da830_register_edma(struct edma_rsv_info *rsv)
  235. {
  236. struct platform_device *edma_pdev;
  237. da8xx_edma0_pdata.rsv = rsv;
  238. da8xx_edma0_pdata.slave_map = da830_edma_map;
  239. da8xx_edma0_pdata.slavecnt = ARRAY_SIZE(da830_edma_map);
  240. edma_pdev = platform_device_register_full(&da8xx_edma0_device);
  241. return IS_ERR(edma_pdev) ? PTR_ERR(edma_pdev) : 0;
  242. }
  243. static const struct dma_slave_map da850_edma0_map[] = {
  244. { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 0) },
  245. { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 1) },
  246. { "davinci-mcbsp.0", "rx", EDMA_FILTER_PARAM(0, 2) },
  247. { "davinci-mcbsp.0", "tx", EDMA_FILTER_PARAM(0, 3) },
  248. { "davinci-mcbsp.1", "rx", EDMA_FILTER_PARAM(0, 4) },
  249. { "davinci-mcbsp.1", "tx", EDMA_FILTER_PARAM(0, 5) },
  250. { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 14) },
  251. { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 15) },
  252. { "da830-mmc.0", "rx", EDMA_FILTER_PARAM(0, 16) },
  253. { "da830-mmc.0", "tx", EDMA_FILTER_PARAM(0, 17) },
  254. { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 18) },
  255. { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 19) },
  256. };
  257. static const struct dma_slave_map da850_edma1_map[] = {
  258. { "da830-mmc.1", "rx", EDMA_FILTER_PARAM(1, 28) },
  259. { "da830-mmc.1", "tx", EDMA_FILTER_PARAM(1, 29) },
  260. };
  261. int __init da850_register_edma(struct edma_rsv_info *rsv[2])
  262. {
  263. struct platform_device *edma_pdev;
  264. if (rsv) {
  265. da8xx_edma0_pdata.rsv = rsv[0];
  266. da850_edma1_pdata.rsv = rsv[1];
  267. }
  268. da8xx_edma0_pdata.slave_map = da850_edma0_map;
  269. da8xx_edma0_pdata.slavecnt = ARRAY_SIZE(da850_edma0_map);
  270. edma_pdev = platform_device_register_full(&da8xx_edma0_device);
  271. if (IS_ERR(edma_pdev)) {
  272. pr_warn("%s: Failed to register eDMA0\n", __func__);
  273. return PTR_ERR(edma_pdev);
  274. }
  275. da850_edma1_pdata.slave_map = da850_edma1_map;
  276. da850_edma1_pdata.slavecnt = ARRAY_SIZE(da850_edma1_map);
  277. edma_pdev = platform_device_register_full(&da850_edma1_device);
  278. return IS_ERR(edma_pdev) ? PTR_ERR(edma_pdev) : 0;
  279. }
  280. static struct resource da8xx_i2c_resources0[] = {
  281. {
  282. .start = DA8XX_I2C0_BASE,
  283. .end = DA8XX_I2C0_BASE + SZ_4K - 1,
  284. .flags = IORESOURCE_MEM,
  285. },
  286. {
  287. .start = IRQ_DA8XX_I2CINT0,
  288. .end = IRQ_DA8XX_I2CINT0,
  289. .flags = IORESOURCE_IRQ,
  290. },
  291. };
  292. static struct platform_device da8xx_i2c_device0 = {
  293. .name = "i2c_davinci",
  294. .id = 1,
  295. .num_resources = ARRAY_SIZE(da8xx_i2c_resources0),
  296. .resource = da8xx_i2c_resources0,
  297. };
  298. static struct resource da8xx_i2c_resources1[] = {
  299. {
  300. .start = DA8XX_I2C1_BASE,
  301. .end = DA8XX_I2C1_BASE + SZ_4K - 1,
  302. .flags = IORESOURCE_MEM,
  303. },
  304. {
  305. .start = IRQ_DA8XX_I2CINT1,
  306. .end = IRQ_DA8XX_I2CINT1,
  307. .flags = IORESOURCE_IRQ,
  308. },
  309. };
  310. static struct platform_device da8xx_i2c_device1 = {
  311. .name = "i2c_davinci",
  312. .id = 2,
  313. .num_resources = ARRAY_SIZE(da8xx_i2c_resources1),
  314. .resource = da8xx_i2c_resources1,
  315. };
  316. int __init da8xx_register_i2c(int instance,
  317. struct davinci_i2c_platform_data *pdata)
  318. {
  319. struct platform_device *pdev;
  320. if (instance == 0)
  321. pdev = &da8xx_i2c_device0;
  322. else if (instance == 1)
  323. pdev = &da8xx_i2c_device1;
  324. else
  325. return -EINVAL;
  326. pdev->dev.platform_data = pdata;
  327. return platform_device_register(pdev);
  328. }
  329. static struct resource da8xx_watchdog_resources[] = {
  330. {
  331. .start = DA8XX_WDOG_BASE,
  332. .end = DA8XX_WDOG_BASE + SZ_4K - 1,
  333. .flags = IORESOURCE_MEM,
  334. },
  335. };
  336. static struct platform_device da8xx_wdt_device = {
  337. .name = "davinci-wdt",
  338. .id = -1,
  339. .num_resources = ARRAY_SIZE(da8xx_watchdog_resources),
  340. .resource = da8xx_watchdog_resources,
  341. };
  342. void da8xx_restart(enum reboot_mode mode, const char *cmd)
  343. {
  344. struct device *dev;
  345. dev = bus_find_device_by_name(&platform_bus_type, NULL, "davinci-wdt");
  346. if (!dev) {
  347. pr_err("%s: failed to find watchdog device\n", __func__);
  348. return;
  349. }
  350. davinci_watchdog_reset(to_platform_device(dev));
  351. }
  352. int __init da8xx_register_watchdog(void)
  353. {
  354. return platform_device_register(&da8xx_wdt_device);
  355. }
  356. static struct resource da8xx_emac_resources[] = {
  357. {
  358. .start = DA8XX_EMAC_CPPI_PORT_BASE,
  359. .end = DA8XX_EMAC_CPPI_PORT_BASE + SZ_16K - 1,
  360. .flags = IORESOURCE_MEM,
  361. },
  362. {
  363. .start = IRQ_DA8XX_C0_RX_THRESH_PULSE,
  364. .end = IRQ_DA8XX_C0_RX_THRESH_PULSE,
  365. .flags = IORESOURCE_IRQ,
  366. },
  367. {
  368. .start = IRQ_DA8XX_C0_RX_PULSE,
  369. .end = IRQ_DA8XX_C0_RX_PULSE,
  370. .flags = IORESOURCE_IRQ,
  371. },
  372. {
  373. .start = IRQ_DA8XX_C0_TX_PULSE,
  374. .end = IRQ_DA8XX_C0_TX_PULSE,
  375. .flags = IORESOURCE_IRQ,
  376. },
  377. {
  378. .start = IRQ_DA8XX_C0_MISC_PULSE,
  379. .end = IRQ_DA8XX_C0_MISC_PULSE,
  380. .flags = IORESOURCE_IRQ,
  381. },
  382. };
  383. struct emac_platform_data da8xx_emac_pdata = {
  384. .ctrl_reg_offset = DA8XX_EMAC_CTRL_REG_OFFSET,
  385. .ctrl_mod_reg_offset = DA8XX_EMAC_MOD_REG_OFFSET,
  386. .ctrl_ram_offset = DA8XX_EMAC_RAM_OFFSET,
  387. .ctrl_ram_size = DA8XX_EMAC_CTRL_RAM_SIZE,
  388. .version = EMAC_VERSION_2,
  389. };
  390. static struct platform_device da8xx_emac_device = {
  391. .name = "davinci_emac",
  392. .id = 1,
  393. .dev = {
  394. .platform_data = &da8xx_emac_pdata,
  395. },
  396. .num_resources = ARRAY_SIZE(da8xx_emac_resources),
  397. .resource = da8xx_emac_resources,
  398. };
  399. static struct resource da8xx_mdio_resources[] = {
  400. {
  401. .start = DA8XX_EMAC_MDIO_BASE,
  402. .end = DA8XX_EMAC_MDIO_BASE + SZ_4K - 1,
  403. .flags = IORESOURCE_MEM,
  404. },
  405. };
  406. static struct platform_device da8xx_mdio_device = {
  407. .name = "davinci_mdio",
  408. .id = 0,
  409. .num_resources = ARRAY_SIZE(da8xx_mdio_resources),
  410. .resource = da8xx_mdio_resources,
  411. };
  412. int __init da8xx_register_emac(void)
  413. {
  414. int ret;
  415. ret = platform_device_register(&da8xx_mdio_device);
  416. if (ret < 0)
  417. return ret;
  418. return platform_device_register(&da8xx_emac_device);
  419. }
  420. static struct resource da830_mcasp1_resources[] = {
  421. {
  422. .name = "mpu",
  423. .start = DAVINCI_DA830_MCASP1_REG_BASE,
  424. .end = DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1,
  425. .flags = IORESOURCE_MEM,
  426. },
  427. /* TX event */
  428. {
  429. .name = "tx",
  430. .start = DAVINCI_DA830_DMA_MCASP1_AXEVT,
  431. .end = DAVINCI_DA830_DMA_MCASP1_AXEVT,
  432. .flags = IORESOURCE_DMA,
  433. },
  434. /* RX event */
  435. {
  436. .name = "rx",
  437. .start = DAVINCI_DA830_DMA_MCASP1_AREVT,
  438. .end = DAVINCI_DA830_DMA_MCASP1_AREVT,
  439. .flags = IORESOURCE_DMA,
  440. },
  441. {
  442. .name = "common",
  443. .start = IRQ_DA8XX_MCASPINT,
  444. .flags = IORESOURCE_IRQ,
  445. },
  446. };
  447. static struct platform_device da830_mcasp1_device = {
  448. .name = "davinci-mcasp",
  449. .id = 1,
  450. .num_resources = ARRAY_SIZE(da830_mcasp1_resources),
  451. .resource = da830_mcasp1_resources,
  452. };
  453. static struct resource da830_mcasp2_resources[] = {
  454. {
  455. .name = "mpu",
  456. .start = DAVINCI_DA830_MCASP2_REG_BASE,
  457. .end = DAVINCI_DA830_MCASP2_REG_BASE + (SZ_1K * 12) - 1,
  458. .flags = IORESOURCE_MEM,
  459. },
  460. /* TX event */
  461. {
  462. .name = "tx",
  463. .start = DAVINCI_DA830_DMA_MCASP2_AXEVT,
  464. .end = DAVINCI_DA830_DMA_MCASP2_AXEVT,
  465. .flags = IORESOURCE_DMA,
  466. },
  467. /* RX event */
  468. {
  469. .name = "rx",
  470. .start = DAVINCI_DA830_DMA_MCASP2_AREVT,
  471. .end = DAVINCI_DA830_DMA_MCASP2_AREVT,
  472. .flags = IORESOURCE_DMA,
  473. },
  474. {
  475. .name = "common",
  476. .start = IRQ_DA8XX_MCASPINT,
  477. .flags = IORESOURCE_IRQ,
  478. },
  479. };
  480. static struct platform_device da830_mcasp2_device = {
  481. .name = "davinci-mcasp",
  482. .id = 2,
  483. .num_resources = ARRAY_SIZE(da830_mcasp2_resources),
  484. .resource = da830_mcasp2_resources,
  485. };
  486. static struct resource da850_mcasp_resources[] = {
  487. {
  488. .name = "mpu",
  489. .start = DAVINCI_DA8XX_MCASP0_REG_BASE,
  490. .end = DAVINCI_DA8XX_MCASP0_REG_BASE + (SZ_1K * 12) - 1,
  491. .flags = IORESOURCE_MEM,
  492. },
  493. /* TX event */
  494. {
  495. .name = "tx",
  496. .start = DAVINCI_DA8XX_DMA_MCASP0_AXEVT,
  497. .end = DAVINCI_DA8XX_DMA_MCASP0_AXEVT,
  498. .flags = IORESOURCE_DMA,
  499. },
  500. /* RX event */
  501. {
  502. .name = "rx",
  503. .start = DAVINCI_DA8XX_DMA_MCASP0_AREVT,
  504. .end = DAVINCI_DA8XX_DMA_MCASP0_AREVT,
  505. .flags = IORESOURCE_DMA,
  506. },
  507. {
  508. .name = "common",
  509. .start = IRQ_DA8XX_MCASPINT,
  510. .flags = IORESOURCE_IRQ,
  511. },
  512. };
  513. static struct platform_device da850_mcasp_device = {
  514. .name = "davinci-mcasp",
  515. .id = 0,
  516. .num_resources = ARRAY_SIZE(da850_mcasp_resources),
  517. .resource = da850_mcasp_resources,
  518. };
  519. void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata)
  520. {
  521. struct platform_device *pdev;
  522. switch (id) {
  523. case 0:
  524. /* Valid for DA830/OMAP-L137 or DA850/OMAP-L138 */
  525. pdev = &da850_mcasp_device;
  526. break;
  527. case 1:
  528. /* Valid for DA830/OMAP-L137 only */
  529. if (!cpu_is_davinci_da830())
  530. return;
  531. pdev = &da830_mcasp1_device;
  532. break;
  533. case 2:
  534. /* Valid for DA830/OMAP-L137 only */
  535. if (!cpu_is_davinci_da830())
  536. return;
  537. pdev = &da830_mcasp2_device;
  538. break;
  539. default:
  540. return;
  541. }
  542. pdev->dev.platform_data = pdata;
  543. platform_device_register(pdev);
  544. }
  545. static struct resource da8xx_pruss_resources[] = {
  546. {
  547. .start = DA8XX_PRUSS_MEM_BASE,
  548. .end = DA8XX_PRUSS_MEM_BASE + 0xFFFF,
  549. .flags = IORESOURCE_MEM,
  550. },
  551. {
  552. .start = IRQ_DA8XX_EVTOUT0,
  553. .end = IRQ_DA8XX_EVTOUT0,
  554. .flags = IORESOURCE_IRQ,
  555. },
  556. {
  557. .start = IRQ_DA8XX_EVTOUT1,
  558. .end = IRQ_DA8XX_EVTOUT1,
  559. .flags = IORESOURCE_IRQ,
  560. },
  561. {
  562. .start = IRQ_DA8XX_EVTOUT2,
  563. .end = IRQ_DA8XX_EVTOUT2,
  564. .flags = IORESOURCE_IRQ,
  565. },
  566. {
  567. .start = IRQ_DA8XX_EVTOUT3,
  568. .end = IRQ_DA8XX_EVTOUT3,
  569. .flags = IORESOURCE_IRQ,
  570. },
  571. {
  572. .start = IRQ_DA8XX_EVTOUT4,
  573. .end = IRQ_DA8XX_EVTOUT4,
  574. .flags = IORESOURCE_IRQ,
  575. },
  576. {
  577. .start = IRQ_DA8XX_EVTOUT5,
  578. .end = IRQ_DA8XX_EVTOUT5,
  579. .flags = IORESOURCE_IRQ,
  580. },
  581. {
  582. .start = IRQ_DA8XX_EVTOUT6,
  583. .end = IRQ_DA8XX_EVTOUT6,
  584. .flags = IORESOURCE_IRQ,
  585. },
  586. {
  587. .start = IRQ_DA8XX_EVTOUT7,
  588. .end = IRQ_DA8XX_EVTOUT7,
  589. .flags = IORESOURCE_IRQ,
  590. },
  591. };
  592. static struct uio_pruss_pdata da8xx_uio_pruss_pdata = {
  593. .pintc_base = 0x4000,
  594. };
  595. static struct platform_device da8xx_uio_pruss_dev = {
  596. .name = "pruss_uio",
  597. .id = -1,
  598. .num_resources = ARRAY_SIZE(da8xx_pruss_resources),
  599. .resource = da8xx_pruss_resources,
  600. .dev = {
  601. .coherent_dma_mask = DMA_BIT_MASK(32),
  602. .platform_data = &da8xx_uio_pruss_pdata,
  603. }
  604. };
  605. int __init da8xx_register_uio_pruss(void)
  606. {
  607. da8xx_uio_pruss_pdata.sram_pool = sram_get_gen_pool();
  608. return platform_device_register(&da8xx_uio_pruss_dev);
  609. }
  610. static struct lcd_ctrl_config lcd_cfg = {
  611. .panel_shade = COLOR_ACTIVE,
  612. .bpp = 16,
  613. };
  614. struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = {
  615. .manu_name = "sharp",
  616. .controller_data = &lcd_cfg,
  617. .type = "Sharp_LCD035Q3DG01",
  618. };
  619. struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata = {
  620. .manu_name = "sharp",
  621. .controller_data = &lcd_cfg,
  622. .type = "Sharp_LK043T1DG01",
  623. };
  624. static struct resource da8xx_lcdc_resources[] = {
  625. [0] = { /* registers */
  626. .start = DA8XX_LCD_CNTRL_BASE,
  627. .end = DA8XX_LCD_CNTRL_BASE + SZ_4K - 1,
  628. .flags = IORESOURCE_MEM,
  629. },
  630. [1] = { /* interrupt */
  631. .start = IRQ_DA8XX_LCDINT,
  632. .end = IRQ_DA8XX_LCDINT,
  633. .flags = IORESOURCE_IRQ,
  634. },
  635. };
  636. static struct platform_device da8xx_lcdc_device = {
  637. .name = "da8xx_lcdc",
  638. .id = 0,
  639. .num_resources = ARRAY_SIZE(da8xx_lcdc_resources),
  640. .resource = da8xx_lcdc_resources,
  641. };
  642. int __init da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata)
  643. {
  644. da8xx_lcdc_device.dev.platform_data = pdata;
  645. return platform_device_register(&da8xx_lcdc_device);
  646. }
  647. static struct resource da8xx_gpio_resources[] = {
  648. { /* registers */
  649. .start = DA8XX_GPIO_BASE,
  650. .end = DA8XX_GPIO_BASE + SZ_4K - 1,
  651. .flags = IORESOURCE_MEM,
  652. },
  653. { /* interrupt */
  654. .start = IRQ_DA8XX_GPIO0,
  655. .end = IRQ_DA8XX_GPIO8,
  656. .flags = IORESOURCE_IRQ,
  657. },
  658. };
  659. static struct platform_device da8xx_gpio_device = {
  660. .name = "davinci_gpio",
  661. .id = -1,
  662. .num_resources = ARRAY_SIZE(da8xx_gpio_resources),
  663. .resource = da8xx_gpio_resources,
  664. };
  665. int __init da8xx_register_gpio(void *pdata)
  666. {
  667. da8xx_gpio_device.dev.platform_data = pdata;
  668. return platform_device_register(&da8xx_gpio_device);
  669. }
  670. static struct resource da8xx_mmcsd0_resources[] = {
  671. { /* registers */
  672. .start = DA8XX_MMCSD0_BASE,
  673. .end = DA8XX_MMCSD0_BASE + SZ_4K - 1,
  674. .flags = IORESOURCE_MEM,
  675. },
  676. { /* interrupt */
  677. .start = IRQ_DA8XX_MMCSDINT0,
  678. .end = IRQ_DA8XX_MMCSDINT0,
  679. .flags = IORESOURCE_IRQ,
  680. },
  681. };
  682. static struct platform_device da8xx_mmcsd0_device = {
  683. .name = "da830-mmc",
  684. .id = 0,
  685. .num_resources = ARRAY_SIZE(da8xx_mmcsd0_resources),
  686. .resource = da8xx_mmcsd0_resources,
  687. };
  688. int __init da8xx_register_mmcsd0(struct davinci_mmc_config *config)
  689. {
  690. da8xx_mmcsd0_device.dev.platform_data = config;
  691. return platform_device_register(&da8xx_mmcsd0_device);
  692. }
  693. #ifdef CONFIG_ARCH_DAVINCI_DA850
  694. static struct resource da850_mmcsd1_resources[] = {
  695. { /* registers */
  696. .start = DA850_MMCSD1_BASE,
  697. .end = DA850_MMCSD1_BASE + SZ_4K - 1,
  698. .flags = IORESOURCE_MEM,
  699. },
  700. { /* interrupt */
  701. .start = IRQ_DA850_MMCSDINT0_1,
  702. .end = IRQ_DA850_MMCSDINT0_1,
  703. .flags = IORESOURCE_IRQ,
  704. },
  705. };
  706. static struct platform_device da850_mmcsd1_device = {
  707. .name = "da830-mmc",
  708. .id = 1,
  709. .num_resources = ARRAY_SIZE(da850_mmcsd1_resources),
  710. .resource = da850_mmcsd1_resources,
  711. };
  712. int __init da850_register_mmcsd1(struct davinci_mmc_config *config)
  713. {
  714. da850_mmcsd1_device.dev.platform_data = config;
  715. return platform_device_register(&da850_mmcsd1_device);
  716. }
  717. #endif
  718. static struct resource da8xx_rproc_resources[] = {
  719. { /* DSP boot address */
  720. .start = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG,
  721. .end = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG + 3,
  722. .flags = IORESOURCE_MEM,
  723. },
  724. { /* DSP interrupt registers */
  725. .start = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG,
  726. .end = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG + 7,
  727. .flags = IORESOURCE_MEM,
  728. },
  729. { /* dsp irq */
  730. .start = IRQ_DA8XX_CHIPINT0,
  731. .end = IRQ_DA8XX_CHIPINT0,
  732. .flags = IORESOURCE_IRQ,
  733. },
  734. };
  735. static struct platform_device da8xx_dsp = {
  736. .name = "davinci-rproc",
  737. .dev = {
  738. .coherent_dma_mask = DMA_BIT_MASK(32),
  739. },
  740. .num_resources = ARRAY_SIZE(da8xx_rproc_resources),
  741. .resource = da8xx_rproc_resources,
  742. };
  743. static bool rproc_mem_inited __initdata;
  744. #if IS_ENABLED(CONFIG_DA8XX_REMOTEPROC)
  745. static phys_addr_t rproc_base __initdata;
  746. static unsigned long rproc_size __initdata;
  747. static int __init early_rproc_mem(char *p)
  748. {
  749. char *endp;
  750. if (p == NULL)
  751. return 0;
  752. rproc_size = memparse(p, &endp);
  753. if (*endp == '@')
  754. rproc_base = memparse(endp + 1, NULL);
  755. return 0;
  756. }
  757. early_param("rproc_mem", early_rproc_mem);
  758. void __init da8xx_rproc_reserve_cma(void)
  759. {
  760. int ret;
  761. if (!rproc_base || !rproc_size) {
  762. pr_err("%s: 'rproc_mem=nn@address' badly specified\n"
  763. " 'nn' and 'address' must both be non-zero\n",
  764. __func__);
  765. return;
  766. }
  767. pr_info("%s: reserving 0x%lx @ 0x%lx...\n",
  768. __func__, rproc_size, (unsigned long)rproc_base);
  769. ret = dma_declare_contiguous(&da8xx_dsp.dev, rproc_size, rproc_base, 0);
  770. if (ret)
  771. pr_err("%s: dma_declare_contiguous failed %d\n", __func__, ret);
  772. else
  773. rproc_mem_inited = true;
  774. }
  775. #else
  776. void __init da8xx_rproc_reserve_cma(void)
  777. {
  778. }
  779. #endif
  780. int __init da8xx_register_rproc(void)
  781. {
  782. int ret;
  783. if (!rproc_mem_inited) {
  784. pr_warn("%s: memory not reserved for DSP, not registering DSP device\n",
  785. __func__);
  786. return -ENOMEM;
  787. }
  788. ret = platform_device_register(&da8xx_dsp);
  789. if (ret)
  790. pr_err("%s: can't register DSP device: %d\n", __func__, ret);
  791. return ret;
  792. };
  793. static struct resource da8xx_rtc_resources[] = {
  794. {
  795. .start = DA8XX_RTC_BASE,
  796. .end = DA8XX_RTC_BASE + SZ_4K - 1,
  797. .flags = IORESOURCE_MEM,
  798. },
  799. { /* timer irq */
  800. .start = IRQ_DA8XX_RTC,
  801. .end = IRQ_DA8XX_RTC,
  802. .flags = IORESOURCE_IRQ,
  803. },
  804. { /* alarm irq */
  805. .start = IRQ_DA8XX_RTC,
  806. .end = IRQ_DA8XX_RTC,
  807. .flags = IORESOURCE_IRQ,
  808. },
  809. };
  810. static struct platform_device da8xx_rtc_device = {
  811. .name = "da830-rtc",
  812. .id = -1,
  813. .num_resources = ARRAY_SIZE(da8xx_rtc_resources),
  814. .resource = da8xx_rtc_resources,
  815. };
  816. int da8xx_register_rtc(void)
  817. {
  818. return platform_device_register(&da8xx_rtc_device);
  819. }
  820. static void __iomem *da8xx_ddr2_ctlr_base;
  821. void __iomem * __init da8xx_get_mem_ctlr(void)
  822. {
  823. if (da8xx_ddr2_ctlr_base)
  824. return da8xx_ddr2_ctlr_base;
  825. da8xx_ddr2_ctlr_base = ioremap(DA8XX_DDR2_CTL_BASE, SZ_32K);
  826. if (!da8xx_ddr2_ctlr_base)
  827. pr_warn("%s: Unable to map DDR2 controller", __func__);
  828. return da8xx_ddr2_ctlr_base;
  829. }
  830. static struct resource da8xx_cpuidle_resources[] = {
  831. {
  832. .start = DA8XX_DDR2_CTL_BASE,
  833. .end = DA8XX_DDR2_CTL_BASE + SZ_32K - 1,
  834. .flags = IORESOURCE_MEM,
  835. },
  836. };
  837. /* DA8XX devices support DDR2 power down */
  838. static struct davinci_cpuidle_config da8xx_cpuidle_pdata = {
  839. .ddr2_pdown = 1,
  840. };
  841. static struct platform_device da8xx_cpuidle_device = {
  842. .name = "cpuidle-davinci",
  843. .num_resources = ARRAY_SIZE(da8xx_cpuidle_resources),
  844. .resource = da8xx_cpuidle_resources,
  845. .dev = {
  846. .platform_data = &da8xx_cpuidle_pdata,
  847. },
  848. };
  849. int __init da8xx_register_cpuidle(void)
  850. {
  851. da8xx_cpuidle_pdata.ddr2_ctlr_base = da8xx_get_mem_ctlr();
  852. return platform_device_register(&da8xx_cpuidle_device);
  853. }
  854. static struct resource da8xx_spi0_resources[] = {
  855. [0] = {
  856. .start = DA8XX_SPI0_BASE,
  857. .end = DA8XX_SPI0_BASE + SZ_4K - 1,
  858. .flags = IORESOURCE_MEM,
  859. },
  860. [1] = {
  861. .start = IRQ_DA8XX_SPINT0,
  862. .end = IRQ_DA8XX_SPINT0,
  863. .flags = IORESOURCE_IRQ,
  864. },
  865. [2] = {
  866. .start = DA8XX_DMA_SPI0_RX,
  867. .end = DA8XX_DMA_SPI0_RX,
  868. .flags = IORESOURCE_DMA,
  869. },
  870. [3] = {
  871. .start = DA8XX_DMA_SPI0_TX,
  872. .end = DA8XX_DMA_SPI0_TX,
  873. .flags = IORESOURCE_DMA,
  874. },
  875. };
  876. static struct resource da8xx_spi1_resources[] = {
  877. [0] = {
  878. .start = DA830_SPI1_BASE,
  879. .end = DA830_SPI1_BASE + SZ_4K - 1,
  880. .flags = IORESOURCE_MEM,
  881. },
  882. [1] = {
  883. .start = IRQ_DA8XX_SPINT1,
  884. .end = IRQ_DA8XX_SPINT1,
  885. .flags = IORESOURCE_IRQ,
  886. },
  887. [2] = {
  888. .start = DA8XX_DMA_SPI1_RX,
  889. .end = DA8XX_DMA_SPI1_RX,
  890. .flags = IORESOURCE_DMA,
  891. },
  892. [3] = {
  893. .start = DA8XX_DMA_SPI1_TX,
  894. .end = DA8XX_DMA_SPI1_TX,
  895. .flags = IORESOURCE_DMA,
  896. },
  897. };
  898. static struct davinci_spi_platform_data da8xx_spi_pdata[] = {
  899. [0] = {
  900. .version = SPI_VERSION_2,
  901. .intr_line = 1,
  902. .dma_event_q = EVENTQ_0,
  903. .prescaler_limit = 2,
  904. },
  905. [1] = {
  906. .version = SPI_VERSION_2,
  907. .intr_line = 1,
  908. .dma_event_q = EVENTQ_0,
  909. .prescaler_limit = 2,
  910. },
  911. };
  912. static struct platform_device da8xx_spi_device[] = {
  913. [0] = {
  914. .name = "spi_davinci",
  915. .id = 0,
  916. .num_resources = ARRAY_SIZE(da8xx_spi0_resources),
  917. .resource = da8xx_spi0_resources,
  918. .dev = {
  919. .platform_data = &da8xx_spi_pdata[0],
  920. },
  921. },
  922. [1] = {
  923. .name = "spi_davinci",
  924. .id = 1,
  925. .num_resources = ARRAY_SIZE(da8xx_spi1_resources),
  926. .resource = da8xx_spi1_resources,
  927. .dev = {
  928. .platform_data = &da8xx_spi_pdata[1],
  929. },
  930. },
  931. };
  932. int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect)
  933. {
  934. if (instance < 0 || instance > 1)
  935. return -EINVAL;
  936. da8xx_spi_pdata[instance].num_chipselect = num_chipselect;
  937. if (instance == 1 && cpu_is_davinci_da850()) {
  938. da8xx_spi1_resources[0].start = DA850_SPI1_BASE;
  939. da8xx_spi1_resources[0].end = DA850_SPI1_BASE + SZ_4K - 1;
  940. }
  941. return platform_device_register(&da8xx_spi_device[instance]);
  942. }
  943. #ifdef CONFIG_ARCH_DAVINCI_DA850
  944. static struct resource da850_sata_resources[] = {
  945. {
  946. .start = DA850_SATA_BASE,
  947. .end = DA850_SATA_BASE + 0x1fff,
  948. .flags = IORESOURCE_MEM,
  949. },
  950. {
  951. .start = DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG,
  952. .end = DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG + 0x3,
  953. .flags = IORESOURCE_MEM,
  954. },
  955. {
  956. .start = IRQ_DA850_SATAINT,
  957. .flags = IORESOURCE_IRQ,
  958. },
  959. };
  960. static u64 da850_sata_dmamask = DMA_BIT_MASK(32);
  961. static struct platform_device da850_sata_device = {
  962. .name = "ahci_da850",
  963. .id = -1,
  964. .dev = {
  965. .dma_mask = &da850_sata_dmamask,
  966. .coherent_dma_mask = DMA_BIT_MASK(32),
  967. },
  968. .num_resources = ARRAY_SIZE(da850_sata_resources),
  969. .resource = da850_sata_resources,
  970. };
  971. int __init da850_register_sata(unsigned long refclkpn)
  972. {
  973. /* please see comment in drivers/ata/ahci_da850.c */
  974. BUG_ON(refclkpn != 100 * 1000 * 1000);
  975. return platform_device_register(&da850_sata_device);
  976. }
  977. #endif