setup-sh7786.c 26 KB

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