setup-sh7770.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /*
  2. * SH7770 Setup
  3. *
  4. * Copyright (C) 2006 - 2008 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/serial_sci.h>
  14. #include <linux/sh_timer.h>
  15. #include <linux/io.h>
  16. static struct plat_sci_port scif0_platform_data = {
  17. .mapbase = 0xff923000,
  18. .flags = UPF_BOOT_AUTOCONF,
  19. .type = PORT_SCIF,
  20. .irqs = { 61, 61, 61, 61 },
  21. };
  22. static struct platform_device scif0_device = {
  23. .name = "sh-sci",
  24. .id = 0,
  25. .dev = {
  26. .platform_data = &scif0_platform_data,
  27. },
  28. };
  29. static struct plat_sci_port scif1_platform_data = {
  30. .mapbase = 0xff924000,
  31. .flags = UPF_BOOT_AUTOCONF,
  32. .type = PORT_SCIF,
  33. .irqs = { 62, 62, 62, 62 },
  34. };
  35. static struct platform_device scif1_device = {
  36. .name = "sh-sci",
  37. .id = 1,
  38. .dev = {
  39. .platform_data = &scif1_platform_data,
  40. },
  41. };
  42. static struct plat_sci_port scif2_platform_data = {
  43. .mapbase = 0xff925000,
  44. .flags = UPF_BOOT_AUTOCONF,
  45. .type = PORT_SCIF,
  46. .irqs = { 63, 63, 63, 63 },
  47. };
  48. static struct platform_device scif2_device = {
  49. .name = "sh-sci",
  50. .id = 2,
  51. .dev = {
  52. .platform_data = &scif2_platform_data,
  53. },
  54. };
  55. static struct plat_sci_port scif3_platform_data = {
  56. .mapbase = 0xff926000,
  57. .flags = UPF_BOOT_AUTOCONF,
  58. .type = PORT_SCIF,
  59. .irqs = { 64, 64, 64, 64 },
  60. };
  61. static struct platform_device scif3_device = {
  62. .name = "sh-sci",
  63. .id = 3,
  64. .dev = {
  65. .platform_data = &scif3_platform_data,
  66. },
  67. };
  68. static struct plat_sci_port scif4_platform_data = {
  69. .mapbase = 0xff927000,
  70. .flags = UPF_BOOT_AUTOCONF,
  71. .type = PORT_SCIF,
  72. .irqs = { 65, 65, 65, 65 },
  73. };
  74. static struct platform_device scif4_device = {
  75. .name = "sh-sci",
  76. .id = 4,
  77. .dev = {
  78. .platform_data = &scif4_platform_data,
  79. },
  80. };
  81. static struct plat_sci_port scif5_platform_data = {
  82. .mapbase = 0xff928000,
  83. .flags = UPF_BOOT_AUTOCONF,
  84. .type = PORT_SCIF,
  85. .irqs = { 66, 66, 66, 66 },
  86. };
  87. static struct platform_device scif5_device = {
  88. .name = "sh-sci",
  89. .id = 5,
  90. .dev = {
  91. .platform_data = &scif5_platform_data,
  92. },
  93. };
  94. static struct plat_sci_port scif6_platform_data = {
  95. .mapbase = 0xff929000,
  96. .flags = UPF_BOOT_AUTOCONF,
  97. .type = PORT_SCIF,
  98. .irqs = { 67, 67, 67, 67 },
  99. };
  100. static struct platform_device scif6_device = {
  101. .name = "sh-sci",
  102. .id = 6,
  103. .dev = {
  104. .platform_data = &scif6_platform_data,
  105. },
  106. };
  107. static struct plat_sci_port scif7_platform_data = {
  108. .mapbase = 0xff92a000,
  109. .flags = UPF_BOOT_AUTOCONF,
  110. .type = PORT_SCIF,
  111. .irqs = { 68, 68, 68, 68 },
  112. };
  113. static struct platform_device scif7_device = {
  114. .name = "sh-sci",
  115. .id = 7,
  116. .dev = {
  117. .platform_data = &scif7_platform_data,
  118. },
  119. };
  120. static struct plat_sci_port scif8_platform_data = {
  121. .mapbase = 0xff92b000,
  122. .flags = UPF_BOOT_AUTOCONF,
  123. .type = PORT_SCIF,
  124. .irqs = { 69, 69, 69, 69 },
  125. };
  126. static struct platform_device scif8_device = {
  127. .name = "sh-sci",
  128. .id = 8,
  129. .dev = {
  130. .platform_data = &scif8_platform_data,
  131. },
  132. };
  133. static struct plat_sci_port scif9_platform_data = {
  134. .mapbase = 0xff92c000,
  135. .flags = UPF_BOOT_AUTOCONF,
  136. .type = PORT_SCIF,
  137. .irqs = { 70, 70, 70, 70 },
  138. };
  139. static struct platform_device scif9_device = {
  140. .name = "sh-sci",
  141. .id = 9,
  142. .dev = {
  143. .platform_data = &scif9_platform_data,
  144. },
  145. };
  146. static struct sh_timer_config tmu0_platform_data = {
  147. .channel_offset = 0x04,
  148. .timer_bit = 0,
  149. .clockevent_rating = 200,
  150. };
  151. static struct resource tmu0_resources[] = {
  152. [0] = {
  153. .start = 0xffd80008,
  154. .end = 0xffd80013,
  155. .flags = IORESOURCE_MEM,
  156. },
  157. [1] = {
  158. .start = 16,
  159. .flags = IORESOURCE_IRQ,
  160. },
  161. };
  162. static struct platform_device tmu0_device = {
  163. .name = "sh_tmu",
  164. .id = 0,
  165. .dev = {
  166. .platform_data = &tmu0_platform_data,
  167. },
  168. .resource = tmu0_resources,
  169. .num_resources = ARRAY_SIZE(tmu0_resources),
  170. };
  171. static struct sh_timer_config tmu1_platform_data = {
  172. .channel_offset = 0x10,
  173. .timer_bit = 1,
  174. .clocksource_rating = 200,
  175. };
  176. static struct resource tmu1_resources[] = {
  177. [0] = {
  178. .start = 0xffd80014,
  179. .end = 0xffd8001f,
  180. .flags = IORESOURCE_MEM,
  181. },
  182. [1] = {
  183. .start = 17,
  184. .flags = IORESOURCE_IRQ,
  185. },
  186. };
  187. static struct platform_device tmu1_device = {
  188. .name = "sh_tmu",
  189. .id = 1,
  190. .dev = {
  191. .platform_data = &tmu1_platform_data,
  192. },
  193. .resource = tmu1_resources,
  194. .num_resources = ARRAY_SIZE(tmu1_resources),
  195. };
  196. static struct sh_timer_config tmu2_platform_data = {
  197. .channel_offset = 0x1c,
  198. .timer_bit = 2,
  199. };
  200. static struct resource tmu2_resources[] = {
  201. [0] = {
  202. .start = 0xffd80020,
  203. .end = 0xffd8002f,
  204. .flags = IORESOURCE_MEM,
  205. },
  206. [1] = {
  207. .start = 18,
  208. .flags = IORESOURCE_IRQ,
  209. },
  210. };
  211. static struct platform_device tmu2_device = {
  212. .name = "sh_tmu",
  213. .id = 2,
  214. .dev = {
  215. .platform_data = &tmu2_platform_data,
  216. },
  217. .resource = tmu2_resources,
  218. .num_resources = ARRAY_SIZE(tmu2_resources),
  219. };
  220. static struct sh_timer_config tmu3_platform_data = {
  221. .channel_offset = 0x04,
  222. .timer_bit = 0,
  223. };
  224. static struct resource tmu3_resources[] = {
  225. [0] = {
  226. .start = 0xffd81008,
  227. .end = 0xffd81013,
  228. .flags = IORESOURCE_MEM,
  229. },
  230. [1] = {
  231. .start = 19,
  232. .flags = IORESOURCE_IRQ,
  233. },
  234. };
  235. static struct platform_device tmu3_device = {
  236. .name = "sh_tmu",
  237. .id = 3,
  238. .dev = {
  239. .platform_data = &tmu3_platform_data,
  240. },
  241. .resource = tmu3_resources,
  242. .num_resources = ARRAY_SIZE(tmu3_resources),
  243. };
  244. static struct sh_timer_config tmu4_platform_data = {
  245. .channel_offset = 0x10,
  246. .timer_bit = 1,
  247. };
  248. static struct resource tmu4_resources[] = {
  249. [0] = {
  250. .start = 0xffd81014,
  251. .end = 0xffd8101f,
  252. .flags = IORESOURCE_MEM,
  253. },
  254. [1] = {
  255. .start = 20,
  256. .flags = IORESOURCE_IRQ,
  257. },
  258. };
  259. static struct platform_device tmu4_device = {
  260. .name = "sh_tmu",
  261. .id = 4,
  262. .dev = {
  263. .platform_data = &tmu4_platform_data,
  264. },
  265. .resource = tmu4_resources,
  266. .num_resources = ARRAY_SIZE(tmu4_resources),
  267. };
  268. static struct sh_timer_config tmu5_platform_data = {
  269. .channel_offset = 0x1c,
  270. .timer_bit = 2,
  271. };
  272. static struct resource tmu5_resources[] = {
  273. [0] = {
  274. .start = 0xffd81020,
  275. .end = 0xffd8102f,
  276. .flags = IORESOURCE_MEM,
  277. },
  278. [1] = {
  279. .start = 21,
  280. .flags = IORESOURCE_IRQ,
  281. },
  282. };
  283. static struct platform_device tmu5_device = {
  284. .name = "sh_tmu",
  285. .id = 5,
  286. .dev = {
  287. .platform_data = &tmu5_platform_data,
  288. },
  289. .resource = tmu5_resources,
  290. .num_resources = ARRAY_SIZE(tmu5_resources),
  291. };
  292. static struct sh_timer_config tmu6_platform_data = {
  293. .channel_offset = 0x04,
  294. .timer_bit = 0,
  295. };
  296. static struct resource tmu6_resources[] = {
  297. [0] = {
  298. .start = 0xffd82008,
  299. .end = 0xffd82013,
  300. .flags = IORESOURCE_MEM,
  301. },
  302. [1] = {
  303. .start = 22,
  304. .flags = IORESOURCE_IRQ,
  305. },
  306. };
  307. static struct platform_device tmu6_device = {
  308. .name = "sh_tmu",
  309. .id = 6,
  310. .dev = {
  311. .platform_data = &tmu6_platform_data,
  312. },
  313. .resource = tmu6_resources,
  314. .num_resources = ARRAY_SIZE(tmu6_resources),
  315. };
  316. static struct sh_timer_config tmu7_platform_data = {
  317. .channel_offset = 0x10,
  318. .timer_bit = 1,
  319. };
  320. static struct resource tmu7_resources[] = {
  321. [0] = {
  322. .start = 0xffd82014,
  323. .end = 0xffd8201f,
  324. .flags = IORESOURCE_MEM,
  325. },
  326. [1] = {
  327. .start = 23,
  328. .flags = IORESOURCE_IRQ,
  329. },
  330. };
  331. static struct platform_device tmu7_device = {
  332. .name = "sh_tmu",
  333. .id = 7,
  334. .dev = {
  335. .platform_data = &tmu7_platform_data,
  336. },
  337. .resource = tmu7_resources,
  338. .num_resources = ARRAY_SIZE(tmu7_resources),
  339. };
  340. static struct sh_timer_config tmu8_platform_data = {
  341. .channel_offset = 0x1c,
  342. .timer_bit = 2,
  343. };
  344. static struct resource tmu8_resources[] = {
  345. [0] = {
  346. .start = 0xffd82020,
  347. .end = 0xffd8202b,
  348. .flags = IORESOURCE_MEM,
  349. },
  350. [1] = {
  351. .start = 24,
  352. .flags = IORESOURCE_IRQ,
  353. },
  354. };
  355. static struct platform_device tmu8_device = {
  356. .name = "sh_tmu",
  357. .id = 8,
  358. .dev = {
  359. .platform_data = &tmu8_platform_data,
  360. },
  361. .resource = tmu8_resources,
  362. .num_resources = ARRAY_SIZE(tmu8_resources),
  363. };
  364. static struct platform_device *sh7770_devices[] __initdata = {
  365. &scif0_device,
  366. &scif1_device,
  367. &scif2_device,
  368. &scif3_device,
  369. &scif4_device,
  370. &scif5_device,
  371. &scif6_device,
  372. &scif7_device,
  373. &scif8_device,
  374. &scif9_device,
  375. &tmu0_device,
  376. &tmu1_device,
  377. &tmu2_device,
  378. &tmu3_device,
  379. &tmu4_device,
  380. &tmu5_device,
  381. &tmu6_device,
  382. &tmu7_device,
  383. &tmu8_device,
  384. };
  385. static int __init sh7770_devices_setup(void)
  386. {
  387. return platform_add_devices(sh7770_devices,
  388. ARRAY_SIZE(sh7770_devices));
  389. }
  390. arch_initcall(sh7770_devices_setup);
  391. static struct platform_device *sh7770_early_devices[] __initdata = {
  392. &scif0_device,
  393. &scif1_device,
  394. &scif2_device,
  395. &scif3_device,
  396. &scif4_device,
  397. &scif5_device,
  398. &scif6_device,
  399. &scif7_device,
  400. &scif8_device,
  401. &scif9_device,
  402. &tmu0_device,
  403. &tmu1_device,
  404. &tmu2_device,
  405. &tmu3_device,
  406. &tmu4_device,
  407. &tmu5_device,
  408. &tmu6_device,
  409. &tmu7_device,
  410. &tmu8_device,
  411. };
  412. void __init plat_early_device_setup(void)
  413. {
  414. early_platform_add_devices(sh7770_early_devices,
  415. ARRAY_SIZE(sh7770_early_devices));
  416. }
  417. enum {
  418. UNUSED = 0,
  419. /* interrupt sources */
  420. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  421. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  422. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  423. IRL_HHLL, IRL_HHLH, IRL_HHHL,
  424. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
  425. GPIO,
  426. TMU0, TMU1, TMU2, TMU2_TICPI,
  427. TMU3, TMU4, TMU5, TMU5_TICPI,
  428. TMU6, TMU7, TMU8,
  429. HAC, IPI, SPDIF, HUDI, I2C,
  430. DMAC0_DMINT0, DMAC0_DMINT1, DMAC0_DMINT2,
  431. I2S0, I2S1, I2S2, I2S3,
  432. SRC_RX, SRC_TX, SRC_SPDIF,
  433. DU, VIDEO_IN, REMOTE, YUV, USB, ATAPI, CAN, GPS, GFX2D,
  434. GFX3D_MBX, GFX3D_DMAC,
  435. EXBUS_ATA,
  436. SPI0, SPI1,
  437. SCIF089, SCIF1234, SCIF567,
  438. ADC,
  439. BBDMAC_0_3, BBDMAC_4_7, BBDMAC_8_10, BBDMAC_11_14,
  440. BBDMAC_15_18, BBDMAC_19_22, BBDMAC_23_26, BBDMAC_27,
  441. BBDMAC_28, BBDMAC_29, BBDMAC_30, BBDMAC_31,
  442. /* interrupt groups */
  443. TMU, DMAC, I2S, SRC, GFX3D, SPI, SCIF, BBDMAC,
  444. };
  445. static struct intc_vect vectors[] __initdata = {
  446. INTC_VECT(GPIO, 0x3e0),
  447. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  448. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2_TICPI, 0x460),
  449. INTC_VECT(TMU3, 0x480), INTC_VECT(TMU4, 0x4a0),
  450. INTC_VECT(TMU5, 0x4c0), INTC_VECT(TMU5_TICPI, 0x4e0),
  451. INTC_VECT(TMU6, 0x500), INTC_VECT(TMU7, 0x520),
  452. INTC_VECT(TMU8, 0x540),
  453. INTC_VECT(HAC, 0x580), INTC_VECT(IPI, 0x5c0),
  454. INTC_VECT(SPDIF, 0x5e0),
  455. INTC_VECT(HUDI, 0x600), INTC_VECT(I2C, 0x620),
  456. INTC_VECT(DMAC0_DMINT0, 0x640), INTC_VECT(DMAC0_DMINT1, 0x660),
  457. INTC_VECT(DMAC0_DMINT2, 0x680),
  458. INTC_VECT(I2S0, 0x6a0), INTC_VECT(I2S1, 0x6c0),
  459. INTC_VECT(I2S2, 0x6e0), INTC_VECT(I2S3, 0x700),
  460. INTC_VECT(SRC_RX, 0x720), INTC_VECT(SRC_TX, 0x740),
  461. INTC_VECT(SRC_SPDIF, 0x760),
  462. INTC_VECT(DU, 0x780), INTC_VECT(VIDEO_IN, 0x7a0),
  463. INTC_VECT(REMOTE, 0x7c0), INTC_VECT(YUV, 0x7e0),
  464. INTC_VECT(USB, 0x840), INTC_VECT(ATAPI, 0x860),
  465. INTC_VECT(CAN, 0x880), INTC_VECT(GPS, 0x8a0),
  466. INTC_VECT(GFX2D, 0x8c0),
  467. INTC_VECT(GFX3D_MBX, 0x900), INTC_VECT(GFX3D_DMAC, 0x920),
  468. INTC_VECT(EXBUS_ATA, 0x940),
  469. INTC_VECT(SPI0, 0x960), INTC_VECT(SPI1, 0x980),
  470. INTC_VECT(SCIF089, 0x9a0), INTC_VECT(SCIF1234, 0x9c0),
  471. INTC_VECT(SCIF1234, 0x9e0), INTC_VECT(SCIF1234, 0xa00),
  472. INTC_VECT(SCIF1234, 0xa20), INTC_VECT(SCIF567, 0xa40),
  473. INTC_VECT(SCIF567, 0xa60), INTC_VECT(SCIF567, 0xa80),
  474. INTC_VECT(SCIF089, 0xaa0), INTC_VECT(SCIF089, 0xac0),
  475. INTC_VECT(ADC, 0xb20),
  476. INTC_VECT(BBDMAC_0_3, 0xba0), INTC_VECT(BBDMAC_0_3, 0xbc0),
  477. INTC_VECT(BBDMAC_0_3, 0xbe0), INTC_VECT(BBDMAC_0_3, 0xc00),
  478. INTC_VECT(BBDMAC_4_7, 0xc20), INTC_VECT(BBDMAC_4_7, 0xc40),
  479. INTC_VECT(BBDMAC_4_7, 0xc60), INTC_VECT(BBDMAC_4_7, 0xc80),
  480. INTC_VECT(BBDMAC_8_10, 0xca0), INTC_VECT(BBDMAC_8_10, 0xcc0),
  481. INTC_VECT(BBDMAC_8_10, 0xce0), INTC_VECT(BBDMAC_11_14, 0xd00),
  482. INTC_VECT(BBDMAC_11_14, 0xd20), INTC_VECT(BBDMAC_11_14, 0xd40),
  483. INTC_VECT(BBDMAC_11_14, 0xd60), INTC_VECT(BBDMAC_15_18, 0xd80),
  484. INTC_VECT(BBDMAC_15_18, 0xda0), INTC_VECT(BBDMAC_15_18, 0xdc0),
  485. INTC_VECT(BBDMAC_15_18, 0xde0), INTC_VECT(BBDMAC_19_22, 0xe00),
  486. INTC_VECT(BBDMAC_19_22, 0xe20), INTC_VECT(BBDMAC_19_22, 0xe40),
  487. INTC_VECT(BBDMAC_19_22, 0xe60), INTC_VECT(BBDMAC_23_26, 0xe80),
  488. INTC_VECT(BBDMAC_23_26, 0xea0), INTC_VECT(BBDMAC_23_26, 0xec0),
  489. INTC_VECT(BBDMAC_23_26, 0xee0), INTC_VECT(BBDMAC_27, 0xf00),
  490. INTC_VECT(BBDMAC_28, 0xf20), INTC_VECT(BBDMAC_29, 0xf40),
  491. INTC_VECT(BBDMAC_30, 0xf60), INTC_VECT(BBDMAC_31, 0xf80),
  492. };
  493. static struct intc_group groups[] __initdata = {
  494. INTC_GROUP(TMU, TMU0, TMU1, TMU2, TMU2_TICPI, TMU3, TMU4, TMU5,
  495. TMU5_TICPI, TMU6, TMU7, TMU8),
  496. INTC_GROUP(DMAC, DMAC0_DMINT0, DMAC0_DMINT1, DMAC0_DMINT2),
  497. INTC_GROUP(I2S, I2S0, I2S1, I2S2, I2S3),
  498. INTC_GROUP(SRC, SRC_RX, SRC_TX, SRC_SPDIF),
  499. INTC_GROUP(GFX3D, GFX3D_MBX, GFX3D_DMAC),
  500. INTC_GROUP(SPI, SPI0, SPI1),
  501. INTC_GROUP(SCIF, SCIF089, SCIF1234, SCIF567),
  502. INTC_GROUP(BBDMAC,
  503. BBDMAC_0_3, BBDMAC_4_7, BBDMAC_8_10, BBDMAC_11_14,
  504. BBDMAC_15_18, BBDMAC_19_22, BBDMAC_23_26, BBDMAC_27,
  505. BBDMAC_28, BBDMAC_29, BBDMAC_30, BBDMAC_31),
  506. };
  507. static struct intc_mask_reg mask_registers[] __initdata = {
  508. { 0xffe00040, 0xffe00044, 32, /* INT2MSKR / INT2MSKCR */
  509. { 0, BBDMAC, ADC, SCIF, SPI, EXBUS_ATA, GFX3D, GFX2D,
  510. GPS, CAN, ATAPI, USB, YUV, REMOTE, VIDEO_IN, DU, SRC, I2S,
  511. DMAC, I2C, HUDI, SPDIF, IPI, HAC, TMU, GPIO } },
  512. };
  513. static struct intc_prio_reg prio_registers[] __initdata = {
  514. { 0xffe00000, 0, 32, 8, /* INT2PRI0 */ { GPIO, TMU0, 0, HAC } },
  515. { 0xffe00004, 0, 32, 8, /* INT2PRI1 */ { IPI, SPDIF, HUDI, I2C } },
  516. { 0xffe00008, 0, 32, 8, /* INT2PRI2 */ { DMAC, I2S, SRC, DU } },
  517. { 0xffe0000c, 0, 32, 8, /* INT2PRI3 */ { VIDEO_IN, REMOTE, YUV, USB } },
  518. { 0xffe00010, 0, 32, 8, /* INT2PRI4 */ { ATAPI, CAN, GPS, GFX2D } },
  519. { 0xffe00014, 0, 32, 8, /* INT2PRI5 */ { 0, GFX3D, EXBUS_ATA, SPI } },
  520. { 0xffe00018, 0, 32, 8, /* INT2PRI6 */ { SCIF1234, SCIF567, SCIF089 } },
  521. { 0xffe0001c, 0, 32, 8, /* INT2PRI7 */ { ADC, 0, 0, BBDMAC_0_3 } },
  522. { 0xffe00020, 0, 32, 8, /* INT2PRI8 */
  523. { BBDMAC_4_7, BBDMAC_8_10, BBDMAC_11_14, BBDMAC_15_18 } },
  524. { 0xffe00024, 0, 32, 8, /* INT2PRI9 */
  525. { BBDMAC_19_22, BBDMAC_23_26, BBDMAC_27, BBDMAC_28 } },
  526. { 0xffe00028, 0, 32, 8, /* INT2PRI10 */
  527. { BBDMAC_29, BBDMAC_30, BBDMAC_31 } },
  528. { 0xffe0002c, 0, 32, 8, /* INT2PRI11 */
  529. { TMU1, TMU2, TMU2_TICPI, TMU3 } },
  530. { 0xffe00030, 0, 32, 8, /* INT2PRI12 */
  531. { TMU4, TMU5, TMU5_TICPI, TMU6 } },
  532. { 0xffe00034, 0, 32, 8, /* INT2PRI13 */
  533. { TMU7, TMU8 } },
  534. };
  535. static DECLARE_INTC_DESC(intc_desc, "sh7770", vectors, groups,
  536. mask_registers, prio_registers, NULL);
  537. /* Support for external interrupt pins in IRQ mode */
  538. static struct intc_vect irq_vectors[] __initdata = {
  539. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  540. INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),
  541. INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),
  542. };
  543. static struct intc_mask_reg irq_mask_registers[] __initdata = {
  544. { 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */
  545. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, } },
  546. };
  547. static struct intc_prio_reg irq_prio_registers[] __initdata = {
  548. { 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  549. IRQ4, IRQ5, } },
  550. };
  551. static struct intc_sense_reg irq_sense_registers[] __initdata = {
  552. { 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  553. IRQ4, IRQ5, } },
  554. };
  555. static DECLARE_INTC_DESC(intc_irq_desc, "sh7770-irq", irq_vectors,
  556. NULL, irq_mask_registers, irq_prio_registers,
  557. irq_sense_registers);
  558. /* External interrupt pins in IRL mode */
  559. static struct intc_vect irl_vectors[] __initdata = {
  560. INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),
  561. INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),
  562. INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),
  563. INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),
  564. INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),
  565. INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),
  566. INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),
  567. INTC_VECT(IRL_HHHL, 0x3c0),
  568. };
  569. static struct intc_mask_reg irl3210_mask_registers[] __initdata = {
  570. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  571. { IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  572. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  573. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  574. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  575. };
  576. static struct intc_mask_reg irl7654_mask_registers[] __initdata = {
  577. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  578. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  579. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  580. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  581. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  582. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  583. };
  584. static DECLARE_INTC_DESC(intc_irl7654_desc, "sh7780-irl7654", irl_vectors,
  585. NULL, irl7654_mask_registers, NULL, NULL);
  586. static DECLARE_INTC_DESC(intc_irl3210_desc, "sh7780-irl3210", irl_vectors,
  587. NULL, irl3210_mask_registers, NULL, NULL);
  588. #define INTC_ICR0 0xffd00000
  589. #define INTC_INTMSK0 0xffd00044
  590. #define INTC_INTMSK1 0xffd00048
  591. #define INTC_INTMSK2 0xffd40080
  592. #define INTC_INTMSKCLR1 0xffd00068
  593. #define INTC_INTMSKCLR2 0xffd40084
  594. void __init plat_irq_setup(void)
  595. {
  596. /* disable IRQ7-0 */
  597. __raw_writel(0xff000000, INTC_INTMSK0);
  598. /* disable IRL3-0 + IRL7-4 */
  599. __raw_writel(0xc0000000, INTC_INTMSK1);
  600. __raw_writel(0xfffefffe, INTC_INTMSK2);
  601. /* select IRL mode for IRL3-0 + IRL7-4 */
  602. __raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);
  603. /* disable holding function, ie enable "SH-4 Mode" */
  604. __raw_writel(__raw_readl(INTC_ICR0) | 0x00200000, INTC_ICR0);
  605. register_intc_controller(&intc_desc);
  606. }
  607. void __init plat_irq_setup_pins(int mode)
  608. {
  609. switch (mode) {
  610. case IRQ_MODE_IRQ:
  611. /* select IRQ mode for IRL3-0 + IRL7-4 */
  612. __raw_writel(__raw_readl(INTC_ICR0) | 0x00c00000, INTC_ICR0);
  613. register_intc_controller(&intc_irq_desc);
  614. break;
  615. case IRQ_MODE_IRL7654:
  616. /* enable IRL7-4 but don't provide any masking */
  617. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  618. __raw_writel(0x0000fffe, INTC_INTMSKCLR2);
  619. break;
  620. case IRQ_MODE_IRL3210:
  621. /* enable IRL0-3 but don't provide any masking */
  622. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  623. __raw_writel(0xfffe0000, INTC_INTMSKCLR2);
  624. break;
  625. case IRQ_MODE_IRL7654_MASK:
  626. /* enable IRL7-4 and mask using cpu intc controller */
  627. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  628. register_intc_controller(&intc_irl7654_desc);
  629. break;
  630. case IRQ_MODE_IRL3210_MASK:
  631. /* enable IRL0-3 and mask using cpu intc controller */
  632. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  633. register_intc_controller(&intc_irl3210_desc);
  634. break;
  635. default:
  636. BUG();
  637. }
  638. }