setup-sh7780.c 16 KB

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