setup-sh7734.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/sh/kernel/cpu/sh4a/setup-sh7734.c
  4. *
  5. * SH7734 Setup
  6. *
  7. * Copyright (C) 2011,2012 Nobuhiro Iwamatsu <[email protected]>
  8. * Copyright (C) 2011,2012 Renesas Solutions Corp.
  9. */
  10. #include <linux/platform_device.h>
  11. #include <linux/init.h>
  12. #include <linux/serial.h>
  13. #include <linux/mm.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/serial_sci.h>
  16. #include <linux/sh_timer.h>
  17. #include <linux/io.h>
  18. #include <asm/clock.h>
  19. #include <asm/irq.h>
  20. #include <asm/platform_early.h>
  21. #include <cpu/sh7734.h>
  22. /* SCIF */
  23. static struct plat_sci_port scif0_platform_data = {
  24. .scscr = SCSCR_REIE,
  25. .type = PORT_SCIF,
  26. .regtype = SCIx_SH4_SCIF_BRG_REGTYPE,
  27. };
  28. static struct resource scif0_resources[] = {
  29. DEFINE_RES_MEM(0xffe40000, 0x100),
  30. DEFINE_RES_IRQ(evt2irq(0x8c0)),
  31. };
  32. static struct platform_device scif0_device = {
  33. .name = "sh-sci",
  34. .id = 0,
  35. .resource = scif0_resources,
  36. .num_resources = ARRAY_SIZE(scif0_resources),
  37. .dev = {
  38. .platform_data = &scif0_platform_data,
  39. },
  40. };
  41. static struct plat_sci_port scif1_platform_data = {
  42. .scscr = SCSCR_REIE,
  43. .type = PORT_SCIF,
  44. .regtype = SCIx_SH4_SCIF_BRG_REGTYPE,
  45. };
  46. static struct resource scif1_resources[] = {
  47. DEFINE_RES_MEM(0xffe41000, 0x100),
  48. DEFINE_RES_IRQ(evt2irq(0x8e0)),
  49. };
  50. static struct platform_device scif1_device = {
  51. .name = "sh-sci",
  52. .id = 1,
  53. .resource = scif1_resources,
  54. .num_resources = ARRAY_SIZE(scif1_resources),
  55. .dev = {
  56. .platform_data = &scif1_platform_data,
  57. },
  58. };
  59. static struct plat_sci_port scif2_platform_data = {
  60. .scscr = SCSCR_REIE,
  61. .type = PORT_SCIF,
  62. .regtype = SCIx_SH4_SCIF_BRG_REGTYPE,
  63. };
  64. static struct resource scif2_resources[] = {
  65. DEFINE_RES_MEM(0xffe42000, 0x100),
  66. DEFINE_RES_IRQ(evt2irq(0x900)),
  67. };
  68. static struct platform_device scif2_device = {
  69. .name = "sh-sci",
  70. .id = 2,
  71. .resource = scif2_resources,
  72. .num_resources = ARRAY_SIZE(scif2_resources),
  73. .dev = {
  74. .platform_data = &scif2_platform_data,
  75. },
  76. };
  77. static struct plat_sci_port scif3_platform_data = {
  78. .scscr = SCSCR_REIE | SCSCR_TOIE,
  79. .type = PORT_SCIF,
  80. .regtype = SCIx_SH4_SCIF_BRG_REGTYPE,
  81. };
  82. static struct resource scif3_resources[] = {
  83. DEFINE_RES_MEM(0xffe43000, 0x100),
  84. DEFINE_RES_IRQ(evt2irq(0x920)),
  85. };
  86. static struct platform_device scif3_device = {
  87. .name = "sh-sci",
  88. .id = 3,
  89. .resource = scif3_resources,
  90. .num_resources = ARRAY_SIZE(scif3_resources),
  91. .dev = {
  92. .platform_data = &scif3_platform_data,
  93. },
  94. };
  95. static struct plat_sci_port scif4_platform_data = {
  96. .scscr = SCSCR_REIE,
  97. .type = PORT_SCIF,
  98. .regtype = SCIx_SH4_SCIF_BRG_REGTYPE,
  99. };
  100. static struct resource scif4_resources[] = {
  101. DEFINE_RES_MEM(0xffe44000, 0x100),
  102. DEFINE_RES_IRQ(evt2irq(0x940)),
  103. };
  104. static struct platform_device scif4_device = {
  105. .name = "sh-sci",
  106. .id = 4,
  107. .resource = scif4_resources,
  108. .num_resources = ARRAY_SIZE(scif4_resources),
  109. .dev = {
  110. .platform_data = &scif4_platform_data,
  111. },
  112. };
  113. static struct plat_sci_port scif5_platform_data = {
  114. .scscr = SCSCR_REIE,
  115. .type = PORT_SCIF,
  116. .regtype = SCIx_SH4_SCIF_BRG_REGTYPE,
  117. };
  118. static struct resource scif5_resources[] = {
  119. DEFINE_RES_MEM(0xffe43000, 0x100),
  120. DEFINE_RES_IRQ(evt2irq(0x960)),
  121. };
  122. static struct platform_device scif5_device = {
  123. .name = "sh-sci",
  124. .id = 5,
  125. .resource = scif5_resources,
  126. .num_resources = ARRAY_SIZE(scif5_resources),
  127. .dev = {
  128. .platform_data = &scif5_platform_data,
  129. },
  130. };
  131. /* RTC */
  132. static struct resource rtc_resources[] = {
  133. [0] = {
  134. .name = "rtc",
  135. .start = 0xFFFC5000,
  136. .end = 0xFFFC5000 + 0x26 - 1,
  137. .flags = IORESOURCE_IO,
  138. },
  139. [1] = {
  140. .start = evt2irq(0xC00),
  141. .flags = IORESOURCE_IRQ,
  142. },
  143. };
  144. static struct platform_device rtc_device = {
  145. .name = "sh-rtc",
  146. .id = -1,
  147. .num_resources = ARRAY_SIZE(rtc_resources),
  148. .resource = rtc_resources,
  149. };
  150. /* I2C 0 */
  151. static struct resource i2c0_resources[] = {
  152. [0] = {
  153. .name = "IIC0",
  154. .start = 0xFFC70000,
  155. .end = 0xFFC7000A - 1,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. [1] = {
  159. .start = evt2irq(0x860),
  160. .flags = IORESOURCE_IRQ,
  161. },
  162. };
  163. static struct platform_device i2c0_device = {
  164. .name = "i2c-sh7734",
  165. .id = 0,
  166. .num_resources = ARRAY_SIZE(i2c0_resources),
  167. .resource = i2c0_resources,
  168. };
  169. /* TMU */
  170. static struct sh_timer_config tmu0_platform_data = {
  171. .channels_mask = 7,
  172. };
  173. static struct resource tmu0_resources[] = {
  174. DEFINE_RES_MEM(0xffd80000, 0x30),
  175. DEFINE_RES_IRQ(evt2irq(0x400)),
  176. DEFINE_RES_IRQ(evt2irq(0x420)),
  177. DEFINE_RES_IRQ(evt2irq(0x440)),
  178. };
  179. static struct platform_device tmu0_device = {
  180. .name = "sh-tmu",
  181. .id = 0,
  182. .dev = {
  183. .platform_data = &tmu0_platform_data,
  184. },
  185. .resource = tmu0_resources,
  186. .num_resources = ARRAY_SIZE(tmu0_resources),
  187. };
  188. static struct sh_timer_config tmu1_platform_data = {
  189. .channels_mask = 7,
  190. };
  191. static struct resource tmu1_resources[] = {
  192. DEFINE_RES_MEM(0xffd81000, 0x30),
  193. DEFINE_RES_IRQ(evt2irq(0x480)),
  194. DEFINE_RES_IRQ(evt2irq(0x4a0)),
  195. DEFINE_RES_IRQ(evt2irq(0x4c0)),
  196. };
  197. static struct platform_device tmu1_device = {
  198. .name = "sh-tmu",
  199. .id = 1,
  200. .dev = {
  201. .platform_data = &tmu1_platform_data,
  202. },
  203. .resource = tmu1_resources,
  204. .num_resources = ARRAY_SIZE(tmu1_resources),
  205. };
  206. static struct sh_timer_config tmu2_platform_data = {
  207. .channels_mask = 7,
  208. };
  209. static struct resource tmu2_resources[] = {
  210. DEFINE_RES_MEM(0xffd82000, 0x30),
  211. DEFINE_RES_IRQ(evt2irq(0x500)),
  212. DEFINE_RES_IRQ(evt2irq(0x520)),
  213. DEFINE_RES_IRQ(evt2irq(0x540)),
  214. };
  215. static struct platform_device tmu2_device = {
  216. .name = "sh-tmu",
  217. .id = 2,
  218. .dev = {
  219. .platform_data = &tmu2_platform_data,
  220. },
  221. .resource = tmu2_resources,
  222. .num_resources = ARRAY_SIZE(tmu2_resources),
  223. };
  224. static struct platform_device *sh7734_devices[] __initdata = {
  225. &scif0_device,
  226. &scif1_device,
  227. &scif2_device,
  228. &scif3_device,
  229. &scif4_device,
  230. &scif5_device,
  231. &tmu0_device,
  232. &tmu1_device,
  233. &tmu2_device,
  234. &rtc_device,
  235. };
  236. static struct platform_device *sh7734_early_devices[] __initdata = {
  237. &scif0_device,
  238. &scif1_device,
  239. &scif2_device,
  240. &scif3_device,
  241. &scif4_device,
  242. &scif5_device,
  243. &tmu0_device,
  244. &tmu1_device,
  245. &tmu2_device,
  246. };
  247. void __init plat_early_device_setup(void)
  248. {
  249. sh_early_platform_add_devices(sh7734_early_devices,
  250. ARRAY_SIZE(sh7734_early_devices));
  251. }
  252. #define GROUP 0
  253. enum {
  254. UNUSED = 0,
  255. /* interrupt sources */
  256. IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,
  257. IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,
  258. IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,
  259. IRL0_HHLL, IRL0_HHLH, IRL0_HHHL,
  260. IRQ0, IRQ1, IRQ2, IRQ3,
  261. DU,
  262. TMU00, TMU10, TMU20, TMU21,
  263. TMU30, TMU40, TMU50, TMU51,
  264. TMU60, TMU70, TMU80,
  265. RESET_WDT,
  266. USB,
  267. HUDI,
  268. SHDMAC,
  269. SSI0, SSI1, SSI2, SSI3,
  270. VIN0,
  271. RGPVG,
  272. _2DG,
  273. MMC,
  274. HSPI,
  275. LBSCATA,
  276. I2C0,
  277. RCAN0,
  278. MIMLB,
  279. SCIF0, SCIF1, SCIF2, SCIF3, SCIF4, SCIF5,
  280. LBSCDMAC0, LBSCDMAC1, LBSCDMAC2,
  281. RCAN1,
  282. SDHI0, SDHI1,
  283. IEBUS,
  284. HPBDMAC0_3, HPBDMAC4_10, HPBDMAC11_18, HPBDMAC19_22, HPBDMAC23_25_27_28,
  285. RTC,
  286. VIN1,
  287. LCDC,
  288. SRC0, SRC1,
  289. GETHER,
  290. SDHI2,
  291. GPIO0_3, GPIO4_5,
  292. STIF0, STIF1,
  293. ADMAC,
  294. HIF,
  295. FLCTL,
  296. ADC,
  297. MTU2,
  298. RSPI,
  299. QSPI,
  300. HSCIF,
  301. VEU3F_VE3,
  302. /* Group */
  303. /* Mask */
  304. STIF_M,
  305. GPIO_M,
  306. HPBDMAC_M,
  307. LBSCDMAC_M,
  308. RCAN_M,
  309. SRC_M,
  310. SCIF_M,
  311. LCDC_M,
  312. _2DG_M,
  313. VIN_M,
  314. TMU_3_M,
  315. TMU_0_M,
  316. /* Priority */
  317. RCAN_P,
  318. LBSCDMAC_P,
  319. /* Common */
  320. SDHI,
  321. SSI,
  322. SPI,
  323. };
  324. static struct intc_vect vectors[] __initdata = {
  325. INTC_VECT(DU, 0x3E0),
  326. INTC_VECT(TMU00, 0x400),
  327. INTC_VECT(TMU10, 0x420),
  328. INTC_VECT(TMU20, 0x440),
  329. INTC_VECT(TMU30, 0x480),
  330. INTC_VECT(TMU40, 0x4A0),
  331. INTC_VECT(TMU50, 0x4C0),
  332. INTC_VECT(TMU51, 0x4E0),
  333. INTC_VECT(TMU60, 0x500),
  334. INTC_VECT(TMU70, 0x520),
  335. INTC_VECT(TMU80, 0x540),
  336. INTC_VECT(RESET_WDT, 0x560),
  337. INTC_VECT(USB, 0x580),
  338. INTC_VECT(HUDI, 0x600),
  339. INTC_VECT(SHDMAC, 0x620),
  340. INTC_VECT(SSI0, 0x6C0),
  341. INTC_VECT(SSI1, 0x6E0),
  342. INTC_VECT(SSI2, 0x700),
  343. INTC_VECT(SSI3, 0x720),
  344. INTC_VECT(VIN0, 0x740),
  345. INTC_VECT(RGPVG, 0x760),
  346. INTC_VECT(_2DG, 0x780),
  347. INTC_VECT(MMC, 0x7A0),
  348. INTC_VECT(HSPI, 0x7E0),
  349. INTC_VECT(LBSCATA, 0x840),
  350. INTC_VECT(I2C0, 0x860),
  351. INTC_VECT(RCAN0, 0x880),
  352. INTC_VECT(SCIF0, 0x8A0),
  353. INTC_VECT(SCIF1, 0x8C0),
  354. INTC_VECT(SCIF2, 0x900),
  355. INTC_VECT(SCIF3, 0x920),
  356. INTC_VECT(SCIF4, 0x940),
  357. INTC_VECT(SCIF5, 0x960),
  358. INTC_VECT(LBSCDMAC0, 0x9E0),
  359. INTC_VECT(LBSCDMAC1, 0xA00),
  360. INTC_VECT(LBSCDMAC2, 0xA20),
  361. INTC_VECT(RCAN1, 0xA60),
  362. INTC_VECT(SDHI0, 0xAE0),
  363. INTC_VECT(SDHI1, 0xB00),
  364. INTC_VECT(IEBUS, 0xB20),
  365. INTC_VECT(HPBDMAC0_3, 0xB60),
  366. INTC_VECT(HPBDMAC4_10, 0xB80),
  367. INTC_VECT(HPBDMAC11_18, 0xBA0),
  368. INTC_VECT(HPBDMAC19_22, 0xBC0),
  369. INTC_VECT(HPBDMAC23_25_27_28, 0xBE0),
  370. INTC_VECT(RTC, 0xC00),
  371. INTC_VECT(VIN1, 0xC20),
  372. INTC_VECT(LCDC, 0xC40),
  373. INTC_VECT(SRC0, 0xC60),
  374. INTC_VECT(SRC1, 0xC80),
  375. INTC_VECT(GETHER, 0xCA0),
  376. INTC_VECT(SDHI2, 0xCC0),
  377. INTC_VECT(GPIO0_3, 0xCE0),
  378. INTC_VECT(GPIO4_5, 0xD00),
  379. INTC_VECT(STIF0, 0xD20),
  380. INTC_VECT(STIF1, 0xD40),
  381. INTC_VECT(ADMAC, 0xDA0),
  382. INTC_VECT(HIF, 0xDC0),
  383. INTC_VECT(FLCTL, 0xDE0),
  384. INTC_VECT(ADC, 0xE00),
  385. INTC_VECT(MTU2, 0xE20),
  386. INTC_VECT(RSPI, 0xE40),
  387. INTC_VECT(QSPI, 0xE60),
  388. INTC_VECT(HSCIF, 0xFC0),
  389. INTC_VECT(VEU3F_VE3, 0xF40),
  390. };
  391. static struct intc_group groups[] __initdata = {
  392. /* Common */
  393. INTC_GROUP(SDHI, SDHI0, SDHI1, SDHI2),
  394. INTC_GROUP(SPI, HSPI, RSPI, QSPI),
  395. INTC_GROUP(SSI, SSI0, SSI1, SSI2, SSI3),
  396. /* Mask group */
  397. INTC_GROUP(STIF_M, STIF0, STIF1), /* 22 */
  398. INTC_GROUP(GPIO_M, GPIO0_3, GPIO4_5), /* 21 */
  399. INTC_GROUP(HPBDMAC_M, HPBDMAC0_3, HPBDMAC4_10, HPBDMAC11_18,
  400. HPBDMAC19_22, HPBDMAC23_25_27_28), /* 19 */
  401. INTC_GROUP(LBSCDMAC_M, LBSCDMAC0, LBSCDMAC1, LBSCDMAC2), /* 18 */
  402. INTC_GROUP(RCAN_M, RCAN0, RCAN1, IEBUS), /* 17 */
  403. INTC_GROUP(SRC_M, SRC0, SRC1), /* 16 */
  404. INTC_GROUP(SCIF_M, SCIF0, SCIF1, SCIF2, SCIF3, SCIF4, SCIF5,
  405. HSCIF), /* 14 */
  406. INTC_GROUP(LCDC_M, LCDC, MIMLB), /* 13 */
  407. INTC_GROUP(_2DG_M, _2DG, RGPVG), /* 12 */
  408. INTC_GROUP(VIN_M, VIN0, VIN1), /* 10 */
  409. INTC_GROUP(TMU_3_M, TMU30, TMU40, TMU50, TMU51,
  410. TMU60, TMU60, TMU70, TMU80), /* 2 */
  411. INTC_GROUP(TMU_0_M, TMU00, TMU10, TMU20, TMU21), /* 1 */
  412. /* Priority group*/
  413. INTC_GROUP(RCAN_P, RCAN0, RCAN1), /* INT2PRI5 */
  414. INTC_GROUP(LBSCDMAC_P, LBSCDMAC0, LBSCDMAC1), /* INT2PRI5 */
  415. };
  416. static struct intc_mask_reg mask_registers[] __initdata = {
  417. { 0xFF804040, 0xFF804044, 32, /* INT2MSKRG / INT2MSKCR */
  418. { 0,
  419. VEU3F_VE3,
  420. SDHI, /* SDHI 0-2 */
  421. ADMAC,
  422. FLCTL,
  423. RESET_WDT,
  424. HIF,
  425. ADC,
  426. MTU2,
  427. STIF_M, /* STIF 0,1 */
  428. GPIO_M, /* GPIO 0-5*/
  429. GETHER,
  430. HPBDMAC_M, /* HPBDMAC 0_3 - 23_25_27_28 */
  431. LBSCDMAC_M, /* LBSCDMAC 0 - 2 */
  432. RCAN_M, /* RCAN, IEBUS */
  433. SRC_M, /* SRC 0,1 */
  434. LBSCATA,
  435. SCIF_M, /* SCIF 0-5, HSCIF */
  436. LCDC_M, /* LCDC, MIMLB */
  437. _2DG_M, /* 2DG, RGPVG */
  438. SPI, /* HSPI, RSPI, QSPI */
  439. VIN_M, /* VIN0, 1 */
  440. SSI, /* SSI 0-3 */
  441. USB,
  442. SHDMAC,
  443. HUDI,
  444. MMC,
  445. RTC,
  446. I2C0, /* I2C */ /* I2C 0, 1*/
  447. TMU_3_M, /* TMU30 - TMU80 */
  448. TMU_0_M, /* TMU00 - TMU21 */
  449. DU } },
  450. };
  451. static struct intc_prio_reg prio_registers[] __initdata = {
  452. { 0xFF804000, 0, 32, 8, /* INT2PRI0 */
  453. { DU, TMU00, TMU10, TMU20 } },
  454. { 0xFF804004, 0, 32, 8, /* INT2PRI1 */
  455. { TMU30, TMU60, RTC, SDHI } },
  456. { 0xFF804008, 0, 32, 8, /* INT2PRI2 */
  457. { HUDI, SHDMAC, USB, SSI } },
  458. { 0xFF80400C, 0, 32, 8, /* INT2PRI3 */
  459. { VIN0, SPI, _2DG, LBSCATA } },
  460. { 0xFF804010, 0, 32, 8, /* INT2PRI4 */
  461. { SCIF0, SCIF3, HSCIF, LCDC } },
  462. { 0xFF804014, 0, 32, 8, /* INT2PRI5 */
  463. { RCAN_P, LBSCDMAC_P, LBSCDMAC2, MMC } },
  464. { 0xFF804018, 0, 32, 8, /* INT2PRI6 */
  465. { HPBDMAC0_3, HPBDMAC4_10, HPBDMAC11_18, HPBDMAC19_22 } },
  466. { 0xFF80401C, 0, 32, 8, /* INT2PRI7 */
  467. { HPBDMAC23_25_27_28, I2C0, SRC0, SRC1 } },
  468. { 0xFF804020, 0, 32, 8, /* INT2PRI8 */
  469. { 0 /* ADIF */, VIN1, RESET_WDT, HIF } },
  470. { 0xFF804024, 0, 32, 8, /* INT2PRI9 */
  471. { ADMAC, FLCTL, GPIO0_3, GPIO4_5 } },
  472. { 0xFF804028, 0, 32, 8, /* INT2PRI10 */
  473. { STIF0, STIF1, VEU3F_VE3, GETHER } },
  474. { 0xFF80402C, 0, 32, 8, /* INT2PRI11 */
  475. { MTU2, RGPVG, MIMLB, IEBUS } },
  476. };
  477. static DECLARE_INTC_DESC(intc_desc, "sh7734", vectors, groups,
  478. mask_registers, prio_registers, NULL);
  479. /* Support for external interrupt pins in IRQ mode */
  480. static struct intc_vect irq3210_vectors[] __initdata = {
  481. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  482. INTC_VECT(IRQ2, 0x2C0), INTC_VECT(IRQ3, 0x300),
  483. };
  484. static struct intc_sense_reg irq3210_sense_registers[] __initdata = {
  485. { 0xFF80201C, 32, 2, /* ICR1 */
  486. { IRQ0, IRQ1, IRQ2, IRQ3, } },
  487. };
  488. static struct intc_mask_reg irq3210_ack_registers[] __initdata = {
  489. { 0xFF802024, 0, 32, /* INTREQ */
  490. { IRQ0, IRQ1, IRQ2, IRQ3, } },
  491. };
  492. static struct intc_mask_reg irq3210_mask_registers[] __initdata = {
  493. { 0xFF802044, 0xFF802064, 32, /* INTMSK0 / INTMSKCLR0 */
  494. { IRQ0, IRQ1, IRQ2, IRQ3, } },
  495. };
  496. static struct intc_prio_reg irq3210_prio_registers[] __initdata = {
  497. { 0xFF802010, 0, 32, 4, /* INTPRI */
  498. { IRQ0, IRQ1, IRQ2, IRQ3, } },
  499. };
  500. static DECLARE_INTC_DESC_ACK(intc_desc_irq3210, "sh7734-irq3210",
  501. irq3210_vectors, NULL,
  502. irq3210_mask_registers, irq3210_prio_registers,
  503. irq3210_sense_registers, irq3210_ack_registers);
  504. /* External interrupt pins in IRL mode */
  505. static struct intc_vect vectors_irl3210[] __initdata = {
  506. INTC_VECT(IRL0_LLLL, 0x200), INTC_VECT(IRL0_LLLH, 0x220),
  507. INTC_VECT(IRL0_LLHL, 0x240), INTC_VECT(IRL0_LLHH, 0x260),
  508. INTC_VECT(IRL0_LHLL, 0x280), INTC_VECT(IRL0_LHLH, 0x2a0),
  509. INTC_VECT(IRL0_LHHL, 0x2c0), INTC_VECT(IRL0_LHHH, 0x2e0),
  510. INTC_VECT(IRL0_HLLL, 0x300), INTC_VECT(IRL0_HLLH, 0x320),
  511. INTC_VECT(IRL0_HLHL, 0x340), INTC_VECT(IRL0_HLHH, 0x360),
  512. INTC_VECT(IRL0_HHLL, 0x380), INTC_VECT(IRL0_HHLH, 0x3a0),
  513. INTC_VECT(IRL0_HHHL, 0x3c0),
  514. };
  515. static DECLARE_INTC_DESC(intc_desc_irl3210, "sh7734-irl3210",
  516. vectors_irl3210, NULL, mask_registers, NULL, NULL);
  517. #define INTC_ICR0 0xFF802000
  518. #define INTC_INTMSK0 0xFF802044
  519. #define INTC_INTMSK1 0xFF802048
  520. #define INTC_INTMSKCLR0 0xFF802064
  521. #define INTC_INTMSKCLR1 0xFF802068
  522. void __init plat_irq_setup(void)
  523. {
  524. /* disable IRQ3-0 */
  525. __raw_writel(0xF0000000, INTC_INTMSK0);
  526. /* disable IRL3-0 */
  527. __raw_writel(0x80000000, INTC_INTMSK1);
  528. /* select IRL mode for IRL3-0 */
  529. __raw_writel(__raw_readl(INTC_ICR0) & ~0x00800000, INTC_ICR0);
  530. /* disable holding function, ie enable "SH-4 Mode (LVLMODE)" */
  531. __raw_writel(__raw_readl(INTC_ICR0) | 0x00200000, INTC_ICR0);
  532. register_intc_controller(&intc_desc);
  533. }
  534. void __init plat_irq_setup_pins(int mode)
  535. {
  536. switch (mode) {
  537. case IRQ_MODE_IRQ3210:
  538. /* select IRQ mode for IRL3-0 */
  539. __raw_writel(__raw_readl(INTC_ICR0) | 0x00800000, INTC_ICR0);
  540. register_intc_controller(&intc_desc_irq3210);
  541. break;
  542. case IRQ_MODE_IRL3210:
  543. /* enable IRL0-3 but don't provide any masking */
  544. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  545. __raw_writel(0xf0000000, INTC_INTMSKCLR0);
  546. break;
  547. case IRQ_MODE_IRL3210_MASK:
  548. /* enable IRL0-3 and mask using cpu intc controller */
  549. __raw_writel(0x80000000, INTC_INTMSKCLR0);
  550. register_intc_controller(&intc_desc_irl3210);
  551. break;
  552. default:
  553. BUG();
  554. }
  555. }