setup-sh73a0.c 20 KB

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