setup-sh7372.c 24 KB

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