setup-r8a7740.c 24 KB

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