setup-sh7372.c 24 KB

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