setup-sh7372.c 25 KB

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