setup-sh7786.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  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. .channel_offset = 0x04,
  159. .timer_bit = 0,
  160. .clockevent_rating = 200,
  161. };
  162. static struct resource tmu0_resources[] = {
  163. [0] = {
  164. .start = 0xffd80008,
  165. .end = 0xffd80013,
  166. .flags = IORESOURCE_MEM,
  167. },
  168. [1] = {
  169. .start = evt2irq(0x400),
  170. .flags = IORESOURCE_IRQ,
  171. },
  172. };
  173. static struct platform_device tmu0_device = {
  174. .name = "sh_tmu",
  175. .id = 0,
  176. .dev = {
  177. .platform_data = &tmu0_platform_data,
  178. },
  179. .resource = tmu0_resources,
  180. .num_resources = ARRAY_SIZE(tmu0_resources),
  181. };
  182. static struct sh_timer_config tmu1_platform_data = {
  183. .channel_offset = 0x10,
  184. .timer_bit = 1,
  185. .clocksource_rating = 200,
  186. };
  187. static struct resource tmu1_resources[] = {
  188. [0] = {
  189. .start = 0xffd80014,
  190. .end = 0xffd8001f,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. [1] = {
  194. .start = evt2irq(0x420),
  195. .flags = IORESOURCE_IRQ,
  196. },
  197. };
  198. static struct platform_device tmu1_device = {
  199. .name = "sh_tmu",
  200. .id = 1,
  201. .dev = {
  202. .platform_data = &tmu1_platform_data,
  203. },
  204. .resource = tmu1_resources,
  205. .num_resources = ARRAY_SIZE(tmu1_resources),
  206. };
  207. static struct sh_timer_config tmu2_platform_data = {
  208. .channel_offset = 0x1c,
  209. .timer_bit = 2,
  210. };
  211. static struct resource tmu2_resources[] = {
  212. [0] = {
  213. .start = 0xffd80020,
  214. .end = 0xffd8002f,
  215. .flags = IORESOURCE_MEM,
  216. },
  217. [1] = {
  218. .start = evt2irq(0x440),
  219. .flags = IORESOURCE_IRQ,
  220. },
  221. };
  222. static struct platform_device tmu2_device = {
  223. .name = "sh_tmu",
  224. .id = 2,
  225. .dev = {
  226. .platform_data = &tmu2_platform_data,
  227. },
  228. .resource = tmu2_resources,
  229. .num_resources = ARRAY_SIZE(tmu2_resources),
  230. };
  231. static struct sh_timer_config tmu3_platform_data = {
  232. .channel_offset = 0x04,
  233. .timer_bit = 0,
  234. };
  235. static struct resource tmu3_resources[] = {
  236. [0] = {
  237. .start = 0xffda0008,
  238. .end = 0xffda0013,
  239. .flags = IORESOURCE_MEM,
  240. },
  241. [1] = {
  242. .start = evt2irq(0x480),
  243. .flags = IORESOURCE_IRQ,
  244. },
  245. };
  246. static struct platform_device tmu3_device = {
  247. .name = "sh_tmu",
  248. .id = 3,
  249. .dev = {
  250. .platform_data = &tmu3_platform_data,
  251. },
  252. .resource = tmu3_resources,
  253. .num_resources = ARRAY_SIZE(tmu3_resources),
  254. };
  255. static struct sh_timer_config tmu4_platform_data = {
  256. .channel_offset = 0x10,
  257. .timer_bit = 1,
  258. };
  259. static struct resource tmu4_resources[] = {
  260. [0] = {
  261. .start = 0xffda0014,
  262. .end = 0xffda001f,
  263. .flags = IORESOURCE_MEM,
  264. },
  265. [1] = {
  266. .start = evt2irq(0x4a0),
  267. .flags = IORESOURCE_IRQ,
  268. },
  269. };
  270. static struct platform_device tmu4_device = {
  271. .name = "sh_tmu",
  272. .id = 4,
  273. .dev = {
  274. .platform_data = &tmu4_platform_data,
  275. },
  276. .resource = tmu4_resources,
  277. .num_resources = ARRAY_SIZE(tmu4_resources),
  278. };
  279. static struct sh_timer_config tmu5_platform_data = {
  280. .channel_offset = 0x1c,
  281. .timer_bit = 2,
  282. };
  283. static struct resource tmu5_resources[] = {
  284. [0] = {
  285. .start = 0xffda0020,
  286. .end = 0xffda002b,
  287. .flags = IORESOURCE_MEM,
  288. },
  289. [1] = {
  290. .start = evt2irq(0x4c0),
  291. .flags = IORESOURCE_IRQ,
  292. },
  293. };
  294. static struct platform_device tmu5_device = {
  295. .name = "sh_tmu",
  296. .id = 5,
  297. .dev = {
  298. .platform_data = &tmu5_platform_data,
  299. },
  300. .resource = tmu5_resources,
  301. .num_resources = ARRAY_SIZE(tmu5_resources),
  302. };
  303. static struct sh_timer_config tmu6_platform_data = {
  304. .channel_offset = 0x04,
  305. .timer_bit = 0,
  306. };
  307. static struct resource tmu6_resources[] = {
  308. [0] = {
  309. .start = 0xffdc0008,
  310. .end = 0xffdc0013,
  311. .flags = IORESOURCE_MEM,
  312. },
  313. [1] = {
  314. .start = evt2irq(0x7a0),
  315. .flags = IORESOURCE_IRQ,
  316. },
  317. };
  318. static struct platform_device tmu6_device = {
  319. .name = "sh_tmu",
  320. .id = 6,
  321. .dev = {
  322. .platform_data = &tmu6_platform_data,
  323. },
  324. .resource = tmu6_resources,
  325. .num_resources = ARRAY_SIZE(tmu6_resources),
  326. };
  327. static struct sh_timer_config tmu7_platform_data = {
  328. .channel_offset = 0x10,
  329. .timer_bit = 1,
  330. };
  331. static struct resource tmu7_resources[] = {
  332. [0] = {
  333. .start = 0xffdc0014,
  334. .end = 0xffdc001f,
  335. .flags = IORESOURCE_MEM,
  336. },
  337. [1] = {
  338. .start = evt2irq(0x7a0),
  339. .flags = IORESOURCE_IRQ,
  340. },
  341. };
  342. static struct platform_device tmu7_device = {
  343. .name = "sh_tmu",
  344. .id = 7,
  345. .dev = {
  346. .platform_data = &tmu7_platform_data,
  347. },
  348. .resource = tmu7_resources,
  349. .num_resources = ARRAY_SIZE(tmu7_resources),
  350. };
  351. static struct sh_timer_config tmu8_platform_data = {
  352. .channel_offset = 0x1c,
  353. .timer_bit = 2,
  354. };
  355. static struct resource tmu8_resources[] = {
  356. [0] = {
  357. .start = 0xffdc0020,
  358. .end = 0xffdc002b,
  359. .flags = IORESOURCE_MEM,
  360. },
  361. [1] = {
  362. .start = evt2irq(0x7a0),
  363. .flags = IORESOURCE_IRQ,
  364. },
  365. };
  366. static struct platform_device tmu8_device = {
  367. .name = "sh_tmu",
  368. .id = 8,
  369. .dev = {
  370. .platform_data = &tmu8_platform_data,
  371. },
  372. .resource = tmu8_resources,
  373. .num_resources = ARRAY_SIZE(tmu8_resources),
  374. };
  375. static struct sh_timer_config tmu9_platform_data = {
  376. .channel_offset = 0x04,
  377. .timer_bit = 0,
  378. };
  379. static struct resource tmu9_resources[] = {
  380. [0] = {
  381. .start = 0xffde0008,
  382. .end = 0xffde0013,
  383. .flags = IORESOURCE_MEM,
  384. },
  385. [1] = {
  386. .start = evt2irq(0x7c0),
  387. .flags = IORESOURCE_IRQ,
  388. },
  389. };
  390. static struct platform_device tmu9_device = {
  391. .name = "sh_tmu",
  392. .id = 9,
  393. .dev = {
  394. .platform_data = &tmu9_platform_data,
  395. },
  396. .resource = tmu9_resources,
  397. .num_resources = ARRAY_SIZE(tmu9_resources),
  398. };
  399. static struct sh_timer_config tmu10_platform_data = {
  400. .channel_offset = 0x10,
  401. .timer_bit = 1,
  402. };
  403. static struct resource tmu10_resources[] = {
  404. [0] = {
  405. .start = 0xffde0014,
  406. .end = 0xffde001f,
  407. .flags = IORESOURCE_MEM,
  408. },
  409. [1] = {
  410. .start = evt2irq(0x7c0),
  411. .flags = IORESOURCE_IRQ,
  412. },
  413. };
  414. static struct platform_device tmu10_device = {
  415. .name = "sh_tmu",
  416. .id = 10,
  417. .dev = {
  418. .platform_data = &tmu10_platform_data,
  419. },
  420. .resource = tmu10_resources,
  421. .num_resources = ARRAY_SIZE(tmu10_resources),
  422. };
  423. static struct sh_timer_config tmu11_platform_data = {
  424. .channel_offset = 0x1c,
  425. .timer_bit = 2,
  426. };
  427. static struct resource tmu11_resources[] = {
  428. [0] = {
  429. .start = 0xffde0020,
  430. .end = 0xffde002b,
  431. .flags = IORESOURCE_MEM,
  432. },
  433. [1] = {
  434. .start = evt2irq(0x7c0),
  435. .flags = IORESOURCE_IRQ,
  436. },
  437. };
  438. static struct platform_device tmu11_device = {
  439. .name = "sh_tmu",
  440. .id = 11,
  441. .dev = {
  442. .platform_data = &tmu11_platform_data,
  443. },
  444. .resource = tmu11_resources,
  445. .num_resources = ARRAY_SIZE(tmu11_resources),
  446. };
  447. static const struct sh_dmae_channel dmac0_channels[] = {
  448. {
  449. .offset = 0,
  450. .dmars = 0,
  451. .dmars_bit = 0,
  452. }, {
  453. .offset = 0x10,
  454. .dmars = 0,
  455. .dmars_bit = 8,
  456. }, {
  457. .offset = 0x20,
  458. .dmars = 4,
  459. .dmars_bit = 0,
  460. }, {
  461. .offset = 0x30,
  462. .dmars = 4,
  463. .dmars_bit = 8,
  464. }, {
  465. .offset = 0x50,
  466. .dmars = 8,
  467. .dmars_bit = 0,
  468. }, {
  469. .offset = 0x60,
  470. .dmars = 8,
  471. .dmars_bit = 8,
  472. }
  473. };
  474. static const unsigned int ts_shift[] = TS_SHIFT;
  475. static struct sh_dmae_pdata dma0_platform_data = {
  476. .channel = dmac0_channels,
  477. .channel_num = ARRAY_SIZE(dmac0_channels),
  478. .ts_low_shift = CHCR_TS_LOW_SHIFT,
  479. .ts_low_mask = CHCR_TS_LOW_MASK,
  480. .ts_high_shift = CHCR_TS_HIGH_SHIFT,
  481. .ts_high_mask = CHCR_TS_HIGH_MASK,
  482. .ts_shift = ts_shift,
  483. .ts_shift_num = ARRAY_SIZE(ts_shift),
  484. .dmaor_init = DMAOR_INIT,
  485. };
  486. /* Resource order important! */
  487. static struct resource dmac0_resources[] = {
  488. {
  489. /* Channel registers and DMAOR */
  490. .start = 0xfe008020,
  491. .end = 0xfe00808f,
  492. .flags = IORESOURCE_MEM,
  493. }, {
  494. /* DMARSx */
  495. .start = 0xfe009000,
  496. .end = 0xfe00900b,
  497. .flags = IORESOURCE_MEM,
  498. }, {
  499. .name = "error_irq",
  500. .start = evt2irq(0x5c0),
  501. .end = evt2irq(0x5c0),
  502. .flags = IORESOURCE_IRQ,
  503. }, {
  504. /* IRQ for channels 0-5 */
  505. .start = evt2irq(0x500),
  506. .end = evt2irq(0x5a0),
  507. .flags = IORESOURCE_IRQ,
  508. },
  509. };
  510. static struct platform_device dma0_device = {
  511. .name = "sh-dma-engine",
  512. .id = 0,
  513. .resource = dmac0_resources,
  514. .num_resources = ARRAY_SIZE(dmac0_resources),
  515. .dev = {
  516. .platform_data = &dma0_platform_data,
  517. },
  518. };
  519. #define USB_EHCI_START 0xffe70000
  520. #define USB_OHCI_START 0xffe70400
  521. static struct resource usb_ehci_resources[] = {
  522. [0] = {
  523. .start = USB_EHCI_START,
  524. .end = USB_EHCI_START + 0x3ff,
  525. .flags = IORESOURCE_MEM,
  526. },
  527. [1] = {
  528. .start = evt2irq(0xba0),
  529. .end = evt2irq(0xba0),
  530. .flags = IORESOURCE_IRQ,
  531. },
  532. };
  533. static struct platform_device usb_ehci_device = {
  534. .name = "sh_ehci",
  535. .id = -1,
  536. .dev = {
  537. .dma_mask = &usb_ehci_device.dev.coherent_dma_mask,
  538. .coherent_dma_mask = DMA_BIT_MASK(32),
  539. },
  540. .num_resources = ARRAY_SIZE(usb_ehci_resources),
  541. .resource = usb_ehci_resources,
  542. };
  543. static struct resource usb_ohci_resources[] = {
  544. [0] = {
  545. .start = USB_OHCI_START,
  546. .end = USB_OHCI_START + 0x3ff,
  547. .flags = IORESOURCE_MEM,
  548. },
  549. [1] = {
  550. .start = evt2irq(0xba0),
  551. .end = evt2irq(0xba0),
  552. .flags = IORESOURCE_IRQ,
  553. },
  554. };
  555. static struct usb_ohci_pdata usb_ohci_pdata;
  556. static struct platform_device usb_ohci_device = {
  557. .name = "ohci-platform",
  558. .id = -1,
  559. .dev = {
  560. .dma_mask = &usb_ohci_device.dev.coherent_dma_mask,
  561. .coherent_dma_mask = DMA_BIT_MASK(32),
  562. .platform_data = &usb_ohci_pdata,
  563. },
  564. .num_resources = ARRAY_SIZE(usb_ohci_resources),
  565. .resource = usb_ohci_resources,
  566. };
  567. static struct platform_device *sh7786_early_devices[] __initdata = {
  568. &scif0_device,
  569. &scif1_device,
  570. &scif2_device,
  571. &scif3_device,
  572. &scif4_device,
  573. &scif5_device,
  574. &tmu0_device,
  575. &tmu1_device,
  576. &tmu2_device,
  577. &tmu3_device,
  578. &tmu4_device,
  579. &tmu5_device,
  580. &tmu6_device,
  581. &tmu7_device,
  582. &tmu8_device,
  583. &tmu9_device,
  584. &tmu10_device,
  585. &tmu11_device,
  586. };
  587. static struct platform_device *sh7786_devices[] __initdata = {
  588. &dma0_device,
  589. &usb_ehci_device,
  590. &usb_ohci_device,
  591. };
  592. /*
  593. * Please call this function if your platform board
  594. * use external clock for USB
  595. * */
  596. #define USBCTL0 0xffe70858
  597. #define CLOCK_MODE_MASK 0xffffff7f
  598. #define EXT_CLOCK_MODE 0x00000080
  599. void __init sh7786_usb_use_exclock(void)
  600. {
  601. u32 val = __raw_readl(USBCTL0) & CLOCK_MODE_MASK;
  602. __raw_writel(val | EXT_CLOCK_MODE, USBCTL0);
  603. }
  604. #define USBINITREG1 0xffe70094
  605. #define USBINITREG2 0xffe7009c
  606. #define USBINITVAL1 0x00ff0040
  607. #define USBINITVAL2 0x00000001
  608. #define USBPCTL1 0xffe70804
  609. #define USBST 0xffe70808
  610. #define PHY_ENB 0x00000001
  611. #define PLL_ENB 0x00000002
  612. #define PHY_RST 0x00000004
  613. #define ACT_PLL_STATUS 0xc0000000
  614. static void __init sh7786_usb_setup(void)
  615. {
  616. int i = 1000000;
  617. /*
  618. * USB initial settings
  619. *
  620. * The following settings are necessary
  621. * for using the USB modules.
  622. *
  623. * see "USB Initial Settings" for detail
  624. */
  625. __raw_writel(USBINITVAL1, USBINITREG1);
  626. __raw_writel(USBINITVAL2, USBINITREG2);
  627. /*
  628. * Set the PHY and PLL enable bit
  629. */
  630. __raw_writel(PHY_ENB | PLL_ENB, USBPCTL1);
  631. while (i--) {
  632. if (ACT_PLL_STATUS == (__raw_readl(USBST) & ACT_PLL_STATUS)) {
  633. /* Set the PHY RST bit */
  634. __raw_writel(PHY_ENB | PLL_ENB | PHY_RST, USBPCTL1);
  635. printk(KERN_INFO "sh7786 usb setup done\n");
  636. break;
  637. }
  638. cpu_relax();
  639. }
  640. }
  641. enum {
  642. UNUSED = 0,
  643. /* interrupt sources */
  644. IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,
  645. IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,
  646. IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,
  647. IRL0_HHLL, IRL0_HHLH, IRL0_HHHL,
  648. IRL4_LLLL, IRL4_LLLH, IRL4_LLHL, IRL4_LLHH,
  649. IRL4_LHLL, IRL4_LHLH, IRL4_LHHL, IRL4_LHHH,
  650. IRL4_HLLL, IRL4_HLLH, IRL4_HLHL, IRL4_HLHH,
  651. IRL4_HHLL, IRL4_HHLH, IRL4_HHHL,
  652. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  653. WDT,
  654. TMU0_0, TMU0_1, TMU0_2, TMU0_3,
  655. TMU1_0, TMU1_1, TMU1_2,
  656. DMAC0_0, DMAC0_1, DMAC0_2, DMAC0_3, DMAC0_4, DMAC0_5, DMAC0_6,
  657. HUDI1, HUDI0,
  658. DMAC1_0, DMAC1_1, DMAC1_2, DMAC1_3,
  659. HPB_0, HPB_1, HPB_2,
  660. SCIF0_0, SCIF0_1, SCIF0_2, SCIF0_3,
  661. SCIF1,
  662. TMU2, TMU3,
  663. SCIF2, SCIF3, SCIF4, SCIF5,
  664. Eth_0, Eth_1,
  665. PCIeC0_0, PCIeC0_1, PCIeC0_2,
  666. PCIeC1_0, PCIeC1_1, PCIeC1_2,
  667. USB,
  668. I2C0, I2C1,
  669. DU,
  670. SSI0, SSI1, SSI2, SSI3,
  671. PCIeC2_0, PCIeC2_1, PCIeC2_2,
  672. HAC0, HAC1,
  673. FLCTL,
  674. HSPI,
  675. GPIO0, GPIO1,
  676. Thermal,
  677. INTICI0, INTICI1, INTICI2, INTICI3,
  678. INTICI4, INTICI5, INTICI6, INTICI7,
  679. /* Muxed sub-events */
  680. TXI1, BRI1, RXI1, ERI1,
  681. };
  682. static struct intc_vect sh7786_vectors[] __initdata = {
  683. INTC_VECT(WDT, 0x3e0),
  684. INTC_VECT(TMU0_0, 0x400), INTC_VECT(TMU0_1, 0x420),
  685. INTC_VECT(TMU0_2, 0x440), INTC_VECT(TMU0_3, 0x460),
  686. INTC_VECT(TMU1_0, 0x480), INTC_VECT(TMU1_1, 0x4a0),
  687. INTC_VECT(TMU1_2, 0x4c0),
  688. INTC_VECT(DMAC0_0, 0x500), INTC_VECT(DMAC0_1, 0x520),
  689. INTC_VECT(DMAC0_2, 0x540), INTC_VECT(DMAC0_3, 0x560),
  690. INTC_VECT(DMAC0_4, 0x580), INTC_VECT(DMAC0_5, 0x5a0),
  691. INTC_VECT(DMAC0_6, 0x5c0),
  692. INTC_VECT(HUDI1, 0x5e0), INTC_VECT(HUDI0, 0x600),
  693. INTC_VECT(DMAC1_0, 0x620), INTC_VECT(DMAC1_1, 0x640),
  694. INTC_VECT(DMAC1_2, 0x660), INTC_VECT(DMAC1_3, 0x680),
  695. INTC_VECT(HPB_0, 0x6a0), INTC_VECT(HPB_1, 0x6c0),
  696. INTC_VECT(HPB_2, 0x6e0),
  697. INTC_VECT(SCIF0_0, 0x700), INTC_VECT(SCIF0_1, 0x720),
  698. INTC_VECT(SCIF0_2, 0x740), INTC_VECT(SCIF0_3, 0x760),
  699. INTC_VECT(SCIF1, 0x780),
  700. INTC_VECT(TMU2, 0x7a0), INTC_VECT(TMU3, 0x7c0),
  701. INTC_VECT(SCIF2, 0x840), INTC_VECT(SCIF3, 0x860),
  702. INTC_VECT(SCIF4, 0x880), INTC_VECT(SCIF5, 0x8a0),
  703. INTC_VECT(Eth_0, 0x8c0), INTC_VECT(Eth_1, 0x8e0),
  704. INTC_VECT(PCIeC0_0, 0xae0), INTC_VECT(PCIeC0_1, 0xb00),
  705. INTC_VECT(PCIeC0_2, 0xb20),
  706. INTC_VECT(PCIeC1_0, 0xb40), INTC_VECT(PCIeC1_1, 0xb60),
  707. INTC_VECT(PCIeC1_2, 0xb80),
  708. INTC_VECT(USB, 0xba0),
  709. INTC_VECT(I2C0, 0xcc0), INTC_VECT(I2C1, 0xce0),
  710. INTC_VECT(DU, 0xd00),
  711. INTC_VECT(SSI0, 0xd20), INTC_VECT(SSI1, 0xd40),
  712. INTC_VECT(SSI2, 0xd60), INTC_VECT(SSI3, 0xd80),
  713. INTC_VECT(PCIeC2_0, 0xda0), INTC_VECT(PCIeC2_1, 0xdc0),
  714. INTC_VECT(PCIeC2_2, 0xde0),
  715. INTC_VECT(HAC0, 0xe00), INTC_VECT(HAC1, 0xe20),
  716. INTC_VECT(FLCTL, 0xe40),
  717. INTC_VECT(HSPI, 0xe80),
  718. INTC_VECT(GPIO0, 0xea0), INTC_VECT(GPIO1, 0xec0),
  719. INTC_VECT(Thermal, 0xee0),
  720. INTC_VECT(INTICI0, 0xf00), INTC_VECT(INTICI1, 0xf20),
  721. INTC_VECT(INTICI2, 0xf40), INTC_VECT(INTICI3, 0xf60),
  722. INTC_VECT(INTICI4, 0xf80), INTC_VECT(INTICI5, 0xfa0),
  723. INTC_VECT(INTICI6, 0xfc0), INTC_VECT(INTICI7, 0xfe0),
  724. };
  725. #define CnINTMSK0 0xfe410030
  726. #define CnINTMSK1 0xfe410040
  727. #define CnINTMSKCLR0 0xfe410050
  728. #define CnINTMSKCLR1 0xfe410060
  729. #define CnINT2MSKR0 0xfe410a20
  730. #define CnINT2MSKR1 0xfe410a24
  731. #define CnINT2MSKR2 0xfe410a28
  732. #define CnINT2MSKR3 0xfe410a2c
  733. #define CnINT2MSKCR0 0xfe410a30
  734. #define CnINT2MSKCR1 0xfe410a34
  735. #define CnINT2MSKCR2 0xfe410a38
  736. #define CnINT2MSKCR3 0xfe410a3c
  737. #define INTMSK2 0xfe410068
  738. #define INTMSKCLR2 0xfe41006c
  739. #define INTDISTCR0 0xfe4100b0
  740. #define INTDISTCR1 0xfe4100b4
  741. #define INT2DISTCR0 0xfe410900
  742. #define INT2DISTCR1 0xfe410904
  743. #define INT2DISTCR2 0xfe410908
  744. #define INT2DISTCR3 0xfe41090c
  745. static struct intc_mask_reg sh7786_mask_registers[] __initdata = {
  746. { CnINTMSK0, CnINTMSKCLR0, 32,
  747. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 },
  748. INTC_SMP_BALANCING(INTDISTCR0) },
  749. { INTMSK2, INTMSKCLR2, 32,
  750. { IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,
  751. IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,
  752. IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,
  753. IRL0_HHLL, IRL0_HHLH, IRL0_HHHL, 0,
  754. IRL4_LLLL, IRL4_LLLH, IRL4_LLHL, IRL4_LLHH,
  755. IRL4_LHLL, IRL4_LHLH, IRL4_LHHL, IRL4_LHHH,
  756. IRL4_HLLL, IRL4_HLLH, IRL4_HLHL, IRL4_HLHH,
  757. IRL4_HHLL, IRL4_HHLH, IRL4_HHHL, 0, } },
  758. { CnINT2MSKR0, CnINT2MSKCR0 , 32,
  759. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  760. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, WDT },
  761. INTC_SMP_BALANCING(INT2DISTCR0) },
  762. { CnINT2MSKR1, CnINT2MSKCR1, 32,
  763. { TMU0_0, TMU0_1, TMU0_2, TMU0_3, TMU1_0, TMU1_1, TMU1_2, 0,
  764. DMAC0_0, DMAC0_1, DMAC0_2, DMAC0_3, DMAC0_4, DMAC0_5, DMAC0_6,
  765. HUDI1, HUDI0,
  766. DMAC1_0, DMAC1_1, DMAC1_2, DMAC1_3,
  767. HPB_0, HPB_1, HPB_2,
  768. SCIF0_0, SCIF0_1, SCIF0_2, SCIF0_3,
  769. SCIF1,
  770. TMU2, TMU3, 0, }, INTC_SMP_BALANCING(INT2DISTCR1) },
  771. { CnINT2MSKR2, CnINT2MSKCR2, 32,
  772. { 0, 0, SCIF2, SCIF3, SCIF4, SCIF5,
  773. Eth_0, Eth_1,
  774. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  775. PCIeC0_0, PCIeC0_1, PCIeC0_2,
  776. PCIeC1_0, PCIeC1_1, PCIeC1_2,
  777. USB, 0, 0 }, INTC_SMP_BALANCING(INT2DISTCR2) },
  778. { CnINT2MSKR3, CnINT2MSKCR3, 32,
  779. { 0, 0, 0, 0, 0, 0,
  780. I2C0, I2C1,
  781. DU, SSI0, SSI1, SSI2, SSI3,
  782. PCIeC2_0, PCIeC2_1, PCIeC2_2,
  783. HAC0, HAC1,
  784. FLCTL, 0,
  785. HSPI, GPIO0, GPIO1, Thermal,
  786. 0, 0, 0, 0, 0, 0, 0, 0 }, INTC_SMP_BALANCING(INT2DISTCR3) },
  787. };
  788. static struct intc_prio_reg sh7786_prio_registers[] __initdata = {
  789. { 0xfe410010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  790. IRQ4, IRQ5, IRQ6, IRQ7 } },
  791. { 0xfe410800, 0, 32, 8, /* INT2PRI0 */ { 0, 0, 0, WDT } },
  792. { 0xfe410804, 0, 32, 8, /* INT2PRI1 */ { TMU0_0, TMU0_1,
  793. TMU0_2, TMU0_3 } },
  794. { 0xfe410808, 0, 32, 8, /* INT2PRI2 */ { TMU1_0, TMU1_1,
  795. TMU1_2, 0 } },
  796. { 0xfe41080c, 0, 32, 8, /* INT2PRI3 */ { DMAC0_0, DMAC0_1,
  797. DMAC0_2, DMAC0_3 } },
  798. { 0xfe410810, 0, 32, 8, /* INT2PRI4 */ { DMAC0_4, DMAC0_5,
  799. DMAC0_6, HUDI1 } },
  800. { 0xfe410814, 0, 32, 8, /* INT2PRI5 */ { HUDI0, DMAC1_0,
  801. DMAC1_1, DMAC1_2 } },
  802. { 0xfe410818, 0, 32, 8, /* INT2PRI6 */ { DMAC1_3, HPB_0,
  803. HPB_1, HPB_2 } },
  804. { 0xfe41081c, 0, 32, 8, /* INT2PRI7 */ { SCIF0_0, SCIF0_1,
  805. SCIF0_2, SCIF0_3 } },
  806. { 0xfe410820, 0, 32, 8, /* INT2PRI8 */ { SCIF1, TMU2, TMU3, 0 } },
  807. { 0xfe410824, 0, 32, 8, /* INT2PRI9 */ { 0, 0, SCIF2, SCIF3 } },
  808. { 0xfe410828, 0, 32, 8, /* INT2PRI10 */ { SCIF4, SCIF5,
  809. Eth_0, Eth_1 } },
  810. { 0xfe41082c, 0, 32, 8, /* INT2PRI11 */ { 0, 0, 0, 0 } },
  811. { 0xfe410830, 0, 32, 8, /* INT2PRI12 */ { 0, 0, 0, 0 } },
  812. { 0xfe410834, 0, 32, 8, /* INT2PRI13 */ { 0, 0, 0, 0 } },
  813. { 0xfe410838, 0, 32, 8, /* INT2PRI14 */ { 0, 0, 0, PCIeC0_0 } },
  814. { 0xfe41083c, 0, 32, 8, /* INT2PRI15 */ { PCIeC0_1, PCIeC0_2,
  815. PCIeC1_0, PCIeC1_1 } },
  816. { 0xfe410840, 0, 32, 8, /* INT2PRI16 */ { PCIeC1_2, USB, 0, 0 } },
  817. { 0xfe410844, 0, 32, 8, /* INT2PRI17 */ { 0, 0, 0, 0 } },
  818. { 0xfe410848, 0, 32, 8, /* INT2PRI18 */ { 0, 0, I2C0, I2C1 } },
  819. { 0xfe41084c, 0, 32, 8, /* INT2PRI19 */ { DU, SSI0, SSI1, SSI2 } },
  820. { 0xfe410850, 0, 32, 8, /* INT2PRI20 */ { SSI3, PCIeC2_0,
  821. PCIeC2_1, PCIeC2_2 } },
  822. { 0xfe410854, 0, 32, 8, /* INT2PRI21 */ { HAC0, HAC1, FLCTL, 0 } },
  823. { 0xfe410858, 0, 32, 8, /* INT2PRI22 */ { HSPI, GPIO0,
  824. GPIO1, Thermal } },
  825. { 0xfe41085c, 0, 32, 8, /* INT2PRI23 */ { 0, 0, 0, 0 } },
  826. { 0xfe410860, 0, 32, 8, /* INT2PRI24 */ { 0, 0, 0, 0 } },
  827. { 0xfe410090, 0xfe4100a0, 32, 4, /* CnICIPRI / CnICIPRICLR */
  828. { INTICI7, INTICI6, INTICI5, INTICI4,
  829. INTICI3, INTICI2, INTICI1, INTICI0 }, INTC_SMP(4, 2) },
  830. };
  831. static struct intc_subgroup sh7786_subgroups[] __initdata = {
  832. { 0xfe410c20, 32, SCIF1,
  833. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  834. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TXI1, BRI1, RXI1, ERI1 } },
  835. };
  836. static struct intc_desc sh7786_intc_desc __initdata = {
  837. .name = "sh7786",
  838. .hw = {
  839. .vectors = sh7786_vectors,
  840. .nr_vectors = ARRAY_SIZE(sh7786_vectors),
  841. .mask_regs = sh7786_mask_registers,
  842. .nr_mask_regs = ARRAY_SIZE(sh7786_mask_registers),
  843. .subgroups = sh7786_subgroups,
  844. .nr_subgroups = ARRAY_SIZE(sh7786_subgroups),
  845. .prio_regs = sh7786_prio_registers,
  846. .nr_prio_regs = ARRAY_SIZE(sh7786_prio_registers),
  847. },
  848. };
  849. /* Support for external interrupt pins in IRQ mode */
  850. static struct intc_vect vectors_irq0123[] __initdata = {
  851. INTC_VECT(IRQ0, 0x200), INTC_VECT(IRQ1, 0x240),
  852. INTC_VECT(IRQ2, 0x280), INTC_VECT(IRQ3, 0x2c0),
  853. };
  854. static struct intc_vect vectors_irq4567[] __initdata = {
  855. INTC_VECT(IRQ4, 0x300), INTC_VECT(IRQ5, 0x340),
  856. INTC_VECT(IRQ6, 0x380), INTC_VECT(IRQ7, 0x3c0),
  857. };
  858. static struct intc_sense_reg sh7786_sense_registers[] __initdata = {
  859. { 0xfe41001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  860. IRQ4, IRQ5, IRQ6, IRQ7 } },
  861. };
  862. static struct intc_mask_reg sh7786_ack_registers[] __initdata = {
  863. { 0xfe410024, 0, 32, /* INTREQ */
  864. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  865. };
  866. static DECLARE_INTC_DESC_ACK(intc_desc_irq0123, "sh7786-irq0123",
  867. vectors_irq0123, NULL, sh7786_mask_registers,
  868. sh7786_prio_registers, sh7786_sense_registers,
  869. sh7786_ack_registers);
  870. static DECLARE_INTC_DESC_ACK(intc_desc_irq4567, "sh7786-irq4567",
  871. vectors_irq4567, NULL, sh7786_mask_registers,
  872. sh7786_prio_registers, sh7786_sense_registers,
  873. sh7786_ack_registers);
  874. /* External interrupt pins in IRL mode */
  875. static struct intc_vect vectors_irl0123[] __initdata = {
  876. INTC_VECT(IRL0_LLLL, 0x200), INTC_VECT(IRL0_LLLH, 0x220),
  877. INTC_VECT(IRL0_LLHL, 0x240), INTC_VECT(IRL0_LLHH, 0x260),
  878. INTC_VECT(IRL0_LHLL, 0x280), INTC_VECT(IRL0_LHLH, 0x2a0),
  879. INTC_VECT(IRL0_LHHL, 0x2c0), INTC_VECT(IRL0_LHHH, 0x2e0),
  880. INTC_VECT(IRL0_HLLL, 0x300), INTC_VECT(IRL0_HLLH, 0x320),
  881. INTC_VECT(IRL0_HLHL, 0x340), INTC_VECT(IRL0_HLHH, 0x360),
  882. INTC_VECT(IRL0_HHLL, 0x380), INTC_VECT(IRL0_HHLH, 0x3a0),
  883. INTC_VECT(IRL0_HHHL, 0x3c0),
  884. };
  885. static struct intc_vect vectors_irl4567[] __initdata = {
  886. INTC_VECT(IRL4_LLLL, 0x900), INTC_VECT(IRL4_LLLH, 0x920),
  887. INTC_VECT(IRL4_LLHL, 0x940), INTC_VECT(IRL4_LLHH, 0x960),
  888. INTC_VECT(IRL4_LHLL, 0x980), INTC_VECT(IRL4_LHLH, 0x9a0),
  889. INTC_VECT(IRL4_LHHL, 0x9c0), INTC_VECT(IRL4_LHHH, 0x9e0),
  890. INTC_VECT(IRL4_HLLL, 0xa00), INTC_VECT(IRL4_HLLH, 0xa20),
  891. INTC_VECT(IRL4_HLHL, 0xa40), INTC_VECT(IRL4_HLHH, 0xa60),
  892. INTC_VECT(IRL4_HHLL, 0xa80), INTC_VECT(IRL4_HHLH, 0xaa0),
  893. INTC_VECT(IRL4_HHHL, 0xac0),
  894. };
  895. static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7786-irl0123", vectors_irl0123,
  896. NULL, sh7786_mask_registers, NULL, NULL);
  897. static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7786-irl4567", vectors_irl4567,
  898. NULL, sh7786_mask_registers, NULL, NULL);
  899. #define INTC_ICR0 0xfe410000
  900. #define INTC_INTMSK0 CnINTMSK0
  901. #define INTC_INTMSK1 CnINTMSK1
  902. #define INTC_INTMSK2 INTMSK2
  903. #define INTC_INTMSKCLR1 CnINTMSKCLR1
  904. #define INTC_INTMSKCLR2 INTMSKCLR2
  905. void __init plat_irq_setup(void)
  906. {
  907. /* disable IRQ3-0 + IRQ7-4 */
  908. __raw_writel(0xff000000, INTC_INTMSK0);
  909. /* disable IRL3-0 + IRL7-4 */
  910. __raw_writel(0xc0000000, INTC_INTMSK1);
  911. __raw_writel(0xfffefffe, INTC_INTMSK2);
  912. /* select IRL mode for IRL3-0 + IRL7-4 */
  913. __raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);
  914. register_intc_controller(&sh7786_intc_desc);
  915. }
  916. void __init plat_irq_setup_pins(int mode)
  917. {
  918. switch (mode) {
  919. case IRQ_MODE_IRQ7654:
  920. /* select IRQ mode for IRL7-4 */
  921. __raw_writel(__raw_readl(INTC_ICR0) | 0x00400000, INTC_ICR0);
  922. register_intc_controller(&intc_desc_irq4567);
  923. break;
  924. case IRQ_MODE_IRQ3210:
  925. /* select IRQ mode for IRL3-0 */
  926. __raw_writel(__raw_readl(INTC_ICR0) | 0x00800000, INTC_ICR0);
  927. register_intc_controller(&intc_desc_irq0123);
  928. break;
  929. case IRQ_MODE_IRL7654:
  930. /* enable IRL7-4 but don't provide any masking */
  931. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  932. __raw_writel(0x0000fffe, INTC_INTMSKCLR2);
  933. break;
  934. case IRQ_MODE_IRL3210:
  935. /* enable IRL0-3 but don't provide any masking */
  936. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  937. __raw_writel(0xfffe0000, INTC_INTMSKCLR2);
  938. break;
  939. case IRQ_MODE_IRL7654_MASK:
  940. /* enable IRL7-4 and mask using cpu intc controller */
  941. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  942. register_intc_controller(&intc_desc_irl4567);
  943. break;
  944. case IRQ_MODE_IRL3210_MASK:
  945. /* enable IRL0-3 and mask using cpu intc controller */
  946. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  947. register_intc_controller(&intc_desc_irl0123);
  948. break;
  949. default:
  950. BUG();
  951. }
  952. }
  953. void __init plat_mem_setup(void)
  954. {
  955. }
  956. static int __init sh7786_devices_setup(void)
  957. {
  958. int ret, irq;
  959. sh7786_usb_setup();
  960. /*
  961. * De-mux SCIF1 IRQs if possible
  962. */
  963. irq = intc_irq_lookup(sh7786_intc_desc.name, TXI1);
  964. if (irq > 0) {
  965. scif1_demux_resources[1].start =
  966. intc_irq_lookup(sh7786_intc_desc.name, ERI1);
  967. scif1_demux_resources[2].start =
  968. intc_irq_lookup(sh7786_intc_desc.name, RXI1);
  969. scif1_demux_resources[3].start = irq;
  970. scif1_demux_resources[4].start =
  971. intc_irq_lookup(sh7786_intc_desc.name, BRI1);
  972. scif1_device.resource = scif1_demux_resources;
  973. scif1_device.num_resources = ARRAY_SIZE(scif1_demux_resources);
  974. }
  975. ret = platform_add_devices(sh7786_early_devices,
  976. ARRAY_SIZE(sh7786_early_devices));
  977. if (unlikely(ret != 0))
  978. return ret;
  979. return platform_add_devices(sh7786_devices,
  980. ARRAY_SIZE(sh7786_devices));
  981. }
  982. arch_initcall(sh7786_devices_setup);
  983. void __init plat_early_device_setup(void)
  984. {
  985. early_platform_add_devices(sh7786_early_devices,
  986. ARRAY_SIZE(sh7786_early_devices));
  987. }