setup-sh7780.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * SH7780 Setup
  3. *
  4. * Copyright (C) 2006 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/platform_device.h>
  11. #include <linux/init.h>
  12. #include <linux/serial.h>
  13. #include <linux/io.h>
  14. #include <linux/serial_sci.h>
  15. #include <linux/sh_dma.h>
  16. #include <linux/sh_timer.h>
  17. #include <linux/sh_intc.h>
  18. #include <cpu/dma-register.h>
  19. static struct plat_sci_port scif0_platform_data = {
  20. .flags = UPF_BOOT_AUTOCONF,
  21. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,
  22. .type = PORT_SCIF,
  23. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  24. };
  25. static struct resource scif0_resources[] = {
  26. DEFINE_RES_MEM(0xffe00000, 0x100),
  27. DEFINE_RES_IRQ(evt2irq(0x700)),
  28. };
  29. static struct platform_device scif0_device = {
  30. .name = "sh-sci",
  31. .id = 0,
  32. .resource = scif0_resources,
  33. .num_resources = ARRAY_SIZE(scif0_resources),
  34. .dev = {
  35. .platform_data = &scif0_platform_data,
  36. },
  37. };
  38. static struct plat_sci_port scif1_platform_data = {
  39. .flags = UPF_BOOT_AUTOCONF,
  40. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,
  41. .type = PORT_SCIF,
  42. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  43. };
  44. static struct resource scif1_resources[] = {
  45. DEFINE_RES_MEM(0xffe10000, 0x100),
  46. DEFINE_RES_IRQ(evt2irq(0xb80)),
  47. };
  48. static struct platform_device scif1_device = {
  49. .name = "sh-sci",
  50. .id = 1,
  51. .resource = scif1_resources,
  52. .num_resources = ARRAY_SIZE(scif1_resources),
  53. .dev = {
  54. .platform_data = &scif1_platform_data,
  55. },
  56. };
  57. static struct sh_timer_config tmu0_platform_data = {
  58. .channel_offset = 0x04,
  59. .timer_bit = 0,
  60. .clockevent_rating = 200,
  61. };
  62. static struct resource tmu0_resources[] = {
  63. [0] = {
  64. .start = 0xffd80008,
  65. .end = 0xffd80013,
  66. .flags = IORESOURCE_MEM,
  67. },
  68. [1] = {
  69. .start = evt2irq(0x580),
  70. .flags = IORESOURCE_IRQ,
  71. },
  72. };
  73. static struct platform_device tmu0_device = {
  74. .name = "sh_tmu",
  75. .id = 0,
  76. .dev = {
  77. .platform_data = &tmu0_platform_data,
  78. },
  79. .resource = tmu0_resources,
  80. .num_resources = ARRAY_SIZE(tmu0_resources),
  81. };
  82. static struct sh_timer_config tmu1_platform_data = {
  83. .channel_offset = 0x10,
  84. .timer_bit = 1,
  85. .clocksource_rating = 200,
  86. };
  87. static struct resource tmu1_resources[] = {
  88. [0] = {
  89. .start = 0xffd80014,
  90. .end = 0xffd8001f,
  91. .flags = IORESOURCE_MEM,
  92. },
  93. [1] = {
  94. .start = evt2irq(0x5a0),
  95. .flags = IORESOURCE_IRQ,
  96. },
  97. };
  98. static struct platform_device tmu1_device = {
  99. .name = "sh_tmu",
  100. .id = 1,
  101. .dev = {
  102. .platform_data = &tmu1_platform_data,
  103. },
  104. .resource = tmu1_resources,
  105. .num_resources = ARRAY_SIZE(tmu1_resources),
  106. };
  107. static struct sh_timer_config tmu2_platform_data = {
  108. .channel_offset = 0x1c,
  109. .timer_bit = 2,
  110. };
  111. static struct resource tmu2_resources[] = {
  112. [0] = {
  113. .start = 0xffd80020,
  114. .end = 0xffd8002f,
  115. .flags = IORESOURCE_MEM,
  116. },
  117. [1] = {
  118. .start = evt2irq(0x5c0),
  119. .flags = IORESOURCE_IRQ,
  120. },
  121. };
  122. static struct platform_device tmu2_device = {
  123. .name = "sh_tmu",
  124. .id = 2,
  125. .dev = {
  126. .platform_data = &tmu2_platform_data,
  127. },
  128. .resource = tmu2_resources,
  129. .num_resources = ARRAY_SIZE(tmu2_resources),
  130. };
  131. static struct sh_timer_config tmu3_platform_data = {
  132. .channel_offset = 0x04,
  133. .timer_bit = 0,
  134. };
  135. static struct resource tmu3_resources[] = {
  136. [0] = {
  137. .start = 0xffdc0008,
  138. .end = 0xffdc0013,
  139. .flags = IORESOURCE_MEM,
  140. },
  141. [1] = {
  142. .start = evt2irq(0xe00),
  143. .flags = IORESOURCE_IRQ,
  144. },
  145. };
  146. static struct platform_device tmu3_device = {
  147. .name = "sh_tmu",
  148. .id = 3,
  149. .dev = {
  150. .platform_data = &tmu3_platform_data,
  151. },
  152. .resource = tmu3_resources,
  153. .num_resources = ARRAY_SIZE(tmu3_resources),
  154. };
  155. static struct sh_timer_config tmu4_platform_data = {
  156. .channel_offset = 0x10,
  157. .timer_bit = 1,
  158. };
  159. static struct resource tmu4_resources[] = {
  160. [0] = {
  161. .start = 0xffdc0014,
  162. .end = 0xffdc001f,
  163. .flags = IORESOURCE_MEM,
  164. },
  165. [1] = {
  166. .start = evt2irq(0xe20),
  167. .flags = IORESOURCE_IRQ,
  168. },
  169. };
  170. static struct platform_device tmu4_device = {
  171. .name = "sh_tmu",
  172. .id = 4,
  173. .dev = {
  174. .platform_data = &tmu4_platform_data,
  175. },
  176. .resource = tmu4_resources,
  177. .num_resources = ARRAY_SIZE(tmu4_resources),
  178. };
  179. static struct sh_timer_config tmu5_platform_data = {
  180. .channel_offset = 0x1c,
  181. .timer_bit = 2,
  182. };
  183. static struct resource tmu5_resources[] = {
  184. [0] = {
  185. .start = 0xffdc0020,
  186. .end = 0xffdc002b,
  187. .flags = IORESOURCE_MEM,
  188. },
  189. [1] = {
  190. .start = evt2irq(0xe40),
  191. .flags = IORESOURCE_IRQ,
  192. },
  193. };
  194. static struct platform_device tmu5_device = {
  195. .name = "sh_tmu",
  196. .id = 5,
  197. .dev = {
  198. .platform_data = &tmu5_platform_data,
  199. },
  200. .resource = tmu5_resources,
  201. .num_resources = ARRAY_SIZE(tmu5_resources),
  202. };
  203. static struct resource rtc_resources[] = {
  204. [0] = {
  205. .start = 0xffe80000,
  206. .end = 0xffe80000 + 0x58 - 1,
  207. .flags = IORESOURCE_IO,
  208. },
  209. [1] = {
  210. /* Shared Period/Carry/Alarm IRQ */
  211. .start = evt2irq(0x480),
  212. .flags = IORESOURCE_IRQ,
  213. },
  214. };
  215. static struct platform_device rtc_device = {
  216. .name = "sh-rtc",
  217. .id = -1,
  218. .num_resources = ARRAY_SIZE(rtc_resources),
  219. .resource = rtc_resources,
  220. };
  221. /* DMA */
  222. static const struct sh_dmae_channel sh7780_dmae0_channels[] = {
  223. {
  224. .offset = 0,
  225. .dmars = 0,
  226. .dmars_bit = 0,
  227. }, {
  228. .offset = 0x10,
  229. .dmars = 0,
  230. .dmars_bit = 8,
  231. }, {
  232. .offset = 0x20,
  233. .dmars = 4,
  234. .dmars_bit = 0,
  235. }, {
  236. .offset = 0x30,
  237. .dmars = 4,
  238. .dmars_bit = 8,
  239. }, {
  240. .offset = 0x50,
  241. .dmars = 8,
  242. .dmars_bit = 0,
  243. }, {
  244. .offset = 0x60,
  245. .dmars = 8,
  246. .dmars_bit = 8,
  247. }
  248. };
  249. static const struct sh_dmae_channel sh7780_dmae1_channels[] = {
  250. {
  251. .offset = 0,
  252. }, {
  253. .offset = 0x10,
  254. }, {
  255. .offset = 0x20,
  256. }, {
  257. .offset = 0x30,
  258. }, {
  259. .offset = 0x50,
  260. }, {
  261. .offset = 0x60,
  262. }
  263. };
  264. static const unsigned int ts_shift[] = TS_SHIFT;
  265. static struct sh_dmae_pdata dma0_platform_data = {
  266. .channel = sh7780_dmae0_channels,
  267. .channel_num = ARRAY_SIZE(sh7780_dmae0_channels),
  268. .ts_low_shift = CHCR_TS_LOW_SHIFT,
  269. .ts_low_mask = CHCR_TS_LOW_MASK,
  270. .ts_high_shift = CHCR_TS_HIGH_SHIFT,
  271. .ts_high_mask = CHCR_TS_HIGH_MASK,
  272. .ts_shift = ts_shift,
  273. .ts_shift_num = ARRAY_SIZE(ts_shift),
  274. .dmaor_init = DMAOR_INIT,
  275. };
  276. static struct sh_dmae_pdata dma1_platform_data = {
  277. .channel = sh7780_dmae1_channels,
  278. .channel_num = ARRAY_SIZE(sh7780_dmae1_channels),
  279. .ts_low_shift = CHCR_TS_LOW_SHIFT,
  280. .ts_low_mask = CHCR_TS_LOW_MASK,
  281. .ts_high_shift = CHCR_TS_HIGH_SHIFT,
  282. .ts_high_mask = CHCR_TS_HIGH_MASK,
  283. .ts_shift = ts_shift,
  284. .ts_shift_num = ARRAY_SIZE(ts_shift),
  285. .dmaor_init = DMAOR_INIT,
  286. };
  287. static struct resource sh7780_dmae0_resources[] = {
  288. [0] = {
  289. /* Channel registers and DMAOR */
  290. .start = 0xfc808020,
  291. .end = 0xfc80808f,
  292. .flags = IORESOURCE_MEM,
  293. },
  294. [1] = {
  295. /* DMARSx */
  296. .start = 0xfc809000,
  297. .end = 0xfc80900b,
  298. .flags = IORESOURCE_MEM,
  299. },
  300. {
  301. /*
  302. * Real DMA error vector is 0x6c0, and channel
  303. * vectors are 0x640-0x6a0, 0x780-0x7a0
  304. */
  305. .name = "error_irq",
  306. .start = evt2irq(0x640),
  307. .end = evt2irq(0x640),
  308. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_SHAREABLE,
  309. },
  310. };
  311. static struct resource sh7780_dmae1_resources[] = {
  312. [0] = {
  313. /* Channel registers and DMAOR */
  314. .start = 0xfc818020,
  315. .end = 0xfc81808f,
  316. .flags = IORESOURCE_MEM,
  317. },
  318. /* DMAC1 has no DMARS */
  319. {
  320. /*
  321. * Real DMA error vector is 0x6c0, and channel
  322. * vectors are 0x7c0-0x7e0, 0xd80-0xde0
  323. */
  324. .name = "error_irq",
  325. .start = evt2irq(0x7c0),
  326. .end = evt2irq(0x7c0),
  327. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_SHAREABLE,
  328. },
  329. };
  330. static struct platform_device dma0_device = {
  331. .name = "sh-dma-engine",
  332. .id = 0,
  333. .resource = sh7780_dmae0_resources,
  334. .num_resources = ARRAY_SIZE(sh7780_dmae0_resources),
  335. .dev = {
  336. .platform_data = &dma0_platform_data,
  337. },
  338. };
  339. static struct platform_device dma1_device = {
  340. .name = "sh-dma-engine",
  341. .id = 1,
  342. .resource = sh7780_dmae1_resources,
  343. .num_resources = ARRAY_SIZE(sh7780_dmae1_resources),
  344. .dev = {
  345. .platform_data = &dma1_platform_data,
  346. },
  347. };
  348. static struct platform_device *sh7780_devices[] __initdata = {
  349. &scif0_device,
  350. &scif1_device,
  351. &tmu0_device,
  352. &tmu1_device,
  353. &tmu2_device,
  354. &tmu3_device,
  355. &tmu4_device,
  356. &tmu5_device,
  357. &rtc_device,
  358. &dma0_device,
  359. &dma1_device,
  360. };
  361. static int __init sh7780_devices_setup(void)
  362. {
  363. return platform_add_devices(sh7780_devices,
  364. ARRAY_SIZE(sh7780_devices));
  365. }
  366. arch_initcall(sh7780_devices_setup);
  367. static struct platform_device *sh7780_early_devices[] __initdata = {
  368. &scif0_device,
  369. &scif1_device,
  370. &tmu0_device,
  371. &tmu1_device,
  372. &tmu2_device,
  373. &tmu3_device,
  374. &tmu4_device,
  375. &tmu5_device,
  376. };
  377. void __init plat_early_device_setup(void)
  378. {
  379. if (mach_is_sh2007()) {
  380. scif0_platform_data.scscr &= ~SCSCR_CKE1;
  381. scif1_platform_data.scscr &= ~SCSCR_CKE1;
  382. }
  383. early_platform_add_devices(sh7780_early_devices,
  384. ARRAY_SIZE(sh7780_early_devices));
  385. }
  386. enum {
  387. UNUSED = 0,
  388. /* interrupt sources */
  389. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  390. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  391. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  392. IRL_HHLL, IRL_HHLH, IRL_HHHL,
  393. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  394. RTC, WDT, TMU0, TMU1, TMU2, TMU2_TICPI,
  395. HUDI, DMAC0, SCIF0, DMAC1, CMT, HAC,
  396. PCISERR, PCIINTA, PCIINTB, PCIINTC, PCIINTD, PCIC5,
  397. SCIF1, SIOF, HSPI, MMCIF, TMU3, TMU4, TMU5, SSI, FLCTL, GPIO,
  398. /* interrupt groups */
  399. TMU012, TMU345,
  400. };
  401. static struct intc_vect vectors[] __initdata = {
  402. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  403. INTC_VECT(RTC, 0x4c0),
  404. INTC_VECT(WDT, 0x560),
  405. INTC_VECT(TMU0, 0x580), INTC_VECT(TMU1, 0x5a0),
  406. INTC_VECT(TMU2, 0x5c0), INTC_VECT(TMU2_TICPI, 0x5e0),
  407. INTC_VECT(HUDI, 0x600),
  408. INTC_VECT(DMAC0, 0x640), INTC_VECT(DMAC0, 0x660),
  409. INTC_VECT(DMAC0, 0x680), INTC_VECT(DMAC0, 0x6a0),
  410. INTC_VECT(DMAC0, 0x6c0),
  411. INTC_VECT(SCIF0, 0x700), INTC_VECT(SCIF0, 0x720),
  412. INTC_VECT(SCIF0, 0x740), INTC_VECT(SCIF0, 0x760),
  413. INTC_VECT(DMAC0, 0x780), INTC_VECT(DMAC0, 0x7a0),
  414. INTC_VECT(DMAC1, 0x7c0), INTC_VECT(DMAC1, 0x7e0),
  415. INTC_VECT(CMT, 0x900), INTC_VECT(HAC, 0x980),
  416. INTC_VECT(PCISERR, 0xa00), INTC_VECT(PCIINTA, 0xa20),
  417. INTC_VECT(PCIINTB, 0xa40), INTC_VECT(PCIINTC, 0xa60),
  418. INTC_VECT(PCIINTD, 0xa80), INTC_VECT(PCIC5, 0xaa0),
  419. INTC_VECT(PCIC5, 0xac0), INTC_VECT(PCIC5, 0xae0),
  420. INTC_VECT(PCIC5, 0xb00), INTC_VECT(PCIC5, 0xb20),
  421. INTC_VECT(SCIF1, 0xb80), INTC_VECT(SCIF1, 0xba0),
  422. INTC_VECT(SCIF1, 0xbc0), INTC_VECT(SCIF1, 0xbe0),
  423. INTC_VECT(SIOF, 0xc00), INTC_VECT(HSPI, 0xc80),
  424. INTC_VECT(MMCIF, 0xd00), INTC_VECT(MMCIF, 0xd20),
  425. INTC_VECT(MMCIF, 0xd40), INTC_VECT(MMCIF, 0xd60),
  426. INTC_VECT(DMAC1, 0xd80), INTC_VECT(DMAC1, 0xda0),
  427. INTC_VECT(DMAC1, 0xdc0), INTC_VECT(DMAC1, 0xde0),
  428. INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20),
  429. INTC_VECT(TMU5, 0xe40),
  430. INTC_VECT(SSI, 0xe80),
  431. INTC_VECT(FLCTL, 0xf00), INTC_VECT(FLCTL, 0xf20),
  432. INTC_VECT(FLCTL, 0xf40), INTC_VECT(FLCTL, 0xf60),
  433. INTC_VECT(GPIO, 0xf80), INTC_VECT(GPIO, 0xfa0),
  434. INTC_VECT(GPIO, 0xfc0), INTC_VECT(GPIO, 0xfe0),
  435. };
  436. static struct intc_group groups[] __initdata = {
  437. INTC_GROUP(TMU012, TMU0, TMU1, TMU2, TMU2_TICPI),
  438. INTC_GROUP(TMU345, TMU3, TMU4, TMU5),
  439. };
  440. static struct intc_mask_reg mask_registers[] __initdata = {
  441. { 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */
  442. { 0, 0, 0, 0, 0, 0, GPIO, FLCTL,
  443. SSI, MMCIF, HSPI, SIOF, PCIC5, PCIINTD, PCIINTC, PCIINTB,
  444. PCIINTA, PCISERR, HAC, CMT, 0, 0, DMAC1, DMAC0,
  445. HUDI, 0, WDT, SCIF1, SCIF0, RTC, TMU345, TMU012 } },
  446. };
  447. static struct intc_prio_reg prio_registers[] __initdata = {
  448. { 0xffd40000, 0, 32, 8, /* INT2PRI0 */ { TMU0, TMU1,
  449. TMU2, TMU2_TICPI } },
  450. { 0xffd40004, 0, 32, 8, /* INT2PRI1 */ { TMU3, TMU4, TMU5, RTC } },
  451. { 0xffd40008, 0, 32, 8, /* INT2PRI2 */ { SCIF0, SCIF1, WDT } },
  452. { 0xffd4000c, 0, 32, 8, /* INT2PRI3 */ { HUDI, DMAC0, DMAC1 } },
  453. { 0xffd40010, 0, 32, 8, /* INT2PRI4 */ { CMT, HAC,
  454. PCISERR, PCIINTA, } },
  455. { 0xffd40014, 0, 32, 8, /* INT2PRI5 */ { PCIINTB, PCIINTC,
  456. PCIINTD, PCIC5 } },
  457. { 0xffd40018, 0, 32, 8, /* INT2PRI6 */ { SIOF, HSPI, MMCIF, SSI } },
  458. { 0xffd4001c, 0, 32, 8, /* INT2PRI7 */ { FLCTL, GPIO } },
  459. };
  460. static DECLARE_INTC_DESC(intc_desc, "sh7780", vectors, groups,
  461. mask_registers, prio_registers, NULL);
  462. /* Support for external interrupt pins in IRQ mode */
  463. static struct intc_vect irq_vectors[] __initdata = {
  464. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  465. INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),
  466. INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),
  467. INTC_VECT(IRQ6, 0x3c0), INTC_VECT(IRQ7, 0x200),
  468. };
  469. static struct intc_mask_reg irq_mask_registers[] __initdata = {
  470. { 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */
  471. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  472. };
  473. static struct intc_prio_reg irq_prio_registers[] __initdata = {
  474. { 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  475. IRQ4, IRQ5, IRQ6, IRQ7 } },
  476. };
  477. static struct intc_sense_reg irq_sense_registers[] __initdata = {
  478. { 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  479. IRQ4, IRQ5, IRQ6, IRQ7 } },
  480. };
  481. static struct intc_mask_reg irq_ack_registers[] __initdata = {
  482. { 0xffd00024, 0, 32, /* INTREQ */
  483. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  484. };
  485. static DECLARE_INTC_DESC_ACK(intc_irq_desc, "sh7780-irq", irq_vectors,
  486. NULL, irq_mask_registers, irq_prio_registers,
  487. irq_sense_registers, irq_ack_registers);
  488. /* External interrupt pins in IRL mode */
  489. static struct intc_vect irl_vectors[] __initdata = {
  490. INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),
  491. INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),
  492. INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),
  493. INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),
  494. INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),
  495. INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),
  496. INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),
  497. INTC_VECT(IRL_HHHL, 0x3c0),
  498. };
  499. static struct intc_mask_reg irl3210_mask_registers[] __initdata = {
  500. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  501. { IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  502. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  503. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  504. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  505. };
  506. static struct intc_mask_reg irl7654_mask_registers[] __initdata = {
  507. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  508. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  509. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  510. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  511. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  512. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  513. };
  514. static DECLARE_INTC_DESC(intc_irl7654_desc, "sh7780-irl7654", irl_vectors,
  515. NULL, irl7654_mask_registers, NULL, NULL);
  516. static DECLARE_INTC_DESC(intc_irl3210_desc, "sh7780-irl3210", irl_vectors,
  517. NULL, irl3210_mask_registers, NULL, NULL);
  518. #define INTC_ICR0 0xffd00000
  519. #define INTC_INTMSK0 0xffd00044
  520. #define INTC_INTMSK1 0xffd00048
  521. #define INTC_INTMSK2 0xffd40080
  522. #define INTC_INTMSKCLR1 0xffd00068
  523. #define INTC_INTMSKCLR2 0xffd40084
  524. void __init plat_irq_setup(void)
  525. {
  526. /* disable IRQ7-0 */
  527. __raw_writel(0xff000000, INTC_INTMSK0);
  528. /* disable IRL3-0 + IRL7-4 */
  529. __raw_writel(0xc0000000, INTC_INTMSK1);
  530. __raw_writel(0xfffefffe, INTC_INTMSK2);
  531. /* select IRL mode for IRL3-0 + IRL7-4 */
  532. __raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);
  533. /* disable holding function, ie enable "SH-4 Mode" */
  534. __raw_writel(__raw_readl(INTC_ICR0) | 0x00200000, INTC_ICR0);
  535. register_intc_controller(&intc_desc);
  536. }
  537. void __init plat_irq_setup_pins(int mode)
  538. {
  539. switch (mode) {
  540. case IRQ_MODE_IRQ:
  541. /* select IRQ mode for IRL3-0 + IRL7-4 */
  542. __raw_writel(__raw_readl(INTC_ICR0) | 0x00c00000, INTC_ICR0);
  543. register_intc_controller(&intc_irq_desc);
  544. break;
  545. case IRQ_MODE_IRL7654:
  546. /* enable IRL7-4 but don't provide any masking */
  547. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  548. __raw_writel(0x0000fffe, INTC_INTMSKCLR2);
  549. break;
  550. case IRQ_MODE_IRL3210:
  551. /* enable IRL0-3 but don't provide any masking */
  552. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  553. __raw_writel(0xfffe0000, INTC_INTMSKCLR2);
  554. break;
  555. case IRQ_MODE_IRL7654_MASK:
  556. /* enable IRL7-4 and mask using cpu intc controller */
  557. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  558. register_intc_controller(&intc_irl7654_desc);
  559. break;
  560. case IRQ_MODE_IRL3210_MASK:
  561. /* enable IRL0-3 and mask using cpu intc controller */
  562. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  563. register_intc_controller(&intc_irl3210_desc);
  564. break;
  565. default:
  566. BUG();
  567. }
  568. }