setup-sh7734.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. /*
  2. * arch/sh/kernel/cpu/sh4a/setup-sh7734.c
  3. * SH7734 Setup
  4. *
  5. * Copyright (C) 2011,2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
  6. * Copyright (C) 2011,2012 Renesas Solutions Corp.
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/platform_device.h>
  13. #include <linux/init.h>
  14. #include <linux/serial.h>
  15. #include <linux/mm.h>
  16. #include <linux/dma-mapping.h>
  17. #include <linux/serial_sci.h>
  18. #include <linux/sh_timer.h>
  19. #include <linux/io.h>
  20. #include <asm/clock.h>
  21. #include <asm/irq.h>
  22. #include <cpu/sh7734.h>
  23. /* SCIF */
  24. static struct plat_sci_port scif0_platform_data = {
  25. .mapbase = 0xFFE40000,
  26. .flags = UPF_BOOT_AUTOCONF,
  27. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  28. .scbrr_algo_id = SCBRR_ALGO_2,
  29. .type = PORT_SCIF,
  30. .irqs = SCIx_IRQ_MUXED(evt2irq(0x8C0)),
  31. .regtype = SCIx_SH4_SCIF_REGTYPE,
  32. };
  33. static struct platform_device scif0_device = {
  34. .name = "sh-sci",
  35. .id = 0,
  36. .dev = {
  37. .platform_data = &scif0_platform_data,
  38. },
  39. };
  40. static struct plat_sci_port scif1_platform_data = {
  41. .mapbase = 0xFFE41000,
  42. .flags = UPF_BOOT_AUTOCONF,
  43. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  44. .scbrr_algo_id = SCBRR_ALGO_2,
  45. .type = PORT_SCIF,
  46. .irqs = SCIx_IRQ_MUXED(evt2irq(0x8E0)),
  47. .regtype = SCIx_SH4_SCIF_REGTYPE,
  48. };
  49. static struct platform_device scif1_device = {
  50. .name = "sh-sci",
  51. .id = 1,
  52. .dev = {
  53. .platform_data = &scif1_platform_data,
  54. },
  55. };
  56. static struct plat_sci_port scif2_platform_data = {
  57. .mapbase = 0xFFE42000,
  58. .flags = UPF_BOOT_AUTOCONF,
  59. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  60. .scbrr_algo_id = SCBRR_ALGO_2,
  61. .type = PORT_SCIF,
  62. .irqs = SCIx_IRQ_MUXED(evt2irq(0x900)),
  63. .regtype = SCIx_SH4_SCIF_REGTYPE,
  64. };
  65. static struct platform_device scif2_device = {
  66. .name = "sh-sci",
  67. .id = 2,
  68. .dev = {
  69. .platform_data = &scif2_platform_data,
  70. },
  71. };
  72. static struct plat_sci_port scif3_platform_data = {
  73. .mapbase = 0xFFE43000,
  74. .flags = UPF_BOOT_AUTOCONF,
  75. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  76. .scbrr_algo_id = SCBRR_ALGO_2,
  77. .type = PORT_SCIF,
  78. .irqs = SCIx_IRQ_MUXED(evt2irq(0x920)),
  79. .regtype = SCIx_SH4_SCIF_REGTYPE,
  80. };
  81. static struct platform_device scif3_device = {
  82. .name = "sh-sci",
  83. .id = 3,
  84. .dev = {
  85. .platform_data = &scif3_platform_data,
  86. },
  87. };
  88. static struct plat_sci_port scif4_platform_data = {
  89. .mapbase = 0xFFE44000,
  90. .flags = UPF_BOOT_AUTOCONF,
  91. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  92. .scbrr_algo_id = SCBRR_ALGO_2,
  93. .type = PORT_SCIF,
  94. .irqs = SCIx_IRQ_MUXED(evt2irq(0x940)),
  95. .regtype = SCIx_SH4_SCIF_REGTYPE,
  96. };
  97. static struct platform_device scif4_device = {
  98. .name = "sh-sci",
  99. .id = 4,
  100. .dev = {
  101. .platform_data = &scif4_platform_data,
  102. },
  103. };
  104. static struct plat_sci_port scif5_platform_data = {
  105. .mapbase = 0xFFE43000,
  106. .flags = UPF_BOOT_AUTOCONF,
  107. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE,
  108. .scbrr_algo_id = SCBRR_ALGO_2,
  109. .type = PORT_SCIF,
  110. .irqs = SCIx_IRQ_MUXED(evt2irq(0x960)),
  111. .regtype = SCIx_SH4_SCIF_REGTYPE,
  112. };
  113. static struct platform_device scif5_device = {
  114. .name = "sh-sci",
  115. .id = 5,
  116. .dev = {
  117. .platform_data = &scif5_platform_data,
  118. },
  119. };
  120. /* RTC */
  121. static struct resource rtc_resources[] = {
  122. [0] = {
  123. .name = "rtc",
  124. .start = 0xFFFC5000,
  125. .end = 0xFFFC5000 + 0x26 - 1,
  126. .flags = IORESOURCE_IO,
  127. },
  128. [1] = {
  129. .start = evt2irq(0xC00),
  130. .flags = IORESOURCE_IRQ,
  131. },
  132. };
  133. static struct platform_device rtc_device = {
  134. .name = "sh-rtc",
  135. .id = -1,
  136. .num_resources = ARRAY_SIZE(rtc_resources),
  137. .resource = rtc_resources,
  138. };
  139. /* I2C 0 */
  140. static struct resource i2c0_resources[] = {
  141. [0] = {
  142. .name = "IIC0",
  143. .start = 0xFFC70000,
  144. .end = 0xFFC7000A - 1,
  145. .flags = IORESOURCE_MEM,
  146. },
  147. [1] = {
  148. .start = evt2irq(0x860),
  149. .flags = IORESOURCE_IRQ,
  150. },
  151. };
  152. static struct platform_device i2c0_device = {
  153. .name = "i2c-sh7734",
  154. .id = 0,
  155. .num_resources = ARRAY_SIZE(i2c0_resources),
  156. .resource = i2c0_resources,
  157. };
  158. /* TMU */
  159. static struct sh_timer_config tmu0_platform_data = {
  160. .channel_offset = 0x04,
  161. .timer_bit = 0,
  162. .clockevent_rating = 200,
  163. };
  164. static struct resource tmu0_resources[] = {
  165. [0] = {
  166. .start = 0xFFD80008,
  167. .end = 0xFFD80014 - 1,
  168. .flags = IORESOURCE_MEM,
  169. },
  170. [1] = {
  171. .start = evt2irq(0x400),
  172. .flags = IORESOURCE_IRQ,
  173. },
  174. };
  175. static struct platform_device tmu0_device = {
  176. .name = "sh_tmu",
  177. .id = 0,
  178. .dev = {
  179. .platform_data = &tmu0_platform_data,
  180. },
  181. .resource = tmu0_resources,
  182. .num_resources = ARRAY_SIZE(tmu0_resources),
  183. };
  184. static struct sh_timer_config tmu1_platform_data = {
  185. .channel_offset = 0x10,
  186. .timer_bit = 1,
  187. .clocksource_rating = 200,
  188. };
  189. static struct resource tmu1_resources[] = {
  190. [0] = {
  191. .start = 0xFFD80014,
  192. .end = 0xFFD80020 - 1,
  193. .flags = IORESOURCE_MEM,
  194. },
  195. [1] = {
  196. .start = evt2irq(0x420),
  197. .flags = IORESOURCE_IRQ,
  198. },
  199. };
  200. static struct platform_device tmu1_device = {
  201. .name = "sh_tmu",
  202. .id = 1,
  203. .dev = {
  204. .platform_data = &tmu1_platform_data,
  205. },
  206. .resource = tmu1_resources,
  207. .num_resources = ARRAY_SIZE(tmu1_resources),
  208. };
  209. static struct sh_timer_config tmu2_platform_data = {
  210. .channel_offset = 0x1c,
  211. .timer_bit = 2,
  212. };
  213. static struct resource tmu2_resources[] = {
  214. [0] = {
  215. .start = 0xFFD80020,
  216. .end = 0xFFD80030 - 1,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. [1] = {
  220. .start = evt2irq(0x440),
  221. .flags = IORESOURCE_IRQ,
  222. },
  223. };
  224. static struct platform_device tmu2_device = {
  225. .name = "sh_tmu",
  226. .id = 2,
  227. .dev = {
  228. .platform_data = &tmu2_platform_data,
  229. },
  230. .resource = tmu2_resources,
  231. .num_resources = ARRAY_SIZE(tmu2_resources),
  232. };
  233. static struct sh_timer_config tmu3_platform_data = {
  234. .channel_offset = 0x04,
  235. .timer_bit = 0,
  236. };
  237. static struct resource tmu3_resources[] = {
  238. [0] = {
  239. .start = 0xFFD81008,
  240. .end = 0xFFD81014 - 1,
  241. .flags = IORESOURCE_MEM,
  242. },
  243. [1] = {
  244. .start = evt2irq(0x480),
  245. .flags = IORESOURCE_IRQ,
  246. },
  247. };
  248. static struct platform_device tmu3_device = {
  249. .name = "sh_tmu",
  250. .id = 3,
  251. .dev = {
  252. .platform_data = &tmu3_platform_data,
  253. },
  254. .resource = tmu3_resources,
  255. .num_resources = ARRAY_SIZE(tmu3_resources),
  256. };
  257. static struct sh_timer_config tmu4_platform_data = {
  258. .channel_offset = 0x10,
  259. .timer_bit = 1,
  260. };
  261. static struct resource tmu4_resources[] = {
  262. [0] = {
  263. .start = 0xFFD81014,
  264. .end = 0xFFD81020 - 1,
  265. .flags = IORESOURCE_MEM,
  266. },
  267. [1] = {
  268. .start = evt2irq(0x4A0),
  269. .flags = IORESOURCE_IRQ,
  270. },
  271. };
  272. static struct platform_device tmu4_device = {
  273. .name = "sh_tmu",
  274. .id = 4,
  275. .dev = {
  276. .platform_data = &tmu4_platform_data,
  277. },
  278. .resource = tmu4_resources,
  279. .num_resources = ARRAY_SIZE(tmu4_resources),
  280. };
  281. static struct sh_timer_config tmu5_platform_data = {
  282. .channel_offset = 0x1c,
  283. .timer_bit = 2,
  284. };
  285. static struct resource tmu5_resources[] = {
  286. [0] = {
  287. .start = 0xFFD81020,
  288. .end = 0xFFD81030 - 1,
  289. .flags = IORESOURCE_MEM,
  290. },
  291. [1] = {
  292. .start = evt2irq(0x4C0),
  293. .flags = IORESOURCE_IRQ,
  294. },
  295. };
  296. static struct platform_device tmu5_device = {
  297. .name = "sh_tmu",
  298. .id = 5,
  299. .dev = {
  300. .platform_data = &tmu5_platform_data,
  301. },
  302. .resource = tmu5_resources,
  303. .num_resources = ARRAY_SIZE(tmu5_resources),
  304. };
  305. static struct sh_timer_config tmu6_platform_data = {
  306. .channel_offset = 0x4,
  307. .timer_bit = 0,
  308. };
  309. static struct resource tmu6_resources[] = {
  310. [0] = {
  311. .start = 0xFFD82008,
  312. .end = 0xFFD82014 - 1,
  313. .flags = IORESOURCE_MEM,
  314. },
  315. [1] = {
  316. .start = evt2irq(0x500),
  317. .flags = IORESOURCE_IRQ,
  318. },
  319. };
  320. static struct platform_device tmu6_device = {
  321. .name = "sh_tmu",
  322. .id = 6,
  323. .dev = {
  324. .platform_data = &tmu6_platform_data,
  325. },
  326. .resource = tmu6_resources,
  327. .num_resources = ARRAY_SIZE(tmu6_resources),
  328. };
  329. static struct sh_timer_config tmu7_platform_data = {
  330. .channel_offset = 0x10,
  331. .timer_bit = 1,
  332. };
  333. static struct resource tmu7_resources[] = {
  334. [0] = {
  335. .start = 0xFFD82014,
  336. .end = 0xFFD82020 - 1,
  337. .flags = IORESOURCE_MEM,
  338. },
  339. [1] = {
  340. .start = evt2irq(0x520),
  341. .flags = IORESOURCE_IRQ,
  342. },
  343. };
  344. static struct platform_device tmu7_device = {
  345. .name = "sh_tmu",
  346. .id = 7,
  347. .dev = {
  348. .platform_data = &tmu7_platform_data,
  349. },
  350. .resource = tmu7_resources,
  351. .num_resources = ARRAY_SIZE(tmu7_resources),
  352. };
  353. static struct sh_timer_config tmu8_platform_data = {
  354. .channel_offset = 0x1c,
  355. .timer_bit = 2,
  356. };
  357. static struct resource tmu8_resources[] = {
  358. [0] = {
  359. .start = 0xFFD82020,
  360. .end = 0xFFD82030 - 1,
  361. .flags = IORESOURCE_MEM,
  362. },
  363. [1] = {
  364. .start = evt2irq(0x540),
  365. .flags = IORESOURCE_IRQ,
  366. },
  367. };
  368. static struct platform_device tmu8_device = {
  369. .name = "sh_tmu",
  370. .id = 8,
  371. .dev = {
  372. .platform_data = &tmu8_platform_data,
  373. },
  374. .resource = tmu8_resources,
  375. .num_resources = ARRAY_SIZE(tmu8_resources),
  376. };
  377. static struct platform_device *sh7734_devices[] __initdata = {
  378. &scif0_device,
  379. &scif1_device,
  380. &scif2_device,
  381. &scif3_device,
  382. &scif4_device,
  383. &scif5_device,
  384. &tmu0_device,
  385. &tmu1_device,
  386. &tmu2_device,
  387. &tmu3_device,
  388. &tmu4_device,
  389. &tmu5_device,
  390. &tmu6_device,
  391. &tmu7_device,
  392. &tmu8_device,
  393. &rtc_device,
  394. };
  395. static struct platform_device *sh7734_early_devices[] __initdata = {
  396. &scif0_device,
  397. &scif1_device,
  398. &scif2_device,
  399. &scif3_device,
  400. &scif4_device,
  401. &scif5_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(sh7734_early_devices,
  415. ARRAY_SIZE(sh7734_early_devices));
  416. }
  417. #define GROUP 0
  418. enum {
  419. UNUSED = 0,
  420. /* interrupt sources */
  421. IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,
  422. IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,
  423. IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,
  424. IRL0_HHLL, IRL0_HHLH, IRL0_HHHL,
  425. IRQ0, IRQ1, IRQ2, IRQ3,
  426. DU,
  427. TMU00, TMU10, TMU20, TMU21,
  428. TMU30, TMU40, TMU50, TMU51,
  429. TMU60, TMU70, TMU80,
  430. RESET_WDT,
  431. USB,
  432. HUDI,
  433. SHDMAC,
  434. SSI0, SSI1, SSI2, SSI3,
  435. VIN0,
  436. RGPVG,
  437. _2DG,
  438. MMC,
  439. HSPI,
  440. LBSCATA,
  441. I2C0,
  442. RCAN0,
  443. MIMLB,
  444. SCIF0, SCIF1, SCIF2, SCIF3, SCIF4, SCIF5,
  445. LBSCDMAC0, LBSCDMAC1, LBSCDMAC2,
  446. RCAN1,
  447. SDHI0, SDHI1,
  448. IEBUS,
  449. HPBDMAC0_3, HPBDMAC4_10, HPBDMAC11_18, HPBDMAC19_22, HPBDMAC23_25_27_28,
  450. RTC,
  451. VIN1,
  452. LCDC,
  453. SRC0, SRC1,
  454. GETHER,
  455. SDHI2,
  456. GPIO0_3, GPIO4_5,
  457. STIF0, STIF1,
  458. ADMAC,
  459. HIF,
  460. FLCTL,
  461. ADC,
  462. MTU2,
  463. RSPI,
  464. QSPI,
  465. HSCIF,
  466. VEU3F_VE3,
  467. /* Group */
  468. /* Mask */
  469. STIF_M,
  470. GPIO_M,
  471. HPBDMAC_M,
  472. LBSCDMAC_M,
  473. RCAN_M,
  474. SRC_M,
  475. SCIF_M,
  476. LCDC_M,
  477. _2DG_M,
  478. VIN_M,
  479. TMU_3_M,
  480. TMU_0_M,
  481. /* Priority */
  482. RCAN_P,
  483. LBSCDMAC_P,
  484. /* Common */
  485. SDHI,
  486. SSI,
  487. SPI,
  488. };
  489. static struct intc_vect vectors[] __initdata = {
  490. INTC_VECT(DU, 0x3E0),
  491. INTC_VECT(TMU00, 0x400),
  492. INTC_VECT(TMU10, 0x420),
  493. INTC_VECT(TMU20, 0x440),
  494. INTC_VECT(TMU30, 0x480),
  495. INTC_VECT(TMU40, 0x4A0),
  496. INTC_VECT(TMU50, 0x4C0),
  497. INTC_VECT(TMU51, 0x4E0),
  498. INTC_VECT(TMU60, 0x500),
  499. INTC_VECT(TMU70, 0x520),
  500. INTC_VECT(TMU80, 0x540),
  501. INTC_VECT(RESET_WDT, 0x560),
  502. INTC_VECT(USB, 0x580),
  503. INTC_VECT(HUDI, 0x600),
  504. INTC_VECT(SHDMAC, 0x620),
  505. INTC_VECT(SSI0, 0x6C0),
  506. INTC_VECT(SSI1, 0x6E0),
  507. INTC_VECT(SSI2, 0x700),
  508. INTC_VECT(SSI3, 0x720),
  509. INTC_VECT(VIN0, 0x740),
  510. INTC_VECT(RGPVG, 0x760),
  511. INTC_VECT(_2DG, 0x780),
  512. INTC_VECT(MMC, 0x7A0),
  513. INTC_VECT(HSPI, 0x7E0),
  514. INTC_VECT(LBSCATA, 0x840),
  515. INTC_VECT(I2C0, 0x860),
  516. INTC_VECT(RCAN0, 0x880),
  517. INTC_VECT(SCIF0, 0x8A0),
  518. INTC_VECT(SCIF1, 0x8C0),
  519. INTC_VECT(SCIF2, 0x900),
  520. INTC_VECT(SCIF3, 0x920),
  521. INTC_VECT(SCIF4, 0x940),
  522. INTC_VECT(SCIF5, 0x960),
  523. INTC_VECT(LBSCDMAC0, 0x9E0),
  524. INTC_VECT(LBSCDMAC1, 0xA00),
  525. INTC_VECT(LBSCDMAC2, 0xA20),
  526. INTC_VECT(RCAN1, 0xA60),
  527. INTC_VECT(SDHI0, 0xAE0),
  528. INTC_VECT(SDHI1, 0xB00),
  529. INTC_VECT(IEBUS, 0xB20),
  530. INTC_VECT(HPBDMAC0_3, 0xB60),
  531. INTC_VECT(HPBDMAC4_10, 0xB80),
  532. INTC_VECT(HPBDMAC11_18, 0xBA0),
  533. INTC_VECT(HPBDMAC19_22, 0xBC0),
  534. INTC_VECT(HPBDMAC23_25_27_28, 0xBE0),
  535. INTC_VECT(RTC, 0xC00),
  536. INTC_VECT(VIN1, 0xC20),
  537. INTC_VECT(LCDC, 0xC40),
  538. INTC_VECT(SRC0, 0xC60),
  539. INTC_VECT(SRC1, 0xC80),
  540. INTC_VECT(GETHER, 0xCA0),
  541. INTC_VECT(SDHI2, 0xCC0),
  542. INTC_VECT(GPIO0_3, 0xCE0),
  543. INTC_VECT(GPIO4_5, 0xD00),
  544. INTC_VECT(STIF0, 0xD20),
  545. INTC_VECT(STIF1, 0xD40),
  546. INTC_VECT(ADMAC, 0xDA0),
  547. INTC_VECT(HIF, 0xDC0),
  548. INTC_VECT(FLCTL, 0xDE0),
  549. INTC_VECT(ADC, 0xE00),
  550. INTC_VECT(MTU2, 0xE20),
  551. INTC_VECT(RSPI, 0xE40),
  552. INTC_VECT(QSPI, 0xE60),
  553. INTC_VECT(HSCIF, 0xFC0),
  554. INTC_VECT(VEU3F_VE3, 0xF40),
  555. };
  556. static struct intc_group groups[] __initdata = {
  557. /* Common */
  558. INTC_GROUP(SDHI, SDHI0, SDHI1, SDHI2),
  559. INTC_GROUP(SPI, HSPI, RSPI, QSPI),
  560. INTC_GROUP(SSI, SSI0, SSI1, SSI2, SSI3),
  561. /* Mask group */
  562. INTC_GROUP(STIF_M, STIF0, STIF1), /* 22 */
  563. INTC_GROUP(GPIO_M, GPIO0_3, GPIO4_5), /* 21 */
  564. INTC_GROUP(HPBDMAC_M, HPBDMAC0_3, HPBDMAC4_10, HPBDMAC11_18,
  565. HPBDMAC19_22, HPBDMAC23_25_27_28), /* 19 */
  566. INTC_GROUP(LBSCDMAC_M, LBSCDMAC0, LBSCDMAC1, LBSCDMAC2), /* 18 */
  567. INTC_GROUP(RCAN_M, RCAN0, RCAN1, IEBUS), /* 17 */
  568. INTC_GROUP(SRC_M, SRC0, SRC1), /* 16 */
  569. INTC_GROUP(SCIF_M, SCIF0, SCIF1, SCIF2, SCIF3, SCIF4, SCIF5,
  570. HSCIF), /* 14 */
  571. INTC_GROUP(LCDC_M, LCDC, MIMLB), /* 13 */
  572. INTC_GROUP(_2DG_M, _2DG, RGPVG), /* 12 */
  573. INTC_GROUP(VIN_M, VIN0, VIN1), /* 10 */
  574. INTC_GROUP(TMU_3_M, TMU30, TMU40, TMU50, TMU51,
  575. TMU60, TMU60, TMU70, TMU80), /* 2 */
  576. INTC_GROUP(TMU_0_M, TMU00, TMU10, TMU20, TMU21), /* 1 */
  577. /* Priority group*/
  578. INTC_GROUP(RCAN_P, RCAN0, RCAN1), /* INT2PRI5 */
  579. INTC_GROUP(LBSCDMAC_P, LBSCDMAC0, LBSCDMAC1), /* INT2PRI5 */
  580. };
  581. static struct intc_mask_reg mask_registers[] __initdata = {
  582. { 0xFF804040, 0xFF804044, 32, /* INT2MSKRG / INT2MSKCR */
  583. { 0,
  584. VEU3F_VE3,
  585. SDHI, /* SDHI 0-2 */
  586. ADMAC,
  587. FLCTL,
  588. RESET_WDT,
  589. HIF,
  590. ADC,
  591. MTU2,
  592. STIF_M, /* STIF 0,1 */
  593. GPIO_M, /* GPIO 0-5*/
  594. GETHER,
  595. HPBDMAC_M, /* HPBDMAC 0_3 - 23_25_27_28 */
  596. LBSCDMAC_M, /* LBSCDMAC 0 - 2 */
  597. RCAN_M, /* RCAN, IEBUS */
  598. SRC_M, /* SRC 0,1 */
  599. LBSCATA,
  600. SCIF_M, /* SCIF 0-5, HSCIF */
  601. LCDC_M, /* LCDC, MIMLB */
  602. _2DG_M, /* 2DG, RGPVG */
  603. SPI, /* HSPI, RSPI, QSPI */
  604. VIN_M, /* VIN0, 1 */
  605. SSI, /* SSI 0-3 */
  606. USB,
  607. SHDMAC,
  608. HUDI,
  609. MMC,
  610. RTC,
  611. I2C0, /* I2C */ /* I2C 0, 1*/
  612. TMU_3_M, /* TMU30 - TMU80 */
  613. TMU_0_M, /* TMU00 - TMU21 */
  614. DU } },
  615. };
  616. static struct intc_prio_reg prio_registers[] __initdata = {
  617. { 0xFF804000, 0, 32, 8, /* INT2PRI0 */
  618. { DU, TMU00, TMU10, TMU20 } },
  619. { 0xFF804004, 0, 32, 8, /* INT2PRI1 */
  620. { TMU30, TMU60, RTC, SDHI } },
  621. { 0xFF804008, 0, 32, 8, /* INT2PRI2 */
  622. { HUDI, SHDMAC, USB, SSI } },
  623. { 0xFF80400C, 0, 32, 8, /* INT2PRI3 */
  624. { VIN0, SPI, _2DG, LBSCATA } },
  625. { 0xFF804010, 0, 32, 8, /* INT2PRI4 */
  626. { SCIF0, SCIF3, HSCIF, LCDC } },
  627. { 0xFF804014, 0, 32, 8, /* INT2PRI5 */
  628. { RCAN_P, LBSCDMAC_P, LBSCDMAC2, MMC } },
  629. { 0xFF804018, 0, 32, 8, /* INT2PRI6 */
  630. { HPBDMAC0_3, HPBDMAC4_10, HPBDMAC11_18, HPBDMAC19_22 } },
  631. { 0xFF80401C, 0, 32, 8, /* INT2PRI7 */
  632. { HPBDMAC23_25_27_28, I2C0, SRC0, SRC1 } },
  633. { 0xFF804020, 0, 32, 8, /* INT2PRI8 */
  634. { 0 /* ADIF */, VIN1, RESET_WDT, HIF } },
  635. { 0xFF804024, 0, 32, 8, /* INT2PRI9 */
  636. { ADMAC, FLCTL, GPIO0_3, GPIO4_5 } },
  637. { 0xFF804028, 0, 32, 8, /* INT2PRI10 */
  638. { STIF0, STIF1, VEU3F_VE3, GETHER } },
  639. { 0xFF80402C, 0, 32, 8, /* INT2PRI11 */
  640. { MTU2, RGPVG, MIMLB, IEBUS } },
  641. };
  642. static DECLARE_INTC_DESC(intc_desc, "sh7734", vectors, groups,
  643. mask_registers, prio_registers, NULL);
  644. /* Support for external interrupt pins in IRQ mode */
  645. static struct intc_vect irq3210_vectors[] __initdata = {
  646. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  647. INTC_VECT(IRQ2, 0x2C0), INTC_VECT(IRQ3, 0x300),
  648. };
  649. static struct intc_sense_reg irq3210_sense_registers[] __initdata = {
  650. { 0xFF80201C, 32, 2, /* ICR1 */
  651. { IRQ0, IRQ1, IRQ2, IRQ3, } },
  652. };
  653. static struct intc_mask_reg irq3210_ack_registers[] __initdata = {
  654. { 0xFF802024, 0, 32, /* INTREQ */
  655. { IRQ0, IRQ1, IRQ2, IRQ3, } },
  656. };
  657. static struct intc_mask_reg irq3210_mask_registers[] __initdata = {
  658. { 0xFF802044, 0xFF802064, 32, /* INTMSK0 / INTMSKCLR0 */
  659. { IRQ0, IRQ1, IRQ2, IRQ3, } },
  660. };
  661. static struct intc_prio_reg irq3210_prio_registers[] __initdata = {
  662. { 0xFF802010, 0, 32, 4, /* INTPRI */
  663. { IRQ0, IRQ1, IRQ2, IRQ3, } },
  664. };
  665. static DECLARE_INTC_DESC_ACK(intc_desc_irq3210, "sh7734-irq3210",
  666. irq3210_vectors, NULL,
  667. irq3210_mask_registers, irq3210_prio_registers,
  668. irq3210_sense_registers, irq3210_ack_registers);
  669. /* External interrupt pins in IRL mode */
  670. static struct intc_vect vectors_irl3210[] __initdata = {
  671. INTC_VECT(IRL0_LLLL, 0x200), INTC_VECT(IRL0_LLLH, 0x220),
  672. INTC_VECT(IRL0_LLHL, 0x240), INTC_VECT(IRL0_LLHH, 0x260),
  673. INTC_VECT(IRL0_LHLL, 0x280), INTC_VECT(IRL0_LHLH, 0x2a0),
  674. INTC_VECT(IRL0_LHHL, 0x2c0), INTC_VECT(IRL0_LHHH, 0x2e0),
  675. INTC_VECT(IRL0_HLLL, 0x300), INTC_VECT(IRL0_HLLH, 0x320),
  676. INTC_VECT(IRL0_HLHL, 0x340), INTC_VECT(IRL0_HLHH, 0x360),
  677. INTC_VECT(IRL0_HHLL, 0x380), INTC_VECT(IRL0_HHLH, 0x3a0),
  678. INTC_VECT(IRL0_HHHL, 0x3c0),
  679. };
  680. static DECLARE_INTC_DESC(intc_desc_irl3210, "sh7734-irl3210",
  681. vectors_irl3210, NULL, mask_registers, NULL, NULL);
  682. #define INTC_ICR0 0xFF802000
  683. #define INTC_INTMSK0 0xFF802044
  684. #define INTC_INTMSK1 0xFF802048
  685. #define INTC_INTMSKCLR0 0xFF802064
  686. #define INTC_INTMSKCLR1 0xFF802068
  687. void __init plat_irq_setup(void)
  688. {
  689. /* disable IRQ3-0 */
  690. __raw_writel(0xF0000000, INTC_INTMSK0);
  691. /* disable IRL3-0 */
  692. __raw_writel(0x80000000, INTC_INTMSK1);
  693. /* select IRL mode for IRL3-0 */
  694. __raw_writel(__raw_readl(INTC_ICR0) & ~0x00800000, INTC_ICR0);
  695. /* disable holding function, ie enable "SH-4 Mode (LVLMODE)" */
  696. __raw_writel(__raw_readl(INTC_ICR0) | 0x00200000, INTC_ICR0);
  697. register_intc_controller(&intc_desc);
  698. }
  699. void __init plat_irq_setup_pins(int mode)
  700. {
  701. switch (mode) {
  702. case IRQ_MODE_IRQ3210:
  703. /* select IRQ mode for IRL3-0 */
  704. __raw_writel(__raw_readl(INTC_ICR0) | 0x00800000, INTC_ICR0);
  705. register_intc_controller(&intc_desc_irq3210);
  706. break;
  707. case IRQ_MODE_IRL3210:
  708. /* enable IRL0-3 but don't provide any masking */
  709. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  710. __raw_writel(0xf0000000, INTC_INTMSKCLR0);
  711. break;
  712. case IRQ_MODE_IRL3210_MASK:
  713. /* enable IRL0-3 and mask using cpu intc controller */
  714. __raw_writel(0x80000000, INTC_INTMSKCLR0);
  715. register_intc_controller(&intc_desc_irl3210);
  716. break;
  717. default:
  718. BUG();
  719. }
  720. }