devices-da8xx.c 26 KB

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