setup-sh7367.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /*
  2. * sh7367 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_timer.h>
  31. #include <mach/hardware.h>
  32. #include <mach/irqs.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. /* SCIFB */
  138. static struct plat_sci_port scif6_platform_data = {
  139. .mapbase = 0xe6c30000,
  140. .flags = UPF_BOOT_AUTOCONF,
  141. .scscr = SCSCR_RE | SCSCR_TE,
  142. .scbrr_algo_id = SCBRR_ALGO_4,
  143. .type = PORT_SCIFB,
  144. .irqs = { evt2irq(0xd60), evt2irq(0xd60),
  145. evt2irq(0xd60), evt2irq(0xd60) },
  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. static struct sh_timer_config cmt10_platform_data = {
  155. .name = "CMT10",
  156. .channel_offset = 0x10,
  157. .timer_bit = 0,
  158. .clockevent_rating = 125,
  159. .clocksource_rating = 125,
  160. };
  161. static struct resource cmt10_resources[] = {
  162. [0] = {
  163. .name = "CMT10",
  164. .start = 0xe6138010,
  165. .end = 0xe613801b,
  166. .flags = IORESOURCE_MEM,
  167. },
  168. [1] = {
  169. .start = evt2irq(0xb00), /* CMT1_CMT10 */
  170. .flags = IORESOURCE_IRQ,
  171. },
  172. };
  173. static struct platform_device cmt10_device = {
  174. .name = "sh_cmt",
  175. .id = 10,
  176. .dev = {
  177. .platform_data = &cmt10_platform_data,
  178. },
  179. .resource = cmt10_resources,
  180. .num_resources = ARRAY_SIZE(cmt10_resources),
  181. };
  182. /* VPU */
  183. static struct uio_info vpu_platform_data = {
  184. .name = "VPU5",
  185. .version = "0",
  186. .irq = intcs_evt2irq(0x980),
  187. };
  188. static struct resource vpu_resources[] = {
  189. [0] = {
  190. .name = "VPU",
  191. .start = 0xfe900000,
  192. .end = 0xfe902807,
  193. .flags = IORESOURCE_MEM,
  194. },
  195. };
  196. static struct platform_device vpu_device = {
  197. .name = "uio_pdrv_genirq",
  198. .id = 0,
  199. .dev = {
  200. .platform_data = &vpu_platform_data,
  201. },
  202. .resource = vpu_resources,
  203. .num_resources = ARRAY_SIZE(vpu_resources),
  204. };
  205. /* VEU0 */
  206. static struct uio_info veu0_platform_data = {
  207. .name = "VEU0",
  208. .version = "0",
  209. .irq = intcs_evt2irq(0x700),
  210. };
  211. static struct resource veu0_resources[] = {
  212. [0] = {
  213. .name = "VEU0",
  214. .start = 0xfe920000,
  215. .end = 0xfe9200b7,
  216. .flags = IORESOURCE_MEM,
  217. },
  218. };
  219. static struct platform_device veu0_device = {
  220. .name = "uio_pdrv_genirq",
  221. .id = 1,
  222. .dev = {
  223. .platform_data = &veu0_platform_data,
  224. },
  225. .resource = veu0_resources,
  226. .num_resources = ARRAY_SIZE(veu0_resources),
  227. };
  228. /* VEU1 */
  229. static struct uio_info veu1_platform_data = {
  230. .name = "VEU1",
  231. .version = "0",
  232. .irq = intcs_evt2irq(0x720),
  233. };
  234. static struct resource veu1_resources[] = {
  235. [0] = {
  236. .name = "VEU1",
  237. .start = 0xfe924000,
  238. .end = 0xfe9240b7,
  239. .flags = IORESOURCE_MEM,
  240. },
  241. };
  242. static struct platform_device veu1_device = {
  243. .name = "uio_pdrv_genirq",
  244. .id = 2,
  245. .dev = {
  246. .platform_data = &veu1_platform_data,
  247. },
  248. .resource = veu1_resources,
  249. .num_resources = ARRAY_SIZE(veu1_resources),
  250. };
  251. /* VEU2 */
  252. static struct uio_info veu2_platform_data = {
  253. .name = "VEU2",
  254. .version = "0",
  255. .irq = intcs_evt2irq(0x740),
  256. };
  257. static struct resource veu2_resources[] = {
  258. [0] = {
  259. .name = "VEU2",
  260. .start = 0xfe928000,
  261. .end = 0xfe9280b7,
  262. .flags = IORESOURCE_MEM,
  263. },
  264. };
  265. static struct platform_device veu2_device = {
  266. .name = "uio_pdrv_genirq",
  267. .id = 3,
  268. .dev = {
  269. .platform_data = &veu2_platform_data,
  270. },
  271. .resource = veu2_resources,
  272. .num_resources = ARRAY_SIZE(veu2_resources),
  273. };
  274. /* VEU3 */
  275. static struct uio_info veu3_platform_data = {
  276. .name = "VEU3",
  277. .version = "0",
  278. .irq = intcs_evt2irq(0x760),
  279. };
  280. static struct resource veu3_resources[] = {
  281. [0] = {
  282. .name = "VEU3",
  283. .start = 0xfe92c000,
  284. .end = 0xfe92c0b7,
  285. .flags = IORESOURCE_MEM,
  286. },
  287. };
  288. static struct platform_device veu3_device = {
  289. .name = "uio_pdrv_genirq",
  290. .id = 4,
  291. .dev = {
  292. .platform_data = &veu3_platform_data,
  293. },
  294. .resource = veu3_resources,
  295. .num_resources = ARRAY_SIZE(veu3_resources),
  296. };
  297. /* VEU2H */
  298. static struct uio_info veu2h_platform_data = {
  299. .name = "VEU2H",
  300. .version = "0",
  301. .irq = intcs_evt2irq(0x520),
  302. };
  303. static struct resource veu2h_resources[] = {
  304. [0] = {
  305. .name = "VEU2H",
  306. .start = 0xfe93c000,
  307. .end = 0xfe93c27b,
  308. .flags = IORESOURCE_MEM,
  309. },
  310. };
  311. static struct platform_device veu2h_device = {
  312. .name = "uio_pdrv_genirq",
  313. .id = 5,
  314. .dev = {
  315. .platform_data = &veu2h_platform_data,
  316. },
  317. .resource = veu2h_resources,
  318. .num_resources = ARRAY_SIZE(veu2h_resources),
  319. };
  320. /* JPU */
  321. static struct uio_info jpu_platform_data = {
  322. .name = "JPU",
  323. .version = "0",
  324. .irq = intcs_evt2irq(0x560),
  325. };
  326. static struct resource jpu_resources[] = {
  327. [0] = {
  328. .name = "JPU",
  329. .start = 0xfe980000,
  330. .end = 0xfe9902d3,
  331. .flags = IORESOURCE_MEM,
  332. },
  333. };
  334. static struct platform_device jpu_device = {
  335. .name = "uio_pdrv_genirq",
  336. .id = 6,
  337. .dev = {
  338. .platform_data = &jpu_platform_data,
  339. },
  340. .resource = jpu_resources,
  341. .num_resources = ARRAY_SIZE(jpu_resources),
  342. };
  343. /* SPU1 */
  344. static struct uio_info spu1_platform_data = {
  345. .name = "SPU1",
  346. .version = "0",
  347. .irq = evt2irq(0xfc0),
  348. };
  349. static struct resource spu1_resources[] = {
  350. [0] = {
  351. .name = "SPU1",
  352. .start = 0xfe300000,
  353. .end = 0xfe3fffff,
  354. .flags = IORESOURCE_MEM,
  355. },
  356. };
  357. static struct platform_device spu1_device = {
  358. .name = "uio_pdrv_genirq",
  359. .id = 7,
  360. .dev = {
  361. .platform_data = &spu1_platform_data,
  362. },
  363. .resource = spu1_resources,
  364. .num_resources = ARRAY_SIZE(spu1_resources),
  365. };
  366. static struct platform_device *sh7367_early_devices[] __initdata = {
  367. &scif0_device,
  368. &scif1_device,
  369. &scif2_device,
  370. &scif3_device,
  371. &scif4_device,
  372. &scif5_device,
  373. &scif6_device,
  374. &cmt10_device,
  375. };
  376. static struct platform_device *sh7367_devices[] __initdata = {
  377. &vpu_device,
  378. &veu0_device,
  379. &veu1_device,
  380. &veu2_device,
  381. &veu3_device,
  382. &veu2h_device,
  383. &jpu_device,
  384. &spu1_device,
  385. };
  386. void __init sh7367_add_standard_devices(void)
  387. {
  388. platform_add_devices(sh7367_early_devices,
  389. ARRAY_SIZE(sh7367_early_devices));
  390. platform_add_devices(sh7367_devices,
  391. ARRAY_SIZE(sh7367_devices));
  392. }
  393. #define SYMSTPCR2 0xe6158048
  394. #define SYMSTPCR2_CMT1 (1 << 29)
  395. void __init sh7367_add_early_devices(void)
  396. {
  397. /* enable clock to CMT1 */
  398. __raw_writel(__raw_readl(SYMSTPCR2) & ~SYMSTPCR2_CMT1, SYMSTPCR2);
  399. early_platform_add_devices(sh7367_early_devices,
  400. ARRAY_SIZE(sh7367_early_devices));
  401. }