setup-r8a7740.c 25 KB

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