setup-sh7734.c 18 KB

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