setup-r8a7740.c 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  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_devices_dt[] __initdata = {
  483. &scif0_device,
  484. &scif1_device,
  485. &scif2_device,
  486. &scif3_device,
  487. &scif4_device,
  488. &scif5_device,
  489. &scif6_device,
  490. &scif7_device,
  491. &scifb_device,
  492. &cmt10_device,
  493. };
  494. static struct platform_device *r8a7740_early_devices[] __initdata = {
  495. &irqpin0_device,
  496. &irqpin1_device,
  497. &irqpin2_device,
  498. &irqpin3_device,
  499. &tmu00_device,
  500. &tmu01_device,
  501. &tmu02_device,
  502. &ipmmu_device,
  503. };
  504. /* DMA */
  505. static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = {
  506. {
  507. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  508. .addr = 0xe6850030,
  509. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  510. .mid_rid = 0xc1,
  511. }, {
  512. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  513. .addr = 0xe6850030,
  514. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  515. .mid_rid = 0xc2,
  516. }, {
  517. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  518. .addr = 0xe6860030,
  519. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  520. .mid_rid = 0xc9,
  521. }, {
  522. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  523. .addr = 0xe6860030,
  524. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  525. .mid_rid = 0xca,
  526. }, {
  527. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  528. .addr = 0xe6870030,
  529. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  530. .mid_rid = 0xcd,
  531. }, {
  532. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  533. .addr = 0xe6870030,
  534. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  535. .mid_rid = 0xce,
  536. }, {
  537. .slave_id = SHDMA_SLAVE_FSIA_TX,
  538. .addr = 0xfe1f0024,
  539. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  540. .mid_rid = 0xb1,
  541. }, {
  542. .slave_id = SHDMA_SLAVE_FSIA_RX,
  543. .addr = 0xfe1f0020,
  544. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  545. .mid_rid = 0xb2,
  546. }, {
  547. .slave_id = SHDMA_SLAVE_FSIB_TX,
  548. .addr = 0xfe1f0064,
  549. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  550. .mid_rid = 0xb5,
  551. },
  552. };
  553. #define DMA_CHANNEL(a, b, c) \
  554. { \
  555. .offset = a, \
  556. .dmars = b, \
  557. .dmars_bit = c, \
  558. .chclr_offset = (0x220 - 0x20) + a \
  559. }
  560. static const struct sh_dmae_channel r8a7740_dmae_channels[] = {
  561. DMA_CHANNEL(0x00, 0, 0),
  562. DMA_CHANNEL(0x10, 0, 8),
  563. DMA_CHANNEL(0x20, 4, 0),
  564. DMA_CHANNEL(0x30, 4, 8),
  565. DMA_CHANNEL(0x50, 8, 0),
  566. DMA_CHANNEL(0x60, 8, 8),
  567. };
  568. static struct sh_dmae_pdata dma_platform_data = {
  569. .slave = r8a7740_dmae_slaves,
  570. .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves),
  571. .channel = r8a7740_dmae_channels,
  572. .channel_num = ARRAY_SIZE(r8a7740_dmae_channels),
  573. .ts_low_shift = TS_LOW_SHIFT,
  574. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  575. .ts_high_shift = TS_HI_SHIFT,
  576. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  577. .ts_shift = dma_ts_shift,
  578. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  579. .dmaor_init = DMAOR_DME,
  580. .chclr_present = 1,
  581. };
  582. /* Resource order important! */
  583. static struct resource r8a7740_dmae0_resources[] = {
  584. {
  585. /* Channel registers and DMAOR */
  586. .start = 0xfe008020,
  587. .end = 0xfe00828f,
  588. .flags = IORESOURCE_MEM,
  589. },
  590. {
  591. /* DMARSx */
  592. .start = 0xfe009000,
  593. .end = 0xfe00900b,
  594. .flags = IORESOURCE_MEM,
  595. },
  596. {
  597. .name = "error_irq",
  598. .start = gic_spi(34),
  599. .end = gic_spi(34),
  600. .flags = IORESOURCE_IRQ,
  601. },
  602. {
  603. /* IRQ for channels 0-5 */
  604. .start = gic_spi(28),
  605. .end = gic_spi(33),
  606. .flags = IORESOURCE_IRQ,
  607. },
  608. };
  609. /* Resource order important! */
  610. static struct resource r8a7740_dmae1_resources[] = {
  611. {
  612. /* Channel registers and DMAOR */
  613. .start = 0xfe018020,
  614. .end = 0xfe01828f,
  615. .flags = IORESOURCE_MEM,
  616. },
  617. {
  618. /* DMARSx */
  619. .start = 0xfe019000,
  620. .end = 0xfe01900b,
  621. .flags = IORESOURCE_MEM,
  622. },
  623. {
  624. .name = "error_irq",
  625. .start = gic_spi(41),
  626. .end = gic_spi(41),
  627. .flags = IORESOURCE_IRQ,
  628. },
  629. {
  630. /* IRQ for channels 0-5 */
  631. .start = gic_spi(35),
  632. .end = gic_spi(40),
  633. .flags = IORESOURCE_IRQ,
  634. },
  635. };
  636. /* Resource order important! */
  637. static struct resource r8a7740_dmae2_resources[] = {
  638. {
  639. /* Channel registers and DMAOR */
  640. .start = 0xfe028020,
  641. .end = 0xfe02828f,
  642. .flags = IORESOURCE_MEM,
  643. },
  644. {
  645. /* DMARSx */
  646. .start = 0xfe029000,
  647. .end = 0xfe02900b,
  648. .flags = IORESOURCE_MEM,
  649. },
  650. {
  651. .name = "error_irq",
  652. .start = gic_spi(48),
  653. .end = gic_spi(48),
  654. .flags = IORESOURCE_IRQ,
  655. },
  656. {
  657. /* IRQ for channels 0-5 */
  658. .start = gic_spi(42),
  659. .end = gic_spi(47),
  660. .flags = IORESOURCE_IRQ,
  661. },
  662. };
  663. static struct platform_device dma0_device = {
  664. .name = "sh-dma-engine",
  665. .id = 0,
  666. .resource = r8a7740_dmae0_resources,
  667. .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources),
  668. .dev = {
  669. .platform_data = &dma_platform_data,
  670. },
  671. };
  672. static struct platform_device dma1_device = {
  673. .name = "sh-dma-engine",
  674. .id = 1,
  675. .resource = r8a7740_dmae1_resources,
  676. .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources),
  677. .dev = {
  678. .platform_data = &dma_platform_data,
  679. },
  680. };
  681. static struct platform_device dma2_device = {
  682. .name = "sh-dma-engine",
  683. .id = 2,
  684. .resource = r8a7740_dmae2_resources,
  685. .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources),
  686. .dev = {
  687. .platform_data = &dma_platform_data,
  688. },
  689. };
  690. /* USB-DMAC */
  691. static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = {
  692. {
  693. .offset = 0,
  694. }, {
  695. .offset = 0x20,
  696. },
  697. };
  698. static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = {
  699. {
  700. .slave_id = SHDMA_SLAVE_USBHS_TX,
  701. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  702. }, {
  703. .slave_id = SHDMA_SLAVE_USBHS_RX,
  704. .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
  705. },
  706. };
  707. static struct sh_dmae_pdata usb_dma_platform_data = {
  708. .slave = r8a7740_usb_dma_slaves,
  709. .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves),
  710. .channel = r8a7740_usb_dma_channels,
  711. .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels),
  712. .ts_low_shift = USBTS_LOW_SHIFT,
  713. .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
  714. .ts_high_shift = USBTS_HI_SHIFT,
  715. .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
  716. .ts_shift = dma_usbts_shift,
  717. .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
  718. .dmaor_init = DMAOR_DME,
  719. .chcr_offset = 0x14,
  720. .chcr_ie_bit = 1 << 5,
  721. .dmaor_is_32bit = 1,
  722. .needs_tend_set = 1,
  723. .no_dmars = 1,
  724. .slave_only = 1,
  725. };
  726. static struct resource r8a7740_usb_dma_resources[] = {
  727. {
  728. /* Channel registers and DMAOR */
  729. .start = 0xe68a0020,
  730. .end = 0xe68a0064 - 1,
  731. .flags = IORESOURCE_MEM,
  732. },
  733. {
  734. /* VCR/SWR/DMICR */
  735. .start = 0xe68a0000,
  736. .end = 0xe68a0014 - 1,
  737. .flags = IORESOURCE_MEM,
  738. },
  739. {
  740. /* IRQ for channels */
  741. .start = gic_spi(49),
  742. .end = gic_spi(49),
  743. .flags = IORESOURCE_IRQ,
  744. },
  745. };
  746. static struct platform_device usb_dma_device = {
  747. .name = "sh-dma-engine",
  748. .id = 3,
  749. .resource = r8a7740_usb_dma_resources,
  750. .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources),
  751. .dev = {
  752. .platform_data = &usb_dma_platform_data,
  753. },
  754. };
  755. /* I2C */
  756. static struct resource i2c0_resources[] = {
  757. [0] = {
  758. .name = "IIC0",
  759. .start = 0xfff20000,
  760. .end = 0xfff20425 - 1,
  761. .flags = IORESOURCE_MEM,
  762. },
  763. [1] = {
  764. .start = gic_spi(201),
  765. .end = gic_spi(204),
  766. .flags = IORESOURCE_IRQ,
  767. },
  768. };
  769. static struct resource i2c1_resources[] = {
  770. [0] = {
  771. .name = "IIC1",
  772. .start = 0xe6c20000,
  773. .end = 0xe6c20425 - 1,
  774. .flags = IORESOURCE_MEM,
  775. },
  776. [1] = {
  777. .start = gic_spi(70), /* IIC1_ALI1 */
  778. .end = gic_spi(73), /* IIC1_DTEI1 */
  779. .flags = IORESOURCE_IRQ,
  780. },
  781. };
  782. static struct platform_device i2c0_device = {
  783. .name = "i2c-sh_mobile",
  784. .id = 0,
  785. .resource = i2c0_resources,
  786. .num_resources = ARRAY_SIZE(i2c0_resources),
  787. };
  788. static struct platform_device i2c1_device = {
  789. .name = "i2c-sh_mobile",
  790. .id = 1,
  791. .resource = i2c1_resources,
  792. .num_resources = ARRAY_SIZE(i2c1_resources),
  793. };
  794. static struct resource pmu_resources[] = {
  795. [0] = {
  796. .start = gic_spi(83),
  797. .end = gic_spi(83),
  798. .flags = IORESOURCE_IRQ,
  799. },
  800. };
  801. static struct platform_device pmu_device = {
  802. .name = "arm-pmu",
  803. .id = -1,
  804. .num_resources = ARRAY_SIZE(pmu_resources),
  805. .resource = pmu_resources,
  806. };
  807. static struct platform_device *r8a7740_late_devices[] __initdata = {
  808. &i2c0_device,
  809. &i2c1_device,
  810. &dma0_device,
  811. &dma1_device,
  812. &dma2_device,
  813. &usb_dma_device,
  814. &pmu_device,
  815. };
  816. /*
  817. * r8a7740 chip has lasting errata on MERAM buffer.
  818. * this is work-around for it.
  819. * see
  820. * "Media RAM (MERAM)" on r8a7740 documentation
  821. */
  822. #define MEBUFCNTR 0xFE950098
  823. void r8a7740_meram_workaround(void)
  824. {
  825. void __iomem *reg;
  826. reg = ioremap_nocache(MEBUFCNTR, 4);
  827. if (reg) {
  828. iowrite32(0x01600164, reg);
  829. iounmap(reg);
  830. }
  831. }
  832. #define ICCR 0x0004
  833. #define ICSTART 0x0070
  834. #define i2c_read(reg, offset) ioread8(reg + offset)
  835. #define i2c_write(reg, offset, data) iowrite8(data, reg + offset)
  836. /*
  837. * r8a7740 chip has lasting errata on I2C I/O pad reset.
  838. * this is work-around for it.
  839. */
  840. static void r8a7740_i2c_workaround(struct platform_device *pdev)
  841. {
  842. struct resource *res;
  843. void __iomem *reg;
  844. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  845. if (unlikely(!res)) {
  846. pr_err("r8a7740 i2c workaround fail (cannot find resource)\n");
  847. return;
  848. }
  849. reg = ioremap(res->start, resource_size(res));
  850. if (unlikely(!reg)) {
  851. pr_err("r8a7740 i2c workaround fail (cannot map IO)\n");
  852. return;
  853. }
  854. i2c_write(reg, ICCR, i2c_read(reg, ICCR) | 0x80);
  855. i2c_read(reg, ICCR); /* dummy read */
  856. i2c_write(reg, ICSTART, i2c_read(reg, ICSTART) | 0x10);
  857. i2c_read(reg, ICSTART); /* dummy read */
  858. udelay(10);
  859. i2c_write(reg, ICCR, 0x01);
  860. i2c_write(reg, ICSTART, 0x00);
  861. udelay(10);
  862. i2c_write(reg, ICCR, 0x10);
  863. udelay(10);
  864. i2c_write(reg, ICCR, 0x00);
  865. udelay(10);
  866. i2c_write(reg, ICCR, 0x10);
  867. udelay(10);
  868. iounmap(reg);
  869. }
  870. void __init r8a7740_add_standard_devices(void)
  871. {
  872. /* I2C work-around */
  873. r8a7740_i2c_workaround(&i2c0_device);
  874. r8a7740_i2c_workaround(&i2c1_device);
  875. r8a7740_init_pm_domains();
  876. /* add devices */
  877. platform_add_devices(r8a7740_early_devices,
  878. ARRAY_SIZE(r8a7740_early_devices));
  879. platform_add_devices(r8a7740_devices_dt,
  880. ARRAY_SIZE(r8a7740_devices_dt));
  881. platform_add_devices(r8a7740_late_devices,
  882. ARRAY_SIZE(r8a7740_late_devices));
  883. /* add devices to PM domain */
  884. rmobile_add_device_to_domain("A3SP", &scif0_device);
  885. rmobile_add_device_to_domain("A3SP", &scif1_device);
  886. rmobile_add_device_to_domain("A3SP", &scif2_device);
  887. rmobile_add_device_to_domain("A3SP", &scif3_device);
  888. rmobile_add_device_to_domain("A3SP", &scif4_device);
  889. rmobile_add_device_to_domain("A3SP", &scif5_device);
  890. rmobile_add_device_to_domain("A3SP", &scif6_device);
  891. rmobile_add_device_to_domain("A3SP", &scif7_device);
  892. rmobile_add_device_to_domain("A3SP", &scifb_device);
  893. rmobile_add_device_to_domain("A3SP", &i2c1_device);
  894. }
  895. void __init r8a7740_add_early_devices(void)
  896. {
  897. early_platform_add_devices(r8a7740_early_devices,
  898. ARRAY_SIZE(r8a7740_early_devices));
  899. early_platform_add_devices(r8a7740_devices_dt,
  900. ARRAY_SIZE(r8a7740_devices_dt));
  901. /* setup early console here as well */
  902. shmobile_setup_console();
  903. }
  904. #ifdef CONFIG_USE_OF
  905. static const struct of_dev_auxdata r8a7740_auxdata_lookup[] __initconst = {
  906. { }
  907. };
  908. void __init r8a7740_add_standard_devices_dt(void)
  909. {
  910. platform_add_devices(r8a7740_devices_dt,
  911. ARRAY_SIZE(r8a7740_devices_dt));
  912. of_platform_populate(NULL, of_default_bus_match_table,
  913. r8a7740_auxdata_lookup, NULL);
  914. }
  915. void __init r8a7740_init_delay(void)
  916. {
  917. shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
  918. };
  919. static void __init r8a7740_generic_init(void)
  920. {
  921. r8a7740_clock_init(0);
  922. r8a7740_add_standard_devices_dt();
  923. }
  924. static const char *r8a7740_boards_compat_dt[] __initdata = {
  925. "renesas,r8a7740",
  926. NULL,
  927. };
  928. DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
  929. .map_io = r8a7740_map_io,
  930. .init_early = r8a7740_init_delay,
  931. .init_irq = r8a7740_init_irq_of,
  932. .init_machine = r8a7740_generic_init,
  933. .init_time = shmobile_timer_init,
  934. .dt_compat = r8a7740_boards_compat_dt,
  935. MACHINE_END
  936. #endif /* CONFIG_USE_OF */