setup-r8a7740.c 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  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. * 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/delay.h>
  21. #include <linux/dma-mapping.h>
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/io.h>
  25. #include <linux/platform_data/irq-renesas-intc-irqpin.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/of_platform.h>
  28. #include <linux/serial_sci.h>
  29. #include <linux/sh_dma.h>
  30. #include <linux/sh_timer.h>
  31. #include <linux/platform_data/sh_ipmmu.h>
  32. #include <mach/dma-register.h>
  33. #include <mach/r8a7740.h>
  34. #include <mach/pm-rmobile.h>
  35. #include <mach/common.h>
  36. #include <mach/irqs.h>
  37. #include <asm/mach-types.h>
  38. #include <asm/mach/map.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/mach/time.h>
  41. static struct map_desc r8a7740_io_desc[] __initdata = {
  42. /*
  43. * for CPGA/INTC/PFC
  44. * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff
  45. */
  46. {
  47. .virtual = 0xe6000000,
  48. .pfn = __phys_to_pfn(0xe6000000),
  49. .length = 160 << 20,
  50. .type = MT_DEVICE_NONSHARED
  51. },
  52. #ifdef CONFIG_CACHE_L2X0
  53. /*
  54. * for l2x0_init()
  55. * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000
  56. */
  57. {
  58. .virtual = 0xf0002000,
  59. .pfn = __phys_to_pfn(0xf0100000),
  60. .length = PAGE_SIZE,
  61. .type = MT_DEVICE_NONSHARED
  62. },
  63. #endif
  64. };
  65. void __init r8a7740_map_io(void)
  66. {
  67. iotable_init(r8a7740_io_desc, ARRAY_SIZE(r8a7740_io_desc));
  68. }
  69. /* PFC */
  70. static const struct resource pfc_resources[] = {
  71. DEFINE_RES_MEM(0xe6050000, 0x8000),
  72. DEFINE_RES_MEM(0xe605800c, 0x0020),
  73. };
  74. void __init r8a7740_pinmux_init(void)
  75. {
  76. platform_device_register_simple("pfc-r8a7740", -1, pfc_resources,
  77. ARRAY_SIZE(pfc_resources));
  78. }
  79. static struct renesas_intc_irqpin_config irqpin0_platform_data = {
  80. .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
  81. };
  82. static struct resource irqpin0_resources[] = {
  83. DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
  84. DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
  85. DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
  86. DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
  87. DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
  88. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ0 */
  89. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ1 */
  90. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ2 */
  91. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ3 */
  92. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ4 */
  93. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ5 */
  94. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ6 */
  95. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ7 */
  96. };
  97. static struct platform_device irqpin0_device = {
  98. .name = "renesas_intc_irqpin",
  99. .id = 0,
  100. .resource = irqpin0_resources,
  101. .num_resources = ARRAY_SIZE(irqpin0_resources),
  102. .dev = {
  103. .platform_data = &irqpin0_platform_data,
  104. },
  105. };
  106. static struct renesas_intc_irqpin_config irqpin1_platform_data = {
  107. .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
  108. };
  109. static struct resource irqpin1_resources[] = {
  110. DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
  111. DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
  112. DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
  113. DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
  114. DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
  115. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ8 */
  116. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ9 */
  117. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ10 */
  118. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ11 */
  119. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ12 */
  120. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ13 */
  121. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ14 */
  122. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ15 */
  123. };
  124. static struct platform_device irqpin1_device = {
  125. .name = "renesas_intc_irqpin",
  126. .id = 1,
  127. .resource = irqpin1_resources,
  128. .num_resources = ARRAY_SIZE(irqpin1_resources),
  129. .dev = {
  130. .platform_data = &irqpin1_platform_data,
  131. },
  132. };
  133. static struct renesas_intc_irqpin_config irqpin2_platform_data = {
  134. .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
  135. };
  136. static struct resource irqpin2_resources[] = {
  137. DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
  138. DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI30A */
  139. DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ30A */
  140. DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK30A */
  141. DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR30A */
  142. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ16 */
  143. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ17 */
  144. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ18 */
  145. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ19 */
  146. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ20 */
  147. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ21 */
  148. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ22 */
  149. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ23 */
  150. };
  151. static struct platform_device irqpin2_device = {
  152. .name = "renesas_intc_irqpin",
  153. .id = 2,
  154. .resource = irqpin2_resources,
  155. .num_resources = ARRAY_SIZE(irqpin2_resources),
  156. .dev = {
  157. .platform_data = &irqpin2_platform_data,
  158. },
  159. };
  160. static struct renesas_intc_irqpin_config irqpin3_platform_data = {
  161. .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
  162. };
  163. static struct resource irqpin3_resources[] = {
  164. DEFINE_RES_MEM(0xe690000c, 4), /* ICR3A */
  165. DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
  166. DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
  167. DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
  168. DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
  169. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ24 */
  170. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ25 */
  171. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ26 */
  172. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ27 */
  173. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ28 */
  174. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ29 */
  175. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ30 */
  176. DEFINE_RES_IRQ(gic_spi(149)), /* IRQ31 */
  177. };
  178. static struct platform_device irqpin3_device = {
  179. .name = "renesas_intc_irqpin",
  180. .id = 3,
  181. .resource = irqpin3_resources,
  182. .num_resources = ARRAY_SIZE(irqpin3_resources),
  183. .dev = {
  184. .platform_data = &irqpin3_platform_data,
  185. },
  186. };
  187. /* SCIFA0 */
  188. static struct plat_sci_port scif0_platform_data = {
  189. .mapbase = 0xe6c40000,
  190. .flags = UPF_BOOT_AUTOCONF,
  191. .scscr = SCSCR_RE | SCSCR_TE,
  192. .scbrr_algo_id = SCBRR_ALGO_4,
  193. .type = PORT_SCIFA,
  194. .irqs = SCIx_IRQ_MUXED(gic_spi(100)),
  195. };
  196. static struct platform_device scif0_device = {
  197. .name = "sh-sci",
  198. .id = 0,
  199. .dev = {
  200. .platform_data = &scif0_platform_data,
  201. },
  202. };
  203. /* SCIFA1 */
  204. static struct plat_sci_port scif1_platform_data = {
  205. .mapbase = 0xe6c50000,
  206. .flags = UPF_BOOT_AUTOCONF,
  207. .scscr = SCSCR_RE | SCSCR_TE,
  208. .scbrr_algo_id = SCBRR_ALGO_4,
  209. .type = PORT_SCIFA,
  210. .irqs = SCIx_IRQ_MUXED(gic_spi(101)),
  211. };
  212. static struct platform_device scif1_device = {
  213. .name = "sh-sci",
  214. .id = 1,
  215. .dev = {
  216. .platform_data = &scif1_platform_data,
  217. },
  218. };
  219. /* SCIFA2 */
  220. static struct plat_sci_port scif2_platform_data = {
  221. .mapbase = 0xe6c60000,
  222. .flags = UPF_BOOT_AUTOCONF,
  223. .scscr = SCSCR_RE | SCSCR_TE,
  224. .scbrr_algo_id = SCBRR_ALGO_4,
  225. .type = PORT_SCIFA,
  226. .irqs = SCIx_IRQ_MUXED(gic_spi(102)),
  227. };
  228. static struct platform_device scif2_device = {
  229. .name = "sh-sci",
  230. .id = 2,
  231. .dev = {
  232. .platform_data = &scif2_platform_data,
  233. },
  234. };
  235. /* SCIFA3 */
  236. static struct plat_sci_port scif3_platform_data = {
  237. .mapbase = 0xe6c70000,
  238. .flags = UPF_BOOT_AUTOCONF,
  239. .scscr = SCSCR_RE | SCSCR_TE,
  240. .scbrr_algo_id = SCBRR_ALGO_4,
  241. .type = PORT_SCIFA,
  242. .irqs = SCIx_IRQ_MUXED(gic_spi(103)),
  243. };
  244. static struct platform_device scif3_device = {
  245. .name = "sh-sci",
  246. .id = 3,
  247. .dev = {
  248. .platform_data = &scif3_platform_data,
  249. },
  250. };
  251. /* SCIFA4 */
  252. static struct plat_sci_port scif4_platform_data = {
  253. .mapbase = 0xe6c80000,
  254. .flags = UPF_BOOT_AUTOCONF,
  255. .scscr = SCSCR_RE | SCSCR_TE,
  256. .scbrr_algo_id = SCBRR_ALGO_4,
  257. .type = PORT_SCIFA,
  258. .irqs = SCIx_IRQ_MUXED(gic_spi(104)),
  259. };
  260. static struct platform_device scif4_device = {
  261. .name = "sh-sci",
  262. .id = 4,
  263. .dev = {
  264. .platform_data = &scif4_platform_data,
  265. },
  266. };
  267. /* SCIFA5 */
  268. static struct plat_sci_port scif5_platform_data = {
  269. .mapbase = 0xe6cb0000,
  270. .flags = UPF_BOOT_AUTOCONF,
  271. .scscr = SCSCR_RE | SCSCR_TE,
  272. .scbrr_algo_id = SCBRR_ALGO_4,
  273. .type = PORT_SCIFA,
  274. .irqs = SCIx_IRQ_MUXED(gic_spi(105)),
  275. };
  276. static struct platform_device scif5_device = {
  277. .name = "sh-sci",
  278. .id = 5,
  279. .dev = {
  280. .platform_data = &scif5_platform_data,
  281. },
  282. };
  283. /* SCIFA6 */
  284. static struct plat_sci_port scif6_platform_data = {
  285. .mapbase = 0xe6cc0000,
  286. .flags = UPF_BOOT_AUTOCONF,
  287. .scscr = SCSCR_RE | SCSCR_TE,
  288. .scbrr_algo_id = SCBRR_ALGO_4,
  289. .type = PORT_SCIFA,
  290. .irqs = SCIx_IRQ_MUXED(gic_spi(106)),
  291. };
  292. static struct platform_device scif6_device = {
  293. .name = "sh-sci",
  294. .id = 6,
  295. .dev = {
  296. .platform_data = &scif6_platform_data,
  297. },
  298. };
  299. /* SCIFA7 */
  300. static struct plat_sci_port scif7_platform_data = {
  301. .mapbase = 0xe6cd0000,
  302. .flags = UPF_BOOT_AUTOCONF,
  303. .scscr = SCSCR_RE | SCSCR_TE,
  304. .scbrr_algo_id = SCBRR_ALGO_4,
  305. .type = PORT_SCIFA,
  306. .irqs = SCIx_IRQ_MUXED(gic_spi(107)),
  307. };
  308. static struct platform_device scif7_device = {
  309. .name = "sh-sci",
  310. .id = 7,
  311. .dev = {
  312. .platform_data = &scif7_platform_data,
  313. },
  314. };
  315. /* SCIFB */
  316. static struct plat_sci_port scifb_platform_data = {
  317. .mapbase = 0xe6c30000,
  318. .flags = UPF_BOOT_AUTOCONF,
  319. .scscr = SCSCR_RE | SCSCR_TE,
  320. .scbrr_algo_id = SCBRR_ALGO_4,
  321. .type = PORT_SCIFB,
  322. .irqs = SCIx_IRQ_MUXED(gic_spi(108)),
  323. };
  324. static struct platform_device scifb_device = {
  325. .name = "sh-sci",
  326. .id = 8,
  327. .dev = {
  328. .platform_data = &scifb_platform_data,
  329. },
  330. };
  331. /* CMT */
  332. static struct sh_timer_config cmt10_platform_data = {
  333. .name = "CMT10",
  334. .channel_offset = 0x10,
  335. .timer_bit = 0,
  336. .clockevent_rating = 125,
  337. .clocksource_rating = 125,
  338. };
  339. static struct resource cmt10_resources[] = {
  340. [0] = {
  341. .name = "CMT10",
  342. .start = 0xe6138010,
  343. .end = 0xe613801b,
  344. .flags = IORESOURCE_MEM,
  345. },
  346. [1] = {
  347. .start = gic_spi(58),
  348. .flags = IORESOURCE_IRQ,
  349. },
  350. };
  351. static struct platform_device cmt10_device = {
  352. .name = "sh_cmt",
  353. .id = 10,
  354. .dev = {
  355. .platform_data = &cmt10_platform_data,
  356. },
  357. .resource = cmt10_resources,
  358. .num_resources = ARRAY_SIZE(cmt10_resources),
  359. };
  360. /* TMU */
  361. static struct sh_timer_config tmu00_platform_data = {
  362. .name = "TMU00",
  363. .channel_offset = 0x4,
  364. .timer_bit = 0,
  365. .clockevent_rating = 200,
  366. };
  367. static struct resource tmu00_resources[] = {
  368. [0] = {
  369. .name = "TMU00",
  370. .start = 0xfff80008,
  371. .end = 0xfff80014 - 1,
  372. .flags = IORESOURCE_MEM,
  373. },
  374. [1] = {
  375. .start = gic_spi(198),
  376. .flags = IORESOURCE_IRQ,
  377. },
  378. };
  379. static struct platform_device tmu00_device = {
  380. .name = "sh_tmu",
  381. .id = 0,
  382. .dev = {
  383. .platform_data = &tmu00_platform_data,
  384. },
  385. .resource = tmu00_resources,
  386. .num_resources = ARRAY_SIZE(tmu00_resources),
  387. };
  388. static struct sh_timer_config tmu01_platform_data = {
  389. .name = "TMU01",
  390. .channel_offset = 0x10,
  391. .timer_bit = 1,
  392. .clocksource_rating = 200,
  393. };
  394. static struct resource tmu01_resources[] = {
  395. [0] = {
  396. .name = "TMU01",
  397. .start = 0xfff80014,
  398. .end = 0xfff80020 - 1,
  399. .flags = IORESOURCE_MEM,
  400. },
  401. [1] = {
  402. .start = gic_spi(199),
  403. .flags = IORESOURCE_IRQ,
  404. },
  405. };
  406. static struct platform_device tmu01_device = {
  407. .name = "sh_tmu",
  408. .id = 1,
  409. .dev = {
  410. .platform_data = &tmu01_platform_data,
  411. },
  412. .resource = tmu01_resources,
  413. .num_resources = ARRAY_SIZE(tmu01_resources),
  414. };
  415. static struct sh_timer_config tmu02_platform_data = {
  416. .name = "TMU02",
  417. .channel_offset = 0x1C,
  418. .timer_bit = 2,
  419. .clocksource_rating = 200,
  420. };
  421. static struct resource tmu02_resources[] = {
  422. [0] = {
  423. .name = "TMU02",
  424. .start = 0xfff80020,
  425. .end = 0xfff8002C - 1,
  426. .flags = IORESOURCE_MEM,
  427. },
  428. [1] = {
  429. .start = gic_spi(200),
  430. .flags = IORESOURCE_IRQ,
  431. },
  432. };
  433. static struct platform_device tmu02_device = {
  434. .name = "sh_tmu",
  435. .id = 2,
  436. .dev = {
  437. .platform_data = &tmu02_platform_data,
  438. },
  439. .resource = tmu02_resources,
  440. .num_resources = ARRAY_SIZE(tmu02_resources),
  441. };
  442. /* IPMMUI (an IPMMU module for ICB/LMB) */
  443. static struct resource ipmmu_resources[] = {
  444. [0] = {
  445. .name = "IPMMUI",
  446. .start = 0xfe951000,
  447. .end = 0xfe9510ff,
  448. .flags = IORESOURCE_MEM,
  449. },
  450. };
  451. static const char * const ipmmu_dev_names[] = {
  452. "sh_mobile_lcdc_fb.0",
  453. "sh_mobile_lcdc_fb.1",
  454. "sh_mobile_ceu.0",
  455. };
  456. static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
  457. .dev_names = ipmmu_dev_names,
  458. .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
  459. };
  460. static struct platform_device ipmmu_device = {
  461. .name = "ipmmu",
  462. .id = -1,
  463. .dev = {
  464. .platform_data = &ipmmu_platform_data,
  465. },
  466. .resource = ipmmu_resources,
  467. .num_resources = ARRAY_SIZE(ipmmu_resources),
  468. };
  469. static struct platform_device *r8a7740_devices_dt[] __initdata = {
  470. &scif0_device,
  471. &scif1_device,
  472. &scif2_device,
  473. &scif3_device,
  474. &scif4_device,
  475. &scif5_device,
  476. &scif6_device,
  477. &scif7_device,
  478. &scifb_device,
  479. &cmt10_device,
  480. };
  481. static struct platform_device *r8a7740_early_devices[] __initdata = {
  482. &irqpin0_device,
  483. &irqpin1_device,
  484. &irqpin2_device,
  485. &irqpin3_device,
  486. &tmu00_device,
  487. &tmu01_device,
  488. &tmu02_device,
  489. &ipmmu_device,
  490. };
  491. /* DMA */
  492. static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = {
  493. {
  494. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  495. .addr = 0xe6850030,
  496. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  497. .mid_rid = 0xc1,
  498. }, {
  499. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  500. .addr = 0xe6850030,
  501. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  502. .mid_rid = 0xc2,
  503. }, {
  504. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  505. .addr = 0xe6860030,
  506. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  507. .mid_rid = 0xc9,
  508. }, {
  509. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  510. .addr = 0xe6860030,
  511. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  512. .mid_rid = 0xca,
  513. }, {
  514. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  515. .addr = 0xe6870030,
  516. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  517. .mid_rid = 0xcd,
  518. }, {
  519. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  520. .addr = 0xe6870030,
  521. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  522. .mid_rid = 0xce,
  523. }, {
  524. .slave_id = SHDMA_SLAVE_FSIA_TX,
  525. .addr = 0xfe1f0024,
  526. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  527. .mid_rid = 0xb1,
  528. }, {
  529. .slave_id = SHDMA_SLAVE_FSIA_RX,
  530. .addr = 0xfe1f0020,
  531. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  532. .mid_rid = 0xb2,
  533. }, {
  534. .slave_id = SHDMA_SLAVE_FSIB_TX,
  535. .addr = 0xfe1f0064,
  536. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  537. .mid_rid = 0xb5,
  538. }, {
  539. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  540. .addr = 0xe6bd0034,
  541. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  542. .mid_rid = 0xd1,
  543. }, {
  544. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  545. .addr = 0xe6bd0034,
  546. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  547. .mid_rid = 0xd2,
  548. },
  549. };
  550. #define DMA_CHANNEL(a, b, c) \
  551. { \
  552. .offset = a, \
  553. .dmars = b, \
  554. .dmars_bit = c, \
  555. .chclr_offset = (0x220 - 0x20) + a \
  556. }
  557. static const struct sh_dmae_channel r8a7740_dmae_channels[] = {
  558. DMA_CHANNEL(0x00, 0, 0),
  559. DMA_CHANNEL(0x10, 0, 8),
  560. DMA_CHANNEL(0x20, 4, 0),
  561. DMA_CHANNEL(0x30, 4, 8),
  562. DMA_CHANNEL(0x50, 8, 0),
  563. DMA_CHANNEL(0x60, 8, 8),
  564. };
  565. static struct sh_dmae_pdata dma_platform_data = {
  566. .slave = r8a7740_dmae_slaves,
  567. .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves),
  568. .channel = r8a7740_dmae_channels,
  569. .channel_num = ARRAY_SIZE(r8a7740_dmae_channels),
  570. .ts_low_shift = TS_LOW_SHIFT,
  571. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  572. .ts_high_shift = TS_HI_SHIFT,
  573. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  574. .ts_shift = dma_ts_shift,
  575. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  576. .dmaor_init = DMAOR_DME,
  577. .chclr_present = 1,
  578. };
  579. /* Resource order important! */
  580. static struct resource r8a7740_dmae0_resources[] = {
  581. {
  582. /* Channel registers and DMAOR */
  583. .start = 0xfe008020,
  584. .end = 0xfe00828f,
  585. .flags = IORESOURCE_MEM,
  586. },
  587. {
  588. /* DMARSx */
  589. .start = 0xfe009000,
  590. .end = 0xfe00900b,
  591. .flags = IORESOURCE_MEM,
  592. },
  593. {
  594. .name = "error_irq",
  595. .start = gic_spi(34),
  596. .end = gic_spi(34),
  597. .flags = IORESOURCE_IRQ,
  598. },
  599. {
  600. /* IRQ for channels 0-5 */
  601. .start = gic_spi(28),
  602. .end = gic_spi(33),
  603. .flags = IORESOURCE_IRQ,
  604. },
  605. };
  606. /* Resource order important! */
  607. static struct resource r8a7740_dmae1_resources[] = {
  608. {
  609. /* Channel registers and DMAOR */
  610. .start = 0xfe018020,
  611. .end = 0xfe01828f,
  612. .flags = IORESOURCE_MEM,
  613. },
  614. {
  615. /* DMARSx */
  616. .start = 0xfe019000,
  617. .end = 0xfe01900b,
  618. .flags = IORESOURCE_MEM,
  619. },
  620. {
  621. .name = "error_irq",
  622. .start = gic_spi(41),
  623. .end = gic_spi(41),
  624. .flags = IORESOURCE_IRQ,
  625. },
  626. {
  627. /* IRQ for channels 0-5 */
  628. .start = gic_spi(35),
  629. .end = gic_spi(40),
  630. .flags = IORESOURCE_IRQ,
  631. },
  632. };
  633. /* Resource order important! */
  634. static struct resource r8a7740_dmae2_resources[] = {
  635. {
  636. /* Channel registers and DMAOR */
  637. .start = 0xfe028020,
  638. .end = 0xfe02828f,
  639. .flags = IORESOURCE_MEM,
  640. },
  641. {
  642. /* DMARSx */
  643. .start = 0xfe029000,
  644. .end = 0xfe02900b,
  645. .flags = IORESOURCE_MEM,
  646. },
  647. {
  648. .name = "error_irq",
  649. .start = gic_spi(48),
  650. .end = gic_spi(48),
  651. .flags = IORESOURCE_IRQ,
  652. },
  653. {
  654. /* IRQ for channels 0-5 */
  655. .start = gic_spi(42),
  656. .end = gic_spi(47),
  657. .flags = IORESOURCE_IRQ,
  658. },
  659. };
  660. static struct platform_device dma0_device = {
  661. .name = "sh-dma-engine",
  662. .id = 0,
  663. .resource = r8a7740_dmae0_resources,
  664. .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources),
  665. .dev = {
  666. .platform_data = &dma_platform_data,
  667. },
  668. };
  669. static struct platform_device dma1_device = {
  670. .name = "sh-dma-engine",
  671. .id = 1,
  672. .resource = r8a7740_dmae1_resources,
  673. .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources),
  674. .dev = {
  675. .platform_data = &dma_platform_data,
  676. },
  677. };
  678. static struct platform_device dma2_device = {
  679. .name = "sh-dma-engine",
  680. .id = 2,
  681. .resource = r8a7740_dmae2_resources,
  682. .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources),
  683. .dev = {
  684. .platform_data = &dma_platform_data,
  685. },
  686. };
  687. /* USB-DMAC */
  688. static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = {
  689. {
  690. .offset = 0,
  691. }, {
  692. .offset = 0x20,
  693. },
  694. };
  695. static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = {
  696. {
  697. .slave_id = SHDMA_SLAVE_USBHS_TX,
  698. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  699. }, {
  700. .slave_id = SHDMA_SLAVE_USBHS_RX,
  701. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  702. },
  703. };
  704. static struct sh_dmae_pdata usb_dma_platform_data = {
  705. .slave = r8a7740_usb_dma_slaves,
  706. .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves),
  707. .channel = r8a7740_usb_dma_channels,
  708. .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels),
  709. .ts_low_shift = USBTS_LOW_SHIFT,
  710. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  711. .ts_high_shift = USBTS_HI_SHIFT,
  712. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  713. .ts_shift = dma_usbts_shift,
  714. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  715. .dmaor_init = DMAOR_DME,
  716. .chcr_offset = 0x14,
  717. .chcr_ie_bit = 1 << 5,
  718. .dmaor_is_32bit = 1,
  719. .needs_tend_set = 1,
  720. .no_dmars = 1,
  721. .slave_only = 1,
  722. };
  723. static struct resource r8a7740_usb_dma_resources[] = {
  724. {
  725. /* Channel registers and DMAOR */
  726. .start = 0xe68a0020,
  727. .end = 0xe68a0064 - 1,
  728. .flags = IORESOURCE_MEM,
  729. },
  730. {
  731. /* VCR/SWR/DMICR */
  732. .start = 0xe68a0000,
  733. .end = 0xe68a0014 - 1,
  734. .flags = IORESOURCE_MEM,
  735. },
  736. {
  737. /* IRQ for channels */
  738. .start = gic_spi(49),
  739. .end = gic_spi(49),
  740. .flags = IORESOURCE_IRQ,
  741. },
  742. };
  743. static struct platform_device usb_dma_device = {
  744. .name = "sh-dma-engine",
  745. .id = 3,
  746. .resource = r8a7740_usb_dma_resources,
  747. .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources),
  748. .dev = {
  749. .platform_data = &usb_dma_platform_data,
  750. },
  751. };
  752. /* I2C */
  753. static struct resource i2c0_resources[] = {
  754. [0] = {
  755. .name = "IIC0",
  756. .start = 0xfff20000,
  757. .end = 0xfff20425 - 1,
  758. .flags = IORESOURCE_MEM,
  759. },
  760. [1] = {
  761. .start = gic_spi(201),
  762. .end = gic_spi(204),
  763. .flags = IORESOURCE_IRQ,
  764. },
  765. };
  766. static struct resource i2c1_resources[] = {
  767. [0] = {
  768. .name = "IIC1",
  769. .start = 0xe6c20000,
  770. .end = 0xe6c20425 - 1,
  771. .flags = IORESOURCE_MEM,
  772. },
  773. [1] = {
  774. .start = gic_spi(70), /* IIC1_ALI1 */
  775. .end = gic_spi(73), /* IIC1_DTEI1 */
  776. .flags = IORESOURCE_IRQ,
  777. },
  778. };
  779. static struct platform_device i2c0_device = {
  780. .name = "i2c-sh_mobile",
  781. .id = 0,
  782. .resource = i2c0_resources,
  783. .num_resources = ARRAY_SIZE(i2c0_resources),
  784. };
  785. static struct platform_device i2c1_device = {
  786. .name = "i2c-sh_mobile",
  787. .id = 1,
  788. .resource = i2c1_resources,
  789. .num_resources = ARRAY_SIZE(i2c1_resources),
  790. };
  791. static struct resource pmu_resources[] = {
  792. [0] = {
  793. .start = gic_spi(83),
  794. .end = gic_spi(83),
  795. .flags = IORESOURCE_IRQ,
  796. },
  797. };
  798. static struct platform_device pmu_device = {
  799. .name = "arm-pmu",
  800. .id = -1,
  801. .num_resources = ARRAY_SIZE(pmu_resources),
  802. .resource = pmu_resources,
  803. };
  804. static struct platform_device *r8a7740_late_devices[] __initdata = {
  805. &i2c0_device,
  806. &i2c1_device,
  807. &dma0_device,
  808. &dma1_device,
  809. &dma2_device,
  810. &usb_dma_device,
  811. &pmu_device,
  812. };
  813. /*
  814. * r8a7740 chip has lasting errata on MERAM buffer.
  815. * this is work-around for it.
  816. * see
  817. * "Media RAM (MERAM)" on r8a7740 documentation
  818. */
  819. #define MEBUFCNTR 0xFE950098
  820. void r8a7740_meram_workaround(void)
  821. {
  822. void __iomem *reg;
  823. reg = ioremap_nocache(MEBUFCNTR, 4);
  824. if (reg) {
  825. iowrite32(0x01600164, reg);
  826. iounmap(reg);
  827. }
  828. }
  829. #define ICCR 0x0004
  830. #define ICSTART 0x0070
  831. #define i2c_read(reg, offset) ioread8(reg + offset)
  832. #define i2c_write(reg, offset, data) iowrite8(data, reg + offset)
  833. /*
  834. * r8a7740 chip has lasting errata on I2C I/O pad reset.
  835. * this is work-around for it.
  836. */
  837. static void r8a7740_i2c_workaround(struct platform_device *pdev)
  838. {
  839. struct resource *res;
  840. void __iomem *reg;
  841. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  842. if (unlikely(!res)) {
  843. pr_err("r8a7740 i2c workaround fail (cannot find resource)\n");
  844. return;
  845. }
  846. reg = ioremap(res->start, resource_size(res));
  847. if (unlikely(!reg)) {
  848. pr_err("r8a7740 i2c workaround fail (cannot map IO)\n");
  849. return;
  850. }
  851. i2c_write(reg, ICCR, i2c_read(reg, ICCR) | 0x80);
  852. i2c_read(reg, ICCR); /* dummy read */
  853. i2c_write(reg, ICSTART, i2c_read(reg, ICSTART) | 0x10);
  854. i2c_read(reg, ICSTART); /* dummy read */
  855. udelay(10);
  856. i2c_write(reg, ICCR, 0x01);
  857. i2c_write(reg, ICSTART, 0x00);
  858. udelay(10);
  859. i2c_write(reg, ICCR, 0x10);
  860. udelay(10);
  861. i2c_write(reg, ICCR, 0x00);
  862. udelay(10);
  863. i2c_write(reg, ICCR, 0x10);
  864. udelay(10);
  865. iounmap(reg);
  866. }
  867. void __init r8a7740_add_standard_devices(void)
  868. {
  869. /* I2C work-around */
  870. r8a7740_i2c_workaround(&i2c0_device);
  871. r8a7740_i2c_workaround(&i2c1_device);
  872. r8a7740_init_pm_domains();
  873. /* add devices */
  874. platform_add_devices(r8a7740_early_devices,
  875. ARRAY_SIZE(r8a7740_early_devices));
  876. platform_add_devices(r8a7740_devices_dt,
  877. ARRAY_SIZE(r8a7740_devices_dt));
  878. platform_add_devices(r8a7740_late_devices,
  879. ARRAY_SIZE(r8a7740_late_devices));
  880. /* add devices to PM domain */
  881. rmobile_add_device_to_domain("A3SP", &scif0_device);
  882. rmobile_add_device_to_domain("A3SP", &scif1_device);
  883. rmobile_add_device_to_domain("A3SP", &scif2_device);
  884. rmobile_add_device_to_domain("A3SP", &scif3_device);
  885. rmobile_add_device_to_domain("A3SP", &scif4_device);
  886. rmobile_add_device_to_domain("A3SP", &scif5_device);
  887. rmobile_add_device_to_domain("A3SP", &scif6_device);
  888. rmobile_add_device_to_domain("A3SP", &scif7_device);
  889. rmobile_add_device_to_domain("A3SP", &scifb_device);
  890. rmobile_add_device_to_domain("A3SP", &i2c1_device);
  891. }
  892. void __init r8a7740_add_early_devices(void)
  893. {
  894. early_platform_add_devices(r8a7740_early_devices,
  895. ARRAY_SIZE(r8a7740_early_devices));
  896. early_platform_add_devices(r8a7740_devices_dt,
  897. ARRAY_SIZE(r8a7740_devices_dt));
  898. /* setup early console here as well */
  899. shmobile_setup_console();
  900. }
  901. #ifdef CONFIG_USE_OF
  902. void __init r8a7740_add_early_devices_dt(void)
  903. {
  904. shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
  905. early_platform_add_devices(r8a7740_early_devices,
  906. ARRAY_SIZE(r8a7740_early_devices));
  907. /* setup early console here as well */
  908. shmobile_setup_console();
  909. }
  910. void __init r8a7740_add_standard_devices_dt(void)
  911. {
  912. platform_add_devices(r8a7740_devices_dt,
  913. ARRAY_SIZE(r8a7740_devices_dt));
  914. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  915. }
  916. void __init r8a7740_init_delay(void)
  917. {
  918. shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
  919. };
  920. static void __init r8a7740_generic_init(void)
  921. {
  922. r8a7740_clock_init(0);
  923. r8a7740_add_standard_devices_dt();
  924. }
  925. static const char *r8a7740_boards_compat_dt[] __initdata = {
  926. "renesas,r8a7740",
  927. NULL,
  928. };
  929. DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
  930. .map_io = r8a7740_map_io,
  931. .init_early = r8a7740_init_delay,
  932. .init_irq = r8a7740_init_irq_of,
  933. .init_machine = r8a7740_generic_init,
  934. .init_time = shmobile_timer_init,
  935. .dt_compat = r8a7740_boards_compat_dt,
  936. MACHINE_END
  937. #endif /* CONFIG_USE_OF */