setup-sh7372.c 22 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. /*
  2. * sh7372 processor support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/of_platform.h>
  26. #include <linux/uio_driver.h>
  27. #include <linux/delay.h>
  28. #include <linux/input.h>
  29. #include <linux/io.h>
  30. #include <linux/serial_sci.h>
  31. #include <linux/sh_dma.h>
  32. #include <linux/sh_timer.h>
  33. #include <linux/pm_domain.h>
  34. #include <linux/dma-mapping.h>
  35. #include <linux/platform_data/sh_ipmmu.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach-types.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/time.h>
  40. #include "common.h"
  41. #include "dma-register.h"
  42. #include "intc.h"
  43. #include "irqs.h"
  44. #include "pm-rmobile.h"
  45. #include "sh7372.h"
  46. static struct map_desc sh7372_io_desc[] __initdata = {
  47. /* create a 1:1 entity map for 0xe6xxxxxx
  48. * used by CPGA, INTC and PFC.
  49. */
  50. {
  51. .virtual = 0xe6000000,
  52. .pfn = __phys_to_pfn(0xe6000000),
  53. .length = 256 << 20,
  54. .type = MT_DEVICE_NONSHARED
  55. },
  56. };
  57. void __init sh7372_map_io(void)
  58. {
  59. iotable_init(sh7372_io_desc, ARRAY_SIZE(sh7372_io_desc));
  60. }
  61. /* PFC */
  62. static struct resource sh7372_pfc_resources[] = {
  63. [0] = {
  64. .start = 0xe6050000,
  65. .end = 0xe6057fff,
  66. .flags = IORESOURCE_MEM,
  67. },
  68. [1] = {
  69. .start = 0xe605800c,
  70. .end = 0xe6058027,
  71. .flags = IORESOURCE_MEM,
  72. }
  73. };
  74. static struct platform_device sh7372_pfc_device = {
  75. .name = "pfc-sh7372",
  76. .id = -1,
  77. .resource = sh7372_pfc_resources,
  78. .num_resources = ARRAY_SIZE(sh7372_pfc_resources),
  79. };
  80. void __init sh7372_pinmux_init(void)
  81. {
  82. platform_device_register(&sh7372_pfc_device);
  83. }
  84. /* SCIF */
  85. #define SH7372_SCIF(scif_type, index, baseaddr, irq) \
  86. static struct plat_sci_port scif##index##_platform_data = { \
  87. .type = scif_type, \
  88. .flags = UPF_BOOT_AUTOCONF, \
  89. .scscr = SCSCR_RE | SCSCR_TE, \
  90. }; \
  91. \
  92. static struct resource scif##index##_resources[] = { \
  93. DEFINE_RES_MEM(baseaddr, 0x100), \
  94. DEFINE_RES_IRQ(irq), \
  95. }; \
  96. \
  97. static struct platform_device scif##index##_device = { \
  98. .name = "sh-sci", \
  99. .id = index, \
  100. .resource = scif##index##_resources, \
  101. .num_resources = ARRAY_SIZE(scif##index##_resources), \
  102. .dev = { \
  103. .platform_data = &scif##index##_platform_data, \
  104. }, \
  105. }
  106. SH7372_SCIF(PORT_SCIFA, 0, 0xe6c40000, evt2irq(0x0c00));
  107. SH7372_SCIF(PORT_SCIFA, 1, 0xe6c50000, evt2irq(0x0c20));
  108. SH7372_SCIF(PORT_SCIFA, 2, 0xe6c60000, evt2irq(0x0c40));
  109. SH7372_SCIF(PORT_SCIFA, 3, 0xe6c70000, evt2irq(0x0c60));
  110. SH7372_SCIF(PORT_SCIFA, 4, 0xe6c80000, evt2irq(0x0d20));
  111. SH7372_SCIF(PORT_SCIFA, 5, 0xe6cb0000, evt2irq(0x0d40));
  112. SH7372_SCIF(PORT_SCIFB, 6, 0xe6c30000, evt2irq(0x0d60));
  113. /* CMT */
  114. static struct sh_timer_config cmt2_platform_data = {
  115. .channels_mask = 0x20,
  116. };
  117. static struct resource cmt2_resources[] = {
  118. DEFINE_RES_MEM(0xe6130000, 0x50),
  119. DEFINE_RES_IRQ(evt2irq(0x0b80)),
  120. };
  121. static struct platform_device cmt2_device = {
  122. .name = "sh-cmt-32-fast",
  123. .id = 2,
  124. .dev = {
  125. .platform_data = &cmt2_platform_data,
  126. },
  127. .resource = cmt2_resources,
  128. .num_resources = ARRAY_SIZE(cmt2_resources),
  129. };
  130. /* TMU */
  131. static struct sh_timer_config tmu0_platform_data = {
  132. .channels_mask = 7,
  133. };
  134. static struct resource tmu0_resources[] = {
  135. DEFINE_RES_MEM(0xfff60000, 0x2c),
  136. DEFINE_RES_IRQ(intcs_evt2irq(0xe80)),
  137. DEFINE_RES_IRQ(intcs_evt2irq(0xea0)),
  138. DEFINE_RES_IRQ(intcs_evt2irq(0xec0)),
  139. };
  140. static struct platform_device tmu0_device = {
  141. .name = "sh-tmu",
  142. .id = 0,
  143. .dev = {
  144. .platform_data = &tmu0_platform_data,
  145. },
  146. .resource = tmu0_resources,
  147. .num_resources = ARRAY_SIZE(tmu0_resources),
  148. };
  149. /* I2C */
  150. static struct resource iic0_resources[] = {
  151. [0] = {
  152. .name = "IIC0",
  153. .start = 0xFFF20000,
  154. .end = 0xFFF20425 - 1,
  155. .flags = IORESOURCE_MEM,
  156. },
  157. [1] = {
  158. .start = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
  159. .end = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
  160. .flags = IORESOURCE_IRQ,
  161. },
  162. };
  163. static struct platform_device iic0_device = {
  164. .name = "i2c-sh_mobile",
  165. .id = 0, /* "i2c0" clock */
  166. .num_resources = ARRAY_SIZE(iic0_resources),
  167. .resource = iic0_resources,
  168. };
  169. static struct resource iic1_resources[] = {
  170. [0] = {
  171. .name = "IIC1",
  172. .start = 0xE6C20000,
  173. .end = 0xE6C20425 - 1,
  174. .flags = IORESOURCE_MEM,
  175. },
  176. [1] = {
  177. .start = evt2irq(0x780), /* IIC1_ALI1 */
  178. .end = evt2irq(0x7e0), /* IIC1_DTEI1 */
  179. .flags = IORESOURCE_IRQ,
  180. },
  181. };
  182. static struct platform_device iic1_device = {
  183. .name = "i2c-sh_mobile",
  184. .id = 1, /* "i2c1" clock */
  185. .num_resources = ARRAY_SIZE(iic1_resources),
  186. .resource = iic1_resources,
  187. };
  188. /* DMA */
  189. static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
  190. {
  191. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  192. .addr = 0xe6c40020,
  193. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  194. .mid_rid = 0x21,
  195. }, {
  196. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  197. .addr = 0xe6c40024,
  198. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  199. .mid_rid = 0x22,
  200. }, {
  201. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  202. .addr = 0xe6c50020,
  203. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  204. .mid_rid = 0x25,
  205. }, {
  206. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  207. .addr = 0xe6c50024,
  208. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  209. .mid_rid = 0x26,
  210. }, {
  211. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  212. .addr = 0xe6c60020,
  213. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  214. .mid_rid = 0x29,
  215. }, {
  216. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  217. .addr = 0xe6c60024,
  218. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  219. .mid_rid = 0x2a,
  220. }, {
  221. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  222. .addr = 0xe6c70020,
  223. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  224. .mid_rid = 0x2d,
  225. }, {
  226. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  227. .addr = 0xe6c70024,
  228. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  229. .mid_rid = 0x2e,
  230. }, {
  231. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  232. .addr = 0xe6c80020,
  233. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  234. .mid_rid = 0x39,
  235. }, {
  236. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  237. .addr = 0xe6c80024,
  238. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  239. .mid_rid = 0x3a,
  240. }, {
  241. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  242. .addr = 0xe6cb0020,
  243. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  244. .mid_rid = 0x35,
  245. }, {
  246. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  247. .addr = 0xe6cb0024,
  248. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  249. .mid_rid = 0x36,
  250. }, {
  251. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  252. .addr = 0xe6c30040,
  253. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  254. .mid_rid = 0x3d,
  255. }, {
  256. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  257. .addr = 0xe6c30060,
  258. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  259. .mid_rid = 0x3e,
  260. }, {
  261. .slave_id = SHDMA_SLAVE_FLCTL0_TX,
  262. .addr = 0xe6a30050,
  263. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  264. .mid_rid = 0x83,
  265. }, {
  266. .slave_id = SHDMA_SLAVE_FLCTL0_RX,
  267. .addr = 0xe6a30050,
  268. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  269. .mid_rid = 0x83,
  270. }, {
  271. .slave_id = SHDMA_SLAVE_FLCTL1_TX,
  272. .addr = 0xe6a30060,
  273. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  274. .mid_rid = 0x87,
  275. }, {
  276. .slave_id = SHDMA_SLAVE_FLCTL1_RX,
  277. .addr = 0xe6a30060,
  278. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  279. .mid_rid = 0x87,
  280. }, {
  281. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  282. .addr = 0xe6850030,
  283. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  284. .mid_rid = 0xc1,
  285. }, {
  286. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  287. .addr = 0xe6850030,
  288. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  289. .mid_rid = 0xc2,
  290. }, {
  291. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  292. .addr = 0xe6860030,
  293. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  294. .mid_rid = 0xc9,
  295. }, {
  296. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  297. .addr = 0xe6860030,
  298. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  299. .mid_rid = 0xca,
  300. }, {
  301. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  302. .addr = 0xe6870030,
  303. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  304. .mid_rid = 0xcd,
  305. }, {
  306. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  307. .addr = 0xe6870030,
  308. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  309. .mid_rid = 0xce,
  310. }, {
  311. .slave_id = SHDMA_SLAVE_FSIA_TX,
  312. .addr = 0xfe1f0024,
  313. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  314. .mid_rid = 0xb1,
  315. }, {
  316. .slave_id = SHDMA_SLAVE_FSIA_RX,
  317. .addr = 0xfe1f0020,
  318. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  319. .mid_rid = 0xb2,
  320. }, {
  321. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  322. .addr = 0xe6bd0034,
  323. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  324. .mid_rid = 0xd1,
  325. }, {
  326. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  327. .addr = 0xe6bd0034,
  328. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  329. .mid_rid = 0xd2,
  330. },
  331. };
  332. #define SH7372_CHCLR (0x220 - 0x20)
  333. static const struct sh_dmae_channel sh7372_dmae_channels[] = {
  334. {
  335. .offset = 0,
  336. .dmars = 0,
  337. .dmars_bit = 0,
  338. .chclr_offset = SH7372_CHCLR + 0,
  339. }, {
  340. .offset = 0x10,
  341. .dmars = 0,
  342. .dmars_bit = 8,
  343. .chclr_offset = SH7372_CHCLR + 0x10,
  344. }, {
  345. .offset = 0x20,
  346. .dmars = 4,
  347. .dmars_bit = 0,
  348. .chclr_offset = SH7372_CHCLR + 0x20,
  349. }, {
  350. .offset = 0x30,
  351. .dmars = 4,
  352. .dmars_bit = 8,
  353. .chclr_offset = SH7372_CHCLR + 0x30,
  354. }, {
  355. .offset = 0x50,
  356. .dmars = 8,
  357. .dmars_bit = 0,
  358. .chclr_offset = SH7372_CHCLR + 0x50,
  359. }, {
  360. .offset = 0x60,
  361. .dmars = 8,
  362. .dmars_bit = 8,
  363. .chclr_offset = SH7372_CHCLR + 0x60,
  364. }
  365. };
  366. static struct sh_dmae_pdata dma_platform_data = {
  367. .slave = sh7372_dmae_slaves,
  368. .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
  369. .channel = sh7372_dmae_channels,
  370. .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
  371. .ts_low_shift = TS_LOW_SHIFT,
  372. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  373. .ts_high_shift = TS_HI_SHIFT,
  374. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  375. .ts_shift = dma_ts_shift,
  376. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  377. .dmaor_init = DMAOR_DME,
  378. .chclr_present = 1,
  379. };
  380. /* Resource order important! */
  381. static struct resource sh7372_dmae0_resources[] = {
  382. {
  383. /* Channel registers and DMAOR */
  384. .start = 0xfe008020,
  385. .end = 0xfe00828f,
  386. .flags = IORESOURCE_MEM,
  387. },
  388. {
  389. /* DMARSx */
  390. .start = 0xfe009000,
  391. .end = 0xfe00900b,
  392. .flags = IORESOURCE_MEM,
  393. },
  394. {
  395. .name = "error_irq",
  396. .start = evt2irq(0x20c0),
  397. .end = evt2irq(0x20c0),
  398. .flags = IORESOURCE_IRQ,
  399. },
  400. {
  401. /* IRQ for channels 0-5 */
  402. .start = evt2irq(0x2000),
  403. .end = evt2irq(0x20a0),
  404. .flags = IORESOURCE_IRQ,
  405. },
  406. };
  407. /* Resource order important! */
  408. static struct resource sh7372_dmae1_resources[] = {
  409. {
  410. /* Channel registers and DMAOR */
  411. .start = 0xfe018020,
  412. .end = 0xfe01828f,
  413. .flags = IORESOURCE_MEM,
  414. },
  415. {
  416. /* DMARSx */
  417. .start = 0xfe019000,
  418. .end = 0xfe01900b,
  419. .flags = IORESOURCE_MEM,
  420. },
  421. {
  422. .name = "error_irq",
  423. .start = evt2irq(0x21c0),
  424. .end = evt2irq(0x21c0),
  425. .flags = IORESOURCE_IRQ,
  426. },
  427. {
  428. /* IRQ for channels 0-5 */
  429. .start = evt2irq(0x2100),
  430. .end = evt2irq(0x21a0),
  431. .flags = IORESOURCE_IRQ,
  432. },
  433. };
  434. /* Resource order important! */
  435. static struct resource sh7372_dmae2_resources[] = {
  436. {
  437. /* Channel registers and DMAOR */
  438. .start = 0xfe028020,
  439. .end = 0xfe02828f,
  440. .flags = IORESOURCE_MEM,
  441. },
  442. {
  443. /* DMARSx */
  444. .start = 0xfe029000,
  445. .end = 0xfe02900b,
  446. .flags = IORESOURCE_MEM,
  447. },
  448. {
  449. .name = "error_irq",
  450. .start = evt2irq(0x22c0),
  451. .end = evt2irq(0x22c0),
  452. .flags = IORESOURCE_IRQ,
  453. },
  454. {
  455. /* IRQ for channels 0-5 */
  456. .start = evt2irq(0x2200),
  457. .end = evt2irq(0x22a0),
  458. .flags = IORESOURCE_IRQ,
  459. },
  460. };
  461. static struct platform_device dma0_device = {
  462. .name = "sh-dma-engine",
  463. .id = 0,
  464. .resource = sh7372_dmae0_resources,
  465. .num_resources = ARRAY_SIZE(sh7372_dmae0_resources),
  466. .dev = {
  467. .platform_data = &dma_platform_data,
  468. },
  469. };
  470. static struct platform_device dma1_device = {
  471. .name = "sh-dma-engine",
  472. .id = 1,
  473. .resource = sh7372_dmae1_resources,
  474. .num_resources = ARRAY_SIZE(sh7372_dmae1_resources),
  475. .dev = {
  476. .platform_data = &dma_platform_data,
  477. },
  478. };
  479. static struct platform_device dma2_device = {
  480. .name = "sh-dma-engine",
  481. .id = 2,
  482. .resource = sh7372_dmae2_resources,
  483. .num_resources = ARRAY_SIZE(sh7372_dmae2_resources),
  484. .dev = {
  485. .platform_data = &dma_platform_data,
  486. },
  487. };
  488. /*
  489. * USB-DMAC
  490. */
  491. static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
  492. {
  493. .offset = 0,
  494. }, {
  495. .offset = 0x20,
  496. },
  497. };
  498. /* USB DMAC0 */
  499. static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
  500. {
  501. .slave_id = SHDMA_SLAVE_USB0_TX,
  502. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  503. }, {
  504. .slave_id = SHDMA_SLAVE_USB0_RX,
  505. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  506. },
  507. };
  508. static struct sh_dmae_pdata usb_dma0_platform_data = {
  509. .slave = sh7372_usb_dmae0_slaves,
  510. .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
  511. .channel = sh7372_usb_dmae_channels,
  512. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  513. .ts_low_shift = USBTS_LOW_SHIFT,
  514. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  515. .ts_high_shift = USBTS_HI_SHIFT,
  516. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  517. .ts_shift = dma_usbts_shift,
  518. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  519. .dmaor_init = DMAOR_DME,
  520. .chcr_offset = 0x14,
  521. .chcr_ie_bit = 1 << 5,
  522. .dmaor_is_32bit = 1,
  523. .needs_tend_set = 1,
  524. .no_dmars = 1,
  525. .slave_only = 1,
  526. };
  527. static struct resource sh7372_usb_dmae0_resources[] = {
  528. {
  529. /* Channel registers and DMAOR */
  530. .start = 0xe68a0020,
  531. .end = 0xe68a0064 - 1,
  532. .flags = IORESOURCE_MEM,
  533. },
  534. {
  535. /* VCR/SWR/DMICR */
  536. .start = 0xe68a0000,
  537. .end = 0xe68a0014 - 1,
  538. .flags = IORESOURCE_MEM,
  539. },
  540. {
  541. /* IRQ for channels */
  542. .start = evt2irq(0x0a00),
  543. .end = evt2irq(0x0a00),
  544. .flags = IORESOURCE_IRQ,
  545. },
  546. };
  547. static struct platform_device usb_dma0_device = {
  548. .name = "sh-dma-engine",
  549. .id = 3,
  550. .resource = sh7372_usb_dmae0_resources,
  551. .num_resources = ARRAY_SIZE(sh7372_usb_dmae0_resources),
  552. .dev = {
  553. .platform_data = &usb_dma0_platform_data,
  554. },
  555. };
  556. /* USB DMAC1 */
  557. static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
  558. {
  559. .slave_id = SHDMA_SLAVE_USB1_TX,
  560. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  561. }, {
  562. .slave_id = SHDMA_SLAVE_USB1_RX,
  563. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  564. },
  565. };
  566. static struct sh_dmae_pdata usb_dma1_platform_data = {
  567. .slave = sh7372_usb_dmae1_slaves,
  568. .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves),
  569. .channel = sh7372_usb_dmae_channels,
  570. .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
  571. .ts_low_shift = USBTS_LOW_SHIFT,
  572. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  573. .ts_high_shift = USBTS_HI_SHIFT,
  574. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  575. .ts_shift = dma_usbts_shift,
  576. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  577. .dmaor_init = DMAOR_DME,
  578. .chcr_offset = 0x14,
  579. .chcr_ie_bit = 1 << 5,
  580. .dmaor_is_32bit = 1,
  581. .needs_tend_set = 1,
  582. .no_dmars = 1,
  583. .slave_only = 1,
  584. };
  585. static struct resource sh7372_usb_dmae1_resources[] = {
  586. {
  587. /* Channel registers and DMAOR */
  588. .start = 0xe68c0020,
  589. .end = 0xe68c0064 - 1,
  590. .flags = IORESOURCE_MEM,
  591. },
  592. {
  593. /* VCR/SWR/DMICR */
  594. .start = 0xe68c0000,
  595. .end = 0xe68c0014 - 1,
  596. .flags = IORESOURCE_MEM,
  597. },
  598. {
  599. /* IRQ for channels */
  600. .start = evt2irq(0x1d00),
  601. .end = evt2irq(0x1d00),
  602. .flags = IORESOURCE_IRQ,
  603. },
  604. };
  605. static struct platform_device usb_dma1_device = {
  606. .name = "sh-dma-engine",
  607. .id = 4,
  608. .resource = sh7372_usb_dmae1_resources,
  609. .num_resources = ARRAY_SIZE(sh7372_usb_dmae1_resources),
  610. .dev = {
  611. .platform_data = &usb_dma1_platform_data,
  612. },
  613. };
  614. /* VPU */
  615. static struct uio_info vpu_platform_data = {
  616. .name = "VPU5HG",
  617. .version = "0",
  618. .irq = intcs_evt2irq(0x980),
  619. };
  620. static struct resource vpu_resources[] = {
  621. [0] = {
  622. .name = "VPU",
  623. .start = 0xfe900000,
  624. .end = 0xfe900157,
  625. .flags = IORESOURCE_MEM,
  626. },
  627. };
  628. static struct platform_device vpu_device = {
  629. .name = "uio_pdrv_genirq",
  630. .id = 0,
  631. .dev = {
  632. .platform_data = &vpu_platform_data,
  633. },
  634. .resource = vpu_resources,
  635. .num_resources = ARRAY_SIZE(vpu_resources),
  636. };
  637. /* VEU0 */
  638. static struct uio_info veu0_platform_data = {
  639. .name = "VEU0",
  640. .version = "0",
  641. .irq = intcs_evt2irq(0x700),
  642. };
  643. static struct resource veu0_resources[] = {
  644. [0] = {
  645. .name = "VEU0",
  646. .start = 0xfe920000,
  647. .end = 0xfe9200cb,
  648. .flags = IORESOURCE_MEM,
  649. },
  650. };
  651. static struct platform_device veu0_device = {
  652. .name = "uio_pdrv_genirq",
  653. .id = 1,
  654. .dev = {
  655. .platform_data = &veu0_platform_data,
  656. },
  657. .resource = veu0_resources,
  658. .num_resources = ARRAY_SIZE(veu0_resources),
  659. };
  660. /* VEU1 */
  661. static struct uio_info veu1_platform_data = {
  662. .name = "VEU1",
  663. .version = "0",
  664. .irq = intcs_evt2irq(0x720),
  665. };
  666. static struct resource veu1_resources[] = {
  667. [0] = {
  668. .name = "VEU1",
  669. .start = 0xfe924000,
  670. .end = 0xfe9240cb,
  671. .flags = IORESOURCE_MEM,
  672. },
  673. };
  674. static struct platform_device veu1_device = {
  675. .name = "uio_pdrv_genirq",
  676. .id = 2,
  677. .dev = {
  678. .platform_data = &veu1_platform_data,
  679. },
  680. .resource = veu1_resources,
  681. .num_resources = ARRAY_SIZE(veu1_resources),
  682. };
  683. /* VEU2 */
  684. static struct uio_info veu2_platform_data = {
  685. .name = "VEU2",
  686. .version = "0",
  687. .irq = intcs_evt2irq(0x740),
  688. };
  689. static struct resource veu2_resources[] = {
  690. [0] = {
  691. .name = "VEU2",
  692. .start = 0xfe928000,
  693. .end = 0xfe928307,
  694. .flags = IORESOURCE_MEM,
  695. },
  696. };
  697. static struct platform_device veu2_device = {
  698. .name = "uio_pdrv_genirq",
  699. .id = 3,
  700. .dev = {
  701. .platform_data = &veu2_platform_data,
  702. },
  703. .resource = veu2_resources,
  704. .num_resources = ARRAY_SIZE(veu2_resources),
  705. };
  706. /* VEU3 */
  707. static struct uio_info veu3_platform_data = {
  708. .name = "VEU3",
  709. .version = "0",
  710. .irq = intcs_evt2irq(0x760),
  711. };
  712. static struct resource veu3_resources[] = {
  713. [0] = {
  714. .name = "VEU3",
  715. .start = 0xfe92c000,
  716. .end = 0xfe92c307,
  717. .flags = IORESOURCE_MEM,
  718. },
  719. };
  720. static struct platform_device veu3_device = {
  721. .name = "uio_pdrv_genirq",
  722. .id = 4,
  723. .dev = {
  724. .platform_data = &veu3_platform_data,
  725. },
  726. .resource = veu3_resources,
  727. .num_resources = ARRAY_SIZE(veu3_resources),
  728. };
  729. /* JPU */
  730. static struct uio_info jpu_platform_data = {
  731. .name = "JPU",
  732. .version = "0",
  733. .irq = intcs_evt2irq(0x560),
  734. };
  735. static struct resource jpu_resources[] = {
  736. [0] = {
  737. .name = "JPU",
  738. .start = 0xfe980000,
  739. .end = 0xfe9902d3,
  740. .flags = IORESOURCE_MEM,
  741. },
  742. };
  743. static struct platform_device jpu_device = {
  744. .name = "uio_pdrv_genirq",
  745. .id = 5,
  746. .dev = {
  747. .platform_data = &jpu_platform_data,
  748. },
  749. .resource = jpu_resources,
  750. .num_resources = ARRAY_SIZE(jpu_resources),
  751. };
  752. /* SPU2DSP0 */
  753. static struct uio_info spu0_platform_data = {
  754. .name = "SPU2DSP0",
  755. .version = "0",
  756. .irq = evt2irq(0x1800),
  757. };
  758. static struct resource spu0_resources[] = {
  759. [0] = {
  760. .name = "SPU2DSP0",
  761. .start = 0xfe200000,
  762. .end = 0xfe2fffff,
  763. .flags = IORESOURCE_MEM,
  764. },
  765. };
  766. static struct platform_device spu0_device = {
  767. .name = "uio_pdrv_genirq",
  768. .id = 6,
  769. .dev = {
  770. .platform_data = &spu0_platform_data,
  771. },
  772. .resource = spu0_resources,
  773. .num_resources = ARRAY_SIZE(spu0_resources),
  774. };
  775. /* SPU2DSP1 */
  776. static struct uio_info spu1_platform_data = {
  777. .name = "SPU2DSP1",
  778. .version = "0",
  779. .irq = evt2irq(0x1820),
  780. };
  781. static struct resource spu1_resources[] = {
  782. [0] = {
  783. .name = "SPU2DSP1",
  784. .start = 0xfe300000,
  785. .end = 0xfe3fffff,
  786. .flags = IORESOURCE_MEM,
  787. },
  788. };
  789. static struct platform_device spu1_device = {
  790. .name = "uio_pdrv_genirq",
  791. .id = 7,
  792. .dev = {
  793. .platform_data = &spu1_platform_data,
  794. },
  795. .resource = spu1_resources,
  796. .num_resources = ARRAY_SIZE(spu1_resources),
  797. };
  798. /* IPMMUI (an IPMMU module for ICB/LMB) */
  799. static struct resource ipmmu_resources[] = {
  800. [0] = {
  801. .name = "IPMMUI",
  802. .start = 0xfe951000,
  803. .end = 0xfe9510ff,
  804. .flags = IORESOURCE_MEM,
  805. },
  806. };
  807. static const char * const ipmmu_dev_names[] = {
  808. "sh_mobile_lcdc_fb.0",
  809. "sh_mobile_lcdc_fb.1",
  810. "sh_mobile_ceu.0",
  811. "uio_pdrv_genirq.0",
  812. "uio_pdrv_genirq.1",
  813. "uio_pdrv_genirq.2",
  814. "uio_pdrv_genirq.3",
  815. "uio_pdrv_genirq.4",
  816. "uio_pdrv_genirq.5",
  817. };
  818. static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
  819. .dev_names = ipmmu_dev_names,
  820. .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
  821. };
  822. static struct platform_device ipmmu_device = {
  823. .name = "ipmmu",
  824. .id = -1,
  825. .dev = {
  826. .platform_data = &ipmmu_platform_data,
  827. },
  828. .resource = ipmmu_resources,
  829. .num_resources = ARRAY_SIZE(ipmmu_resources),
  830. };
  831. static struct platform_device *sh7372_early_devices[] __initdata = {
  832. &scif0_device,
  833. &scif1_device,
  834. &scif2_device,
  835. &scif3_device,
  836. &scif4_device,
  837. &scif5_device,
  838. &scif6_device,
  839. &cmt2_device,
  840. &tmu0_device,
  841. &ipmmu_device,
  842. };
  843. static struct platform_device *sh7372_late_devices[] __initdata = {
  844. &iic0_device,
  845. &iic1_device,
  846. &dma0_device,
  847. &dma1_device,
  848. &dma2_device,
  849. &usb_dma0_device,
  850. &usb_dma1_device,
  851. &vpu_device,
  852. &veu0_device,
  853. &veu1_device,
  854. &veu2_device,
  855. &veu3_device,
  856. &jpu_device,
  857. &spu0_device,
  858. &spu1_device,
  859. };
  860. void __init sh7372_add_standard_devices(void)
  861. {
  862. static struct pm_domain_device domain_devices[] __initdata = {
  863. { "A3RV", &vpu_device, },
  864. { "A4MP", &spu0_device, },
  865. { "A4MP", &spu1_device, },
  866. { "A3SP", &scif0_device, },
  867. { "A3SP", &scif1_device, },
  868. { "A3SP", &scif2_device, },
  869. { "A3SP", &scif3_device, },
  870. { "A3SP", &scif4_device, },
  871. { "A3SP", &scif5_device, },
  872. { "A3SP", &scif6_device, },
  873. { "A3SP", &iic1_device, },
  874. { "A3SP", &dma0_device, },
  875. { "A3SP", &dma1_device, },
  876. { "A3SP", &dma2_device, },
  877. { "A3SP", &usb_dma0_device, },
  878. { "A3SP", &usb_dma1_device, },
  879. { "A4R", &iic0_device, },
  880. { "A4R", &veu0_device, },
  881. { "A4R", &veu1_device, },
  882. { "A4R", &veu2_device, },
  883. { "A4R", &veu3_device, },
  884. { "A4R", &jpu_device, },
  885. { "A4R", &tmu0_device, },
  886. };
  887. sh7372_init_pm_domains();
  888. platform_add_devices(sh7372_early_devices,
  889. ARRAY_SIZE(sh7372_early_devices));
  890. platform_add_devices(sh7372_late_devices,
  891. ARRAY_SIZE(sh7372_late_devices));
  892. rmobile_add_devices_to_domains(domain_devices,
  893. ARRAY_SIZE(domain_devices));
  894. }
  895. void __init sh7372_earlytimer_init(void)
  896. {
  897. sh7372_clock_init();
  898. shmobile_earlytimer_init();
  899. }
  900. void __init sh7372_add_early_devices(void)
  901. {
  902. early_platform_add_devices(sh7372_early_devices,
  903. ARRAY_SIZE(sh7372_early_devices));
  904. /* setup early console here as well */
  905. shmobile_setup_console();
  906. }
  907. #ifdef CONFIG_USE_OF
  908. void __init sh7372_add_early_devices_dt(void)
  909. {
  910. shmobile_init_delay();
  911. sh7372_add_early_devices();
  912. }
  913. void __init sh7372_add_standard_devices_dt(void)
  914. {
  915. /* clocks are setup late during boot in the case of DT */
  916. sh7372_clock_init();
  917. platform_add_devices(sh7372_early_devices,
  918. ARRAY_SIZE(sh7372_early_devices));
  919. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  920. }
  921. static const char *sh7372_boards_compat_dt[] __initdata = {
  922. "renesas,sh7372",
  923. NULL,
  924. };
  925. DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
  926. .map_io = sh7372_map_io,
  927. .init_early = sh7372_add_early_devices_dt,
  928. .init_irq = sh7372_init_irq,
  929. .handle_irq = shmobile_handle_irq_intc,
  930. .init_machine = sh7372_add_standard_devices_dt,
  931. .dt_compat = sh7372_boards_compat_dt,
  932. MACHINE_END
  933. #endif /* CONFIG_USE_OF */