setup-sh7780.c 16 KB

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