setup-sh7786.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  1. /*
  2. * SH7786 Setup
  3. *
  4. * Copyright (C) 2009 - 2011 Renesas Solutions Corp.
  5. * Kuninori Morimoto <morimoto.kuninori@renesas.com>
  6. * Paul Mundt <paul.mundt@renesas.com>
  7. *
  8. * Based on SH7785 Setup
  9. *
  10. * Copyright (C) 2007 Paul Mundt
  11. *
  12. * This file is subject to the terms and conditions of the GNU General Public
  13. * License. See the file "COPYING" in the main directory of this archive
  14. * for more details.
  15. */
  16. #include <linux/platform_device.h>
  17. #include <linux/init.h>
  18. #include <linux/serial.h>
  19. #include <linux/serial_sci.h>
  20. #include <linux/io.h>
  21. #include <linux/mm.h>
  22. #include <linux/dma-mapping.h>
  23. #include <linux/sh_timer.h>
  24. #include <linux/sh_dma.h>
  25. #include <linux/sh_intc.h>
  26. #include <linux/usb/ohci_pdriver.h>
  27. #include <cpu/dma-register.h>
  28. #include <asm/mmzone.h>
  29. static struct plat_sci_port scif0_platform_data = {
  30. .scscr = SCSCR_REIE | SCSCR_CKE1,
  31. .type = PORT_SCIF,
  32. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  33. };
  34. static struct resource scif0_resources[] = {
  35. DEFINE_RES_MEM(0xffea0000, 0x100),
  36. DEFINE_RES_IRQ(evt2irq(0x700)),
  37. DEFINE_RES_IRQ(evt2irq(0x720)),
  38. DEFINE_RES_IRQ(evt2irq(0x760)),
  39. DEFINE_RES_IRQ(evt2irq(0x740)),
  40. };
  41. static struct platform_device scif0_device = {
  42. .name = "sh-sci",
  43. .id = 0,
  44. .resource = scif0_resources,
  45. .num_resources = ARRAY_SIZE(scif0_resources),
  46. .dev = {
  47. .platform_data = &scif0_platform_data,
  48. },
  49. };
  50. /*
  51. * The rest of these all have multiplexed IRQs
  52. */
  53. static struct plat_sci_port scif1_platform_data = {
  54. .scscr = SCSCR_REIE | SCSCR_CKE1,
  55. .type = PORT_SCIF,
  56. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  57. };
  58. static struct resource scif1_resources[] = {
  59. DEFINE_RES_MEM(0xffeb0000, 0x100),
  60. DEFINE_RES_IRQ(evt2irq(0x780)),
  61. };
  62. static struct resource scif1_demux_resources[] = {
  63. DEFINE_RES_MEM(0xffeb0000, 0x100),
  64. /* Placeholders, see sh7786_devices_setup() */
  65. DEFINE_RES_IRQ(0),
  66. DEFINE_RES_IRQ(0),
  67. DEFINE_RES_IRQ(0),
  68. DEFINE_RES_IRQ(0),
  69. };
  70. static struct platform_device scif1_device = {
  71. .name = "sh-sci",
  72. .id = 1,
  73. .resource = scif1_resources,
  74. .num_resources = ARRAY_SIZE(scif1_resources),
  75. .dev = {
  76. .platform_data = &scif1_platform_data,
  77. },
  78. };
  79. static struct plat_sci_port scif2_platform_data = {
  80. .scscr = SCSCR_REIE | SCSCR_CKE1,
  81. .type = PORT_SCIF,
  82. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  83. };
  84. static struct resource scif2_resources[] = {
  85. DEFINE_RES_MEM(0xffec0000, 0x100),
  86. DEFINE_RES_IRQ(evt2irq(0x840)),
  87. };
  88. static struct platform_device scif2_device = {
  89. .name = "sh-sci",
  90. .id = 2,
  91. .resource = scif2_resources,
  92. .num_resources = ARRAY_SIZE(scif2_resources),
  93. .dev = {
  94. .platform_data = &scif2_platform_data,
  95. },
  96. };
  97. static struct plat_sci_port scif3_platform_data = {
  98. .scscr = SCSCR_REIE | SCSCR_CKE1,
  99. .type = PORT_SCIF,
  100. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  101. };
  102. static struct resource scif3_resources[] = {
  103. DEFINE_RES_MEM(0xffed0000, 0x100),
  104. DEFINE_RES_IRQ(evt2irq(0x860)),
  105. };
  106. static struct platform_device scif3_device = {
  107. .name = "sh-sci",
  108. .id = 3,
  109. .resource = scif3_resources,
  110. .num_resources = ARRAY_SIZE(scif3_resources),
  111. .dev = {
  112. .platform_data = &scif3_platform_data,
  113. },
  114. };
  115. static struct plat_sci_port scif4_platform_data = {
  116. .scscr = SCSCR_REIE | SCSCR_CKE1,
  117. .type = PORT_SCIF,
  118. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  119. };
  120. static struct resource scif4_resources[] = {
  121. DEFINE_RES_MEM(0xffee0000, 0x100),
  122. DEFINE_RES_IRQ(evt2irq(0x880)),
  123. };
  124. static struct platform_device scif4_device = {
  125. .name = "sh-sci",
  126. .id = 4,
  127. .resource = scif4_resources,
  128. .num_resources = ARRAY_SIZE(scif4_resources),
  129. .dev = {
  130. .platform_data = &scif4_platform_data,
  131. },
  132. };
  133. static struct plat_sci_port scif5_platform_data = {
  134. .scscr = SCSCR_REIE | SCSCR_CKE1,
  135. .type = PORT_SCIF,
  136. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  137. };
  138. static struct resource scif5_resources[] = {
  139. DEFINE_RES_MEM(0xffef0000, 0x100),
  140. DEFINE_RES_IRQ(evt2irq(0x8a0)),
  141. };
  142. static struct platform_device scif5_device = {
  143. .name = "sh-sci",
  144. .id = 5,
  145. .resource = scif5_resources,
  146. .num_resources = ARRAY_SIZE(scif5_resources),
  147. .dev = {
  148. .platform_data = &scif5_platform_data,
  149. },
  150. };
  151. static struct sh_timer_config tmu0_platform_data = {
  152. .channels_mask = 7,
  153. };
  154. static struct resource tmu0_resources[] = {
  155. DEFINE_RES_MEM(0xffd80000, 0x30),
  156. DEFINE_RES_IRQ(evt2irq(0x400)),
  157. DEFINE_RES_IRQ(evt2irq(0x420)),
  158. DEFINE_RES_IRQ(evt2irq(0x440)),
  159. };
  160. static struct platform_device tmu0_device = {
  161. .name = "sh-tmu",
  162. .id = 0,
  163. .dev = {
  164. .platform_data = &tmu0_platform_data,
  165. },
  166. .resource = tmu0_resources,
  167. .num_resources = ARRAY_SIZE(tmu0_resources),
  168. };
  169. static struct sh_timer_config tmu1_platform_data = {
  170. .channels_mask = 7,
  171. };
  172. static struct resource tmu1_resources[] = {
  173. DEFINE_RES_MEM(0xffda0000, 0x2c),
  174. DEFINE_RES_IRQ(evt2irq(0x480)),
  175. DEFINE_RES_IRQ(evt2irq(0x4a0)),
  176. DEFINE_RES_IRQ(evt2irq(0x4c0)),
  177. };
  178. static struct platform_device tmu1_device = {
  179. .name = "sh-tmu",
  180. .id = 1,
  181. .dev = {
  182. .platform_data = &tmu1_platform_data,
  183. },
  184. .resource = tmu1_resources,
  185. .num_resources = ARRAY_SIZE(tmu1_resources),
  186. };
  187. static struct sh_timer_config tmu2_platform_data = {
  188. .channels_mask = 7,
  189. };
  190. static struct resource tmu2_resources[] = {
  191. DEFINE_RES_MEM(0xffdc0000, 0x2c),
  192. DEFINE_RES_IRQ(evt2irq(0x7a0)),
  193. DEFINE_RES_IRQ(evt2irq(0x7a0)),
  194. DEFINE_RES_IRQ(evt2irq(0x7a0)),
  195. };
  196. static struct platform_device tmu2_device = {
  197. .name = "sh-tmu",
  198. .id = 2,
  199. .dev = {
  200. .platform_data = &tmu2_platform_data,
  201. },
  202. .resource = tmu2_resources,
  203. .num_resources = ARRAY_SIZE(tmu2_resources),
  204. };
  205. static struct sh_timer_config tmu3_platform_data = {
  206. .channels_mask = 7,
  207. };
  208. static struct resource tmu3_resources[] = {
  209. DEFINE_RES_MEM(0xffde0000, 0x2c),
  210. DEFINE_RES_IRQ(evt2irq(0x7c0)),
  211. DEFINE_RES_IRQ(evt2irq(0x7c0)),
  212. DEFINE_RES_IRQ(evt2irq(0x7c0)),
  213. };
  214. static struct platform_device tmu3_device = {
  215. .name = "sh-tmu",
  216. .id = 3,
  217. .dev = {
  218. .platform_data = &tmu3_platform_data,
  219. },
  220. .resource = tmu3_resources,
  221. .num_resources = ARRAY_SIZE(tmu3_resources),
  222. };
  223. static const struct sh_dmae_channel dmac0_channels[] = {
  224. {
  225. .offset = 0,
  226. .dmars = 0,
  227. .dmars_bit = 0,
  228. }, {
  229. .offset = 0x10,
  230. .dmars = 0,
  231. .dmars_bit = 8,
  232. }, {
  233. .offset = 0x20,
  234. .dmars = 4,
  235. .dmars_bit = 0,
  236. }, {
  237. .offset = 0x30,
  238. .dmars = 4,
  239. .dmars_bit = 8,
  240. }, {
  241. .offset = 0x50,
  242. .dmars = 8,
  243. .dmars_bit = 0,
  244. }, {
  245. .offset = 0x60,
  246. .dmars = 8,
  247. .dmars_bit = 8,
  248. }
  249. };
  250. static const unsigned int ts_shift[] = TS_SHIFT;
  251. static struct sh_dmae_pdata dma0_platform_data = {
  252. .channel = dmac0_channels,
  253. .channel_num = ARRAY_SIZE(dmac0_channels),
  254. .ts_low_shift = CHCR_TS_LOW_SHIFT,
  255. .ts_low_mask = CHCR_TS_LOW_MASK,
  256. .ts_high_shift = CHCR_TS_HIGH_SHIFT,
  257. .ts_high_mask = CHCR_TS_HIGH_MASK,
  258. .ts_shift = ts_shift,
  259. .ts_shift_num = ARRAY_SIZE(ts_shift),
  260. .dmaor_init = DMAOR_INIT,
  261. };
  262. /* Resource order important! */
  263. static struct resource dmac0_resources[] = {
  264. {
  265. /* Channel registers and DMAOR */
  266. .start = 0xfe008020,
  267. .end = 0xfe00808f,
  268. .flags = IORESOURCE_MEM,
  269. }, {
  270. /* DMARSx */
  271. .start = 0xfe009000,
  272. .end = 0xfe00900b,
  273. .flags = IORESOURCE_MEM,
  274. }, {
  275. .name = "error_irq",
  276. .start = evt2irq(0x5c0),
  277. .end = evt2irq(0x5c0),
  278. .flags = IORESOURCE_IRQ,
  279. }, {
  280. /* IRQ for channels 0-5 */
  281. .start = evt2irq(0x500),
  282. .end = evt2irq(0x5a0),
  283. .flags = IORESOURCE_IRQ,
  284. },
  285. };
  286. static struct platform_device dma0_device = {
  287. .name = "sh-dma-engine",
  288. .id = 0,
  289. .resource = dmac0_resources,
  290. .num_resources = ARRAY_SIZE(dmac0_resources),
  291. .dev = {
  292. .platform_data = &dma0_platform_data,
  293. },
  294. };
  295. #define USB_EHCI_START 0xffe70000
  296. #define USB_OHCI_START 0xffe70400
  297. static struct resource usb_ehci_resources[] = {
  298. [0] = {
  299. .start = USB_EHCI_START,
  300. .end = USB_EHCI_START + 0x3ff,
  301. .flags = IORESOURCE_MEM,
  302. },
  303. [1] = {
  304. .start = evt2irq(0xba0),
  305. .end = evt2irq(0xba0),
  306. .flags = IORESOURCE_IRQ,
  307. },
  308. };
  309. static struct platform_device usb_ehci_device = {
  310. .name = "sh_ehci",
  311. .id = -1,
  312. .dev = {
  313. .dma_mask = &usb_ehci_device.dev.coherent_dma_mask,
  314. .coherent_dma_mask = DMA_BIT_MASK(32),
  315. },
  316. .num_resources = ARRAY_SIZE(usb_ehci_resources),
  317. .resource = usb_ehci_resources,
  318. };
  319. static struct resource usb_ohci_resources[] = {
  320. [0] = {
  321. .start = USB_OHCI_START,
  322. .end = USB_OHCI_START + 0x3ff,
  323. .flags = IORESOURCE_MEM,
  324. },
  325. [1] = {
  326. .start = evt2irq(0xba0),
  327. .end = evt2irq(0xba0),
  328. .flags = IORESOURCE_IRQ,
  329. },
  330. };
  331. static struct usb_ohci_pdata usb_ohci_pdata;
  332. static struct platform_device usb_ohci_device = {
  333. .name = "ohci-platform",
  334. .id = -1,
  335. .dev = {
  336. .dma_mask = &usb_ohci_device.dev.coherent_dma_mask,
  337. .coherent_dma_mask = DMA_BIT_MASK(32),
  338. .platform_data = &usb_ohci_pdata,
  339. },
  340. .num_resources = ARRAY_SIZE(usb_ohci_resources),
  341. .resource = usb_ohci_resources,
  342. };
  343. static struct platform_device *sh7786_early_devices[] __initdata = {
  344. &scif0_device,
  345. &scif1_device,
  346. &scif2_device,
  347. &scif3_device,
  348. &scif4_device,
  349. &scif5_device,
  350. &tmu0_device,
  351. &tmu1_device,
  352. &tmu2_device,
  353. };
  354. static struct platform_device *sh7786_devices[] __initdata = {
  355. &dma0_device,
  356. &usb_ehci_device,
  357. &usb_ohci_device,
  358. };
  359. /*
  360. * Please call this function if your platform board
  361. * use external clock for USB
  362. * */
  363. #define USBCTL0 0xffe70858
  364. #define CLOCK_MODE_MASK 0xffffff7f
  365. #define EXT_CLOCK_MODE 0x00000080
  366. void __init sh7786_usb_use_exclock(void)
  367. {
  368. u32 val = __raw_readl(USBCTL0) & CLOCK_MODE_MASK;
  369. __raw_writel(val | EXT_CLOCK_MODE, USBCTL0);
  370. }
  371. #define USBINITREG1 0xffe70094
  372. #define USBINITREG2 0xffe7009c
  373. #define USBINITVAL1 0x00ff0040
  374. #define USBINITVAL2 0x00000001
  375. #define USBPCTL1 0xffe70804
  376. #define USBST 0xffe70808
  377. #define PHY_ENB 0x00000001
  378. #define PLL_ENB 0x00000002
  379. #define PHY_RST 0x00000004
  380. #define ACT_PLL_STATUS 0xc0000000
  381. static void __init sh7786_usb_setup(void)
  382. {
  383. int i = 1000000;
  384. /*
  385. * USB initial settings
  386. *
  387. * The following settings are necessary
  388. * for using the USB modules.
  389. *
  390. * see "USB Initial Settings" for detail
  391. */
  392. __raw_writel(USBINITVAL1, USBINITREG1);
  393. __raw_writel(USBINITVAL2, USBINITREG2);
  394. /*
  395. * Set the PHY and PLL enable bit
  396. */
  397. __raw_writel(PHY_ENB | PLL_ENB, USBPCTL1);
  398. while (i--) {
  399. if (ACT_PLL_STATUS == (__raw_readl(USBST) & ACT_PLL_STATUS)) {
  400. /* Set the PHY RST bit */
  401. __raw_writel(PHY_ENB | PLL_ENB | PHY_RST, USBPCTL1);
  402. printk(KERN_INFO "sh7786 usb setup done\n");
  403. break;
  404. }
  405. cpu_relax();
  406. }
  407. }
  408. enum {
  409. UNUSED = 0,
  410. /* interrupt sources */
  411. IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,
  412. IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,
  413. IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,
  414. IRL0_HHLL, IRL0_HHLH, IRL0_HHHL,
  415. IRL4_LLLL, IRL4_LLLH, IRL4_LLHL, IRL4_LLHH,
  416. IRL4_LHLL, IRL4_LHLH, IRL4_LHHL, IRL4_LHHH,
  417. IRL4_HLLL, IRL4_HLLH, IRL4_HLHL, IRL4_HLHH,
  418. IRL4_HHLL, IRL4_HHLH, IRL4_HHHL,
  419. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  420. WDT,
  421. TMU0_0, TMU0_1, TMU0_2, TMU0_3,
  422. TMU1_0, TMU1_1, TMU1_2,
  423. DMAC0_0, DMAC0_1, DMAC0_2, DMAC0_3, DMAC0_4, DMAC0_5, DMAC0_6,
  424. HUDI1, HUDI0,
  425. DMAC1_0, DMAC1_1, DMAC1_2, DMAC1_3,
  426. HPB_0, HPB_1, HPB_2,
  427. SCIF0_0, SCIF0_1, SCIF0_2, SCIF0_3,
  428. SCIF1,
  429. TMU2, TMU3,
  430. SCIF2, SCIF3, SCIF4, SCIF5,
  431. Eth_0, Eth_1,
  432. PCIeC0_0, PCIeC0_1, PCIeC0_2,
  433. PCIeC1_0, PCIeC1_1, PCIeC1_2,
  434. USB,
  435. I2C0, I2C1,
  436. DU,
  437. SSI0, SSI1, SSI2, SSI3,
  438. PCIeC2_0, PCIeC2_1, PCIeC2_2,
  439. HAC0, HAC1,
  440. FLCTL,
  441. HSPI,
  442. GPIO0, GPIO1,
  443. Thermal,
  444. INTICI0, INTICI1, INTICI2, INTICI3,
  445. INTICI4, INTICI5, INTICI6, INTICI7,
  446. /* Muxed sub-events */
  447. TXI1, BRI1, RXI1, ERI1,
  448. };
  449. static struct intc_vect sh7786_vectors[] __initdata = {
  450. INTC_VECT(WDT, 0x3e0),
  451. INTC_VECT(TMU0_0, 0x400), INTC_VECT(TMU0_1, 0x420),
  452. INTC_VECT(TMU0_2, 0x440), INTC_VECT(TMU0_3, 0x460),
  453. INTC_VECT(TMU1_0, 0x480), INTC_VECT(TMU1_1, 0x4a0),
  454. INTC_VECT(TMU1_2, 0x4c0),
  455. INTC_VECT(DMAC0_0, 0x500), INTC_VECT(DMAC0_1, 0x520),
  456. INTC_VECT(DMAC0_2, 0x540), INTC_VECT(DMAC0_3, 0x560),
  457. INTC_VECT(DMAC0_4, 0x580), INTC_VECT(DMAC0_5, 0x5a0),
  458. INTC_VECT(DMAC0_6, 0x5c0),
  459. INTC_VECT(HUDI1, 0x5e0), INTC_VECT(HUDI0, 0x600),
  460. INTC_VECT(DMAC1_0, 0x620), INTC_VECT(DMAC1_1, 0x640),
  461. INTC_VECT(DMAC1_2, 0x660), INTC_VECT(DMAC1_3, 0x680),
  462. INTC_VECT(HPB_0, 0x6a0), INTC_VECT(HPB_1, 0x6c0),
  463. INTC_VECT(HPB_2, 0x6e0),
  464. INTC_VECT(SCIF0_0, 0x700), INTC_VECT(SCIF0_1, 0x720),
  465. INTC_VECT(SCIF0_2, 0x740), INTC_VECT(SCIF0_3, 0x760),
  466. INTC_VECT(SCIF1, 0x780),
  467. INTC_VECT(TMU2, 0x7a0), INTC_VECT(TMU3, 0x7c0),
  468. INTC_VECT(SCIF2, 0x840), INTC_VECT(SCIF3, 0x860),
  469. INTC_VECT(SCIF4, 0x880), INTC_VECT(SCIF5, 0x8a0),
  470. INTC_VECT(Eth_0, 0x8c0), INTC_VECT(Eth_1, 0x8e0),
  471. INTC_VECT(PCIeC0_0, 0xae0), INTC_VECT(PCIeC0_1, 0xb00),
  472. INTC_VECT(PCIeC0_2, 0xb20),
  473. INTC_VECT(PCIeC1_0, 0xb40), INTC_VECT(PCIeC1_1, 0xb60),
  474. INTC_VECT(PCIeC1_2, 0xb80),
  475. INTC_VECT(USB, 0xba0),
  476. INTC_VECT(I2C0, 0xcc0), INTC_VECT(I2C1, 0xce0),
  477. INTC_VECT(DU, 0xd00),
  478. INTC_VECT(SSI0, 0xd20), INTC_VECT(SSI1, 0xd40),
  479. INTC_VECT(SSI2, 0xd60), INTC_VECT(SSI3, 0xd80),
  480. INTC_VECT(PCIeC2_0, 0xda0), INTC_VECT(PCIeC2_1, 0xdc0),
  481. INTC_VECT(PCIeC2_2, 0xde0),
  482. INTC_VECT(HAC0, 0xe00), INTC_VECT(HAC1, 0xe20),
  483. INTC_VECT(FLCTL, 0xe40),
  484. INTC_VECT(HSPI, 0xe80),
  485. INTC_VECT(GPIO0, 0xea0), INTC_VECT(GPIO1, 0xec0),
  486. INTC_VECT(Thermal, 0xee0),
  487. INTC_VECT(INTICI0, 0xf00), INTC_VECT(INTICI1, 0xf20),
  488. INTC_VECT(INTICI2, 0xf40), INTC_VECT(INTICI3, 0xf60),
  489. INTC_VECT(INTICI4, 0xf80), INTC_VECT(INTICI5, 0xfa0),
  490. INTC_VECT(INTICI6, 0xfc0), INTC_VECT(INTICI7, 0xfe0),
  491. };
  492. #define CnINTMSK0 0xfe410030
  493. #define CnINTMSK1 0xfe410040
  494. #define CnINTMSKCLR0 0xfe410050
  495. #define CnINTMSKCLR1 0xfe410060
  496. #define CnINT2MSKR0 0xfe410a20
  497. #define CnINT2MSKR1 0xfe410a24
  498. #define CnINT2MSKR2 0xfe410a28
  499. #define CnINT2MSKR3 0xfe410a2c
  500. #define CnINT2MSKCR0 0xfe410a30
  501. #define CnINT2MSKCR1 0xfe410a34
  502. #define CnINT2MSKCR2 0xfe410a38
  503. #define CnINT2MSKCR3 0xfe410a3c
  504. #define INTMSK2 0xfe410068
  505. #define INTMSKCLR2 0xfe41006c
  506. #define INTDISTCR0 0xfe4100b0
  507. #define INTDISTCR1 0xfe4100b4
  508. #define INT2DISTCR0 0xfe410900
  509. #define INT2DISTCR1 0xfe410904
  510. #define INT2DISTCR2 0xfe410908
  511. #define INT2DISTCR3 0xfe41090c
  512. static struct intc_mask_reg sh7786_mask_registers[] __initdata = {
  513. { CnINTMSK0, CnINTMSKCLR0, 32,
  514. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 },
  515. INTC_SMP_BALANCING(INTDISTCR0) },
  516. { INTMSK2, INTMSKCLR2, 32,
  517. { IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,
  518. IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,
  519. IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,
  520. IRL0_HHLL, IRL0_HHLH, IRL0_HHHL, 0,
  521. IRL4_LLLL, IRL4_LLLH, IRL4_LLHL, IRL4_LLHH,
  522. IRL4_LHLL, IRL4_LHLH, IRL4_LHHL, IRL4_LHHH,
  523. IRL4_HLLL, IRL4_HLLH, IRL4_HLHL, IRL4_HLHH,
  524. IRL4_HHLL, IRL4_HHLH, IRL4_HHHL, 0, } },
  525. { CnINT2MSKR0, CnINT2MSKCR0 , 32,
  526. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  527. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, WDT },
  528. INTC_SMP_BALANCING(INT2DISTCR0) },
  529. { CnINT2MSKR1, CnINT2MSKCR1, 32,
  530. { TMU0_0, TMU0_1, TMU0_2, TMU0_3, TMU1_0, TMU1_1, TMU1_2, 0,
  531. DMAC0_0, DMAC0_1, DMAC0_2, DMAC0_3, DMAC0_4, DMAC0_5, DMAC0_6,
  532. HUDI1, HUDI0,
  533. DMAC1_0, DMAC1_1, DMAC1_2, DMAC1_3,
  534. HPB_0, HPB_1, HPB_2,
  535. SCIF0_0, SCIF0_1, SCIF0_2, SCIF0_3,
  536. SCIF1,
  537. TMU2, TMU3, 0, }, INTC_SMP_BALANCING(INT2DISTCR1) },
  538. { CnINT2MSKR2, CnINT2MSKCR2, 32,
  539. { 0, 0, SCIF2, SCIF3, SCIF4, SCIF5,
  540. Eth_0, Eth_1,
  541. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  542. PCIeC0_0, PCIeC0_1, PCIeC0_2,
  543. PCIeC1_0, PCIeC1_1, PCIeC1_2,
  544. USB, 0, 0 }, INTC_SMP_BALANCING(INT2DISTCR2) },
  545. { CnINT2MSKR3, CnINT2MSKCR3, 32,
  546. { 0, 0, 0, 0, 0, 0,
  547. I2C0, I2C1,
  548. DU, SSI0, SSI1, SSI2, SSI3,
  549. PCIeC2_0, PCIeC2_1, PCIeC2_2,
  550. HAC0, HAC1,
  551. FLCTL, 0,
  552. HSPI, GPIO0, GPIO1, Thermal,
  553. 0, 0, 0, 0, 0, 0, 0, 0 }, INTC_SMP_BALANCING(INT2DISTCR3) },
  554. };
  555. static struct intc_prio_reg sh7786_prio_registers[] __initdata = {
  556. { 0xfe410010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  557. IRQ4, IRQ5, IRQ6, IRQ7 } },
  558. { 0xfe410800, 0, 32, 8, /* INT2PRI0 */ { 0, 0, 0, WDT } },
  559. { 0xfe410804, 0, 32, 8, /* INT2PRI1 */ { TMU0_0, TMU0_1,
  560. TMU0_2, TMU0_3 } },
  561. { 0xfe410808, 0, 32, 8, /* INT2PRI2 */ { TMU1_0, TMU1_1,
  562. TMU1_2, 0 } },
  563. { 0xfe41080c, 0, 32, 8, /* INT2PRI3 */ { DMAC0_0, DMAC0_1,
  564. DMAC0_2, DMAC0_3 } },
  565. { 0xfe410810, 0, 32, 8, /* INT2PRI4 */ { DMAC0_4, DMAC0_5,
  566. DMAC0_6, HUDI1 } },
  567. { 0xfe410814, 0, 32, 8, /* INT2PRI5 */ { HUDI0, DMAC1_0,
  568. DMAC1_1, DMAC1_2 } },
  569. { 0xfe410818, 0, 32, 8, /* INT2PRI6 */ { DMAC1_3, HPB_0,
  570. HPB_1, HPB_2 } },
  571. { 0xfe41081c, 0, 32, 8, /* INT2PRI7 */ { SCIF0_0, SCIF0_1,
  572. SCIF0_2, SCIF0_3 } },
  573. { 0xfe410820, 0, 32, 8, /* INT2PRI8 */ { SCIF1, TMU2, TMU3, 0 } },
  574. { 0xfe410824, 0, 32, 8, /* INT2PRI9 */ { 0, 0, SCIF2, SCIF3 } },
  575. { 0xfe410828, 0, 32, 8, /* INT2PRI10 */ { SCIF4, SCIF5,
  576. Eth_0, Eth_1 } },
  577. { 0xfe41082c, 0, 32, 8, /* INT2PRI11 */ { 0, 0, 0, 0 } },
  578. { 0xfe410830, 0, 32, 8, /* INT2PRI12 */ { 0, 0, 0, 0 } },
  579. { 0xfe410834, 0, 32, 8, /* INT2PRI13 */ { 0, 0, 0, 0 } },
  580. { 0xfe410838, 0, 32, 8, /* INT2PRI14 */ { 0, 0, 0, PCIeC0_0 } },
  581. { 0xfe41083c, 0, 32, 8, /* INT2PRI15 */ { PCIeC0_1, PCIeC0_2,
  582. PCIeC1_0, PCIeC1_1 } },
  583. { 0xfe410840, 0, 32, 8, /* INT2PRI16 */ { PCIeC1_2, USB, 0, 0 } },
  584. { 0xfe410844, 0, 32, 8, /* INT2PRI17 */ { 0, 0, 0, 0 } },
  585. { 0xfe410848, 0, 32, 8, /* INT2PRI18 */ { 0, 0, I2C0, I2C1 } },
  586. { 0xfe41084c, 0, 32, 8, /* INT2PRI19 */ { DU, SSI0, SSI1, SSI2 } },
  587. { 0xfe410850, 0, 32, 8, /* INT2PRI20 */ { SSI3, PCIeC2_0,
  588. PCIeC2_1, PCIeC2_2 } },
  589. { 0xfe410854, 0, 32, 8, /* INT2PRI21 */ { HAC0, HAC1, FLCTL, 0 } },
  590. { 0xfe410858, 0, 32, 8, /* INT2PRI22 */ { HSPI, GPIO0,
  591. GPIO1, Thermal } },
  592. { 0xfe41085c, 0, 32, 8, /* INT2PRI23 */ { 0, 0, 0, 0 } },
  593. { 0xfe410860, 0, 32, 8, /* INT2PRI24 */ { 0, 0, 0, 0 } },
  594. { 0xfe410090, 0xfe4100a0, 32, 4, /* CnICIPRI / CnICIPRICLR */
  595. { INTICI7, INTICI6, INTICI5, INTICI4,
  596. INTICI3, INTICI2, INTICI1, INTICI0 }, INTC_SMP(4, 2) },
  597. };
  598. static struct intc_subgroup sh7786_subgroups[] __initdata = {
  599. { 0xfe410c20, 32, SCIF1,
  600. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  601. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TXI1, BRI1, RXI1, ERI1 } },
  602. };
  603. static struct intc_desc sh7786_intc_desc __initdata = {
  604. .name = "sh7786",
  605. .hw = {
  606. .vectors = sh7786_vectors,
  607. .nr_vectors = ARRAY_SIZE(sh7786_vectors),
  608. .mask_regs = sh7786_mask_registers,
  609. .nr_mask_regs = ARRAY_SIZE(sh7786_mask_registers),
  610. .subgroups = sh7786_subgroups,
  611. .nr_subgroups = ARRAY_SIZE(sh7786_subgroups),
  612. .prio_regs = sh7786_prio_registers,
  613. .nr_prio_regs = ARRAY_SIZE(sh7786_prio_registers),
  614. },
  615. };
  616. /* Support for external interrupt pins in IRQ mode */
  617. static struct intc_vect vectors_irq0123[] __initdata = {
  618. INTC_VECT(IRQ0, 0x200), INTC_VECT(IRQ1, 0x240),
  619. INTC_VECT(IRQ2, 0x280), INTC_VECT(IRQ3, 0x2c0),
  620. };
  621. static struct intc_vect vectors_irq4567[] __initdata = {
  622. INTC_VECT(IRQ4, 0x300), INTC_VECT(IRQ5, 0x340),
  623. INTC_VECT(IRQ6, 0x380), INTC_VECT(IRQ7, 0x3c0),
  624. };
  625. static struct intc_sense_reg sh7786_sense_registers[] __initdata = {
  626. { 0xfe41001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  627. IRQ4, IRQ5, IRQ6, IRQ7 } },
  628. };
  629. static struct intc_mask_reg sh7786_ack_registers[] __initdata = {
  630. { 0xfe410024, 0, 32, /* INTREQ */
  631. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  632. };
  633. static DECLARE_INTC_DESC_ACK(intc_desc_irq0123, "sh7786-irq0123",
  634. vectors_irq0123, NULL, sh7786_mask_registers,
  635. sh7786_prio_registers, sh7786_sense_registers,
  636. sh7786_ack_registers);
  637. static DECLARE_INTC_DESC_ACK(intc_desc_irq4567, "sh7786-irq4567",
  638. vectors_irq4567, NULL, sh7786_mask_registers,
  639. sh7786_prio_registers, sh7786_sense_registers,
  640. sh7786_ack_registers);
  641. /* External interrupt pins in IRL mode */
  642. static struct intc_vect vectors_irl0123[] __initdata = {
  643. INTC_VECT(IRL0_LLLL, 0x200), INTC_VECT(IRL0_LLLH, 0x220),
  644. INTC_VECT(IRL0_LLHL, 0x240), INTC_VECT(IRL0_LLHH, 0x260),
  645. INTC_VECT(IRL0_LHLL, 0x280), INTC_VECT(IRL0_LHLH, 0x2a0),
  646. INTC_VECT(IRL0_LHHL, 0x2c0), INTC_VECT(IRL0_LHHH, 0x2e0),
  647. INTC_VECT(IRL0_HLLL, 0x300), INTC_VECT(IRL0_HLLH, 0x320),
  648. INTC_VECT(IRL0_HLHL, 0x340), INTC_VECT(IRL0_HLHH, 0x360),
  649. INTC_VECT(IRL0_HHLL, 0x380), INTC_VECT(IRL0_HHLH, 0x3a0),
  650. INTC_VECT(IRL0_HHHL, 0x3c0),
  651. };
  652. static struct intc_vect vectors_irl4567[] __initdata = {
  653. INTC_VECT(IRL4_LLLL, 0x900), INTC_VECT(IRL4_LLLH, 0x920),
  654. INTC_VECT(IRL4_LLHL, 0x940), INTC_VECT(IRL4_LLHH, 0x960),
  655. INTC_VECT(IRL4_LHLL, 0x980), INTC_VECT(IRL4_LHLH, 0x9a0),
  656. INTC_VECT(IRL4_LHHL, 0x9c0), INTC_VECT(IRL4_LHHH, 0x9e0),
  657. INTC_VECT(IRL4_HLLL, 0xa00), INTC_VECT(IRL4_HLLH, 0xa20),
  658. INTC_VECT(IRL4_HLHL, 0xa40), INTC_VECT(IRL4_HLHH, 0xa60),
  659. INTC_VECT(IRL4_HHLL, 0xa80), INTC_VECT(IRL4_HHLH, 0xaa0),
  660. INTC_VECT(IRL4_HHHL, 0xac0),
  661. };
  662. static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7786-irl0123", vectors_irl0123,
  663. NULL, sh7786_mask_registers, NULL, NULL);
  664. static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7786-irl4567", vectors_irl4567,
  665. NULL, sh7786_mask_registers, NULL, NULL);
  666. #define INTC_ICR0 0xfe410000
  667. #define INTC_INTMSK0 CnINTMSK0
  668. #define INTC_INTMSK1 CnINTMSK1
  669. #define INTC_INTMSK2 INTMSK2
  670. #define INTC_INTMSKCLR1 CnINTMSKCLR1
  671. #define INTC_INTMSKCLR2 INTMSKCLR2
  672. void __init plat_irq_setup(void)
  673. {
  674. /* disable IRQ3-0 + IRQ7-4 */
  675. __raw_writel(0xff000000, INTC_INTMSK0);
  676. /* disable IRL3-0 + IRL7-4 */
  677. __raw_writel(0xc0000000, INTC_INTMSK1);
  678. __raw_writel(0xfffefffe, INTC_INTMSK2);
  679. /* select IRL mode for IRL3-0 + IRL7-4 */
  680. __raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);
  681. register_intc_controller(&sh7786_intc_desc);
  682. }
  683. void __init plat_irq_setup_pins(int mode)
  684. {
  685. switch (mode) {
  686. case IRQ_MODE_IRQ7654:
  687. /* select IRQ mode for IRL7-4 */
  688. __raw_writel(__raw_readl(INTC_ICR0) | 0x00400000, INTC_ICR0);
  689. register_intc_controller(&intc_desc_irq4567);
  690. break;
  691. case IRQ_MODE_IRQ3210:
  692. /* select IRQ mode for IRL3-0 */
  693. __raw_writel(__raw_readl(INTC_ICR0) | 0x00800000, INTC_ICR0);
  694. register_intc_controller(&intc_desc_irq0123);
  695. break;
  696. case IRQ_MODE_IRL7654:
  697. /* enable IRL7-4 but don't provide any masking */
  698. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  699. __raw_writel(0x0000fffe, INTC_INTMSKCLR2);
  700. break;
  701. case IRQ_MODE_IRL3210:
  702. /* enable IRL0-3 but don't provide any masking */
  703. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  704. __raw_writel(0xfffe0000, INTC_INTMSKCLR2);
  705. break;
  706. case IRQ_MODE_IRL7654_MASK:
  707. /* enable IRL7-4 and mask using cpu intc controller */
  708. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  709. register_intc_controller(&intc_desc_irl4567);
  710. break;
  711. case IRQ_MODE_IRL3210_MASK:
  712. /* enable IRL0-3 and mask using cpu intc controller */
  713. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  714. register_intc_controller(&intc_desc_irl0123);
  715. break;
  716. default:
  717. BUG();
  718. }
  719. }
  720. void __init plat_mem_setup(void)
  721. {
  722. }
  723. static int __init sh7786_devices_setup(void)
  724. {
  725. int ret, irq;
  726. sh7786_usb_setup();
  727. /*
  728. * De-mux SCIF1 IRQs if possible
  729. */
  730. irq = intc_irq_lookup(sh7786_intc_desc.name, TXI1);
  731. if (irq > 0) {
  732. scif1_demux_resources[1].start =
  733. intc_irq_lookup(sh7786_intc_desc.name, ERI1);
  734. scif1_demux_resources[2].start =
  735. intc_irq_lookup(sh7786_intc_desc.name, RXI1);
  736. scif1_demux_resources[3].start = irq;
  737. scif1_demux_resources[4].start =
  738. intc_irq_lookup(sh7786_intc_desc.name, BRI1);
  739. scif1_device.resource = scif1_demux_resources;
  740. scif1_device.num_resources = ARRAY_SIZE(scif1_demux_resources);
  741. }
  742. ret = platform_add_devices(sh7786_early_devices,
  743. ARRAY_SIZE(sh7786_early_devices));
  744. if (unlikely(ret != 0))
  745. return ret;
  746. return platform_add_devices(sh7786_devices,
  747. ARRAY_SIZE(sh7786_devices));
  748. }
  749. arch_initcall(sh7786_devices_setup);
  750. void __init plat_early_device_setup(void)
  751. {
  752. early_platform_add_devices(sh7786_early_devices,
  753. ARRAY_SIZE(sh7786_early_devices));
  754. }