setup-sh7786.c 23 KB

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