setup-sh7780.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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. .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. if (mach_is_sh2007()) {
  365. scif0_platform_data.scscr &= ~SCSCR_CKE1;
  366. scif0_platform_data.scbrr_algo_id = SCBRR_ALGO_2;
  367. scif1_platform_data.scscr &= ~SCSCR_CKE1;
  368. scif1_platform_data.scbrr_algo_id = SCBRR_ALGO_2;
  369. }
  370. early_platform_add_devices(sh7780_early_devices,
  371. ARRAY_SIZE(sh7780_early_devices));
  372. }
  373. enum {
  374. UNUSED = 0,
  375. /* interrupt sources */
  376. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  377. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  378. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  379. IRL_HHLL, IRL_HHLH, IRL_HHHL,
  380. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  381. RTC, WDT, TMU0, TMU1, TMU2, TMU2_TICPI,
  382. HUDI, DMAC0, SCIF0, DMAC1, CMT, HAC,
  383. PCISERR, PCIINTA, PCIINTB, PCIINTC, PCIINTD, PCIC5,
  384. SCIF1, SIOF, HSPI, MMCIF, TMU3, TMU4, TMU5, SSI, FLCTL, GPIO,
  385. /* interrupt groups */
  386. TMU012, TMU345,
  387. };
  388. static struct intc_vect vectors[] __initdata = {
  389. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  390. INTC_VECT(RTC, 0x4c0),
  391. INTC_VECT(WDT, 0x560),
  392. INTC_VECT(TMU0, 0x580), INTC_VECT(TMU1, 0x5a0),
  393. INTC_VECT(TMU2, 0x5c0), INTC_VECT(TMU2_TICPI, 0x5e0),
  394. INTC_VECT(HUDI, 0x600),
  395. INTC_VECT(DMAC0, 0x640), INTC_VECT(DMAC0, 0x660),
  396. INTC_VECT(DMAC0, 0x680), INTC_VECT(DMAC0, 0x6a0),
  397. INTC_VECT(DMAC0, 0x6c0),
  398. INTC_VECT(SCIF0, 0x700), INTC_VECT(SCIF0, 0x720),
  399. INTC_VECT(SCIF0, 0x740), INTC_VECT(SCIF0, 0x760),
  400. INTC_VECT(DMAC0, 0x780), INTC_VECT(DMAC0, 0x7a0),
  401. INTC_VECT(DMAC1, 0x7c0), INTC_VECT(DMAC1, 0x7e0),
  402. INTC_VECT(CMT, 0x900), INTC_VECT(HAC, 0x980),
  403. INTC_VECT(PCISERR, 0xa00), INTC_VECT(PCIINTA, 0xa20),
  404. INTC_VECT(PCIINTB, 0xa40), INTC_VECT(PCIINTC, 0xa60),
  405. INTC_VECT(PCIINTD, 0xa80), INTC_VECT(PCIC5, 0xaa0),
  406. INTC_VECT(PCIC5, 0xac0), INTC_VECT(PCIC5, 0xae0),
  407. INTC_VECT(PCIC5, 0xb00), INTC_VECT(PCIC5, 0xb20),
  408. INTC_VECT(SCIF1, 0xb80), INTC_VECT(SCIF1, 0xba0),
  409. INTC_VECT(SCIF1, 0xbc0), INTC_VECT(SCIF1, 0xbe0),
  410. INTC_VECT(SIOF, 0xc00), INTC_VECT(HSPI, 0xc80),
  411. INTC_VECT(MMCIF, 0xd00), INTC_VECT(MMCIF, 0xd20),
  412. INTC_VECT(MMCIF, 0xd40), INTC_VECT(MMCIF, 0xd60),
  413. INTC_VECT(DMAC1, 0xd80), INTC_VECT(DMAC1, 0xda0),
  414. INTC_VECT(DMAC1, 0xdc0), INTC_VECT(DMAC1, 0xde0),
  415. INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20),
  416. INTC_VECT(TMU5, 0xe40),
  417. INTC_VECT(SSI, 0xe80),
  418. INTC_VECT(FLCTL, 0xf00), INTC_VECT(FLCTL, 0xf20),
  419. INTC_VECT(FLCTL, 0xf40), INTC_VECT(FLCTL, 0xf60),
  420. INTC_VECT(GPIO, 0xf80), INTC_VECT(GPIO, 0xfa0),
  421. INTC_VECT(GPIO, 0xfc0), INTC_VECT(GPIO, 0xfe0),
  422. };
  423. static struct intc_group groups[] __initdata = {
  424. INTC_GROUP(TMU012, TMU0, TMU1, TMU2, TMU2_TICPI),
  425. INTC_GROUP(TMU345, TMU3, TMU4, TMU5),
  426. };
  427. static struct intc_mask_reg mask_registers[] __initdata = {
  428. { 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */
  429. { 0, 0, 0, 0, 0, 0, GPIO, FLCTL,
  430. SSI, MMCIF, HSPI, SIOF, PCIC5, PCIINTD, PCIINTC, PCIINTB,
  431. PCIINTA, PCISERR, HAC, CMT, 0, 0, DMAC1, DMAC0,
  432. HUDI, 0, WDT, SCIF1, SCIF0, RTC, TMU345, TMU012 } },
  433. };
  434. static struct intc_prio_reg prio_registers[] __initdata = {
  435. { 0xffd40000, 0, 32, 8, /* INT2PRI0 */ { TMU0, TMU1,
  436. TMU2, TMU2_TICPI } },
  437. { 0xffd40004, 0, 32, 8, /* INT2PRI1 */ { TMU3, TMU4, TMU5, RTC } },
  438. { 0xffd40008, 0, 32, 8, /* INT2PRI2 */ { SCIF0, SCIF1, WDT } },
  439. { 0xffd4000c, 0, 32, 8, /* INT2PRI3 */ { HUDI, DMAC0, DMAC1 } },
  440. { 0xffd40010, 0, 32, 8, /* INT2PRI4 */ { CMT, HAC,
  441. PCISERR, PCIINTA, } },
  442. { 0xffd40014, 0, 32, 8, /* INT2PRI5 */ { PCIINTB, PCIINTC,
  443. PCIINTD, PCIC5 } },
  444. { 0xffd40018, 0, 32, 8, /* INT2PRI6 */ { SIOF, HSPI, MMCIF, SSI } },
  445. { 0xffd4001c, 0, 32, 8, /* INT2PRI7 */ { FLCTL, GPIO } },
  446. };
  447. static DECLARE_INTC_DESC(intc_desc, "sh7780", vectors, groups,
  448. mask_registers, prio_registers, NULL);
  449. /* Support for external interrupt pins in IRQ mode */
  450. static struct intc_vect irq_vectors[] __initdata = {
  451. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  452. INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),
  453. INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),
  454. INTC_VECT(IRQ6, 0x3c0), INTC_VECT(IRQ7, 0x200),
  455. };
  456. static struct intc_mask_reg irq_mask_registers[] __initdata = {
  457. { 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */
  458. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  459. };
  460. static struct intc_prio_reg irq_prio_registers[] __initdata = {
  461. { 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  462. IRQ4, IRQ5, IRQ6, IRQ7 } },
  463. };
  464. static struct intc_sense_reg irq_sense_registers[] __initdata = {
  465. { 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  466. IRQ4, IRQ5, IRQ6, IRQ7 } },
  467. };
  468. static struct intc_mask_reg irq_ack_registers[] __initdata = {
  469. { 0xffd00024, 0, 32, /* INTREQ */
  470. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  471. };
  472. static DECLARE_INTC_DESC_ACK(intc_irq_desc, "sh7780-irq", irq_vectors,
  473. NULL, irq_mask_registers, irq_prio_registers,
  474. irq_sense_registers, irq_ack_registers);
  475. /* External interrupt pins in IRL mode */
  476. static struct intc_vect irl_vectors[] __initdata = {
  477. INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),
  478. INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),
  479. INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),
  480. INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),
  481. INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),
  482. INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),
  483. INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),
  484. INTC_VECT(IRL_HHHL, 0x3c0),
  485. };
  486. static struct intc_mask_reg irl3210_mask_registers[] __initdata = {
  487. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  488. { IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  489. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  490. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  491. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  492. };
  493. static struct intc_mask_reg irl7654_mask_registers[] __initdata = {
  494. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  495. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  496. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  497. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  498. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  499. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  500. };
  501. static DECLARE_INTC_DESC(intc_irl7654_desc, "sh7780-irl7654", irl_vectors,
  502. NULL, irl7654_mask_registers, NULL, NULL);
  503. static DECLARE_INTC_DESC(intc_irl3210_desc, "sh7780-irl3210", irl_vectors,
  504. NULL, irl3210_mask_registers, NULL, NULL);
  505. #define INTC_ICR0 0xffd00000
  506. #define INTC_INTMSK0 0xffd00044
  507. #define INTC_INTMSK1 0xffd00048
  508. #define INTC_INTMSK2 0xffd40080
  509. #define INTC_INTMSKCLR1 0xffd00068
  510. #define INTC_INTMSKCLR2 0xffd40084
  511. void __init plat_irq_setup(void)
  512. {
  513. /* disable IRQ7-0 */
  514. __raw_writel(0xff000000, INTC_INTMSK0);
  515. /* disable IRL3-0 + IRL7-4 */
  516. __raw_writel(0xc0000000, INTC_INTMSK1);
  517. __raw_writel(0xfffefffe, INTC_INTMSK2);
  518. /* select IRL mode for IRL3-0 + IRL7-4 */
  519. __raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);
  520. /* disable holding function, ie enable "SH-4 Mode" */
  521. __raw_writel(__raw_readl(INTC_ICR0) | 0x00200000, INTC_ICR0);
  522. register_intc_controller(&intc_desc);
  523. }
  524. void __init plat_irq_setup_pins(int mode)
  525. {
  526. switch (mode) {
  527. case IRQ_MODE_IRQ:
  528. /* select IRQ mode for IRL3-0 + IRL7-4 */
  529. __raw_writel(__raw_readl(INTC_ICR0) | 0x00c00000, INTC_ICR0);
  530. register_intc_controller(&intc_irq_desc);
  531. break;
  532. case IRQ_MODE_IRL7654:
  533. /* enable IRL7-4 but don't provide any masking */
  534. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  535. __raw_writel(0x0000fffe, INTC_INTMSKCLR2);
  536. break;
  537. case IRQ_MODE_IRL3210:
  538. /* enable IRL0-3 but don't provide any masking */
  539. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  540. __raw_writel(0xfffe0000, INTC_INTMSKCLR2);
  541. break;
  542. case IRQ_MODE_IRL7654_MASK:
  543. /* enable IRL7-4 and mask using cpu intc controller */
  544. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  545. register_intc_controller(&intc_irl7654_desc);
  546. break;
  547. case IRQ_MODE_IRL3210_MASK:
  548. /* enable IRL0-3 and mask using cpu intc controller */
  549. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  550. register_intc_controller(&intc_irl3210_desc);
  551. break;
  552. default:
  553. BUG();
  554. }
  555. }