setup-sh73a0.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974
  1. /*
  2. * sh73a0 processor support
  3. *
  4. * Copyright (C) 2010 Takashi Yoshii
  5. * Copyright (C) 2010 Magnus Damm
  6. * Copyright (C) 2008 Yoshihiro Shimoda
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/of_platform.h>
  27. #include <linux/delay.h>
  28. #include <linux/input.h>
  29. #include <linux/io.h>
  30. #include <linux/serial_sci.h>
  31. #include <linux/sh_dma.h>
  32. #include <linux/sh_intc.h>
  33. #include <linux/sh_timer.h>
  34. #include <linux/platform_data/sh_ipmmu.h>
  35. #include <linux/platform_data/irq-renesas-intc-irqpin.h>
  36. #include <mach/dma-register.h>
  37. #include <mach/irqs.h>
  38. #include <mach/sh73a0.h>
  39. #include <mach/common.h>
  40. #include <asm/mach-types.h>
  41. #include <asm/mach/map.h>
  42. #include <asm/mach/arch.h>
  43. #include <asm/mach/time.h>
  44. static struct map_desc sh73a0_io_desc[] __initdata = {
  45. /* create a 1:1 entity map for 0xe6xxxxxx
  46. * used by CPGA, INTC and PFC.
  47. */
  48. {
  49. .virtual = 0xe6000000,
  50. .pfn = __phys_to_pfn(0xe6000000),
  51. .length = 256 << 20,
  52. .type = MT_DEVICE_NONSHARED
  53. },
  54. };
  55. void __init sh73a0_map_io(void)
  56. {
  57. iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
  58. }
  59. /* PFC */
  60. static struct resource pfc_resources[] __initdata = {
  61. DEFINE_RES_MEM(0xe6050000, 0x8000),
  62. DEFINE_RES_MEM(0xe605801c, 0x000c),
  63. };
  64. void __init sh73a0_pinmux_init(void)
  65. {
  66. platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
  67. ARRAY_SIZE(pfc_resources));
  68. }
  69. static struct plat_sci_port scif0_platform_data = {
  70. .mapbase = 0xe6c40000,
  71. .flags = UPF_BOOT_AUTOCONF,
  72. .scscr = SCSCR_RE | SCSCR_TE,
  73. .scbrr_algo_id = SCBRR_ALGO_4,
  74. .type = PORT_SCIFA,
  75. .irqs = { gic_spi(72), gic_spi(72),
  76. gic_spi(72), gic_spi(72) },
  77. };
  78. static struct platform_device scif0_device = {
  79. .name = "sh-sci",
  80. .id = 0,
  81. .dev = {
  82. .platform_data = &scif0_platform_data,
  83. },
  84. };
  85. static struct plat_sci_port scif1_platform_data = {
  86. .mapbase = 0xe6c50000,
  87. .flags = UPF_BOOT_AUTOCONF,
  88. .scscr = SCSCR_RE | SCSCR_TE,
  89. .scbrr_algo_id = SCBRR_ALGO_4,
  90. .type = PORT_SCIFA,
  91. .irqs = { gic_spi(73), gic_spi(73),
  92. gic_spi(73), gic_spi(73) },
  93. };
  94. static struct platform_device scif1_device = {
  95. .name = "sh-sci",
  96. .id = 1,
  97. .dev = {
  98. .platform_data = &scif1_platform_data,
  99. },
  100. };
  101. static struct plat_sci_port scif2_platform_data = {
  102. .mapbase = 0xe6c60000,
  103. .flags = UPF_BOOT_AUTOCONF,
  104. .scscr = SCSCR_RE | SCSCR_TE,
  105. .scbrr_algo_id = SCBRR_ALGO_4,
  106. .type = PORT_SCIFA,
  107. .irqs = { gic_spi(74), gic_spi(74),
  108. gic_spi(74), gic_spi(74) },
  109. };
  110. static struct platform_device scif2_device = {
  111. .name = "sh-sci",
  112. .id = 2,
  113. .dev = {
  114. .platform_data = &scif2_platform_data,
  115. },
  116. };
  117. static struct plat_sci_port scif3_platform_data = {
  118. .mapbase = 0xe6c70000,
  119. .flags = UPF_BOOT_AUTOCONF,
  120. .scscr = SCSCR_RE | SCSCR_TE,
  121. .scbrr_algo_id = SCBRR_ALGO_4,
  122. .type = PORT_SCIFA,
  123. .irqs = { gic_spi(75), gic_spi(75),
  124. gic_spi(75), gic_spi(75) },
  125. };
  126. static struct platform_device scif3_device = {
  127. .name = "sh-sci",
  128. .id = 3,
  129. .dev = {
  130. .platform_data = &scif3_platform_data,
  131. },
  132. };
  133. static struct plat_sci_port scif4_platform_data = {
  134. .mapbase = 0xe6c80000,
  135. .flags = UPF_BOOT_AUTOCONF,
  136. .scscr = SCSCR_RE | SCSCR_TE,
  137. .scbrr_algo_id = SCBRR_ALGO_4,
  138. .type = PORT_SCIFA,
  139. .irqs = { gic_spi(78), gic_spi(78),
  140. gic_spi(78), gic_spi(78) },
  141. };
  142. static struct platform_device scif4_device = {
  143. .name = "sh-sci",
  144. .id = 4,
  145. .dev = {
  146. .platform_data = &scif4_platform_data,
  147. },
  148. };
  149. static struct plat_sci_port scif5_platform_data = {
  150. .mapbase = 0xe6cb0000,
  151. .flags = UPF_BOOT_AUTOCONF,
  152. .scscr = SCSCR_RE | SCSCR_TE,
  153. .scbrr_algo_id = SCBRR_ALGO_4,
  154. .type = PORT_SCIFA,
  155. .irqs = { gic_spi(79), gic_spi(79),
  156. gic_spi(79), gic_spi(79) },
  157. };
  158. static struct platform_device scif5_device = {
  159. .name = "sh-sci",
  160. .id = 5,
  161. .dev = {
  162. .platform_data = &scif5_platform_data,
  163. },
  164. };
  165. static struct plat_sci_port scif6_platform_data = {
  166. .mapbase = 0xe6cc0000,
  167. .flags = UPF_BOOT_AUTOCONF,
  168. .scscr = SCSCR_RE | SCSCR_TE,
  169. .scbrr_algo_id = SCBRR_ALGO_4,
  170. .type = PORT_SCIFA,
  171. .irqs = { gic_spi(156), gic_spi(156),
  172. gic_spi(156), gic_spi(156) },
  173. };
  174. static struct platform_device scif6_device = {
  175. .name = "sh-sci",
  176. .id = 6,
  177. .dev = {
  178. .platform_data = &scif6_platform_data,
  179. },
  180. };
  181. static struct plat_sci_port scif7_platform_data = {
  182. .mapbase = 0xe6cd0000,
  183. .flags = UPF_BOOT_AUTOCONF,
  184. .scscr = SCSCR_RE | SCSCR_TE,
  185. .scbrr_algo_id = SCBRR_ALGO_4,
  186. .type = PORT_SCIFA,
  187. .irqs = { gic_spi(143), gic_spi(143),
  188. gic_spi(143), gic_spi(143) },
  189. };
  190. static struct platform_device scif7_device = {
  191. .name = "sh-sci",
  192. .id = 7,
  193. .dev = {
  194. .platform_data = &scif7_platform_data,
  195. },
  196. };
  197. static struct plat_sci_port scif8_platform_data = {
  198. .mapbase = 0xe6c30000,
  199. .flags = UPF_BOOT_AUTOCONF,
  200. .scscr = SCSCR_RE | SCSCR_TE,
  201. .scbrr_algo_id = SCBRR_ALGO_4,
  202. .type = PORT_SCIFB,
  203. .irqs = { gic_spi(80), gic_spi(80),
  204. gic_spi(80), gic_spi(80) },
  205. };
  206. static struct platform_device scif8_device = {
  207. .name = "sh-sci",
  208. .id = 8,
  209. .dev = {
  210. .platform_data = &scif8_platform_data,
  211. },
  212. };
  213. static struct sh_timer_config cmt10_platform_data = {
  214. .name = "CMT10",
  215. .channel_offset = 0x10,
  216. .timer_bit = 0,
  217. .clockevent_rating = 80,
  218. .clocksource_rating = 125,
  219. };
  220. static struct resource cmt10_resources[] = {
  221. [0] = {
  222. .name = "CMT10",
  223. .start = 0xe6138010,
  224. .end = 0xe613801b,
  225. .flags = IORESOURCE_MEM,
  226. },
  227. [1] = {
  228. .start = gic_spi(65),
  229. .flags = IORESOURCE_IRQ,
  230. },
  231. };
  232. static struct platform_device cmt10_device = {
  233. .name = "sh_cmt",
  234. .id = 10,
  235. .dev = {
  236. .platform_data = &cmt10_platform_data,
  237. },
  238. .resource = cmt10_resources,
  239. .num_resources = ARRAY_SIZE(cmt10_resources),
  240. };
  241. /* TMU */
  242. static struct sh_timer_config tmu00_platform_data = {
  243. .name = "TMU00",
  244. .channel_offset = 0x4,
  245. .timer_bit = 0,
  246. .clockevent_rating = 200,
  247. };
  248. static struct resource tmu00_resources[] = {
  249. [0] = DEFINE_RES_MEM_NAMED(0xfff60008, 0xc, "TMU00"),
  250. [1] = {
  251. .start = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
  252. .flags = IORESOURCE_IRQ,
  253. },
  254. };
  255. static struct platform_device tmu00_device = {
  256. .name = "sh_tmu",
  257. .id = 0,
  258. .dev = {
  259. .platform_data = &tmu00_platform_data,
  260. },
  261. .resource = tmu00_resources,
  262. .num_resources = ARRAY_SIZE(tmu00_resources),
  263. };
  264. static struct sh_timer_config tmu01_platform_data = {
  265. .name = "TMU01",
  266. .channel_offset = 0x10,
  267. .timer_bit = 1,
  268. .clocksource_rating = 200,
  269. };
  270. static struct resource tmu01_resources[] = {
  271. [0] = DEFINE_RES_MEM_NAMED(0xfff60014, 0xc, "TMU00"),
  272. [1] = {
  273. .start = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
  274. .flags = IORESOURCE_IRQ,
  275. },
  276. };
  277. static struct platform_device tmu01_device = {
  278. .name = "sh_tmu",
  279. .id = 1,
  280. .dev = {
  281. .platform_data = &tmu01_platform_data,
  282. },
  283. .resource = tmu01_resources,
  284. .num_resources = ARRAY_SIZE(tmu01_resources),
  285. };
  286. static struct resource i2c0_resources[] = {
  287. [0] = DEFINE_RES_MEM_NAMED(0xe6820000, 0x426, "IIC0"),
  288. [1] = {
  289. .start = gic_spi(167),
  290. .end = gic_spi(170),
  291. .flags = IORESOURCE_IRQ,
  292. },
  293. };
  294. static struct resource i2c1_resources[] = {
  295. [0] = DEFINE_RES_MEM_NAMED(0xe6822000, 0x426, "IIC1"),
  296. [1] = {
  297. .start = gic_spi(51),
  298. .end = gic_spi(54),
  299. .flags = IORESOURCE_IRQ,
  300. },
  301. };
  302. static struct resource i2c2_resources[] = {
  303. [0] = DEFINE_RES_MEM_NAMED(0xe6824000, 0x426, "IIC2"),
  304. [1] = {
  305. .start = gic_spi(171),
  306. .end = gic_spi(174),
  307. .flags = IORESOURCE_IRQ,
  308. },
  309. };
  310. static struct resource i2c3_resources[] = {
  311. [0] = DEFINE_RES_MEM_NAMED(0xe6826000, 0x426, "IIC3"),
  312. [1] = {
  313. .start = gic_spi(183),
  314. .end = gic_spi(186),
  315. .flags = IORESOURCE_IRQ,
  316. },
  317. };
  318. static struct resource i2c4_resources[] = {
  319. [0] = DEFINE_RES_MEM_NAMED(0xe6828000, 0x426, "IIC4"),
  320. [1] = {
  321. .start = gic_spi(187),
  322. .end = gic_spi(190),
  323. .flags = IORESOURCE_IRQ,
  324. },
  325. };
  326. static struct platform_device i2c0_device = {
  327. .name = "i2c-sh_mobile",
  328. .id = 0,
  329. .resource = i2c0_resources,
  330. .num_resources = ARRAY_SIZE(i2c0_resources),
  331. };
  332. static struct platform_device i2c1_device = {
  333. .name = "i2c-sh_mobile",
  334. .id = 1,
  335. .resource = i2c1_resources,
  336. .num_resources = ARRAY_SIZE(i2c1_resources),
  337. };
  338. static struct platform_device i2c2_device = {
  339. .name = "i2c-sh_mobile",
  340. .id = 2,
  341. .resource = i2c2_resources,
  342. .num_resources = ARRAY_SIZE(i2c2_resources),
  343. };
  344. static struct platform_device i2c3_device = {
  345. .name = "i2c-sh_mobile",
  346. .id = 3,
  347. .resource = i2c3_resources,
  348. .num_resources = ARRAY_SIZE(i2c3_resources),
  349. };
  350. static struct platform_device i2c4_device = {
  351. .name = "i2c-sh_mobile",
  352. .id = 4,
  353. .resource = i2c4_resources,
  354. .num_resources = ARRAY_SIZE(i2c4_resources),
  355. };
  356. static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
  357. {
  358. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  359. .addr = 0xe6c40020,
  360. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  361. .mid_rid = 0x21,
  362. }, {
  363. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  364. .addr = 0xe6c40024,
  365. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  366. .mid_rid = 0x22,
  367. }, {
  368. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  369. .addr = 0xe6c50020,
  370. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  371. .mid_rid = 0x25,
  372. }, {
  373. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  374. .addr = 0xe6c50024,
  375. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  376. .mid_rid = 0x26,
  377. }, {
  378. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  379. .addr = 0xe6c60020,
  380. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  381. .mid_rid = 0x29,
  382. }, {
  383. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  384. .addr = 0xe6c60024,
  385. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  386. .mid_rid = 0x2a,
  387. }, {
  388. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  389. .addr = 0xe6c70020,
  390. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  391. .mid_rid = 0x2d,
  392. }, {
  393. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  394. .addr = 0xe6c70024,
  395. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  396. .mid_rid = 0x2e,
  397. }, {
  398. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  399. .addr = 0xe6c80020,
  400. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  401. .mid_rid = 0x39,
  402. }, {
  403. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  404. .addr = 0xe6c80024,
  405. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  406. .mid_rid = 0x3a,
  407. }, {
  408. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  409. .addr = 0xe6cb0020,
  410. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  411. .mid_rid = 0x35,
  412. }, {
  413. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  414. .addr = 0xe6cb0024,
  415. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  416. .mid_rid = 0x36,
  417. }, {
  418. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  419. .addr = 0xe6cc0020,
  420. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  421. .mid_rid = 0x1d,
  422. }, {
  423. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  424. .addr = 0xe6cc0024,
  425. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  426. .mid_rid = 0x1e,
  427. }, {
  428. .slave_id = SHDMA_SLAVE_SCIF7_TX,
  429. .addr = 0xe6cd0020,
  430. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  431. .mid_rid = 0x19,
  432. }, {
  433. .slave_id = SHDMA_SLAVE_SCIF7_RX,
  434. .addr = 0xe6cd0024,
  435. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  436. .mid_rid = 0x1a,
  437. }, {
  438. .slave_id = SHDMA_SLAVE_SCIF8_TX,
  439. .addr = 0xe6c30040,
  440. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  441. .mid_rid = 0x3d,
  442. }, {
  443. .slave_id = SHDMA_SLAVE_SCIF8_RX,
  444. .addr = 0xe6c30060,
  445. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  446. .mid_rid = 0x3e,
  447. }, {
  448. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  449. .addr = 0xee100030,
  450. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  451. .mid_rid = 0xc1,
  452. }, {
  453. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  454. .addr = 0xee100030,
  455. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  456. .mid_rid = 0xc2,
  457. }, {
  458. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  459. .addr = 0xee120030,
  460. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  461. .mid_rid = 0xc9,
  462. }, {
  463. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  464. .addr = 0xee120030,
  465. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  466. .mid_rid = 0xca,
  467. }, {
  468. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  469. .addr = 0xee140030,
  470. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  471. .mid_rid = 0xcd,
  472. }, {
  473. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  474. .addr = 0xee140030,
  475. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  476. .mid_rid = 0xce,
  477. }, {
  478. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  479. .addr = 0xe6bd0034,
  480. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  481. .mid_rid = 0xd1,
  482. }, {
  483. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  484. .addr = 0xe6bd0034,
  485. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  486. .mid_rid = 0xd2,
  487. },
  488. };
  489. #define DMAE_CHANNEL(_offset) \
  490. { \
  491. .offset = _offset - 0x20, \
  492. .dmars = _offset - 0x20 + 0x40, \
  493. }
  494. static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
  495. DMAE_CHANNEL(0x8000),
  496. DMAE_CHANNEL(0x8080),
  497. DMAE_CHANNEL(0x8100),
  498. DMAE_CHANNEL(0x8180),
  499. DMAE_CHANNEL(0x8200),
  500. DMAE_CHANNEL(0x8280),
  501. DMAE_CHANNEL(0x8300),
  502. DMAE_CHANNEL(0x8380),
  503. DMAE_CHANNEL(0x8400),
  504. DMAE_CHANNEL(0x8480),
  505. DMAE_CHANNEL(0x8500),
  506. DMAE_CHANNEL(0x8580),
  507. DMAE_CHANNEL(0x8600),
  508. DMAE_CHANNEL(0x8680),
  509. DMAE_CHANNEL(0x8700),
  510. DMAE_CHANNEL(0x8780),
  511. DMAE_CHANNEL(0x8800),
  512. DMAE_CHANNEL(0x8880),
  513. DMAE_CHANNEL(0x8900),
  514. DMAE_CHANNEL(0x8980),
  515. };
  516. static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
  517. .slave = sh73a0_dmae_slaves,
  518. .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
  519. .channel = sh73a0_dmae_channels,
  520. .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
  521. .ts_low_shift = TS_LOW_SHIFT,
  522. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  523. .ts_high_shift = TS_HI_SHIFT,
  524. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  525. .ts_shift = dma_ts_shift,
  526. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  527. .dmaor_init = DMAOR_DME,
  528. };
  529. static struct resource sh73a0_dmae_resources[] = {
  530. DEFINE_RES_MEM(0xfe000020, 0x89e0),
  531. {
  532. .name = "error_irq",
  533. .start = gic_spi(129),
  534. .end = gic_spi(129),
  535. .flags = IORESOURCE_IRQ,
  536. },
  537. {
  538. /* IRQ for channels 0-19 */
  539. .start = gic_spi(109),
  540. .end = gic_spi(128),
  541. .flags = IORESOURCE_IRQ,
  542. },
  543. };
  544. static struct platform_device dma0_device = {
  545. .name = "sh-dma-engine",
  546. .id = 0,
  547. .resource = sh73a0_dmae_resources,
  548. .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
  549. .dev = {
  550. .platform_data = &sh73a0_dmae_platform_data,
  551. },
  552. };
  553. /* MPDMAC */
  554. static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
  555. {
  556. .slave_id = SHDMA_SLAVE_FSI2A_RX,
  557. .addr = 0xec230020,
  558. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  559. .mid_rid = 0xd6, /* CHECK ME */
  560. }, {
  561. .slave_id = SHDMA_SLAVE_FSI2A_TX,
  562. .addr = 0xec230024,
  563. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  564. .mid_rid = 0xd5, /* CHECK ME */
  565. }, {
  566. .slave_id = SHDMA_SLAVE_FSI2C_RX,
  567. .addr = 0xec230060,
  568. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  569. .mid_rid = 0xda, /* CHECK ME */
  570. }, {
  571. .slave_id = SHDMA_SLAVE_FSI2C_TX,
  572. .addr = 0xec230064,
  573. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  574. .mid_rid = 0xd9, /* CHECK ME */
  575. }, {
  576. .slave_id = SHDMA_SLAVE_FSI2B_RX,
  577. .addr = 0xec240020,
  578. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  579. .mid_rid = 0x8e, /* CHECK ME */
  580. }, {
  581. .slave_id = SHDMA_SLAVE_FSI2B_TX,
  582. .addr = 0xec240024,
  583. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  584. .mid_rid = 0x8d, /* CHECK ME */
  585. }, {
  586. .slave_id = SHDMA_SLAVE_FSI2D_RX,
  587. .addr = 0xec240060,
  588. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  589. .mid_rid = 0x9a, /* CHECK ME */
  590. },
  591. };
  592. #define MPDMA_CHANNEL(a, b, c) \
  593. { \
  594. .offset = a, \
  595. .dmars = b, \
  596. .dmars_bit = c, \
  597. .chclr_offset = (0x220 - 0x20) + a \
  598. }
  599. static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
  600. MPDMA_CHANNEL(0x00, 0, 0),
  601. MPDMA_CHANNEL(0x10, 0, 8),
  602. MPDMA_CHANNEL(0x20, 4, 0),
  603. MPDMA_CHANNEL(0x30, 4, 8),
  604. MPDMA_CHANNEL(0x50, 8, 0),
  605. MPDMA_CHANNEL(0x70, 8, 8),
  606. };
  607. static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
  608. .slave = sh73a0_mpdma_slaves,
  609. .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
  610. .channel = sh73a0_mpdma_channels,
  611. .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
  612. .ts_low_shift = TS_LOW_SHIFT,
  613. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  614. .ts_high_shift = TS_HI_SHIFT,
  615. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  616. .ts_shift = dma_ts_shift,
  617. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  618. .dmaor_init = DMAOR_DME,
  619. .chclr_present = 1,
  620. };
  621. /* Resource order important! */
  622. static struct resource sh73a0_mpdma_resources[] = {
  623. /* Channel registers and DMAOR */
  624. DEFINE_RES_MEM(0xec618020, 0x270),
  625. /* DMARSx */
  626. DEFINE_RES_MEM(0xec619000, 0xc),
  627. {
  628. .name = "error_irq",
  629. .start = gic_spi(181),
  630. .end = gic_spi(181),
  631. .flags = IORESOURCE_IRQ,
  632. },
  633. {
  634. /* IRQ for channels 0-5 */
  635. .start = gic_spi(175),
  636. .end = gic_spi(180),
  637. .flags = IORESOURCE_IRQ,
  638. },
  639. };
  640. static struct platform_device mpdma0_device = {
  641. .name = "sh-dma-engine",
  642. .id = 1,
  643. .resource = sh73a0_mpdma_resources,
  644. .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
  645. .dev = {
  646. .platform_data = &sh73a0_mpdma_platform_data,
  647. },
  648. };
  649. static struct resource pmu_resources[] = {
  650. [0] = {
  651. .start = gic_spi(55),
  652. .end = gic_spi(55),
  653. .flags = IORESOURCE_IRQ,
  654. },
  655. [1] = {
  656. .start = gic_spi(56),
  657. .end = gic_spi(56),
  658. .flags = IORESOURCE_IRQ,
  659. },
  660. };
  661. static struct platform_device pmu_device = {
  662. .name = "arm-pmu",
  663. .id = -1,
  664. .num_resources = ARRAY_SIZE(pmu_resources),
  665. .resource = pmu_resources,
  666. };
  667. /* an IPMMU module for ICB */
  668. static struct resource ipmmu_resources[] = {
  669. DEFINE_RES_MEM_NAMED(0xfe951000, 0x100, "IPMMU"),
  670. };
  671. static const char * const ipmmu_dev_names[] = {
  672. "sh_mobile_lcdc_fb.0",
  673. };
  674. static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
  675. .dev_names = ipmmu_dev_names,
  676. .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
  677. };
  678. static struct platform_device ipmmu_device = {
  679. .name = "ipmmu",
  680. .id = -1,
  681. .dev = {
  682. .platform_data = &ipmmu_platform_data,
  683. },
  684. .resource = ipmmu_resources,
  685. .num_resources = ARRAY_SIZE(ipmmu_resources),
  686. };
  687. static struct renesas_intc_irqpin_config irqpin0_platform_data = {
  688. .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
  689. };
  690. static struct resource irqpin0_resources[] = {
  691. DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
  692. DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
  693. DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
  694. DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
  695. DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
  696. DEFINE_RES_IRQ(gic_spi(1)), /* IRQ0 */
  697. DEFINE_RES_IRQ(gic_spi(2)), /* IRQ1 */
  698. DEFINE_RES_IRQ(gic_spi(3)), /* IRQ2 */
  699. DEFINE_RES_IRQ(gic_spi(4)), /* IRQ3 */
  700. DEFINE_RES_IRQ(gic_spi(5)), /* IRQ4 */
  701. DEFINE_RES_IRQ(gic_spi(6)), /* IRQ5 */
  702. DEFINE_RES_IRQ(gic_spi(7)), /* IRQ6 */
  703. DEFINE_RES_IRQ(gic_spi(8)), /* IRQ7 */
  704. };
  705. static struct platform_device irqpin0_device = {
  706. .name = "renesas_intc_irqpin",
  707. .id = 0,
  708. .resource = irqpin0_resources,
  709. .num_resources = ARRAY_SIZE(irqpin0_resources),
  710. .dev = {
  711. .platform_data = &irqpin0_platform_data,
  712. },
  713. };
  714. static struct renesas_intc_irqpin_config irqpin1_platform_data = {
  715. .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
  716. .control_parent = true, /* Disable spurious IRQ10 */
  717. };
  718. static struct resource irqpin1_resources[] = {
  719. DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
  720. DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
  721. DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
  722. DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
  723. DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
  724. DEFINE_RES_IRQ(gic_spi(9)), /* IRQ8 */
  725. DEFINE_RES_IRQ(gic_spi(10)), /* IRQ9 */
  726. DEFINE_RES_IRQ(gic_spi(11)), /* IRQ10 */
  727. DEFINE_RES_IRQ(gic_spi(12)), /* IRQ11 */
  728. DEFINE_RES_IRQ(gic_spi(13)), /* IRQ12 */
  729. DEFINE_RES_IRQ(gic_spi(14)), /* IRQ13 */
  730. DEFINE_RES_IRQ(gic_spi(15)), /* IRQ14 */
  731. DEFINE_RES_IRQ(gic_spi(16)), /* IRQ15 */
  732. };
  733. static struct platform_device irqpin1_device = {
  734. .name = "renesas_intc_irqpin",
  735. .id = 1,
  736. .resource = irqpin1_resources,
  737. .num_resources = ARRAY_SIZE(irqpin1_resources),
  738. .dev = {
  739. .platform_data = &irqpin1_platform_data,
  740. },
  741. };
  742. static struct renesas_intc_irqpin_config irqpin2_platform_data = {
  743. .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
  744. };
  745. static struct resource irqpin2_resources[] = {
  746. DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
  747. DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI20A */
  748. DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ20A */
  749. DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK20A */
  750. DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR20A */
  751. DEFINE_RES_IRQ(gic_spi(17)), /* IRQ16 */
  752. DEFINE_RES_IRQ(gic_spi(18)), /* IRQ17 */
  753. DEFINE_RES_IRQ(gic_spi(19)), /* IRQ18 */
  754. DEFINE_RES_IRQ(gic_spi(20)), /* IRQ19 */
  755. DEFINE_RES_IRQ(gic_spi(21)), /* IRQ20 */
  756. DEFINE_RES_IRQ(gic_spi(22)), /* IRQ21 */
  757. DEFINE_RES_IRQ(gic_spi(23)), /* IRQ22 */
  758. DEFINE_RES_IRQ(gic_spi(24)), /* IRQ23 */
  759. };
  760. static struct platform_device irqpin2_device = {
  761. .name = "renesas_intc_irqpin",
  762. .id = 2,
  763. .resource = irqpin2_resources,
  764. .num_resources = ARRAY_SIZE(irqpin2_resources),
  765. .dev = {
  766. .platform_data = &irqpin2_platform_data,
  767. },
  768. };
  769. static struct renesas_intc_irqpin_config irqpin3_platform_data = {
  770. .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
  771. };
  772. static struct resource irqpin3_resources[] = {
  773. DEFINE_RES_MEM(0xe690000c, 4), /* ICR4A */
  774. DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
  775. DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
  776. DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
  777. DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
  778. DEFINE_RES_IRQ(gic_spi(25)), /* IRQ24 */
  779. DEFINE_RES_IRQ(gic_spi(26)), /* IRQ25 */
  780. DEFINE_RES_IRQ(gic_spi(27)), /* IRQ26 */
  781. DEFINE_RES_IRQ(gic_spi(28)), /* IRQ27 */
  782. DEFINE_RES_IRQ(gic_spi(29)), /* IRQ28 */
  783. DEFINE_RES_IRQ(gic_spi(30)), /* IRQ29 */
  784. DEFINE_RES_IRQ(gic_spi(31)), /* IRQ30 */
  785. DEFINE_RES_IRQ(gic_spi(32)), /* IRQ31 */
  786. };
  787. static struct platform_device irqpin3_device = {
  788. .name = "renesas_intc_irqpin",
  789. .id = 3,
  790. .resource = irqpin3_resources,
  791. .num_resources = ARRAY_SIZE(irqpin3_resources),
  792. .dev = {
  793. .platform_data = &irqpin3_platform_data,
  794. },
  795. };
  796. static struct platform_device *sh73a0_devices_dt[] __initdata = {
  797. &scif0_device,
  798. &scif1_device,
  799. &scif2_device,
  800. &scif3_device,
  801. &scif4_device,
  802. &scif5_device,
  803. &scif6_device,
  804. &scif7_device,
  805. &scif8_device,
  806. &cmt10_device,
  807. };
  808. static struct platform_device *sh73a0_early_devices[] __initdata = {
  809. &tmu00_device,
  810. &tmu01_device,
  811. &ipmmu_device,
  812. };
  813. static struct platform_device *sh73a0_late_devices[] __initdata = {
  814. &i2c0_device,
  815. &i2c1_device,
  816. &i2c2_device,
  817. &i2c3_device,
  818. &i2c4_device,
  819. &dma0_device,
  820. &mpdma0_device,
  821. &pmu_device,
  822. &irqpin0_device,
  823. &irqpin1_device,
  824. &irqpin2_device,
  825. &irqpin3_device,
  826. };
  827. #define SRCR2 IOMEM(0xe61580b0)
  828. void __init sh73a0_add_standard_devices(void)
  829. {
  830. /* Clear software reset bit on SY-DMAC module */
  831. __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
  832. platform_add_devices(sh73a0_devices_dt,
  833. ARRAY_SIZE(sh73a0_devices_dt));
  834. platform_add_devices(sh73a0_early_devices,
  835. ARRAY_SIZE(sh73a0_early_devices));
  836. platform_add_devices(sh73a0_late_devices,
  837. ARRAY_SIZE(sh73a0_late_devices));
  838. }
  839. void __init sh73a0_init_delay(void)
  840. {
  841. shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
  842. }
  843. /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
  844. void __init __weak sh73a0_register_twd(void) { }
  845. void __init sh73a0_earlytimer_init(void)
  846. {
  847. sh73a0_init_delay();
  848. sh73a0_clock_init();
  849. shmobile_earlytimer_init();
  850. sh73a0_register_twd();
  851. }
  852. void __init sh73a0_add_early_devices(void)
  853. {
  854. early_platform_add_devices(sh73a0_devices_dt,
  855. ARRAY_SIZE(sh73a0_devices_dt));
  856. early_platform_add_devices(sh73a0_early_devices,
  857. ARRAY_SIZE(sh73a0_early_devices));
  858. /* setup early console here as well */
  859. shmobile_setup_console();
  860. }
  861. #ifdef CONFIG_USE_OF
  862. void __init sh73a0_add_standard_devices_dt(void)
  863. {
  864. struct platform_device_info devinfo = { .name = "cpufreq-cpu0", .id = -1, };
  865. /* clocks are setup late during boot in the case of DT */
  866. sh73a0_clock_init();
  867. platform_add_devices(sh73a0_devices_dt,
  868. ARRAY_SIZE(sh73a0_devices_dt));
  869. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  870. /* Instantiate cpufreq-cpu0 */
  871. platform_device_register_full(&devinfo);
  872. }
  873. static const char *sh73a0_boards_compat_dt[] __initdata = {
  874. "renesas,sh73a0",
  875. NULL,
  876. };
  877. DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
  878. .smp = smp_ops(sh73a0_smp_ops),
  879. .map_io = sh73a0_map_io,
  880. .init_early = sh73a0_init_delay,
  881. .nr_irqs = NR_IRQS_LEGACY,
  882. .init_machine = sh73a0_add_standard_devices_dt,
  883. .dt_compat = sh73a0_boards_compat_dt,
  884. MACHINE_END
  885. #endif /* CONFIG_USE_OF */