setup-sh7372.c 22 KB

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