setup-sh7780.c 16 KB

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