setup-shx3.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. /*
  2. * SH-X3 Prototype Setup
  3. *
  4. * Copyright (C) 2007 - 2009 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/platform_device.h>
  11. #include <linux/init.h>
  12. #include <linux/serial.h>
  13. #include <linux/serial_sci.h>
  14. #include <linux/io.h>
  15. #include <linux/sh_timer.h>
  16. #include <asm/mmzone.h>
  17. /*
  18. * This intentionally only registers SCIF ports 0, 1, and 3. SCIF 2
  19. * INTEVT values overlap with the FPU EXPEVT ones, requiring special
  20. * demuxing in the exception dispatch path.
  21. *
  22. * As this overlap is something that never should have made it in to
  23. * silicon in the first place, we just refuse to deal with the port at
  24. * all rather than adding infrastructure to hack around it.
  25. */
  26. static struct plat_sci_port scif0_platform_data = {
  27. .mapbase = 0xffc30000,
  28. .flags = UPF_BOOT_AUTOCONF,
  29. .type = PORT_SCIF,
  30. .irqs = { 40, 41, 43, 42 },
  31. };
  32. static struct platform_device scif0_device = {
  33. .name = "sh-sci",
  34. .id = 0,
  35. .dev = {
  36. .platform_data = &scif0_platform_data,
  37. },
  38. };
  39. static struct plat_sci_port scif1_platform_data = {
  40. .mapbase = 0xffc40000,
  41. .flags = UPF_BOOT_AUTOCONF,
  42. .type = PORT_SCIF,
  43. .irqs = { 44, 45, 47, 46 },
  44. };
  45. static struct platform_device scif1_device = {
  46. .name = "sh-sci",
  47. .id = 1,
  48. .dev = {
  49. .platform_data = &scif1_platform_data,
  50. },
  51. };
  52. static struct plat_sci_port scif2_platform_data = {
  53. .mapbase = 0xffc60000,
  54. .flags = UPF_BOOT_AUTOCONF,
  55. .type = PORT_SCIF,
  56. .irqs = { 52, 53, 55, 54 },
  57. };
  58. static struct platform_device scif2_device = {
  59. .name = "sh-sci",
  60. .id = 2,
  61. .dev = {
  62. .platform_data = &scif2_platform_data,
  63. },
  64. };
  65. static struct sh_timer_config tmu0_platform_data = {
  66. .channel_offset = 0x04,
  67. .timer_bit = 0,
  68. .clockevent_rating = 200,
  69. };
  70. static struct resource tmu0_resources[] = {
  71. [0] = {
  72. .start = 0xffc10008,
  73. .end = 0xffc10013,
  74. .flags = IORESOURCE_MEM,
  75. },
  76. [1] = {
  77. .start = 16,
  78. .flags = IORESOURCE_IRQ,
  79. },
  80. };
  81. static struct platform_device tmu0_device = {
  82. .name = "sh_tmu",
  83. .id = 0,
  84. .dev = {
  85. .platform_data = &tmu0_platform_data,
  86. },
  87. .resource = tmu0_resources,
  88. .num_resources = ARRAY_SIZE(tmu0_resources),
  89. };
  90. static struct sh_timer_config tmu1_platform_data = {
  91. .channel_offset = 0x10,
  92. .timer_bit = 1,
  93. .clocksource_rating = 200,
  94. };
  95. static struct resource tmu1_resources[] = {
  96. [0] = {
  97. .start = 0xffc10014,
  98. .end = 0xffc1001f,
  99. .flags = IORESOURCE_MEM,
  100. },
  101. [1] = {
  102. .start = 17,
  103. .flags = IORESOURCE_IRQ,
  104. },
  105. };
  106. static struct platform_device tmu1_device = {
  107. .name = "sh_tmu",
  108. .id = 1,
  109. .dev = {
  110. .platform_data = &tmu1_platform_data,
  111. },
  112. .resource = tmu1_resources,
  113. .num_resources = ARRAY_SIZE(tmu1_resources),
  114. };
  115. static struct sh_timer_config tmu2_platform_data = {
  116. .channel_offset = 0x1c,
  117. .timer_bit = 2,
  118. };
  119. static struct resource tmu2_resources[] = {
  120. [0] = {
  121. .start = 0xffc10020,
  122. .end = 0xffc1002f,
  123. .flags = IORESOURCE_MEM,
  124. },
  125. [1] = {
  126. .start = 18,
  127. .flags = IORESOURCE_IRQ,
  128. },
  129. };
  130. static struct platform_device tmu2_device = {
  131. .name = "sh_tmu",
  132. .id = 2,
  133. .dev = {
  134. .platform_data = &tmu2_platform_data,
  135. },
  136. .resource = tmu2_resources,
  137. .num_resources = ARRAY_SIZE(tmu2_resources),
  138. };
  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 = 0xffc20008,
  146. .end = 0xffc20013,
  147. .flags = IORESOURCE_MEM,
  148. },
  149. [1] = {
  150. .start = 19,
  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 = 0xffc20014,
  170. .end = 0xffc2001f,
  171. .flags = IORESOURCE_MEM,
  172. },
  173. [1] = {
  174. .start = 20,
  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. static struct sh_timer_config tmu5_platform_data = {
  188. .channel_offset = 0x1c,
  189. .timer_bit = 2,
  190. };
  191. static struct resource tmu5_resources[] = {
  192. [0] = {
  193. .start = 0xffc20020,
  194. .end = 0xffc2002b,
  195. .flags = IORESOURCE_MEM,
  196. },
  197. [1] = {
  198. .start = 21,
  199. .flags = IORESOURCE_IRQ,
  200. },
  201. };
  202. static struct platform_device tmu5_device = {
  203. .name = "sh_tmu",
  204. .id = 5,
  205. .dev = {
  206. .platform_data = &tmu5_platform_data,
  207. },
  208. .resource = tmu5_resources,
  209. .num_resources = ARRAY_SIZE(tmu5_resources),
  210. };
  211. static struct platform_device *shx3_early_devices[] __initdata = {
  212. &scif0_device,
  213. &scif1_device,
  214. &scif2_device,
  215. &tmu0_device,
  216. &tmu1_device,
  217. &tmu2_device,
  218. &tmu3_device,
  219. &tmu4_device,
  220. &tmu5_device,
  221. };
  222. static int __init shx3_devices_setup(void)
  223. {
  224. return platform_add_devices(shx3_early_devices,
  225. ARRAY_SIZE(shx3_early_devices));
  226. }
  227. arch_initcall(shx3_devices_setup);
  228. void __init plat_early_device_setup(void)
  229. {
  230. early_platform_add_devices(shx3_early_devices,
  231. ARRAY_SIZE(shx3_early_devices));
  232. }
  233. enum {
  234. UNUSED = 0,
  235. /* interrupt sources */
  236. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  237. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  238. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  239. IRL_HHLL, IRL_HHLH, IRL_HHHL,
  240. IRQ0, IRQ1, IRQ2, IRQ3,
  241. HUDII,
  242. TMU0, TMU1, TMU2, TMU3, TMU4, TMU5,
  243. PCII0, PCII1, PCII2, PCII3, PCII4,
  244. PCII5, PCII6, PCII7, PCII8, PCII9,
  245. SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI,
  246. SCIF1_ERI, SCIF1_RXI, SCIF1_BRI, SCIF1_TXI,
  247. SCIF2_ERI, SCIF2_RXI, SCIF2_BRI, SCIF2_TXI,
  248. SCIF3_ERI, SCIF3_RXI, SCIF3_BRI, SCIF3_TXI,
  249. DMAC0_DMINT0, DMAC0_DMINT1, DMAC0_DMINT2, DMAC0_DMINT3,
  250. DMAC0_DMINT4, DMAC0_DMINT5, DMAC0_DMAE,
  251. DU,
  252. DMAC1_DMINT6, DMAC1_DMINT7, DMAC1_DMINT8, DMAC1_DMINT9,
  253. DMAC1_DMINT10, DMAC1_DMINT11, DMAC1_DMAE,
  254. IIC, VIN0, VIN1, VCORE0, ATAPI,
  255. DTU0, DTU1, DTU2, DTU3,
  256. FE0, FE1,
  257. GPIO0, GPIO1, GPIO2, GPIO3,
  258. PAM, IRM,
  259. INTICI0, INTICI1, INTICI2, INTICI3,
  260. INTICI4, INTICI5, INTICI6, INTICI7,
  261. /* interrupt groups */
  262. IRL, PCII56789, SCIF0, SCIF1, SCIF2, SCIF3,
  263. DMAC0, DMAC1,
  264. };
  265. static struct intc_vect vectors[] __initdata = {
  266. INTC_VECT(HUDII, 0x3e0),
  267. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  268. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU3, 0x460),
  269. INTC_VECT(TMU4, 0x480), INTC_VECT(TMU5, 0x4a0),
  270. INTC_VECT(PCII0, 0x500), INTC_VECT(PCII1, 0x520),
  271. INTC_VECT(PCII2, 0x540), INTC_VECT(PCII3, 0x560),
  272. INTC_VECT(PCII4, 0x580), INTC_VECT(PCII5, 0x5a0),
  273. INTC_VECT(PCII6, 0x5c0), INTC_VECT(PCII7, 0x5e0),
  274. INTC_VECT(PCII8, 0x600), INTC_VECT(PCII9, 0x620),
  275. INTC_VECT(SCIF0_ERI, 0x700), INTC_VECT(SCIF0_RXI, 0x720),
  276. INTC_VECT(SCIF0_BRI, 0x740), INTC_VECT(SCIF0_TXI, 0x760),
  277. INTC_VECT(SCIF1_ERI, 0x780), INTC_VECT(SCIF1_RXI, 0x7a0),
  278. INTC_VECT(SCIF1_BRI, 0x7c0), INTC_VECT(SCIF1_TXI, 0x7e0),
  279. INTC_VECT(SCIF3_ERI, 0x880), INTC_VECT(SCIF3_RXI, 0x8a0),
  280. INTC_VECT(SCIF3_BRI, 0x8c0), INTC_VECT(SCIF3_TXI, 0x8e0),
  281. INTC_VECT(DMAC0_DMINT0, 0x900), INTC_VECT(DMAC0_DMINT1, 0x920),
  282. INTC_VECT(DMAC0_DMINT2, 0x940), INTC_VECT(DMAC0_DMINT3, 0x960),
  283. INTC_VECT(DMAC0_DMINT4, 0x980), INTC_VECT(DMAC0_DMINT5, 0x9a0),
  284. INTC_VECT(DMAC0_DMAE, 0x9c0),
  285. INTC_VECT(DU, 0x9e0),
  286. INTC_VECT(DMAC1_DMINT6, 0xa00), INTC_VECT(DMAC1_DMINT7, 0xa20),
  287. INTC_VECT(DMAC1_DMINT8, 0xa40), INTC_VECT(DMAC1_DMINT9, 0xa60),
  288. INTC_VECT(DMAC1_DMINT10, 0xa80), INTC_VECT(DMAC1_DMINT11, 0xaa0),
  289. INTC_VECT(DMAC1_DMAE, 0xac0),
  290. INTC_VECT(IIC, 0xae0),
  291. INTC_VECT(VIN0, 0xb00), INTC_VECT(VIN1, 0xb20),
  292. INTC_VECT(VCORE0, 0xb00), INTC_VECT(ATAPI, 0xb60),
  293. INTC_VECT(DTU0, 0xc00), INTC_VECT(DTU0, 0xc20),
  294. INTC_VECT(DTU0, 0xc40),
  295. INTC_VECT(DTU1, 0xc60), INTC_VECT(DTU1, 0xc80),
  296. INTC_VECT(DTU1, 0xca0),
  297. INTC_VECT(DTU2, 0xcc0), INTC_VECT(DTU2, 0xce0),
  298. INTC_VECT(DTU2, 0xd00),
  299. INTC_VECT(DTU3, 0xd20), INTC_VECT(DTU3, 0xd40),
  300. INTC_VECT(DTU3, 0xd60),
  301. INTC_VECT(FE0, 0xe00), INTC_VECT(FE1, 0xe20),
  302. INTC_VECT(GPIO0, 0xe40), INTC_VECT(GPIO1, 0xe60),
  303. INTC_VECT(GPIO2, 0xe80), INTC_VECT(GPIO3, 0xea0),
  304. INTC_VECT(PAM, 0xec0), INTC_VECT(IRM, 0xee0),
  305. INTC_VECT(INTICI0, 0xf00), INTC_VECT(INTICI1, 0xf20),
  306. INTC_VECT(INTICI2, 0xf40), INTC_VECT(INTICI3, 0xf60),
  307. INTC_VECT(INTICI4, 0xf80), INTC_VECT(INTICI5, 0xfa0),
  308. INTC_VECT(INTICI6, 0xfc0), INTC_VECT(INTICI7, 0xfe0),
  309. };
  310. static struct intc_group groups[] __initdata = {
  311. INTC_GROUP(IRL, IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  312. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  313. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  314. IRL_HHLL, IRL_HHLH, IRL_HHHL),
  315. INTC_GROUP(PCII56789, PCII5, PCII6, PCII7, PCII8, PCII9),
  316. INTC_GROUP(SCIF0, SCIF0_ERI, SCIF0_RXI, SCIF0_BRI, SCIF0_TXI),
  317. INTC_GROUP(SCIF1, SCIF1_ERI, SCIF1_RXI, SCIF1_BRI, SCIF1_TXI),
  318. INTC_GROUP(SCIF3, SCIF3_ERI, SCIF3_RXI, SCIF3_BRI, SCIF3_TXI),
  319. INTC_GROUP(DMAC0, DMAC0_DMINT0, DMAC0_DMINT1, DMAC0_DMINT2,
  320. DMAC0_DMINT3, DMAC0_DMINT4, DMAC0_DMINT5, DMAC0_DMAE),
  321. INTC_GROUP(DMAC1, DMAC1_DMINT6, DMAC1_DMINT7, DMAC1_DMINT8,
  322. DMAC1_DMINT9, DMAC1_DMINT10, DMAC1_DMINT11),
  323. };
  324. static struct intc_mask_reg mask_registers[] __initdata = {
  325. { 0xfe410030, 0xfe410050, 32, /* CnINTMSK0 / CnINTMSKCLR0 */
  326. { IRQ0, IRQ1, IRQ2, IRQ3 } },
  327. { 0xfe410040, 0xfe410060, 32, /* CnINTMSK1 / CnINTMSKCLR1 */
  328. { IRL } },
  329. { 0xfe410820, 0xfe410850, 32, /* CnINT2MSK0 / CnINT2MSKCLR0 */
  330. { FE1, FE0, 0, ATAPI, VCORE0, VIN1, VIN0, IIC,
  331. DU, GPIO3, GPIO2, GPIO1, GPIO0, PAM, 0, 0,
  332. 0, 0, 0, 0, 0, 0, 0, 0, /* HUDI bits ignored */
  333. 0, TMU5, TMU4, TMU3, TMU2, TMU1, TMU0, 0, } },
  334. { 0xfe410830, 0xfe410860, 32, /* CnINT2MSK1 / CnINT2MSKCLR1 */
  335. { 0, 0, 0, 0, DTU3, DTU2, DTU1, DTU0, /* IRM bits ignored */
  336. PCII9, PCII8, PCII7, PCII6, PCII5, PCII4, PCII3, PCII2,
  337. PCII1, PCII0, DMAC1_DMAE, DMAC1_DMINT11,
  338. DMAC1_DMINT10, DMAC1_DMINT9, DMAC1_DMINT8, DMAC1_DMINT7,
  339. DMAC1_DMINT6, DMAC0_DMAE, DMAC0_DMINT5, DMAC0_DMINT4,
  340. DMAC0_DMINT3, DMAC0_DMINT2, DMAC0_DMINT1, DMAC0_DMINT0 } },
  341. { 0xfe410840, 0xfe410870, 32, /* CnINT2MSK2 / CnINT2MSKCLR2 */
  342. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  343. SCIF3_TXI, SCIF3_BRI, SCIF3_RXI, SCIF3_ERI,
  344. SCIF2_TXI, SCIF2_BRI, SCIF2_RXI, SCIF2_ERI,
  345. SCIF1_TXI, SCIF1_BRI, SCIF1_RXI, SCIF1_ERI,
  346. SCIF0_TXI, SCIF0_BRI, SCIF0_RXI, SCIF0_ERI } },
  347. };
  348. static struct intc_prio_reg prio_registers[] __initdata = {
  349. { 0xfe410010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3 } },
  350. { 0xfe410800, 0, 32, 4, /* INT2PRI0 */ { 0, HUDII, TMU5, TMU4,
  351. TMU3, TMU2, TMU1, TMU0 } },
  352. { 0xfe410804, 0, 32, 4, /* INT2PRI1 */ { DTU3, DTU2, DTU1, DTU0,
  353. SCIF3, SCIF2,
  354. SCIF1, SCIF0 } },
  355. { 0xfe410808, 0, 32, 4, /* INT2PRI2 */ { DMAC1, DMAC0,
  356. PCII56789, PCII4,
  357. PCII3, PCII2,
  358. PCII1, PCII0 } },
  359. { 0xfe41080c, 0, 32, 4, /* INT2PRI3 */ { FE1, FE0, ATAPI, VCORE0,
  360. VIN1, VIN0, IIC, DU} },
  361. { 0xfe410810, 0, 32, 4, /* INT2PRI4 */ { 0, 0, PAM, GPIO3,
  362. GPIO2, GPIO1, GPIO0, IRM } },
  363. { 0xfe410090, 0xfe4100a0, 32, 4, /* CnICIPRI / CnICIPRICLR */
  364. { INTICI7, INTICI6, INTICI5, INTICI4,
  365. INTICI3, INTICI2, INTICI1, INTICI0 }, INTC_SMP(4, 4) },
  366. };
  367. static DECLARE_INTC_DESC(intc_desc, "shx3", vectors, groups,
  368. mask_registers, prio_registers, NULL);
  369. /* Support for external interrupt pins in IRQ mode */
  370. static struct intc_vect vectors_irq[] __initdata = {
  371. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  372. INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),
  373. };
  374. static struct intc_sense_reg sense_registers[] __initdata = {
  375. { 0xfe41001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3 } },
  376. };
  377. static DECLARE_INTC_DESC(intc_desc_irq, "shx3-irq", vectors_irq, groups,
  378. mask_registers, prio_registers, sense_registers);
  379. /* External interrupt pins in IRL mode */
  380. static struct intc_vect vectors_irl[] __initdata = {
  381. INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),
  382. INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),
  383. INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),
  384. INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),
  385. INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),
  386. INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),
  387. INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),
  388. INTC_VECT(IRL_HHHL, 0x3c0),
  389. };
  390. static DECLARE_INTC_DESC(intc_desc_irl, "shx3-irl", vectors_irl, groups,
  391. mask_registers, prio_registers, NULL);
  392. void __init plat_irq_setup_pins(int mode)
  393. {
  394. switch (mode) {
  395. case IRQ_MODE_IRQ:
  396. register_intc_controller(&intc_desc_irq);
  397. break;
  398. case IRQ_MODE_IRL3210:
  399. register_intc_controller(&intc_desc_irl);
  400. break;
  401. default:
  402. BUG();
  403. }
  404. }
  405. void __init plat_irq_setup(void)
  406. {
  407. register_intc_controller(&intc_desc);
  408. }
  409. void __init plat_mem_setup(void)
  410. {
  411. unsigned int nid = 1;
  412. /* Register CPU#0 URAM space as Node 1 */
  413. setup_bootmem_node(nid++, 0x145f0000, 0x14610000); /* CPU0 */
  414. #if 0
  415. /* XXX: Not yet.. */
  416. setup_bootmem_node(nid++, 0x14df0000, 0x14e10000); /* CPU1 */
  417. setup_bootmem_node(nid++, 0x155f0000, 0x15610000); /* CPU2 */
  418. setup_bootmem_node(nid++, 0x15df0000, 0x15e10000); /* CPU3 */
  419. #endif
  420. setup_bootmem_node(nid++, 0x16000000, 0x16020000); /* CSM */
  421. }