setup-sh7750.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /*
  2. * SH7750/SH7751 Setup
  3. *
  4. * Copyright (C) 2006 Paul Mundt
  5. * Copyright (C) 2006 Jamie Lenehan
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/init.h>
  13. #include <linux/serial.h>
  14. #include <linux/io.h>
  15. #include <linux/sh_timer.h>
  16. #include <linux/serial_sci.h>
  17. static struct resource rtc_resources[] = {
  18. [0] = {
  19. .start = 0xffc80000,
  20. .end = 0xffc80000 + 0x58 - 1,
  21. .flags = IORESOURCE_IO,
  22. },
  23. [1] = {
  24. /* Shared Period/Carry/Alarm IRQ */
  25. .start = 20,
  26. .flags = IORESOURCE_IRQ,
  27. },
  28. };
  29. static struct platform_device rtc_device = {
  30. .name = "sh-rtc",
  31. .id = -1,
  32. .num_resources = ARRAY_SIZE(rtc_resources),
  33. .resource = rtc_resources,
  34. };
  35. static struct plat_sci_port scif0_platform_data = {
  36. .mapbase = 0xffe00000,
  37. .flags = UPF_BOOT_AUTOCONF,
  38. .type = PORT_SCI,
  39. .irqs = { 23, 23, 23, 0 },
  40. };
  41. static struct platform_device scif0_device = {
  42. .name = "sh-sci",
  43. .id = 0,
  44. .dev = {
  45. .platform_data = &scif0_platform_data,
  46. },
  47. };
  48. static struct plat_sci_port scif1_platform_data = {
  49. .mapbase = 0xffe80000,
  50. .flags = UPF_BOOT_AUTOCONF,
  51. .type = PORT_SCIF,
  52. .irqs = { 40, 40, 40, 40 },
  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 sh_timer_config tmu0_platform_data = {
  62. .channel_offset = 0x04,
  63. .timer_bit = 0,
  64. .clockevent_rating = 200,
  65. };
  66. static struct resource tmu0_resources[] = {
  67. [0] = {
  68. .start = 0xffd80008,
  69. .end = 0xffd80013,
  70. .flags = IORESOURCE_MEM,
  71. },
  72. [1] = {
  73. .start = 16,
  74. .flags = IORESOURCE_IRQ,
  75. },
  76. };
  77. static struct platform_device tmu0_device = {
  78. .name = "sh_tmu",
  79. .id = 0,
  80. .dev = {
  81. .platform_data = &tmu0_platform_data,
  82. },
  83. .resource = tmu0_resources,
  84. .num_resources = ARRAY_SIZE(tmu0_resources),
  85. };
  86. static struct sh_timer_config tmu1_platform_data = {
  87. .channel_offset = 0x10,
  88. .timer_bit = 1,
  89. .clocksource_rating = 200,
  90. };
  91. static struct resource tmu1_resources[] = {
  92. [0] = {
  93. .start = 0xffd80014,
  94. .end = 0xffd8001f,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. [1] = {
  98. .start = 17,
  99. .flags = IORESOURCE_IRQ,
  100. },
  101. };
  102. static struct platform_device tmu1_device = {
  103. .name = "sh_tmu",
  104. .id = 1,
  105. .dev = {
  106. .platform_data = &tmu1_platform_data,
  107. },
  108. .resource = tmu1_resources,
  109. .num_resources = ARRAY_SIZE(tmu1_resources),
  110. };
  111. static struct sh_timer_config tmu2_platform_data = {
  112. .channel_offset = 0x1c,
  113. .timer_bit = 2,
  114. };
  115. static struct resource tmu2_resources[] = {
  116. [0] = {
  117. .start = 0xffd80020,
  118. .end = 0xffd8002f,
  119. .flags = IORESOURCE_MEM,
  120. },
  121. [1] = {
  122. .start = 18,
  123. .flags = IORESOURCE_IRQ,
  124. },
  125. };
  126. static struct platform_device tmu2_device = {
  127. .name = "sh_tmu",
  128. .id = 2,
  129. .dev = {
  130. .platform_data = &tmu2_platform_data,
  131. },
  132. .resource = tmu2_resources,
  133. .num_resources = ARRAY_SIZE(tmu2_resources),
  134. };
  135. /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
  136. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  137. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  138. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  139. static struct sh_timer_config tmu3_platform_data = {
  140. .channel_offset = 0x04,
  141. .timer_bit = 0,
  142. };
  143. static struct resource tmu3_resources[] = {
  144. [0] = {
  145. .start = 0xfe100008,
  146. .end = 0xfe100013,
  147. .flags = IORESOURCE_MEM,
  148. },
  149. [1] = {
  150. .start = 72,
  151. .flags = IORESOURCE_IRQ,
  152. },
  153. };
  154. static struct platform_device tmu3_device = {
  155. .name = "sh_tmu",
  156. .id = 3,
  157. .dev = {
  158. .platform_data = &tmu3_platform_data,
  159. },
  160. .resource = tmu3_resources,
  161. .num_resources = ARRAY_SIZE(tmu3_resources),
  162. };
  163. static struct sh_timer_config tmu4_platform_data = {
  164. .channel_offset = 0x10,
  165. .timer_bit = 1,
  166. };
  167. static struct resource tmu4_resources[] = {
  168. [0] = {
  169. .start = 0xfe100014,
  170. .end = 0xfe10001f,
  171. .flags = IORESOURCE_MEM,
  172. },
  173. [1] = {
  174. .start = 76,
  175. .flags = IORESOURCE_IRQ,
  176. },
  177. };
  178. static struct platform_device tmu4_device = {
  179. .name = "sh_tmu",
  180. .id = 4,
  181. .dev = {
  182. .platform_data = &tmu4_platform_data,
  183. },
  184. .resource = tmu4_resources,
  185. .num_resources = ARRAY_SIZE(tmu4_resources),
  186. };
  187. #endif
  188. static struct platform_device *sh7750_devices[] __initdata = {
  189. &scif0_device,
  190. &scif1_device,
  191. &rtc_device,
  192. &tmu0_device,
  193. &tmu1_device,
  194. &tmu2_device,
  195. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  196. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  197. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  198. &tmu3_device,
  199. &tmu4_device,
  200. #endif
  201. };
  202. static int __init sh7750_devices_setup(void)
  203. {
  204. return platform_add_devices(sh7750_devices,
  205. ARRAY_SIZE(sh7750_devices));
  206. }
  207. arch_initcall(sh7750_devices_setup);
  208. static struct platform_device *sh7750_early_devices[] __initdata = {
  209. &scif0_device,
  210. &scif1_device,
  211. &tmu0_device,
  212. &tmu1_device,
  213. &tmu2_device,
  214. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  215. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  216. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  217. &tmu3_device,
  218. &tmu4_device,
  219. #endif
  220. };
  221. void __init plat_early_device_setup(void)
  222. {
  223. early_platform_add_devices(sh7750_early_devices,
  224. ARRAY_SIZE(sh7750_early_devices));
  225. }
  226. enum {
  227. UNUSED = 0,
  228. /* interrupt sources */
  229. IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */
  230. HUDI, GPIOI, DMAC,
  231. PCIC0_PCISERR, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  232. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3,
  233. TMU3, TMU4, TMU0, TMU1, TMU2, RTC, SCI1, SCIF, WDT, REF,
  234. /* interrupt groups */
  235. PCIC1,
  236. };
  237. static struct intc_vect vectors[] __initdata = {
  238. INTC_VECT(HUDI, 0x600), INTC_VECT(GPIOI, 0x620),
  239. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  240. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  241. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  242. INTC_VECT(RTC, 0x4c0),
  243. INTC_VECT(SCI1, 0x4e0), INTC_VECT(SCI1, 0x500),
  244. INTC_VECT(SCI1, 0x520), INTC_VECT(SCI1, 0x540),
  245. INTC_VECT(SCIF, 0x700), INTC_VECT(SCIF, 0x720),
  246. INTC_VECT(SCIF, 0x740), INTC_VECT(SCIF, 0x760),
  247. INTC_VECT(WDT, 0x560),
  248. INTC_VECT(REF, 0x580), INTC_VECT(REF, 0x5a0),
  249. };
  250. static struct intc_prio_reg prio_registers[] __initdata = {
  251. { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  252. { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, REF, SCI1, 0 } },
  253. { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI, DMAC, SCIF, HUDI } },
  254. { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },
  255. { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
  256. TMU4, TMU3,
  257. PCIC1, PCIC0_PCISERR } },
  258. };
  259. static DECLARE_INTC_DESC(intc_desc, "sh7750", vectors, NULL,
  260. NULL, prio_registers, NULL);
  261. /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
  262. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  263. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  264. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  265. defined(CONFIG_CPU_SUBTYPE_SH7091)
  266. static struct intc_vect vectors_dma4[] __initdata = {
  267. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  268. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  269. INTC_VECT(DMAC, 0x6c0),
  270. };
  271. static DECLARE_INTC_DESC(intc_desc_dma4, "sh7750_dma4",
  272. vectors_dma4, NULL,
  273. NULL, prio_registers, NULL);
  274. #endif
  275. /* SH7750R and SH7751R both have 8-channel DMA controllers */
  276. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  277. static struct intc_vect vectors_dma8[] __initdata = {
  278. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  279. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  280. INTC_VECT(DMAC, 0x780), INTC_VECT(DMAC, 0x7a0),
  281. INTC_VECT(DMAC, 0x7c0), INTC_VECT(DMAC, 0x7e0),
  282. INTC_VECT(DMAC, 0x6c0),
  283. };
  284. static DECLARE_INTC_DESC(intc_desc_dma8, "sh7750_dma8",
  285. vectors_dma8, NULL,
  286. NULL, prio_registers, NULL);
  287. #endif
  288. /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
  289. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  290. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  291. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  292. static struct intc_vect vectors_tmu34[] __initdata = {
  293. INTC_VECT(TMU3, 0xb00), INTC_VECT(TMU4, 0xb80),
  294. };
  295. static struct intc_mask_reg mask_registers[] __initdata = {
  296. { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
  297. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  298. 0, 0, 0, 0, 0, 0, TMU4, TMU3,
  299. PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  300. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2,
  301. PCIC1_PCIDMA3, PCIC0_PCISERR } },
  302. };
  303. static DECLARE_INTC_DESC(intc_desc_tmu34, "sh7750_tmu34",
  304. vectors_tmu34, NULL,
  305. mask_registers, prio_registers, NULL);
  306. #endif
  307. /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
  308. static struct intc_vect vectors_irlm[] __initdata = {
  309. INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),
  310. INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),
  311. };
  312. static DECLARE_INTC_DESC(intc_desc_irlm, "sh7750_irlm", vectors_irlm, NULL,
  313. NULL, prio_registers, NULL);
  314. /* SH7751 and SH7751R both have PCI */
  315. #if defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  316. static struct intc_vect vectors_pci[] __initdata = {
  317. INTC_VECT(PCIC0_PCISERR, 0xa00), INTC_VECT(PCIC1_PCIERR, 0xae0),
  318. INTC_VECT(PCIC1_PCIPWDWN, 0xac0), INTC_VECT(PCIC1_PCIPWON, 0xaa0),
  319. INTC_VECT(PCIC1_PCIDMA0, 0xa80), INTC_VECT(PCIC1_PCIDMA1, 0xa60),
  320. INTC_VECT(PCIC1_PCIDMA2, 0xa40), INTC_VECT(PCIC1_PCIDMA3, 0xa20),
  321. };
  322. static struct intc_group groups_pci[] __initdata = {
  323. INTC_GROUP(PCIC1, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  324. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3),
  325. };
  326. static DECLARE_INTC_DESC(intc_desc_pci, "sh7750_pci", vectors_pci, groups_pci,
  327. mask_registers, prio_registers, NULL);
  328. #endif
  329. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  330. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  331. defined(CONFIG_CPU_SUBTYPE_SH7091)
  332. void __init plat_irq_setup(void)
  333. {
  334. /*
  335. * same vectors for SH7750, SH7750S and SH7091 except for IRLM,
  336. * see below..
  337. */
  338. register_intc_controller(&intc_desc);
  339. register_intc_controller(&intc_desc_dma4);
  340. }
  341. #endif
  342. #if defined(CONFIG_CPU_SUBTYPE_SH7750R)
  343. void __init plat_irq_setup(void)
  344. {
  345. register_intc_controller(&intc_desc);
  346. register_intc_controller(&intc_desc_dma8);
  347. register_intc_controller(&intc_desc_tmu34);
  348. }
  349. #endif
  350. #if defined(CONFIG_CPU_SUBTYPE_SH7751)
  351. void __init plat_irq_setup(void)
  352. {
  353. register_intc_controller(&intc_desc);
  354. register_intc_controller(&intc_desc_dma4);
  355. register_intc_controller(&intc_desc_tmu34);
  356. register_intc_controller(&intc_desc_pci);
  357. }
  358. #endif
  359. #if defined(CONFIG_CPU_SUBTYPE_SH7751R)
  360. void __init plat_irq_setup(void)
  361. {
  362. register_intc_controller(&intc_desc);
  363. register_intc_controller(&intc_desc_dma8);
  364. register_intc_controller(&intc_desc_tmu34);
  365. register_intc_controller(&intc_desc_pci);
  366. }
  367. #endif
  368. #define INTC_ICR 0xffd00000UL
  369. #define INTC_ICR_IRLM (1<<7)
  370. void __init plat_irq_setup_pins(int mode)
  371. {
  372. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7091)
  373. BUG(); /* impossible to mask interrupts on SH7750 and SH7091 */
  374. return;
  375. #endif
  376. switch (mode) {
  377. case IRQ_MODE_IRQ: /* individual interrupt mode for IRL3-0 */
  378. __raw_writew(__raw_readw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
  379. register_intc_controller(&intc_desc_irlm);
  380. break;
  381. default:
  382. BUG();
  383. }
  384. }