setup-r8a7740.c 24 KB

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