setup-sh73a0.c 20 KB

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