setup-sh73a0.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  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. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/irq.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/of_platform.h>
  23. #include <linux/delay.h>
  24. #include <linux/input.h>
  25. #include <linux/i2c/i2c-sh_mobile.h>
  26. #include <linux/io.h>
  27. #include <linux/serial_sci.h>
  28. #include <linux/sh_dma.h>
  29. #include <linux/sh_timer.h>
  30. #include <linux/platform_data/sh_ipmmu.h>
  31. #include <linux/platform_data/irq-renesas-intc-irqpin.h>
  32. #include <asm/hardware/cache-l2x0.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/time.h>
  37. #include "common.h"
  38. #include "dma-register.h"
  39. #include "intc.h"
  40. #include "irqs.h"
  41. #include "sh73a0.h"
  42. static struct map_desc sh73a0_io_desc[] __initdata = {
  43. /* create a 1:1 identity mapping for 0xe6xxxxxx
  44. * used by CPGA, INTC and PFC.
  45. */
  46. {
  47. .virtual = 0xe6000000,
  48. .pfn = __phys_to_pfn(0xe6000000),
  49. .length = 256 << 20,
  50. .type = MT_DEVICE_NONSHARED
  51. },
  52. };
  53. void __init sh73a0_map_io(void)
  54. {
  55. debug_ll_io_init();
  56. iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
  57. }
  58. /* PFC */
  59. static struct resource pfc_resources[] __initdata = {
  60. DEFINE_RES_MEM(0xe6050000, 0x8000),
  61. DEFINE_RES_MEM(0xe605801c, 0x000c),
  62. };
  63. void __init sh73a0_pinmux_init(void)
  64. {
  65. platform_device_register_simple("pfc-sh73a0", -1, pfc_resources,
  66. ARRAY_SIZE(pfc_resources));
  67. }
  68. /* SCIF */
  69. #define SH73A0_SCIF(scif_type, index, baseaddr, irq) \
  70. static struct plat_sci_port scif##index##_platform_data = { \
  71. .type = scif_type, \
  72. .flags = UPF_BOOT_AUTOCONF, \
  73. .scscr = SCSCR_RE | SCSCR_TE, \
  74. }; \
  75. \
  76. static struct resource scif##index##_resources[] = { \
  77. DEFINE_RES_MEM(baseaddr, 0x100), \
  78. DEFINE_RES_IRQ(irq), \
  79. }; \
  80. \
  81. static struct platform_device scif##index##_device = { \
  82. .name = "sh-sci", \
  83. .id = index, \
  84. .resource = scif##index##_resources, \
  85. .num_resources = ARRAY_SIZE(scif##index##_resources), \
  86. .dev = { \
  87. .platform_data = &scif##index##_platform_data, \
  88. }, \
  89. }
  90. SH73A0_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(72));
  91. SH73A0_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(73));
  92. SH73A0_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(74));
  93. SH73A0_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(75));
  94. SH73A0_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(78));
  95. SH73A0_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(79));
  96. SH73A0_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(156));
  97. SH73A0_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(143));
  98. SH73A0_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(80));
  99. static struct sh_timer_config cmt1_platform_data = {
  100. .channels_mask = 0x3f,
  101. };
  102. static struct resource cmt1_resources[] = {
  103. DEFINE_RES_MEM(0xe6138000, 0x200),
  104. DEFINE_RES_IRQ(gic_spi(65)),
  105. };
  106. static struct platform_device cmt1_device = {
  107. .name = "sh-cmt-48",
  108. .id = 1,
  109. .dev = {
  110. .platform_data = &cmt1_platform_data,
  111. },
  112. .resource = cmt1_resources,
  113. .num_resources = ARRAY_SIZE(cmt1_resources),
  114. };
  115. /* TMU */
  116. static struct sh_timer_config tmu0_platform_data = {
  117. .channels_mask = 7,
  118. };
  119. static struct resource tmu0_resources[] = {
  120. DEFINE_RES_MEM(0xfff60000, 0x2c),
  121. DEFINE_RES_IRQ(intcs_evt2irq(0xe80)),
  122. DEFINE_RES_IRQ(intcs_evt2irq(0xea0)),
  123. DEFINE_RES_IRQ(intcs_evt2irq(0xec0)),
  124. };
  125. static struct platform_device tmu0_device = {
  126. .name = "sh-tmu",
  127. .id = 0,
  128. .dev = {
  129. .platform_data = &tmu0_platform_data,
  130. },
  131. .resource = tmu0_resources,
  132. .num_resources = ARRAY_SIZE(tmu0_resources),
  133. };
  134. static struct resource i2c0_resources[] = {
  135. [0] = DEFINE_RES_MEM(0xe6820000, 0x426),
  136. [1] = {
  137. .start = gic_spi(167),
  138. .end = gic_spi(170),
  139. .flags = IORESOURCE_IRQ,
  140. },
  141. };
  142. static struct resource i2c1_resources[] = {
  143. [0] = DEFINE_RES_MEM(0xe6822000, 0x426),
  144. [1] = {
  145. .start = gic_spi(51),
  146. .end = gic_spi(54),
  147. .flags = IORESOURCE_IRQ,
  148. },
  149. };
  150. static struct resource i2c2_resources[] = {
  151. [0] = DEFINE_RES_MEM(0xe6824000, 0x426),
  152. [1] = {
  153. .start = gic_spi(171),
  154. .end = gic_spi(174),
  155. .flags = IORESOURCE_IRQ,
  156. },
  157. };
  158. static struct resource i2c3_resources[] = {
  159. [0] = DEFINE_RES_MEM(0xe6826000, 0x426),
  160. [1] = {
  161. .start = gic_spi(183),
  162. .end = gic_spi(186),
  163. .flags = IORESOURCE_IRQ,
  164. },
  165. };
  166. static struct resource i2c4_resources[] = {
  167. [0] = DEFINE_RES_MEM(0xe6828000, 0x426),
  168. [1] = {
  169. .start = gic_spi(187),
  170. .end = gic_spi(190),
  171. .flags = IORESOURCE_IRQ,
  172. },
  173. };
  174. static struct i2c_sh_mobile_platform_data i2c_platform_data = {
  175. .clks_per_count = 2,
  176. };
  177. static struct platform_device i2c0_device = {
  178. .name = "i2c-sh_mobile",
  179. .id = 0,
  180. .resource = i2c0_resources,
  181. .num_resources = ARRAY_SIZE(i2c0_resources),
  182. .dev = {
  183. .platform_data = &i2c_platform_data,
  184. },
  185. };
  186. static struct platform_device i2c1_device = {
  187. .name = "i2c-sh_mobile",
  188. .id = 1,
  189. .resource = i2c1_resources,
  190. .num_resources = ARRAY_SIZE(i2c1_resources),
  191. .dev = {
  192. .platform_data = &i2c_platform_data,
  193. },
  194. };
  195. static struct platform_device i2c2_device = {
  196. .name = "i2c-sh_mobile",
  197. .id = 2,
  198. .resource = i2c2_resources,
  199. .num_resources = ARRAY_SIZE(i2c2_resources),
  200. .dev = {
  201. .platform_data = &i2c_platform_data,
  202. },
  203. };
  204. static struct platform_device i2c3_device = {
  205. .name = "i2c-sh_mobile",
  206. .id = 3,
  207. .resource = i2c3_resources,
  208. .num_resources = ARRAY_SIZE(i2c3_resources),
  209. .dev = {
  210. .platform_data = &i2c_platform_data,
  211. },
  212. };
  213. static struct platform_device i2c4_device = {
  214. .name = "i2c-sh_mobile",
  215. .id = 4,
  216. .resource = i2c4_resources,
  217. .num_resources = ARRAY_SIZE(i2c4_resources),
  218. .dev = {
  219. .platform_data = &i2c_platform_data,
  220. },
  221. };
  222. static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
  223. {
  224. .slave_id = SHDMA_SLAVE_SCIF0_TX,
  225. .addr = 0xe6c40020,
  226. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  227. .mid_rid = 0x21,
  228. }, {
  229. .slave_id = SHDMA_SLAVE_SCIF0_RX,
  230. .addr = 0xe6c40024,
  231. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  232. .mid_rid = 0x22,
  233. }, {
  234. .slave_id = SHDMA_SLAVE_SCIF1_TX,
  235. .addr = 0xe6c50020,
  236. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  237. .mid_rid = 0x25,
  238. }, {
  239. .slave_id = SHDMA_SLAVE_SCIF1_RX,
  240. .addr = 0xe6c50024,
  241. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  242. .mid_rid = 0x26,
  243. }, {
  244. .slave_id = SHDMA_SLAVE_SCIF2_TX,
  245. .addr = 0xe6c60020,
  246. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  247. .mid_rid = 0x29,
  248. }, {
  249. .slave_id = SHDMA_SLAVE_SCIF2_RX,
  250. .addr = 0xe6c60024,
  251. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  252. .mid_rid = 0x2a,
  253. }, {
  254. .slave_id = SHDMA_SLAVE_SCIF3_TX,
  255. .addr = 0xe6c70020,
  256. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  257. .mid_rid = 0x2d,
  258. }, {
  259. .slave_id = SHDMA_SLAVE_SCIF3_RX,
  260. .addr = 0xe6c70024,
  261. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  262. .mid_rid = 0x2e,
  263. }, {
  264. .slave_id = SHDMA_SLAVE_SCIF4_TX,
  265. .addr = 0xe6c80020,
  266. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  267. .mid_rid = 0x39,
  268. }, {
  269. .slave_id = SHDMA_SLAVE_SCIF4_RX,
  270. .addr = 0xe6c80024,
  271. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  272. .mid_rid = 0x3a,
  273. }, {
  274. .slave_id = SHDMA_SLAVE_SCIF5_TX,
  275. .addr = 0xe6cb0020,
  276. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  277. .mid_rid = 0x35,
  278. }, {
  279. .slave_id = SHDMA_SLAVE_SCIF5_RX,
  280. .addr = 0xe6cb0024,
  281. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  282. .mid_rid = 0x36,
  283. }, {
  284. .slave_id = SHDMA_SLAVE_SCIF6_TX,
  285. .addr = 0xe6cc0020,
  286. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  287. .mid_rid = 0x1d,
  288. }, {
  289. .slave_id = SHDMA_SLAVE_SCIF6_RX,
  290. .addr = 0xe6cc0024,
  291. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  292. .mid_rid = 0x1e,
  293. }, {
  294. .slave_id = SHDMA_SLAVE_SCIF7_TX,
  295. .addr = 0xe6cd0020,
  296. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  297. .mid_rid = 0x19,
  298. }, {
  299. .slave_id = SHDMA_SLAVE_SCIF7_RX,
  300. .addr = 0xe6cd0024,
  301. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  302. .mid_rid = 0x1a,
  303. }, {
  304. .slave_id = SHDMA_SLAVE_SCIF8_TX,
  305. .addr = 0xe6c30040,
  306. .chcr = CHCR_TX(XMIT_SZ_8BIT),
  307. .mid_rid = 0x3d,
  308. }, {
  309. .slave_id = SHDMA_SLAVE_SCIF8_RX,
  310. .addr = 0xe6c30060,
  311. .chcr = CHCR_RX(XMIT_SZ_8BIT),
  312. .mid_rid = 0x3e,
  313. }, {
  314. .slave_id = SHDMA_SLAVE_SDHI0_TX,
  315. .addr = 0xee100030,
  316. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  317. .mid_rid = 0xc1,
  318. }, {
  319. .slave_id = SHDMA_SLAVE_SDHI0_RX,
  320. .addr = 0xee100030,
  321. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  322. .mid_rid = 0xc2,
  323. }, {
  324. .slave_id = SHDMA_SLAVE_SDHI1_TX,
  325. .addr = 0xee120030,
  326. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  327. .mid_rid = 0xc9,
  328. }, {
  329. .slave_id = SHDMA_SLAVE_SDHI1_RX,
  330. .addr = 0xee120030,
  331. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  332. .mid_rid = 0xca,
  333. }, {
  334. .slave_id = SHDMA_SLAVE_SDHI2_TX,
  335. .addr = 0xee140030,
  336. .chcr = CHCR_TX(XMIT_SZ_16BIT),
  337. .mid_rid = 0xcd,
  338. }, {
  339. .slave_id = SHDMA_SLAVE_SDHI2_RX,
  340. .addr = 0xee140030,
  341. .chcr = CHCR_RX(XMIT_SZ_16BIT),
  342. .mid_rid = 0xce,
  343. }, {
  344. .slave_id = SHDMA_SLAVE_MMCIF_TX,
  345. .addr = 0xe6bd0034,
  346. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  347. .mid_rid = 0xd1,
  348. }, {
  349. .slave_id = SHDMA_SLAVE_MMCIF_RX,
  350. .addr = 0xe6bd0034,
  351. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  352. .mid_rid = 0xd2,
  353. },
  354. };
  355. #define DMAE_CHANNEL(_offset) \
  356. { \
  357. .offset = _offset - 0x20, \
  358. .dmars = _offset - 0x20 + 0x40, \
  359. }
  360. static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
  361. DMAE_CHANNEL(0x8000),
  362. DMAE_CHANNEL(0x8080),
  363. DMAE_CHANNEL(0x8100),
  364. DMAE_CHANNEL(0x8180),
  365. DMAE_CHANNEL(0x8200),
  366. DMAE_CHANNEL(0x8280),
  367. DMAE_CHANNEL(0x8300),
  368. DMAE_CHANNEL(0x8380),
  369. DMAE_CHANNEL(0x8400),
  370. DMAE_CHANNEL(0x8480),
  371. DMAE_CHANNEL(0x8500),
  372. DMAE_CHANNEL(0x8580),
  373. DMAE_CHANNEL(0x8600),
  374. DMAE_CHANNEL(0x8680),
  375. DMAE_CHANNEL(0x8700),
  376. DMAE_CHANNEL(0x8780),
  377. DMAE_CHANNEL(0x8800),
  378. DMAE_CHANNEL(0x8880),
  379. DMAE_CHANNEL(0x8900),
  380. DMAE_CHANNEL(0x8980),
  381. };
  382. static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
  383. .slave = sh73a0_dmae_slaves,
  384. .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
  385. .channel = sh73a0_dmae_channels,
  386. .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
  387. .ts_low_shift = TS_LOW_SHIFT,
  388. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  389. .ts_high_shift = TS_HI_SHIFT,
  390. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  391. .ts_shift = dma_ts_shift,
  392. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  393. .dmaor_init = DMAOR_DME,
  394. };
  395. static struct resource sh73a0_dmae_resources[] = {
  396. DEFINE_RES_MEM(0xfe000020, 0x89e0),
  397. {
  398. .name = "error_irq",
  399. .start = gic_spi(129),
  400. .end = gic_spi(129),
  401. .flags = IORESOURCE_IRQ,
  402. },
  403. {
  404. /* IRQ for channels 0-19 */
  405. .start = gic_spi(109),
  406. .end = gic_spi(128),
  407. .flags = IORESOURCE_IRQ,
  408. },
  409. };
  410. static struct platform_device dma0_device = {
  411. .name = "sh-dma-engine",
  412. .id = 0,
  413. .resource = sh73a0_dmae_resources,
  414. .num_resources = ARRAY_SIZE(sh73a0_dmae_resources),
  415. .dev = {
  416. .platform_data = &sh73a0_dmae_platform_data,
  417. },
  418. };
  419. /* MPDMAC */
  420. static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
  421. {
  422. .slave_id = SHDMA_SLAVE_FSI2A_RX,
  423. .addr = 0xec230020,
  424. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  425. .mid_rid = 0xd6, /* CHECK ME */
  426. }, {
  427. .slave_id = SHDMA_SLAVE_FSI2A_TX,
  428. .addr = 0xec230024,
  429. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  430. .mid_rid = 0xd5, /* CHECK ME */
  431. }, {
  432. .slave_id = SHDMA_SLAVE_FSI2C_RX,
  433. .addr = 0xec230060,
  434. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  435. .mid_rid = 0xda, /* CHECK ME */
  436. }, {
  437. .slave_id = SHDMA_SLAVE_FSI2C_TX,
  438. .addr = 0xec230064,
  439. .chcr = CHCR_TX(XMIT_SZ_32BIT),
  440. .mid_rid = 0xd9, /* CHECK ME */
  441. }, {
  442. .slave_id = SHDMA_SLAVE_FSI2B_RX,
  443. .addr = 0xec240020,
  444. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  445. .mid_rid = 0x8e, /* CHECK ME */
  446. }, {
  447. .slave_id = SHDMA_SLAVE_FSI2B_TX,
  448. .addr = 0xec240024,
  449. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  450. .mid_rid = 0x8d, /* CHECK ME */
  451. }, {
  452. .slave_id = SHDMA_SLAVE_FSI2D_RX,
  453. .addr = 0xec240060,
  454. .chcr = CHCR_RX(XMIT_SZ_32BIT),
  455. .mid_rid = 0x9a, /* CHECK ME */
  456. },
  457. };
  458. #define MPDMA_CHANNEL(a, b, c) \
  459. { \
  460. .offset = a, \
  461. .dmars = b, \
  462. .dmars_bit = c, \
  463. .chclr_offset = (0x220 - 0x20) + a \
  464. }
  465. static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
  466. MPDMA_CHANNEL(0x00, 0, 0),
  467. MPDMA_CHANNEL(0x10, 0, 8),
  468. MPDMA_CHANNEL(0x20, 4, 0),
  469. MPDMA_CHANNEL(0x30, 4, 8),
  470. MPDMA_CHANNEL(0x50, 8, 0),
  471. MPDMA_CHANNEL(0x70, 8, 8),
  472. };
  473. static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
  474. .slave = sh73a0_mpdma_slaves,
  475. .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
  476. .channel = sh73a0_mpdma_channels,
  477. .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
  478. .ts_low_shift = TS_LOW_SHIFT,
  479. .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
  480. .ts_high_shift = TS_HI_SHIFT,
  481. .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
  482. .ts_shift = dma_ts_shift,
  483. .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
  484. .dmaor_init = DMAOR_DME,
  485. .chclr_present = 1,
  486. };
  487. /* Resource order important! */
  488. static struct resource sh73a0_mpdma_resources[] = {
  489. /* Channel registers and DMAOR */
  490. DEFINE_RES_MEM(0xec618020, 0x270),
  491. /* DMARSx */
  492. DEFINE_RES_MEM(0xec619000, 0xc),
  493. {
  494. .name = "error_irq",
  495. .start = gic_spi(181),
  496. .end = gic_spi(181),
  497. .flags = IORESOURCE_IRQ,
  498. },
  499. {
  500. /* IRQ for channels 0-5 */
  501. .start = gic_spi(175),
  502. .end = gic_spi(180),
  503. .flags = IORESOURCE_IRQ,
  504. },
  505. };
  506. static struct platform_device mpdma0_device = {
  507. .name = "sh-dma-engine",
  508. .id = 1,
  509. .resource = sh73a0_mpdma_resources,
  510. .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
  511. .dev = {
  512. .platform_data = &sh73a0_mpdma_platform_data,
  513. },
  514. };
  515. static struct resource pmu_resources[] = {
  516. [0] = {
  517. .start = gic_spi(55),
  518. .end = gic_spi(55),
  519. .flags = IORESOURCE_IRQ,
  520. },
  521. [1] = {
  522. .start = gic_spi(56),
  523. .end = gic_spi(56),
  524. .flags = IORESOURCE_IRQ,
  525. },
  526. };
  527. static struct platform_device pmu_device = {
  528. .name = "armv7-pmu",
  529. .id = -1,
  530. .num_resources = ARRAY_SIZE(pmu_resources),
  531. .resource = pmu_resources,
  532. };
  533. /* an IPMMU module for ICB */
  534. static struct resource ipmmu_resources[] = {
  535. DEFINE_RES_MEM(0xfe951000, 0x100),
  536. };
  537. static const char * const ipmmu_dev_names[] = {
  538. "sh_mobile_lcdc_fb.0",
  539. };
  540. static struct shmobile_ipmmu_platform_data ipmmu_platform_data = {
  541. .dev_names = ipmmu_dev_names,
  542. .num_dev_names = ARRAY_SIZE(ipmmu_dev_names),
  543. };
  544. static struct platform_device ipmmu_device = {
  545. .name = "ipmmu",
  546. .id = -1,
  547. .dev = {
  548. .platform_data = &ipmmu_platform_data,
  549. },
  550. .resource = ipmmu_resources,
  551. .num_resources = ARRAY_SIZE(ipmmu_resources),
  552. };
  553. static struct renesas_intc_irqpin_config irqpin0_platform_data = {
  554. .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */
  555. .control_parent = true,
  556. };
  557. static struct resource irqpin0_resources[] = {
  558. DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */
  559. DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */
  560. DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */
  561. DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */
  562. DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */
  563. DEFINE_RES_IRQ(gic_spi(1)), /* IRQ0 */
  564. DEFINE_RES_IRQ(gic_spi(2)), /* IRQ1 */
  565. DEFINE_RES_IRQ(gic_spi(3)), /* IRQ2 */
  566. DEFINE_RES_IRQ(gic_spi(4)), /* IRQ3 */
  567. DEFINE_RES_IRQ(gic_spi(5)), /* IRQ4 */
  568. DEFINE_RES_IRQ(gic_spi(6)), /* IRQ5 */
  569. DEFINE_RES_IRQ(gic_spi(7)), /* IRQ6 */
  570. DEFINE_RES_IRQ(gic_spi(8)), /* IRQ7 */
  571. };
  572. static struct platform_device irqpin0_device = {
  573. .name = "renesas_intc_irqpin",
  574. .id = 0,
  575. .resource = irqpin0_resources,
  576. .num_resources = ARRAY_SIZE(irqpin0_resources),
  577. .dev = {
  578. .platform_data = &irqpin0_platform_data,
  579. },
  580. };
  581. static struct renesas_intc_irqpin_config irqpin1_platform_data = {
  582. .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */
  583. .control_parent = true, /* Disable spurious IRQ10 */
  584. };
  585. static struct resource irqpin1_resources[] = {
  586. DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */
  587. DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */
  588. DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */
  589. DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */
  590. DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */
  591. DEFINE_RES_IRQ(gic_spi(9)), /* IRQ8 */
  592. DEFINE_RES_IRQ(gic_spi(10)), /* IRQ9 */
  593. DEFINE_RES_IRQ(gic_spi(11)), /* IRQ10 */
  594. DEFINE_RES_IRQ(gic_spi(12)), /* IRQ11 */
  595. DEFINE_RES_IRQ(gic_spi(13)), /* IRQ12 */
  596. DEFINE_RES_IRQ(gic_spi(14)), /* IRQ13 */
  597. DEFINE_RES_IRQ(gic_spi(15)), /* IRQ14 */
  598. DEFINE_RES_IRQ(gic_spi(16)), /* IRQ15 */
  599. };
  600. static struct platform_device irqpin1_device = {
  601. .name = "renesas_intc_irqpin",
  602. .id = 1,
  603. .resource = irqpin1_resources,
  604. .num_resources = ARRAY_SIZE(irqpin1_resources),
  605. .dev = {
  606. .platform_data = &irqpin1_platform_data,
  607. },
  608. };
  609. static struct renesas_intc_irqpin_config irqpin2_platform_data = {
  610. .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */
  611. .control_parent = true,
  612. };
  613. static struct resource irqpin2_resources[] = {
  614. DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */
  615. DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI20A */
  616. DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ20A */
  617. DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK20A */
  618. DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR20A */
  619. DEFINE_RES_IRQ(gic_spi(17)), /* IRQ16 */
  620. DEFINE_RES_IRQ(gic_spi(18)), /* IRQ17 */
  621. DEFINE_RES_IRQ(gic_spi(19)), /* IRQ18 */
  622. DEFINE_RES_IRQ(gic_spi(20)), /* IRQ19 */
  623. DEFINE_RES_IRQ(gic_spi(21)), /* IRQ20 */
  624. DEFINE_RES_IRQ(gic_spi(22)), /* IRQ21 */
  625. DEFINE_RES_IRQ(gic_spi(23)), /* IRQ22 */
  626. DEFINE_RES_IRQ(gic_spi(24)), /* IRQ23 */
  627. };
  628. static struct platform_device irqpin2_device = {
  629. .name = "renesas_intc_irqpin",
  630. .id = 2,
  631. .resource = irqpin2_resources,
  632. .num_resources = ARRAY_SIZE(irqpin2_resources),
  633. .dev = {
  634. .platform_data = &irqpin2_platform_data,
  635. },
  636. };
  637. static struct renesas_intc_irqpin_config irqpin3_platform_data = {
  638. .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */
  639. .control_parent = true,
  640. };
  641. static struct resource irqpin3_resources[] = {
  642. DEFINE_RES_MEM(0xe690000c, 4), /* ICR4A */
  643. DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */
  644. DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */
  645. DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */
  646. DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */
  647. DEFINE_RES_IRQ(gic_spi(25)), /* IRQ24 */
  648. DEFINE_RES_IRQ(gic_spi(26)), /* IRQ25 */
  649. DEFINE_RES_IRQ(gic_spi(27)), /* IRQ26 */
  650. DEFINE_RES_IRQ(gic_spi(28)), /* IRQ27 */
  651. DEFINE_RES_IRQ(gic_spi(29)), /* IRQ28 */
  652. DEFINE_RES_IRQ(gic_spi(30)), /* IRQ29 */
  653. DEFINE_RES_IRQ(gic_spi(31)), /* IRQ30 */
  654. DEFINE_RES_IRQ(gic_spi(32)), /* IRQ31 */
  655. };
  656. static struct platform_device irqpin3_device = {
  657. .name = "renesas_intc_irqpin",
  658. .id = 3,
  659. .resource = irqpin3_resources,
  660. .num_resources = ARRAY_SIZE(irqpin3_resources),
  661. .dev = {
  662. .platform_data = &irqpin3_platform_data,
  663. },
  664. };
  665. static struct platform_device *sh73a0_early_devices[] __initdata = {
  666. &scif0_device,
  667. &scif1_device,
  668. &scif2_device,
  669. &scif3_device,
  670. &scif4_device,
  671. &scif5_device,
  672. &scif6_device,
  673. &scif7_device,
  674. &scif8_device,
  675. &tmu0_device,
  676. &ipmmu_device,
  677. &cmt1_device,
  678. };
  679. static struct platform_device *sh73a0_late_devices[] __initdata = {
  680. &i2c0_device,
  681. &i2c1_device,
  682. &i2c2_device,
  683. &i2c3_device,
  684. &i2c4_device,
  685. &dma0_device,
  686. &mpdma0_device,
  687. &pmu_device,
  688. &irqpin0_device,
  689. &irqpin1_device,
  690. &irqpin2_device,
  691. &irqpin3_device,
  692. };
  693. #define SRCR2 IOMEM(0xe61580b0)
  694. void __init sh73a0_add_standard_devices(void)
  695. {
  696. /* Clear software reset bit on SY-DMAC module */
  697. __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
  698. platform_add_devices(sh73a0_early_devices,
  699. ARRAY_SIZE(sh73a0_early_devices));
  700. platform_add_devices(sh73a0_late_devices,
  701. ARRAY_SIZE(sh73a0_late_devices));
  702. }
  703. /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
  704. void __init __weak sh73a0_register_twd(void) { }
  705. void __init sh73a0_earlytimer_init(void)
  706. {
  707. shmobile_init_delay();
  708. #ifndef CONFIG_COMMON_CLK
  709. sh73a0_clock_init();
  710. #endif
  711. shmobile_earlytimer_init();
  712. sh73a0_register_twd();
  713. }
  714. void __init sh73a0_add_early_devices(void)
  715. {
  716. early_platform_add_devices(sh73a0_early_devices,
  717. ARRAY_SIZE(sh73a0_early_devices));
  718. /* setup early console here as well */
  719. shmobile_setup_console();
  720. }
  721. #ifdef CONFIG_USE_OF
  722. static void __init sh73a0_generic_init(void)
  723. {
  724. #ifdef CONFIG_CACHE_L2X0
  725. /* Shared attribute override enable, 64K*8way */
  726. l2x0_init(IOMEM(0xf0100000), 0x00400000, 0xc20f0fff);
  727. #endif
  728. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  729. }
  730. static const char *sh73a0_boards_compat_dt[] __initdata = {
  731. "renesas,sh73a0",
  732. NULL,
  733. };
  734. DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
  735. .smp = smp_ops(sh73a0_smp_ops),
  736. .map_io = sh73a0_map_io,
  737. .init_early = shmobile_init_delay,
  738. .init_machine = sh73a0_generic_init,
  739. .init_late = shmobile_init_late,
  740. .dt_compat = sh73a0_boards_compat_dt,
  741. MACHINE_END
  742. #endif /* CONFIG_USE_OF */