setup-sh7780.c 15 KB

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