setup-sh7377.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. /*
  2. * sh7377 processor support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/uio_driver.h>
  26. #include <linux/delay.h>
  27. #include <linux/input.h>
  28. #include <linux/io.h>
  29. #include <linux/serial_sci.h>
  30. #include <linux/sh_intc.h>
  31. #include <linux/sh_timer.h>
  32. #include <mach/hardware.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. /* SCIFA0 */
  36. static struct plat_sci_port scif0_platform_data = {
  37. .mapbase = 0xe6c40000,
  38. .flags = UPF_BOOT_AUTOCONF,
  39. .scscr = SCSCR_RE | SCSCR_TE,
  40. .scbrr_algo_id = SCBRR_ALGO_4,
  41. .type = PORT_SCIFA,
  42. .irqs = { evt2irq(0xc00), evt2irq(0xc00),
  43. evt2irq(0xc00), evt2irq(0xc00) },
  44. };
  45. static struct platform_device scif0_device = {
  46. .name = "sh-sci",
  47. .id = 0,
  48. .dev = {
  49. .platform_data = &scif0_platform_data,
  50. },
  51. };
  52. /* SCIFA1 */
  53. static struct plat_sci_port scif1_platform_data = {
  54. .mapbase = 0xe6c50000,
  55. .flags = UPF_BOOT_AUTOCONF,
  56. .scscr = SCSCR_RE | SCSCR_TE,
  57. .scbrr_algo_id = SCBRR_ALGO_4,
  58. .type = PORT_SCIFA,
  59. .irqs = { evt2irq(0xc20), evt2irq(0xc20),
  60. evt2irq(0xc20), evt2irq(0xc20) },
  61. };
  62. static struct platform_device scif1_device = {
  63. .name = "sh-sci",
  64. .id = 1,
  65. .dev = {
  66. .platform_data = &scif1_platform_data,
  67. },
  68. };
  69. /* SCIFA2 */
  70. static struct plat_sci_port scif2_platform_data = {
  71. .mapbase = 0xe6c60000,
  72. .flags = UPF_BOOT_AUTOCONF,
  73. .scscr = SCSCR_RE | SCSCR_TE,
  74. .scbrr_algo_id = SCBRR_ALGO_4,
  75. .type = PORT_SCIFA,
  76. .irqs = { evt2irq(0xc40), evt2irq(0xc40),
  77. evt2irq(0xc40), evt2irq(0xc40) },
  78. };
  79. static struct platform_device scif2_device = {
  80. .name = "sh-sci",
  81. .id = 2,
  82. .dev = {
  83. .platform_data = &scif2_platform_data,
  84. },
  85. };
  86. /* SCIFA3 */
  87. static struct plat_sci_port scif3_platform_data = {
  88. .mapbase = 0xe6c70000,
  89. .flags = UPF_BOOT_AUTOCONF,
  90. .scscr = SCSCR_RE | SCSCR_TE,
  91. .scbrr_algo_id = SCBRR_ALGO_4,
  92. .type = PORT_SCIFA,
  93. .irqs = { evt2irq(0xc60), evt2irq(0xc60),
  94. evt2irq(0xc60), evt2irq(0xc60) },
  95. };
  96. static struct platform_device scif3_device = {
  97. .name = "sh-sci",
  98. .id = 3,
  99. .dev = {
  100. .platform_data = &scif3_platform_data,
  101. },
  102. };
  103. /* SCIFA4 */
  104. static struct plat_sci_port scif4_platform_data = {
  105. .mapbase = 0xe6c80000,
  106. .flags = UPF_BOOT_AUTOCONF,
  107. .scscr = SCSCR_RE | SCSCR_TE,
  108. .scbrr_algo_id = SCBRR_ALGO_4,
  109. .type = PORT_SCIFA,
  110. .irqs = { evt2irq(0xd20), evt2irq(0xd20),
  111. evt2irq(0xd20), evt2irq(0xd20) },
  112. };
  113. static struct platform_device scif4_device = {
  114. .name = "sh-sci",
  115. .id = 4,
  116. .dev = {
  117. .platform_data = &scif4_platform_data,
  118. },
  119. };
  120. /* SCIFA5 */
  121. static struct plat_sci_port scif5_platform_data = {
  122. .mapbase = 0xe6cb0000,
  123. .flags = UPF_BOOT_AUTOCONF,
  124. .scscr = SCSCR_RE | SCSCR_TE,
  125. .scbrr_algo_id = SCBRR_ALGO_4,
  126. .type = PORT_SCIFA,
  127. .irqs = { evt2irq(0xd40), evt2irq(0xd40),
  128. evt2irq(0xd40), evt2irq(0xd40) },
  129. };
  130. static struct platform_device scif5_device = {
  131. .name = "sh-sci",
  132. .id = 5,
  133. .dev = {
  134. .platform_data = &scif5_platform_data,
  135. },
  136. };
  137. /* SCIFA6 */
  138. static struct plat_sci_port scif6_platform_data = {
  139. .mapbase = 0xe6cc0000,
  140. .flags = UPF_BOOT_AUTOCONF,
  141. .scscr = SCSCR_RE | SCSCR_TE,
  142. .scbrr_algo_id = SCBRR_ALGO_4,
  143. .type = PORT_SCIFA,
  144. .irqs = { intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80),
  145. intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80) },
  146. };
  147. static struct platform_device scif6_device = {
  148. .name = "sh-sci",
  149. .id = 6,
  150. .dev = {
  151. .platform_data = &scif6_platform_data,
  152. },
  153. };
  154. /* SCIFB */
  155. static struct plat_sci_port scif7_platform_data = {
  156. .mapbase = 0xe6c30000,
  157. .flags = UPF_BOOT_AUTOCONF,
  158. .scscr = SCSCR_RE | SCSCR_TE,
  159. .scbrr_algo_id = SCBRR_ALGO_4,
  160. .type = PORT_SCIFB,
  161. .irqs = { evt2irq(0xd60), evt2irq(0xd60),
  162. evt2irq(0xd60), evt2irq(0xd60) },
  163. };
  164. static struct platform_device scif7_device = {
  165. .name = "sh-sci",
  166. .id = 7,
  167. .dev = {
  168. .platform_data = &scif7_platform_data,
  169. },
  170. };
  171. static struct sh_timer_config cmt10_platform_data = {
  172. .name = "CMT10",
  173. .channel_offset = 0x10,
  174. .timer_bit = 0,
  175. .clockevent_rating = 125,
  176. .clocksource_rating = 125,
  177. };
  178. static struct resource cmt10_resources[] = {
  179. [0] = {
  180. .name = "CMT10",
  181. .start = 0xe6138010,
  182. .end = 0xe613801b,
  183. .flags = IORESOURCE_MEM,
  184. },
  185. [1] = {
  186. .start = evt2irq(0xb00), /* CMT1_CMT10 */
  187. .flags = IORESOURCE_IRQ,
  188. },
  189. };
  190. static struct platform_device cmt10_device = {
  191. .name = "sh_cmt",
  192. .id = 10,
  193. .dev = {
  194. .platform_data = &cmt10_platform_data,
  195. },
  196. .resource = cmt10_resources,
  197. .num_resources = ARRAY_SIZE(cmt10_resources),
  198. };
  199. /* VPU */
  200. static struct uio_info vpu_platform_data = {
  201. .name = "VPU5HG",
  202. .version = "0",
  203. .irq = intcs_evt2irq(0x980),
  204. };
  205. static struct resource vpu_resources[] = {
  206. [0] = {
  207. .name = "VPU",
  208. .start = 0xfe900000,
  209. .end = 0xfe900157,
  210. .flags = IORESOURCE_MEM,
  211. },
  212. };
  213. static struct platform_device vpu_device = {
  214. .name = "uio_pdrv_genirq",
  215. .id = 0,
  216. .dev = {
  217. .platform_data = &vpu_platform_data,
  218. },
  219. .resource = vpu_resources,
  220. .num_resources = ARRAY_SIZE(vpu_resources),
  221. };
  222. /* VEU0 */
  223. static struct uio_info veu0_platform_data = {
  224. .name = "VEU0",
  225. .version = "0",
  226. .irq = intcs_evt2irq(0x700),
  227. };
  228. static struct resource veu0_resources[] = {
  229. [0] = {
  230. .name = "VEU0",
  231. .start = 0xfe920000,
  232. .end = 0xfe9200cb,
  233. .flags = IORESOURCE_MEM,
  234. },
  235. };
  236. static struct platform_device veu0_device = {
  237. .name = "uio_pdrv_genirq",
  238. .id = 1,
  239. .dev = {
  240. .platform_data = &veu0_platform_data,
  241. },
  242. .resource = veu0_resources,
  243. .num_resources = ARRAY_SIZE(veu0_resources),
  244. };
  245. /* VEU1 */
  246. static struct uio_info veu1_platform_data = {
  247. .name = "VEU1",
  248. .version = "0",
  249. .irq = intcs_evt2irq(0x720),
  250. };
  251. static struct resource veu1_resources[] = {
  252. [0] = {
  253. .name = "VEU1",
  254. .start = 0xfe924000,
  255. .end = 0xfe9240cb,
  256. .flags = IORESOURCE_MEM,
  257. },
  258. };
  259. static struct platform_device veu1_device = {
  260. .name = "uio_pdrv_genirq",
  261. .id = 2,
  262. .dev = {
  263. .platform_data = &veu1_platform_data,
  264. },
  265. .resource = veu1_resources,
  266. .num_resources = ARRAY_SIZE(veu1_resources),
  267. };
  268. /* VEU2 */
  269. static struct uio_info veu2_platform_data = {
  270. .name = "VEU2",
  271. .version = "0",
  272. .irq = intcs_evt2irq(0x740),
  273. };
  274. static struct resource veu2_resources[] = {
  275. [0] = {
  276. .name = "VEU2",
  277. .start = 0xfe928000,
  278. .end = 0xfe928307,
  279. .flags = IORESOURCE_MEM,
  280. },
  281. };
  282. static struct platform_device veu2_device = {
  283. .name = "uio_pdrv_genirq",
  284. .id = 3,
  285. .dev = {
  286. .platform_data = &veu2_platform_data,
  287. },
  288. .resource = veu2_resources,
  289. .num_resources = ARRAY_SIZE(veu2_resources),
  290. };
  291. /* VEU3 */
  292. static struct uio_info veu3_platform_data = {
  293. .name = "VEU3",
  294. .version = "0",
  295. .irq = intcs_evt2irq(0x760),
  296. };
  297. static struct resource veu3_resources[] = {
  298. [0] = {
  299. .name = "VEU3",
  300. .start = 0xfe92c000,
  301. .end = 0xfe92c307,
  302. .flags = IORESOURCE_MEM,
  303. },
  304. };
  305. static struct platform_device veu3_device = {
  306. .name = "uio_pdrv_genirq",
  307. .id = 4,
  308. .dev = {
  309. .platform_data = &veu3_platform_data,
  310. },
  311. .resource = veu3_resources,
  312. .num_resources = ARRAY_SIZE(veu3_resources),
  313. };
  314. /* JPU */
  315. static struct uio_info jpu_platform_data = {
  316. .name = "JPU",
  317. .version = "0",
  318. .irq = intcs_evt2irq(0x560),
  319. };
  320. static struct resource jpu_resources[] = {
  321. [0] = {
  322. .name = "JPU",
  323. .start = 0xfe980000,
  324. .end = 0xfe9902d3,
  325. .flags = IORESOURCE_MEM,
  326. },
  327. };
  328. static struct platform_device jpu_device = {
  329. .name = "uio_pdrv_genirq",
  330. .id = 5,
  331. .dev = {
  332. .platform_data = &jpu_platform_data,
  333. },
  334. .resource = jpu_resources,
  335. .num_resources = ARRAY_SIZE(jpu_resources),
  336. };
  337. /* SPU2DSP0 */
  338. static struct uio_info spu0_platform_data = {
  339. .name = "SPU2DSP0",
  340. .version = "0",
  341. .irq = evt2irq(0x1800),
  342. };
  343. static struct resource spu0_resources[] = {
  344. [0] = {
  345. .name = "SPU2DSP0",
  346. .start = 0xfe200000,
  347. .end = 0xfe2fffff,
  348. .flags = IORESOURCE_MEM,
  349. },
  350. };
  351. static struct platform_device spu0_device = {
  352. .name = "uio_pdrv_genirq",
  353. .id = 6,
  354. .dev = {
  355. .platform_data = &spu0_platform_data,
  356. },
  357. .resource = spu0_resources,
  358. .num_resources = ARRAY_SIZE(spu0_resources),
  359. };
  360. /* SPU2DSP1 */
  361. static struct uio_info spu1_platform_data = {
  362. .name = "SPU2DSP1",
  363. .version = "0",
  364. .irq = evt2irq(0x1820),
  365. };
  366. static struct resource spu1_resources[] = {
  367. [0] = {
  368. .name = "SPU2DSP1",
  369. .start = 0xfe300000,
  370. .end = 0xfe3fffff,
  371. .flags = IORESOURCE_MEM,
  372. },
  373. };
  374. static struct platform_device spu1_device = {
  375. .name = "uio_pdrv_genirq",
  376. .id = 7,
  377. .dev = {
  378. .platform_data = &spu1_platform_data,
  379. },
  380. .resource = spu1_resources,
  381. .num_resources = ARRAY_SIZE(spu1_resources),
  382. };
  383. static struct platform_device *sh7377_early_devices[] __initdata = {
  384. &scif0_device,
  385. &scif1_device,
  386. &scif2_device,
  387. &scif3_device,
  388. &scif4_device,
  389. &scif5_device,
  390. &scif6_device,
  391. &scif7_device,
  392. &cmt10_device,
  393. };
  394. static struct platform_device *sh7377_devices[] __initdata = {
  395. &vpu_device,
  396. &veu0_device,
  397. &veu1_device,
  398. &veu2_device,
  399. &veu3_device,
  400. &jpu_device,
  401. &spu0_device,
  402. &spu1_device,
  403. };
  404. void __init sh7377_add_standard_devices(void)
  405. {
  406. platform_add_devices(sh7377_early_devices,
  407. ARRAY_SIZE(sh7377_early_devices));
  408. platform_add_devices(sh7377_devices,
  409. ARRAY_SIZE(sh7377_devices));
  410. }
  411. #define SMSTPCR3 0xe615013c
  412. #define SMSTPCR3_CMT1 (1 << 29)
  413. void __init sh7377_add_early_devices(void)
  414. {
  415. /* enable clock to CMT1 */
  416. __raw_writel(__raw_readl(SMSTPCR3) & ~SMSTPCR3_CMT1, SMSTPCR3);
  417. early_platform_add_devices(sh7377_early_devices,
  418. ARRAY_SIZE(sh7377_early_devices));
  419. }