setup-r8a7740.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. /*
  2. * R8A7740 processor support
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  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. #include <linux/dma-mapping.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/io.h>
  20. #include <linux/irqchip.h>
  21. #include <linux/irqchip/arm-gic.h>
  22. #include <linux/platform_data/irq-renesas-intc-irqpin.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/of_platform.h>
  25. #include <linux/serial_sci.h>
  26. #include <linux/sh_dma.h>
  27. #include <linux/sh_timer.h>
  28. #include <linux/platform_data/sh_ipmmu.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/map.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/time.h>
  33. #include <asm/hardware/cache-l2x0.h>
  34. #include "common.h"
  35. #include "dma-register.h"
  36. #include "irqs.h"
  37. #include "pm-rmobile.h"
  38. #include "r8a7740.h"
  39. static struct map_desc r8a7740_io_desc[] __initdata = {
  40. /*
  41. * for CPGA/INTC/PFC
  42. * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff
  43. */
  44. {
  45. .virtual = 0xe6000000,
  46. .pfn = __phys_to_pfn(0xe6000000),
  47. .length = 160 << 20,
  48. .type = MT_DEVICE_NONSHARED
  49. },
  50. #ifdef CONFIG_CACHE_L2X0
  51. /*
  52. * for l2x0_init()
  53. * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000
  54. */
  55. {
  56. .virtual = 0xf0002000,
  57. .pfn = __phys_to_pfn(0xf0100000),
  58. .length = PAGE_SIZE,
  59. .type = MT_DEVICE_NONSHARED
  60. },
  61. #endif
  62. };
  63. void __init r8a7740_map_io(void)
  64. {
  65. debug_ll_io_init();
  66. iotable_init(r8a7740_io_desc, ARRAY_SIZE(r8a7740_io_desc));
  67. }
  68. /* PFC */
  69. static const struct resource pfc_resources[] = {
  70. DEFINE_RES_MEM(0xe6050000, 0x8000),
  71. DEFINE_RES_MEM(0xe605800c, 0x0020),
  72. };
  73. void __init r8a7740_pinmux_init(void)
  74. {
  75. platform_device_register_simple("pfc-r8a7740", -1, pfc_resources,
  76. ARRAY_SIZE(pfc_resources));
  77. }
  78. static struct renesas_intc_irqpin_config irqpin0_platform_data = {
  79. .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
  80. };
  81. static struct resource irqpin0_resources[] = {
  82. DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
  83. DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
  84. DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
  85. DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
  86. DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
  87. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ0 */
  88. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ1 */
  89. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ2 */
  90. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ3 */
  91. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ4 */
  92. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ5 */
  93. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ6 */
  94. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ7 */
  95. };
  96. static struct platform_device irqpin0_device = {
  97. .name = "renesas_intc_irqpin",
  98. .id = 0,
  99. .resource = irqpin0_resources,
  100. .num_resources = ARRAY_SIZE(irqpin0_resources),
  101. .dev = {
  102. .platform_data = &irqpin0_platform_data,
  103. },
  104. };
  105. static struct renesas_intc_irqpin_config irqpin1_platform_data = {
  106. .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
  107. };
  108. static struct resource irqpin1_resources[] = {
  109. DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
  110. DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
  111. DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
  112. DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
  113. DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
  114. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ8 */
  115. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ9 */
  116. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ10 */
  117. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ11 */
  118. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ12 */
  119. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ13 */
  120. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ14 */
  121. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ15 */
  122. };
  123. static struct platform_device irqpin1_device = {
  124. .name = "renesas_intc_irqpin",
  125. .id = 1,
  126. .resource = irqpin1_resources,
  127. .num_resources = ARRAY_SIZE(irqpin1_resources),
  128. .dev = {
  129. .platform_data = &irqpin1_platform_data,
  130. },
  131. };
  132. static struct renesas_intc_irqpin_config irqpin2_platform_data = {
  133. .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
  134. };
  135. static struct resource irqpin2_resources[] = {
  136. DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
  137. DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI30A */
  138. DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ30A */
  139. DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK30A */
  140. DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR30A */
  141. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ16 */
  142. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ17 */
  143. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ18 */
  144. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ19 */
  145. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ20 */
  146. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ21 */
  147. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ22 */
  148. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ23 */
  149. };
  150. static struct platform_device irqpin2_device = {
  151. .name = "renesas_intc_irqpin",
  152. .id = 2,
  153. .resource = irqpin2_resources,
  154. .num_resources = ARRAY_SIZE(irqpin2_resources),
  155. .dev = {
  156. .platform_data = &irqpin2_platform_data,
  157. },
  158. };
  159. static struct renesas_intc_irqpin_config irqpin3_platform_data = {
  160. .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
  161. };
  162. static struct resource irqpin3_resources[] = {
  163. DEFINE_RES_MEM(0xe690000c, 4), /* ICR3A */
  164. DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
  165. DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
  166. DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
  167. DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
  168. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ24 */
  169. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ25 */
  170. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ26 */
  171. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ27 */
  172. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ28 */
  173. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ29 */
  174. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ30 */
  175. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ31 */
  176. };
  177. static struct platform_device irqpin3_device = {
  178. .name = "renesas_intc_irqpin",
  179. .id = 3,
  180. .resource = irqpin3_resources,
  181. .num_resources = ARRAY_SIZE(irqpin3_resources),
  182. .dev = {
  183. .platform_data = &irqpin3_platform_data,
  184. },
  185. };
  186. /* SCIF */
  187. #define R8A7740_SCIF(scif_type, index, baseaddr, irq) \
  188. static struct plat_sci_port scif##index##_platform_data = { \
  189. .type = scif_type, \
  190. .flags = UPF_BOOT_AUTOCONF, \
  191. .scscr = SCSCR_RE | SCSCR_TE, \
  192. }; \
  193. \
  194. static struct resource scif##index##_resources[] = { \
  195. DEFINE_RES_MEM(baseaddr, 0x100), \
  196. DEFINE_RES_IRQ(irq), \
  197. }; \
  198. \
  199. static struct platform_device scif##index##_device = { \
  200. .name = "sh-sci", \
  201. .id = index, \
  202. .resource = scif##index##_resources, \
  203. .num_resources = ARRAY_SIZE(scif##index##_resources), \
  204. .dev = { \
  205. .platform_data = &scif##index##_platform_data, \
  206. }, \
  207. }
  208. R8A7740_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(100));
  209. R8A7740_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(101));
  210. R8A7740_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(102));
  211. R8A7740_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(103));
  212. R8A7740_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(104));
  213. R8A7740_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(105));
  214. R8A7740_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(106));
  215. R8A7740_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(107));
  216. R8A7740_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(108));
  217. /* CMT */
  218. static struct sh_timer_config cmt1_platform_data = {
  219. .channels_mask = 0x3f,
  220. };
  221. static struct resource cmt1_resources[] = {
  222. DEFINE_RES_MEM(0xe6138000, 0x170),
  223. DEFINE_RES_IRQ(gic_spi(58)),
  224. };
  225. static struct platform_device cmt1_device = {
  226. .name = "sh-cmt-48",
  227. .id = 1,
  228. .dev = {
  229. .platform_data = &cmt1_platform_data,
  230. },
  231. .resource = cmt1_resources,
  232. .num_resources = ARRAY_SIZE(cmt1_resources),
  233. };
  234. /* TMU */
  235. static struct sh_timer_config tmu0_platform_data = {
  236. .channels_mask = 7,
  237. };
  238. static struct resource tmu0_resources[] = {
  239. DEFINE_RES_MEM(0xfff80000, 0x2c),
  240. DEFINE_RES_IRQ(gic_spi(198)),
  241. DEFINE_RES_IRQ(gic_spi(199)),
  242. DEFINE_RES_IRQ(gic_spi(200)),
  243. };
  244. static struct platform_device tmu0_device = {
  245. .name = "sh-tmu",
  246. .id = 0,
  247. .dev = {
  248. .platform_data = &tmu0_platform_data,
  249. },
  250. .resource = tmu0_resources,
  251. .num_resources = ARRAY_SIZE(tmu0_resources),
  252. };
  253. /* IPMMUI (an IPMMU module for ICB/LMB) */
  254. static struct resource ipmmu_resources[] = {
  255. [0] = {
  256. .name = "IPMMUI",
  257. .start = 0xfe951000,
  258. .end = 0xfe9510ff,
  259. .flags = IORESOURCE_MEM,
  260. },
  261. };
  262. static const char * const ipmmu_dev_names[] = {
  263. "sh_mobile_lcdc_fb.0",
  264. "sh_mobile_lcdc_fb.1",
  265. "sh_mobile_ceu.0",
  266. };
  267. static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
  268. .dev_names = ipmmu_dev_names,
  269. .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
  270. };
  271. static struct platform_device ipmmu_device = {
  272. .name = "ipmmu",
  273. .id = -1,
  274. .dev = {
  275. .platform_data = &ipmmu_platform_data,
  276. },
  277. .resource = ipmmu_resources,
  278. .num_resources = ARRAY_SIZE(ipmmu_resources),
  279. };
  280. static struct platform_device *r8a7740_early_devices[] __initdata = {
  281. &scif0_device,
  282. &scif1_device,
  283. &scif2_device,
  284. &scif3_device,
  285. &scif4_device,
  286. &scif5_device,
  287. &scif6_device,
  288. &scif7_device,
  289. &scif8_device,
  290. &irqpin0_device,
  291. &irqpin1_device,
  292. &irqpin2_device,
  293. &irqpin3_device,
  294. &tmu0_device,
  295. &ipmmu_device,
  296. &cmt1_device,
  297. };
  298. /* DMA */
  299. static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = {
  300. {
  301. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  302. .addr = 0xe6850030,
  303. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  304. .mid_rid = 0xc1,
  305. }, {
  306. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  307. .addr = 0xe6850030,
  308. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  309. .mid_rid = 0xc2,
  310. }, {
  311. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  312. .addr = 0xe6860030,
  313. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  314. .mid_rid = 0xc9,
  315. }, {
  316. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  317. .addr = 0xe6860030,
  318. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  319. .mid_rid = 0xca,
  320. }, {
  321. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  322. .addr = 0xe6870030,
  323. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  324. .mid_rid = 0xcd,
  325. }, {
  326. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  327. .addr = 0xe6870030,
  328. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  329. .mid_rid = 0xce,
  330. }, {
  331. .slave_id = SHDMA_SLAVE_FSIA_TX,
  332. .addr = 0xfe1f0024,
  333. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  334. .mid_rid = 0xb1,
  335. }, {
  336. .slave_id = SHDMA_SLAVE_FSIA_RX,
  337. .addr = 0xfe1f0020,
  338. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  339. .mid_rid = 0xb2,
  340. }, {
  341. .slave_id = SHDMA_SLAVE_FSIB_TX,
  342. .addr = 0xfe1f0064,
  343. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  344. .mid_rid = 0xb5,
  345. }, {
  346. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  347. .addr = 0xe6bd0034,
  348. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  349. .mid_rid = 0xd1,
  350. }, {
  351. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  352. .addr = 0xe6bd0034,
  353. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  354. .mid_rid = 0xd2,
  355. },
  356. };
  357. #define DMA_CHANNEL(a, b, c) \
  358. { \
  359. .offset = a, \
  360. .dmars = b, \
  361. .dmars_bit = c, \
  362. .chclr_offset = (0x220 - 0x20) + a \
  363. }
  364. static const struct sh_dmae_channel r8a7740_dmae_channels[] = {
  365. DMA_CHANNEL(0x00, 0, 0),
  366. DMA_CHANNEL(0x10, 0, 8),
  367. DMA_CHANNEL(0x20, 4, 0),
  368. DMA_CHANNEL(0x30, 4, 8),
  369. DMA_CHANNEL(0x50, 8, 0),
  370. DMA_CHANNEL(0x60, 8, 8),
  371. };
  372. static struct sh_dmae_pdata dma_platform_data = {
  373. .slave = r8a7740_dmae_slaves,
  374. .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves),
  375. .channel = r8a7740_dmae_channels,
  376. .channel_num = ARRAY_SIZE(r8a7740_dmae_channels),
  377. .ts_low_shift = TS_LOW_SHIFT,
  378. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  379. .ts_high_shift = TS_HI_SHIFT,
  380. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  381. .ts_shift = dma_ts_shift,
  382. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  383. .dmaor_init = DMAOR_DME,
  384. .chclr_present = 1,
  385. };
  386. /* Resource order important! */
  387. static struct resource r8a7740_dmae0_resources[] = {
  388. {
  389. /* Channel registers and DMAOR */
  390. .start = 0xfe008020,
  391. .end = 0xfe00828f,
  392. .flags = IORESOURCE_MEM,
  393. },
  394. {
  395. /* DMARSx */
  396. .start = 0xfe009000,
  397. .end = 0xfe00900b,
  398. .flags = IORESOURCE_MEM,
  399. },
  400. {
  401. .name = "error_irq",
  402. .start = gic_spi(34),
  403. .end = gic_spi(34),
  404. .flags = IORESOURCE_IRQ,
  405. },
  406. {
  407. /* IRQ for channels 0-5 */
  408. .start = gic_spi(28),
  409. .end = gic_spi(33),
  410. .flags = IORESOURCE_IRQ,
  411. },
  412. };
  413. /* Resource order important! */
  414. static struct resource r8a7740_dmae1_resources[] = {
  415. {
  416. /* Channel registers and DMAOR */
  417. .start = 0xfe018020,
  418. .end = 0xfe01828f,
  419. .flags = IORESOURCE_MEM,
  420. },
  421. {
  422. /* DMARSx */
  423. .start = 0xfe019000,
  424. .end = 0xfe01900b,
  425. .flags = IORESOURCE_MEM,
  426. },
  427. {
  428. .name = "error_irq",
  429. .start = gic_spi(41),
  430. .end = gic_spi(41),
  431. .flags = IORESOURCE_IRQ,
  432. },
  433. {
  434. /* IRQ for channels 0-5 */
  435. .start = gic_spi(35),
  436. .end = gic_spi(40),
  437. .flags = IORESOURCE_IRQ,
  438. },
  439. };
  440. /* Resource order important! */
  441. static struct resource r8a7740_dmae2_resources[] = {
  442. {
  443. /* Channel registers and DMAOR */
  444. .start = 0xfe028020,
  445. .end = 0xfe02828f,
  446. .flags = IORESOURCE_MEM,
  447. },
  448. {
  449. /* DMARSx */
  450. .start = 0xfe029000,
  451. .end = 0xfe02900b,
  452. .flags = IORESOURCE_MEM,
  453. },
  454. {
  455. .name = "error_irq",
  456. .start = gic_spi(48),
  457. .end = gic_spi(48),
  458. .flags = IORESOURCE_IRQ,
  459. },
  460. {
  461. /* IRQ for channels 0-5 */
  462. .start = gic_spi(42),
  463. .end = gic_spi(47),
  464. .flags = IORESOURCE_IRQ,
  465. },
  466. };
  467. static struct platform_device dma0_device = {
  468. .name = "sh-dma-engine",
  469. .id = 0,
  470. .resource = r8a7740_dmae0_resources,
  471. .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources),
  472. .dev = {
  473. .platform_data = &dma_platform_data,
  474. },
  475. };
  476. static struct platform_device dma1_device = {
  477. .name = "sh-dma-engine",
  478. .id = 1,
  479. .resource = r8a7740_dmae1_resources,
  480. .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources),
  481. .dev = {
  482. .platform_data = &dma_platform_data,
  483. },
  484. };
  485. static struct platform_device dma2_device = {
  486. .name = "sh-dma-engine",
  487. .id = 2,
  488. .resource = r8a7740_dmae2_resources,
  489. .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources),
  490. .dev = {
  491. .platform_data = &dma_platform_data,
  492. },
  493. };
  494. /* USB-DMAC */
  495. static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = {
  496. {
  497. .offset = 0,
  498. }, {
  499. .offset = 0x20,
  500. },
  501. };
  502. static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = {
  503. {
  504. .slave_id = SHDMA_SLAVE_USBHS_TX,
  505. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  506. }, {
  507. .slave_id = SHDMA_SLAVE_USBHS_RX,
  508. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  509. },
  510. };
  511. static struct sh_dmae_pdata usb_dma_platform_data = {
  512. .slave = r8a7740_usb_dma_slaves,
  513. .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves),
  514. .channel = r8a7740_usb_dma_channels,
  515. .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels),
  516. .ts_low_shift = USBTS_LOW_SHIFT,
  517. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  518. .ts_high_shift = USBTS_HI_SHIFT,
  519. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  520. .ts_shift = dma_usbts_shift,
  521. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  522. .dmaor_init = DMAOR_DME,
  523. .chcr_offset = 0x14,
  524. .chcr_ie_bit = 1 << 5,
  525. .dmaor_is_32bit = 1,
  526. .needs_tend_set = 1,
  527. .no_dmars = 1,
  528. .slave_only = 1,
  529. };
  530. static struct resource r8a7740_usb_dma_resources[] = {
  531. {
  532. /* Channel registers and DMAOR */
  533. .start = 0xe68a0020,
  534. .end = 0xe68a0064 - 1,
  535. .flags = IORESOURCE_MEM,
  536. },
  537. {
  538. /* VCR/SWR/DMICR */
  539. .start = 0xe68a0000,
  540. .end = 0xe68a0014 - 1,
  541. .flags = IORESOURCE_MEM,
  542. },
  543. {
  544. /* IRQ for channels */
  545. .start = gic_spi(49),
  546. .end = gic_spi(49),
  547. .flags = IORESOURCE_IRQ,
  548. },
  549. };
  550. static struct platform_device usb_dma_device = {
  551. .name = "sh-dma-engine",
  552. .id = 3,
  553. .resource = r8a7740_usb_dma_resources,
  554. .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources),
  555. .dev = {
  556. .platform_data = &usb_dma_platform_data,
  557. },
  558. };
  559. /* I2C */
  560. static struct resource i2c0_resources[] = {
  561. [0] = {
  562. .name = "IIC0",
  563. .start = 0xfff20000,
  564. .end = 0xfff20425 - 1,
  565. .flags = IORESOURCE_MEM,
  566. },
  567. [1] = {
  568. .start = gic_spi(201),
  569. .end = gic_spi(204),
  570. .flags = IORESOURCE_IRQ,
  571. },
  572. };
  573. static struct resource i2c1_resources[] = {
  574. [0] = {
  575. .name = "IIC1",
  576. .start = 0xe6c20000,
  577. .end = 0xe6c20425 - 1,
  578. .flags = IORESOURCE_MEM,
  579. },
  580. [1] = {
  581. .start = gic_spi(70), /* IIC1_ALI1 */
  582. .end = gic_spi(73), /* IIC1_DTEI1 */
  583. .flags = IORESOURCE_IRQ,
  584. },
  585. };
  586. static struct platform_device i2c0_device = {
  587. .name = "i2c-sh_mobile",
  588. .id = 0,
  589. .resource = i2c0_resources,
  590. .num_resources = ARRAY_SIZE(i2c0_resources),
  591. };
  592. static struct platform_device i2c1_device = {
  593. .name = "i2c-sh_mobile",
  594. .id = 1,
  595. .resource = i2c1_resources,
  596. .num_resources = ARRAY_SIZE(i2c1_resources),
  597. };
  598. static struct resource pmu_resources[] = {
  599. [0] = {
  600. .start = gic_spi(83),
  601. .end = gic_spi(83),
  602. .flags = IORESOURCE_IRQ,
  603. },
  604. };
  605. static struct platform_device pmu_device = {
  606. .name = "armv7-pmu",
  607. .id = -1,
  608. .num_resources = ARRAY_SIZE(pmu_resources),
  609. .resource = pmu_resources,
  610. };
  611. static struct platform_device *r8a7740_late_devices[] __initdata = {
  612. &i2c0_device,
  613. &i2c1_device,
  614. &dma0_device,
  615. &dma1_device,
  616. &dma2_device,
  617. &usb_dma_device,
  618. &pmu_device,
  619. };
  620. /*
  621. * r8a7740 chip has lasting errata on MERAM buffer.
  622. * this is work-around for it.
  623. * see
  624. * "Media RAM (MERAM)" on r8a7740 documentation
  625. */
  626. #define MEBUFCNTR 0xFE950098
  627. void __init r8a7740_meram_workaround(void)
  628. {
  629. void __iomem *reg;
  630. reg = ioremap_nocache(MEBUFCNTR, 4);
  631. if (reg) {
  632. iowrite32(0x01600164, reg);
  633. iounmap(reg);
  634. }
  635. }
  636. void __init r8a7740_add_standard_devices(void)
  637. {
  638. static struct pm_domain_device domain_devices[] __initdata = {
  639. { "A4R", &tmu0_device },
  640. { "A4R", &i2c0_device },
  641. { "A4S", &irqpin0_device },
  642. { "A4S", &irqpin1_device },
  643. { "A4S", &irqpin2_device },
  644. { "A4S", &irqpin3_device },
  645. { "A3SP", &scif0_device },
  646. { "A3SP", &scif1_device },
  647. { "A3SP", &scif2_device },
  648. { "A3SP", &scif3_device },
  649. { "A3SP", &scif4_device },
  650. { "A3SP", &scif5_device },
  651. { "A3SP", &scif6_device },
  652. { "A3SP", &scif7_device },
  653. { "A3SP", &scif8_device },
  654. { "A3SP", &i2c1_device },
  655. { "A3SP", &ipmmu_device },
  656. { "A3SP", &dma0_device },
  657. { "A3SP", &dma1_device },
  658. { "A3SP", &dma2_device },
  659. { "A3SP", &usb_dma_device },
  660. };
  661. r8a7740_init_pm_domains();
  662. /* add devices */
  663. platform_add_devices(r8a7740_early_devices,
  664. ARRAY_SIZE(r8a7740_early_devices));
  665. platform_add_devices(r8a7740_late_devices,
  666. ARRAY_SIZE(r8a7740_late_devices));
  667. /* add devices to PM domain */
  668. rmobile_add_devices_to_domains(domain_devices,
  669. ARRAY_SIZE(domain_devices));
  670. }
  671. void __init r8a7740_add_early_devices(void)
  672. {
  673. early_platform_add_devices(r8a7740_early_devices,
  674. ARRAY_SIZE(r8a7740_early_devices));
  675. /* setup early console here as well */
  676. shmobile_setup_console();
  677. }
  678. #ifdef CONFIG_USE_OF
  679. void __init r8a7740_init_irq_of(void)
  680. {
  681. void __iomem *intc_prio_base = ioremap_nocache(0xe6900010, 0x10);
  682. void __iomem *intc_msk_base = ioremap_nocache(0xe6900040, 0x10);
  683. void __iomem *pfc_inta_ctrl = ioremap_nocache(0xe605807c, 0x4);
  684. #ifdef CONFIG_ARCH_SHMOBILE_LEGACY
  685. void __iomem *gic_dist_base = ioremap_nocache(0xc2800000, 0x1000);
  686. void __iomem *gic_cpu_base = ioremap_nocache(0xc2000000, 0x1000);
  687. gic_init(0, 29, gic_dist_base, gic_cpu_base);
  688. #else
  689. irqchip_init();
  690. #endif
  691. /* route signals to GIC */
  692. iowrite32(0x0, pfc_inta_ctrl);
  693. /*
  694. * To mask the shared interrupt to SPI 149 we must ensure to set
  695. * PRIO *and* MASK. Else we run into IRQ floods when registering
  696. * the intc_irqpin devices
  697. */
  698. iowrite32(0x0, intc_prio_base + 0x0);
  699. iowrite32(0x0, intc_prio_base + 0x4);
  700. iowrite32(0x0, intc_prio_base + 0x8);
  701. iowrite32(0x0, intc_prio_base + 0xc);
  702. iowrite8(0xff, intc_msk_base + 0x0);
  703. iowrite8(0xff, intc_msk_base + 0x4);
  704. iowrite8(0xff, intc_msk_base + 0x8);
  705. iowrite8(0xff, intc_msk_base + 0xc);
  706. iounmap(intc_prio_base);
  707. iounmap(intc_msk_base);
  708. iounmap(pfc_inta_ctrl);
  709. }
  710. static void __init r8a7740_generic_init(void)
  711. {
  712. r8a7740_meram_workaround();
  713. #ifdef CONFIG_CACHE_L2X0
  714. /* Shared attribute override enable, 32K*8way */
  715. l2x0_init(IOMEM(0xf0002000), 0x00400000, 0xc20f0fff);
  716. #endif
  717. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  718. }
  719. static const char *r8a7740_boards_compat_dt[] __initdata = {
  720. "renesas,r8a7740",
  721. NULL,
  722. };
  723. DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
  724. .map_io = r8a7740_map_io,
  725. .init_early = shmobile_init_delay,
  726. .init_irq = r8a7740_init_irq_of,
  727. .init_machine = r8a7740_generic_init,
  728. .init_late = shmobile_init_late,
  729. .dt_compat = r8a7740_boards_compat_dt,
  730. MACHINE_END
  731. #endif /* CONFIG_USE_OF */