setup-sh7372.c 25 KB

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