setup-r8a7740.c 24 KB

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