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