setup-sh73a0.c 21 KB

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