setup-sh7780.c 15 KB

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