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