setup-sh7372.c 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. /*
  2. * sh7372 processor support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/of_platform.h>
  26. #include <linux/uio_driver.h>
  27. #include <linux/delay.h>
  28. #include <linux/input.h>
  29. #include <linux/io.h>
  30. #include <linux/serial_sci.h>
  31. #include <linux/sh_dma.h>
  32. #include <linux/sh_intc.h>
  33. #include <linux/sh_timer.h>
  34. #include <linux/pm_domain.h>
  35. #include <linux/dma-mapping.h>
  36. #include <mach/dma-register.h>
  37. #include <mach/hardware.h>
  38. #include <mach/irqs.h>
  39. #include <mach/sh7372.h>
  40. #include <mach/common.h>
  41. #include <asm/mach/map.h>
  42. #include <asm/mach-types.h>
  43. #include <asm/mach/arch.h>
  44. #include <asm/mach/time.h>
  45. static struct map_desc sh7372_io_desc[] __initdata = {
  46. /* create a 1:1 entity map for 0xe6xxxxxx
  47. * used by CPGA, INTC and PFC.
  48. */
  49. {
  50. .virtual = 0xe6000000,
  51. .pfn = __phys_to_pfn(0xe6000000),
  52. .length = 256 << 20,
  53. .type = MT_DEVICE_NONSHARED
  54. },
  55. };
  56. void __init sh7372_map_io(void)
  57. {
  58. iotable_init(sh7372_io_desc, ARRAY_SIZE(sh7372_io_desc));
  59. }
  60. /* SCIFA0 */
  61. static struct plat_sci_port scif0_platform_data = {
  62. .mapbase = 0xe6c40000,
  63. .flags = UPF_BOOT_AUTOCONF,
  64. .scscr = SCSCR_RE | SCSCR_TE,
  65. .scbrr_algo_id = SCBRR_ALGO_4,
  66. .type = PORT_SCIFA,
  67. .irqs = { evt2irq(0x0c00), evt2irq(0x0c00),
  68. evt2irq(0x0c00), evt2irq(0x0c00) },
  69. };
  70. static struct platform_device scif0_device = {
  71. .name = "sh-sci",
  72. .id = 0,
  73. .dev = {
  74. .platform_data = &scif0_platform_data,
  75. },
  76. };
  77. /* SCIFA1 */
  78. static struct plat_sci_port scif1_platform_data = {
  79. .mapbase = 0xe6c50000,
  80. .flags = UPF_BOOT_AUTOCONF,
  81. .scscr = SCSCR_RE | SCSCR_TE,
  82. .scbrr_algo_id = SCBRR_ALGO_4,
  83. .type = PORT_SCIFA,
  84. .irqs = { evt2irq(0x0c20), evt2irq(0x0c20),
  85. evt2irq(0x0c20), evt2irq(0x0c20) },
  86. };
  87. static struct platform_device scif1_device = {
  88. .name = "sh-sci",
  89. .id = 1,
  90. .dev = {
  91. .platform_data = &scif1_platform_data,
  92. },
  93. };
  94. /* SCIFA2 */
  95. static struct plat_sci_port scif2_platform_data = {
  96. .mapbase = 0xe6c60000,
  97. .flags = UPF_BOOT_AUTOCONF,
  98. .scscr = SCSCR_RE | SCSCR_TE,
  99. .scbrr_algo_id = SCBRR_ALGO_4,
  100. .type = PORT_SCIFA,
  101. .irqs = { evt2irq(0x0c40), evt2irq(0x0c40),
  102. evt2irq(0x0c40), evt2irq(0x0c40) },
  103. };
  104. static struct platform_device scif2_device = {
  105. .name = "sh-sci",
  106. .id = 2,
  107. .dev = {
  108. .platform_data = &scif2_platform_data,
  109. },
  110. };
  111. /* SCIFA3 */
  112. static struct plat_sci_port scif3_platform_data = {
  113. .mapbase = 0xe6c70000,
  114. .flags = UPF_BOOT_AUTOCONF,
  115. .scscr = SCSCR_RE | SCSCR_TE,
  116. .scbrr_algo_id = SCBRR_ALGO_4,
  117. .type = PORT_SCIFA,
  118. .irqs = { evt2irq(0x0c60), evt2irq(0x0c60),
  119. evt2irq(0x0c60), evt2irq(0x0c60) },
  120. };
  121. static struct platform_device scif3_device = {
  122. .name = "sh-sci",
  123. .id = 3,
  124. .dev = {
  125. .platform_data = &scif3_platform_data,
  126. },
  127. };
  128. /* SCIFA4 */
  129. static struct plat_sci_port scif4_platform_data = {
  130. .mapbase = 0xe6c80000,
  131. .flags = UPF_BOOT_AUTOCONF,
  132. .scscr = SCSCR_RE | SCSCR_TE,
  133. .scbrr_algo_id = SCBRR_ALGO_4,
  134. .type = PORT_SCIFA,
  135. .irqs = { evt2irq(0x0d20), evt2irq(0x0d20),
  136. evt2irq(0x0d20), evt2irq(0x0d20) },
  137. };
  138. static struct platform_device scif4_device = {
  139. .name = "sh-sci",
  140. .id = 4,
  141. .dev = {
  142. .platform_data = &scif4_platform_data,
  143. },
  144. };
  145. /* SCIFA5 */
  146. static struct plat_sci_port scif5_platform_data = {
  147. .mapbase = 0xe6cb0000,
  148. .flags = UPF_BOOT_AUTOCONF,
  149. .scscr = SCSCR_RE | SCSCR_TE,
  150. .scbrr_algo_id = SCBRR_ALGO_4,
  151. .type = PORT_SCIFA,
  152. .irqs = { evt2irq(0x0d40), evt2irq(0x0d40),
  153. evt2irq(0x0d40), evt2irq(0x0d40) },
  154. };
  155. static struct platform_device scif5_device = {
  156. .name = "sh-sci",
  157. .id = 5,
  158. .dev = {
  159. .platform_data = &scif5_platform_data,
  160. },
  161. };
  162. /* SCIFB */
  163. static struct plat_sci_port scif6_platform_data = {
  164. .mapbase = 0xe6c30000,
  165. .flags = UPF_BOOT_AUTOCONF,
  166. .scscr = SCSCR_RE | SCSCR_TE,
  167. .scbrr_algo_id = SCBRR_ALGO_4,
  168. .type = PORT_SCIFB,
  169. .irqs = { evt2irq(0x0d60), evt2irq(0x0d60),
  170. evt2irq(0x0d60), evt2irq(0x0d60) },
  171. };
  172. static struct platform_device scif6_device = {
  173. .name = "sh-sci",
  174. .id = 6,
  175. .dev = {
  176. .platform_data = &scif6_platform_data,
  177. },
  178. };
  179. /* CMT */
  180. static struct sh_timer_config cmt2_platform_data = {
  181. .name = "CMT2",
  182. .channel_offset = 0x40,
  183. .timer_bit = 5,
  184. .clockevent_rating = 125,
  185. .clocksource_rating = 125,
  186. };
  187. static struct resource cmt2_resources[] = {
  188. [0] = {
  189. .name = "CMT2",
  190. .start = 0xe6130040,
  191. .end = 0xe613004b,
  192. .flags = IORESOURCE_MEM,
  193. },
  194. [1] = {
  195. .start = evt2irq(0x0b80), /* CMT2 */
  196. .flags = IORESOURCE_IRQ,
  197. },
  198. };
  199. static struct platform_device cmt2_device = {
  200. .name = "sh_cmt",
  201. .id = 2,
  202. .dev = {
  203. .platform_data = &cmt2_platform_data,
  204. },
  205. .resource = cmt2_resources,
  206. .num_resources = ARRAY_SIZE(cmt2_resources),
  207. };
  208. /* TMU */
  209. static struct sh_timer_config tmu00_platform_data = {
  210. .name = "TMU00",
  211. .channel_offset = 0x4,
  212. .timer_bit = 0,
  213. .clockevent_rating = 200,
  214. };
  215. static struct resource tmu00_resources[] = {
  216. [0] = {
  217. .name = "TMU00",
  218. .start = 0xfff60008,
  219. .end = 0xfff60013,
  220. .flags = IORESOURCE_MEM,
  221. },
  222. [1] = {
  223. .start = intcs_evt2irq(0xe80), /* TMU_TUNI0 */
  224. .flags = IORESOURCE_IRQ,
  225. },
  226. };
  227. static struct platform_device tmu00_device = {
  228. .name = "sh_tmu",
  229. .id = 0,
  230. .dev = {
  231. .platform_data = &tmu00_platform_data,
  232. },
  233. .resource = tmu00_resources,
  234. .num_resources = ARRAY_SIZE(tmu00_resources),
  235. };
  236. static struct sh_timer_config tmu01_platform_data = {
  237. .name = "TMU01",
  238. .channel_offset = 0x10,
  239. .timer_bit = 1,
  240. .clocksource_rating = 200,
  241. };
  242. static struct resource tmu01_resources[] = {
  243. [0] = {
  244. .name = "TMU01",
  245. .start = 0xfff60014,
  246. .end = 0xfff6001f,
  247. .flags = IORESOURCE_MEM,
  248. },
  249. [1] = {
  250. .start = intcs_evt2irq(0xea0), /* TMU_TUNI1 */
  251. .flags = IORESOURCE_IRQ,
  252. },
  253. };
  254. static struct platform_device tmu01_device = {
  255. .name = "sh_tmu",
  256. .id = 1,
  257. .dev = {
  258. .platform_data = &tmu01_platform_data,
  259. },
  260. .resource = tmu01_resources,
  261. .num_resources = ARRAY_SIZE(tmu01_resources),
  262. };
  263. /* I2C */
  264. static struct resource iic0_resources[] = {
  265. [0] = {
  266. .name = "IIC0",
  267. .start = 0xFFF20000,
  268. .end = 0xFFF20425 - 1,
  269. .flags = IORESOURCE_MEM,
  270. },
  271. [1] = {
  272. .start = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
  273. .end = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
  274. .flags = IORESOURCE_IRQ,
  275. },
  276. };
  277. static struct platform_device iic0_device = {
  278. .name = "i2c-sh_mobile",
  279. .id = 0, /* "i2c0" clock */
  280. .num_resources = ARRAY_SIZE(iic0_resources),
  281. .resource = iic0_resources,
  282. };
  283. static struct resource iic1_resources[] = {
  284. [0] = {
  285. .name = "IIC1",
  286. .start = 0xE6C20000,
  287. .end = 0xE6C20425 - 1,
  288. .flags = IORESOURCE_MEM,
  289. },
  290. [1] = {
  291. .start = evt2irq(0x780), /* IIC1_ALI1 */
  292. .end = evt2irq(0x7e0), /* IIC1_DTEI1 */
  293. .flags = IORESOURCE_IRQ,
  294. },
  295. };
  296. static struct platform_device iic1_device = {
  297. .name = "i2c-sh_mobile",
  298. .id = 1, /* "i2c1" clock */
  299. .num_resources = ARRAY_SIZE(iic1_resources),
  300. .resource = iic1_resources,
  301. };
  302. /* DMA */
  303. static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
  304. {
  305. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  306. .addr = 0xe6c40020,
  307. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  308. .mid_rid = 0x21,
  309. }, {
  310. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  311. .addr = 0xe6c40024,
  312. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  313. .mid_rid = 0x22,
  314. }, {
  315. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  316. .addr = 0xe6c50020,
  317. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  318. .mid_rid = 0x25,
  319. }, {
  320. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  321. .addr = 0xe6c50024,
  322. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  323. .mid_rid = 0x26,
  324. }, {
  325. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  326. .addr = 0xe6c60020,
  327. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  328. .mid_rid = 0x29,
  329. }, {
  330. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  331. .addr = 0xe6c60024,
  332. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  333. .mid_rid = 0x2a,
  334. }, {
  335. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  336. .addr = 0xe6c70020,
  337. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  338. .mid_rid = 0x2d,
  339. }, {
  340. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  341. .addr = 0xe6c70024,
  342. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  343. .mid_rid = 0x2e,
  344. }, {
  345. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  346. .addr = 0xe6c80020,
  347. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  348. .mid_rid = 0x39,
  349. }, {
  350. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  351. .addr = 0xe6c80024,
  352. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  353. .mid_rid = 0x3a,
  354. }, {
  355. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  356. .addr = 0xe6cb0020,
  357. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  358. .mid_rid = 0x35,
  359. }, {
  360. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  361. .addr = 0xe6cb0024,
  362. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  363. .mid_rid = 0x36,
  364. }, {
  365. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  366. .addr = 0xe6c30040,
  367. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  368. .mid_rid = 0x3d,
  369. }, {
  370. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  371. .addr = 0xe6c30060,
  372. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  373. .mid_rid = 0x3e,
  374. }, {
  375. .slave_id = SHDMA_SLAVE_FLCTL0_TX,
  376. .addr = 0xe6a30050,
  377. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  378. .mid_rid = 0x83,
  379. }, {
  380. .slave_id = SHDMA_SLAVE_FLCTL0_RX,
  381. .addr = 0xe6a30050,
  382. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  383. .mid_rid = 0x83,
  384. }, {
  385. .slave_id = SHDMA_SLAVE_FLCTL1_TX,
  386. .addr = 0xe6a30060,
  387. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  388. .mid_rid = 0x87,
  389. }, {
  390. .slave_id = SHDMA_SLAVE_FLCTL1_RX,
  391. .addr = 0xe6a30060,
  392. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  393. .mid_rid = 0x87,
  394. }, {
  395. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  396. .addr = 0xe6850030,
  397. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  398. .mid_rid = 0xc1,
  399. }, {
  400. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  401. .addr = 0xe6850030,
  402. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  403. .mid_rid = 0xc2,
  404. }, {
  405. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  406. .addr = 0xe6860030,
  407. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  408. .mid_rid = 0xc9,
  409. }, {
  410. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  411. .addr = 0xe6860030,
  412. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  413. .mid_rid = 0xca,
  414. }, {
  415. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  416. .addr = 0xe6870030,
  417. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  418. .mid_rid = 0xcd,
  419. }, {
  420. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  421. .addr = 0xe6870030,
  422. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  423. .mid_rid = 0xce,
  424. }, {
  425. .slave_id = SHDMA_SLAVE_FSIA_TX,
  426. .addr = 0xfe1f0024,
  427. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  428. .mid_rid = 0xb1,
  429. }, {
  430. .slave_id = SHDMA_SLAVE_FSIA_RX,
  431. .addr = 0xfe1f0020,
  432. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  433. .mid_rid = 0xb2,
  434. }, {
  435. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  436. .addr = 0xe6bd0034,
  437. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  438. .mid_rid = 0xd1,
  439. }, {
  440. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  441. .addr = 0xe6bd0034,
  442. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  443. .mid_rid = 0xd2,
  444. },
  445. };
  446. #define SH7372_CHCLR (0x220 - 0x20)
  447. static const struct sh_dmae_channel sh7372_dmae_channels[] = {
  448. {
  449. .offset = 0,
  450. .dmars = 0,
  451. .dmars_bit = 0,
  452. .chclr_offset = SH7372_CHCLR + 0,
  453. }, {
  454. .offset = 0x10,
  455. .dmars = 0,
  456. .dmars_bit = 8,
  457. .chclr_offset = SH7372_CHCLR + 0x10,
  458. }, {
  459. .offset = 0x20,
  460. .dmars = 4,
  461. .dmars_bit = 0,
  462. .chclr_offset = SH7372_CHCLR + 0x20,
  463. }, {
  464. .offset = 0x30,
  465. .dmars = 4,
  466. .dmars_bit = 8,
  467. .chclr_offset = SH7372_CHCLR + 0x30,
  468. }, {
  469. .offset = 0x50,
  470. .dmars = 8,
  471. .dmars_bit = 0,
  472. .chclr_offset = SH7372_CHCLR + 0x50,
  473. }, {
  474. .offset = 0x60,
  475. .dmars = 8,
  476. .dmars_bit = 8,
  477. .chclr_offset = SH7372_CHCLR + 0x60,
  478. }
  479. };
  480. static struct sh_dmae_pdata dma_platform_data = {
  481. .slave = sh7372_dmae_slaves,
  482. .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
  483. .channel = sh7372_dmae_channels,
  484. .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
  485. .ts_low_shift = TS_LOW_SHIFT,
  486. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  487. .ts_high_shift = TS_HI_SHIFT,
  488. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  489. .ts_shift = dma_ts_shift,
  490. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  491. .dmaor_init = DMAOR_DME,
  492. .chclr_present = 1,
  493. };
  494. /* Resource order important! */
  495. static struct resource sh7372_dmae0_resources[] = {
  496. {
  497. /* Channel registers and DMAOR */
  498. .start = 0xfe008020,
  499. .end = 0xfe00828f,
  500. .flags = IORESOURCE_MEM,
  501. },
  502. {
  503. /* DMARSx */
  504. .start = 0xfe009000,
  505. .end = 0xfe00900b,
  506. .flags = IORESOURCE_MEM,
  507. },
  508. {
  509. .name = "error_irq",
  510. .start = evt2irq(0x20c0),
  511. .end = evt2irq(0x20c0),
  512. .flags = IORESOURCE_IRQ,
  513. },
  514. {
  515. /* IRQ for channels 0-5 */
  516. .start = evt2irq(0x2000),
  517. .end = evt2irq(0x20a0),
  518. .flags = IORESOURCE_IRQ,
  519. },
  520. };
  521. /* Resource order important! */
  522. static struct resource sh7372_dmae1_resources[] = {
  523. {
  524. /* Channel registers and DMAOR */
  525. .start = 0xfe018020,
  526. .end = 0xfe01828f,
  527. .flags = IORESOURCE_MEM,
  528. },
  529. {
  530. /* DMARSx */
  531. .start = 0xfe019000,
  532. .end = 0xfe01900b,
  533. .flags = IORESOURCE_MEM,
  534. },
  535. {
  536. .name = "error_irq",
  537. .start = evt2irq(0x21c0),
  538. .end = evt2irq(0x21c0),
  539. .flags = IORESOURCE_IRQ,
  540. },
  541. {
  542. /* IRQ for channels 0-5 */
  543. .start = evt2irq(0x2100),
  544. .end = evt2irq(0x21a0),
  545. .flags = IORESOURCE_IRQ,
  546. },
  547. };
  548. /* Resource order important! */
  549. static struct resource sh7372_dmae2_resources[] = {
  550. {
  551. /* Channel registers and DMAOR */
  552. .start = 0xfe028020,
  553. .end = 0xfe02828f,
  554. .flags = IORESOURCE_MEM,
  555. },
  556. {
  557. /* DMARSx */
  558. .start = 0xfe029000,
  559. .end = 0xfe02900b,
  560. .flags = IORESOURCE_MEM,
  561. },
  562. {
  563. .name = "error_irq",
  564. .start = evt2irq(0x22c0),
  565. .end = evt2irq(0x22c0),
  566. .flags = IORESOURCE_IRQ,
  567. },
  568. {
  569. /* IRQ for channels 0-5 */
  570. .start = evt2irq(0x2200),
  571. .end = evt2irq(0x22a0),
  572. .flags = IORESOURCE_IRQ,
  573. },
  574. };
  575. static struct platform_device dma0_device = {
  576. .name = "sh-dma-engine",
  577. .id = 0,
  578. .resource = sh7372_dmae0_resources,
  579. .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
  580. .dev = {
  581. .platform_data = &dma_platform_data,
  582. },
  583. };
  584. static struct platform_device dma1_device = {
  585. .name = "sh-dma-engine",
  586. .id = 1,
  587. .resource = sh7372_dmae1_resources,
  588. .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
  589. .dev = {
  590. .platform_data = &dma_platform_data,
  591. },
  592. };
  593. static struct platform_device dma2_device = {
  594. .name = "sh-dma-engine",
  595. .id = 2,
  596. .resource = sh7372_dmae2_resources,
  597. .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
  598. .dev = {
  599. .platform_data = &dma_platform_data,
  600. },
  601. };
  602. /*
  603. * USB-DMAC
  604. */
  605. static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
  606. {
  607. .offset = 0,
  608. }, {
  609. .offset = 0x20,
  610. },
  611. };
  612. /* USB DMAC0 */
  613. static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
  614. {
  615. .slave_id = SHDMA_SLAVE_USB0_TX,
  616. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  617. }, {
  618. .slave_id = SHDMA_SLAVE_USB0_RX,
  619. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  620. },
  621. };
  622. static struct sh_dmae_pdata usb_dma0_platform_data = {
  623. .slave = sh7372_usb_dmae0_slaves,
  624. .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
  625. .channel = sh7372_usb_dmae_channels,
  626. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  627. .ts_low_shift = USBTS_LOW_SHIFT,
  628. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  629. .ts_high_shift = USBTS_HI_SHIFT,
  630. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  631. .ts_shift = dma_usbts_shift,
  632. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  633. .dmaor_init = DMAOR_DME,
  634. .chcr_offset = 0x14,
  635. .chcr_ie_bit = 1 << 5,
  636. .dmaor_is_32bit = 1,
  637. .needs_tend_set = 1,
  638. .no_dmars = 1,
  639. .slave_only = 1,
  640. };
  641. static struct resource sh7372_usb_dmae0_resources[] = {
  642. {
  643. /* Channel registers and DMAOR */
  644. .start = 0xe68a0020,
  645. .end = 0xe68a0064 - 1,
  646. .flags = IORESOURCE_MEM,
  647. },
  648. {
  649. /* VCR/SWR/DMICR */
  650. .start = 0xe68a0000,
  651. .end = 0xe68a0014 - 1,
  652. .flags = IORESOURCE_MEM,
  653. },
  654. {
  655. /* IRQ for channels */
  656. .start = evt2irq(0x0a00),
  657. .end = evt2irq(0x0a00),
  658. .flags = IORESOURCE_IRQ,
  659. },
  660. };
  661. static struct platform_device usb_dma0_device = {
  662. .name = "sh-dma-engine",
  663. .id = 3,
  664. .resource = sh7372_usb_dmae0_resources,
  665. .num_resources = ARRAY_SIZE(sh7372_usb_dmae0_resources),
  666. .dev = {
  667. .platform_data = &usb_dma0_platform_data,
  668. },
  669. };
  670. /* USB DMAC1 */
  671. static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
  672. {
  673. .slave_id = SHDMA_SLAVE_USB1_TX,
  674. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  675. }, {
  676. .slave_id = SHDMA_SLAVE_USB1_RX,
  677. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  678. },
  679. };
  680. static struct sh_dmae_pdata usb_dma1_platform_data = {
  681. .slave = sh7372_usb_dmae1_slaves,
  682. .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves),
  683. .channel = sh7372_usb_dmae_channels,
  684. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  685. .ts_low_shift = USBTS_LOW_SHIFT,
  686. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  687. .ts_high_shift = USBTS_HI_SHIFT,
  688. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  689. .ts_shift = dma_usbts_shift,
  690. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  691. .dmaor_init = DMAOR_DME,
  692. .chcr_offset = 0x14,
  693. .chcr_ie_bit = 1 << 5,
  694. .dmaor_is_32bit = 1,
  695. .needs_tend_set = 1,
  696. .no_dmars = 1,
  697. .slave_only = 1,
  698. };
  699. static struct resource sh7372_usb_dmae1_resources[] = {
  700. {
  701. /* Channel registers and DMAOR */
  702. .start = 0xe68c0020,
  703. .end = 0xe68c0064 - 1,
  704. .flags = IORESOURCE_MEM,
  705. },
  706. {
  707. /* VCR/SWR/DMICR */
  708. .start = 0xe68c0000,
  709. .end = 0xe68c0014 - 1,
  710. .flags = IORESOURCE_MEM,
  711. },
  712. {
  713. /* IRQ for channels */
  714. .start = evt2irq(0x1d00),
  715. .end = evt2irq(0x1d00),
  716. .flags = IORESOURCE_IRQ,
  717. },
  718. };
  719. static struct platform_device usb_dma1_device = {
  720. .name = "sh-dma-engine",
  721. .id = 4,
  722. .resource = sh7372_usb_dmae1_resources,
  723. .num_resources = ARRAY_SIZE(sh7372_usb_dmae1_resources),
  724. .dev = {
  725. .platform_data = &usb_dma1_platform_data,
  726. },
  727. };
  728. /* VPU */
  729. static struct uio_info vpu_platform_data = {
  730. .name = "VPU5HG",
  731. .version = "0",
  732. .irq = intcs_evt2irq(0x980),
  733. };
  734. static struct resource vpu_resources[] = {
  735. [0] = {
  736. .name = "VPU",
  737. .start = 0xfe900000,
  738. .end = 0xfe900157,
  739. .flags = IORESOURCE_MEM,
  740. },
  741. };
  742. static struct platform_device vpu_device = {
  743. .name = "uio_pdrv_genirq",
  744. .id = 0,
  745. .dev = {
  746. .platform_data = &vpu_platform_data,
  747. },
  748. .resource = vpu_resources,
  749. .num_resources = ARRAY_SIZE(vpu_resources),
  750. };
  751. /* VEU0 */
  752. static struct uio_info veu0_platform_data = {
  753. .name = "VEU0",
  754. .version = "0",
  755. .irq = intcs_evt2irq(0x700),
  756. };
  757. static struct resource veu0_resources[] = {
  758. [0] = {
  759. .name = "VEU0",
  760. .start = 0xfe920000,
  761. .end = 0xfe9200cb,
  762. .flags = IORESOURCE_MEM,
  763. },
  764. };
  765. static struct platform_device veu0_device = {
  766. .name = "uio_pdrv_genirq",
  767. .id = 1,
  768. .dev = {
  769. .platform_data = &veu0_platform_data,
  770. },
  771. .resource = veu0_resources,
  772. .num_resources = ARRAY_SIZE(veu0_resources),
  773. };
  774. /* VEU1 */
  775. static struct uio_info veu1_platform_data = {
  776. .name = "VEU1",
  777. .version = "0",
  778. .irq = intcs_evt2irq(0x720),
  779. };
  780. static struct resource veu1_resources[] = {
  781. [0] = {
  782. .name = "VEU1",
  783. .start = 0xfe924000,
  784. .end = 0xfe9240cb,
  785. .flags = IORESOURCE_MEM,
  786. },
  787. };
  788. static struct platform_device veu1_device = {
  789. .name = "uio_pdrv_genirq",
  790. .id = 2,
  791. .dev = {
  792. .platform_data = &veu1_platform_data,
  793. },
  794. .resource = veu1_resources,
  795. .num_resources = ARRAY_SIZE(veu1_resources),
  796. };
  797. /* VEU2 */
  798. static struct uio_info veu2_platform_data = {
  799. .name = "VEU2",
  800. .version = "0",
  801. .irq = intcs_evt2irq(0x740),
  802. };
  803. static struct resource veu2_resources[] = {
  804. [0] = {
  805. .name = "VEU2",
  806. .start = 0xfe928000,
  807. .end = 0xfe928307,
  808. .flags = IORESOURCE_MEM,
  809. },
  810. };
  811. static struct platform_device veu2_device = {
  812. .name = "uio_pdrv_genirq",
  813. .id = 3,
  814. .dev = {
  815. .platform_data = &veu2_platform_data,
  816. },
  817. .resource = veu2_resources,
  818. .num_resources = ARRAY_SIZE(veu2_resources),
  819. };
  820. /* VEU3 */
  821. static struct uio_info veu3_platform_data = {
  822. .name = "VEU3",
  823. .version = "0",
  824. .irq = intcs_evt2irq(0x760),
  825. };
  826. static struct resource veu3_resources[] = {
  827. [0] = {
  828. .name = "VEU3",
  829. .start = 0xfe92c000,
  830. .end = 0xfe92c307,
  831. .flags = IORESOURCE_MEM,
  832. },
  833. };
  834. static struct platform_device veu3_device = {
  835. .name = "uio_pdrv_genirq",
  836. .id = 4,
  837. .dev = {
  838. .platform_data = &veu3_platform_data,
  839. },
  840. .resource = veu3_resources,
  841. .num_resources = ARRAY_SIZE(veu3_resources),
  842. };
  843. /* JPU */
  844. static struct uio_info jpu_platform_data = {
  845. .name = "JPU",
  846. .version = "0",
  847. .irq = intcs_evt2irq(0x560),
  848. };
  849. static struct resource jpu_resources[] = {
  850. [0] = {
  851. .name = "JPU",
  852. .start = 0xfe980000,
  853. .end = 0xfe9902d3,
  854. .flags = IORESOURCE_MEM,
  855. },
  856. };
  857. static struct platform_device jpu_device = {
  858. .name = "uio_pdrv_genirq",
  859. .id = 5,
  860. .dev = {
  861. .platform_data = &jpu_platform_data,
  862. },
  863. .resource = jpu_resources,
  864. .num_resources = ARRAY_SIZE(jpu_resources),
  865. };
  866. /* SPU2DSP0 */
  867. static struct uio_info spu0_platform_data = {
  868. .name = "SPU2DSP0",
  869. .version = "0",
  870. .irq = evt2irq(0x1800),
  871. };
  872. static struct resource spu0_resources[] = {
  873. [0] = {
  874. .name = "SPU2DSP0",
  875. .start = 0xfe200000,
  876. .end = 0xfe2fffff,
  877. .flags = IORESOURCE_MEM,
  878. },
  879. };
  880. static struct platform_device spu0_device = {
  881. .name = "uio_pdrv_genirq",
  882. .id = 6,
  883. .dev = {
  884. .platform_data = &spu0_platform_data,
  885. },
  886. .resource = spu0_resources,
  887. .num_resources = ARRAY_SIZE(spu0_resources),
  888. };
  889. /* SPU2DSP1 */
  890. static struct uio_info spu1_platform_data = {
  891. .name = "SPU2DSP1",
  892. .version = "0",
  893. .irq = evt2irq(0x1820),
  894. };
  895. static struct resource spu1_resources[] = {
  896. [0] = {
  897. .name = "SPU2DSP1",
  898. .start = 0xfe300000,
  899. .end = 0xfe3fffff,
  900. .flags = IORESOURCE_MEM,
  901. },
  902. };
  903. static struct platform_device spu1_device = {
  904. .name = "uio_pdrv_genirq",
  905. .id = 7,
  906. .dev = {
  907. .platform_data = &spu1_platform_data,
  908. },
  909. .resource = spu1_resources,
  910. .num_resources = ARRAY_SIZE(spu1_resources),
  911. };
  912. static struct platform_device *sh7372_early_devices[] __initdata = {
  913. &scif0_device,
  914. &scif1_device,
  915. &scif2_device,
  916. &scif3_device,
  917. &scif4_device,
  918. &scif5_device,
  919. &scif6_device,
  920. &cmt2_device,
  921. &tmu00_device,
  922. &tmu01_device,
  923. };
  924. static struct platform_device *sh7372_late_devices[] __initdata = {
  925. &iic0_device,
  926. &iic1_device,
  927. &dma0_device,
  928. &dma1_device,
  929. &dma2_device,
  930. &usb_dma0_device,
  931. &usb_dma1_device,
  932. &vpu_device,
  933. &veu0_device,
  934. &veu1_device,
  935. &veu2_device,
  936. &veu3_device,
  937. &jpu_device,
  938. &spu0_device,
  939. &spu1_device,
  940. };
  941. void __init sh7372_add_standard_devices(void)
  942. {
  943. struct pm_domain_device domain_devices[] = {
  944. { "A3RV", &vpu_device, },
  945. { "A4MP", &spu0_device, },
  946. { "A4MP", &spu1_device, },
  947. { "A3SP", &scif0_device, },
  948. { "A3SP", &scif1_device, },
  949. { "A3SP", &scif2_device, },
  950. { "A3SP", &scif3_device, },
  951. { "A3SP", &scif4_device, },
  952. { "A3SP", &scif5_device, },
  953. { "A3SP", &scif6_device, },
  954. { "A3SP", &iic1_device, },
  955. { "A3SP", &dma0_device, },
  956. { "A3SP", &dma1_device, },
  957. { "A3SP", &dma2_device, },
  958. { "A3SP", &usb_dma0_device, },
  959. { "A3SP", &usb_dma1_device, },
  960. { "A4R", &iic0_device, },
  961. { "A4R", &veu0_device, },
  962. { "A4R", &veu1_device, },
  963. { "A4R", &veu2_device, },
  964. { "A4R", &veu3_device, },
  965. { "A4R", &jpu_device, },
  966. { "A4R", &tmu00_device, },
  967. { "A4R", &tmu01_device, },
  968. };
  969. sh7372_init_pm_domains();
  970. platform_add_devices(sh7372_early_devices,
  971. ARRAY_SIZE(sh7372_early_devices));
  972. platform_add_devices(sh7372_late_devices,
  973. ARRAY_SIZE(sh7372_late_devices));
  974. rmobile_add_devices_to_domains(domain_devices,
  975. ARRAY_SIZE(domain_devices));
  976. }
  977. static void __init sh7372_earlytimer_init(void)
  978. {
  979. sh7372_clock_init();
  980. shmobile_earlytimer_init();
  981. }
  982. void __init sh7372_add_early_devices(void)
  983. {
  984. early_platform_add_devices(sh7372_early_devices,
  985. ARRAY_SIZE(sh7372_early_devices));
  986. /* setup early console here as well */
  987. shmobile_setup_console();
  988. /* override timer setup with soc-specific code */
  989. shmobile_timer.init = sh7372_earlytimer_init;
  990. }
  991. #ifdef CONFIG_USE_OF
  992. void __init sh7372_add_early_devices_dt(void)
  993. {
  994. shmobile_setup_delay(800, 1, 3); /* Cortex-A8 @ 800MHz */
  995. early_platform_add_devices(sh7372_early_devices,
  996. ARRAY_SIZE(sh7372_early_devices));
  997. /* setup early console here as well */
  998. shmobile_setup_console();
  999. }
  1000. static const struct of_dev_auxdata sh7372_auxdata_lookup[] __initconst = {
  1001. { }
  1002. };
  1003. void __init sh7372_add_standard_devices_dt(void)
  1004. {
  1005. /* clocks are setup late during boot in the case of DT */
  1006. sh7372_clock_init();
  1007. platform_add_devices(sh7372_early_devices,
  1008. ARRAY_SIZE(sh7372_early_devices));
  1009. of_platform_populate(NULL, of_default_bus_match_table,
  1010. sh7372_auxdata_lookup, NULL);
  1011. }
  1012. static const char *sh7372_boards_compat_dt[] __initdata = {
  1013. "renesas,sh7372",
  1014. NULL,
  1015. };
  1016. DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
  1017. .map_io = sh7372_map_io,
  1018. .init_early = sh7372_add_early_devices_dt,
  1019. .nr_irqs = NR_IRQS_LEGACY,
  1020. .init_irq = sh7372_init_irq,
  1021. .handle_irq = shmobile_handle_irq_intc,
  1022. .init_machine = sh7372_add_standard_devices_dt,
  1023. .timer = &shmobile_timer,
  1024. .dt_compat = sh7372_boards_compat_dt,
  1025. MACHINE_END
  1026. #endif /* CONFIG_USE_OF */