setup-sh7377.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  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 <mach/common.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/arch.h>
  37. static struct map_desc sh7377_io_desc[] __initdata = {
  38. /* create a 1:1 entity map for 0xe6xxxxxx
  39. * used by CPGA, INTC and PFC.
  40. */
  41. {
  42. .virtual = 0xe6000000,
  43. .pfn = __phys_to_pfn(0xe6000000),
  44. .length = 256 << 20,
  45. .type = MT_DEVICE_NONSHARED
  46. },
  47. };
  48. void __init sh7377_map_io(void)
  49. {
  50. iotable_init(sh7377_io_desc, ARRAY_SIZE(sh7377_io_desc));
  51. }
  52. /* SCIFA0 */
  53. static struct plat_sci_port scif0_platform_data = {
  54. .mapbase = 0xe6c40000,
  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(0xc00), evt2irq(0xc00),
  60. evt2irq(0xc00), evt2irq(0xc00) },
  61. };
  62. static struct platform_device scif0_device = {
  63. .name = "sh-sci",
  64. .id = 0,
  65. .dev = {
  66. .platform_data = &scif0_platform_data,
  67. },
  68. };
  69. /* SCIFA1 */
  70. static struct plat_sci_port scif1_platform_data = {
  71. .mapbase = 0xe6c50000,
  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(0xc20), evt2irq(0xc20),
  77. evt2irq(0xc20), evt2irq(0xc20) },
  78. };
  79. static struct platform_device scif1_device = {
  80. .name = "sh-sci",
  81. .id = 1,
  82. .dev = {
  83. .platform_data = &scif1_platform_data,
  84. },
  85. };
  86. /* SCIFA2 */
  87. static struct plat_sci_port scif2_platform_data = {
  88. .mapbase = 0xe6c60000,
  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(0xc40), evt2irq(0xc40),
  94. evt2irq(0xc40), evt2irq(0xc40) },
  95. };
  96. static struct platform_device scif2_device = {
  97. .name = "sh-sci",
  98. .id = 2,
  99. .dev = {
  100. .platform_data = &scif2_platform_data,
  101. },
  102. };
  103. /* SCIFA3 */
  104. static struct plat_sci_port scif3_platform_data = {
  105. .mapbase = 0xe6c70000,
  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(0xc60), evt2irq(0xc60),
  111. evt2irq(0xc60), evt2irq(0xc60) },
  112. };
  113. static struct platform_device scif3_device = {
  114. .name = "sh-sci",
  115. .id = 3,
  116. .dev = {
  117. .platform_data = &scif3_platform_data,
  118. },
  119. };
  120. /* SCIFA4 */
  121. static struct plat_sci_port scif4_platform_data = {
  122. .mapbase = 0xe6c80000,
  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(0xd20), evt2irq(0xd20),
  128. evt2irq(0xd20), evt2irq(0xd20) },
  129. };
  130. static struct platform_device scif4_device = {
  131. .name = "sh-sci",
  132. .id = 4,
  133. .dev = {
  134. .platform_data = &scif4_platform_data,
  135. },
  136. };
  137. /* SCIFA5 */
  138. static struct plat_sci_port scif5_platform_data = {
  139. .mapbase = 0xe6cb0000,
  140. .flags = UPF_BOOT_AUTOCONF,
  141. .scscr = SCSCR_RE | SCSCR_TE,
  142. .scbrr_algo_id = SCBRR_ALGO_4,
  143. .type = PORT_SCIFA,
  144. .irqs = { evt2irq(0xd40), evt2irq(0xd40),
  145. evt2irq(0xd40), evt2irq(0xd40) },
  146. };
  147. static struct platform_device scif5_device = {
  148. .name = "sh-sci",
  149. .id = 5,
  150. .dev = {
  151. .platform_data = &scif5_platform_data,
  152. },
  153. };
  154. /* SCIFA6 */
  155. static struct plat_sci_port scif6_platform_data = {
  156. .mapbase = 0xe6cc0000,
  157. .flags = UPF_BOOT_AUTOCONF,
  158. .scscr = SCSCR_RE | SCSCR_TE,
  159. .scbrr_algo_id = SCBRR_ALGO_4,
  160. .type = PORT_SCIFA,
  161. .irqs = { intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80),
  162. intcs_evt2irq(0x1a80), intcs_evt2irq(0x1a80) },
  163. };
  164. static struct platform_device scif6_device = {
  165. .name = "sh-sci",
  166. .id = 6,
  167. .dev = {
  168. .platform_data = &scif6_platform_data,
  169. },
  170. };
  171. /* SCIFB */
  172. static struct plat_sci_port scif7_platform_data = {
  173. .mapbase = 0xe6c30000,
  174. .flags = UPF_BOOT_AUTOCONF,
  175. .scscr = SCSCR_RE | SCSCR_TE,
  176. .scbrr_algo_id = SCBRR_ALGO_4,
  177. .type = PORT_SCIFB,
  178. .irqs = { evt2irq(0xd60), evt2irq(0xd60),
  179. evt2irq(0xd60), evt2irq(0xd60) },
  180. };
  181. static struct platform_device scif7_device = {
  182. .name = "sh-sci",
  183. .id = 7,
  184. .dev = {
  185. .platform_data = &scif7_platform_data,
  186. },
  187. };
  188. static struct sh_timer_config cmt10_platform_data = {
  189. .name = "CMT10",
  190. .channel_offset = 0x10,
  191. .timer_bit = 0,
  192. .clockevent_rating = 125,
  193. .clocksource_rating = 125,
  194. };
  195. static struct resource cmt10_resources[] = {
  196. [0] = {
  197. .name = "CMT10",
  198. .start = 0xe6138010,
  199. .end = 0xe613801b,
  200. .flags = IORESOURCE_MEM,
  201. },
  202. [1] = {
  203. .start = evt2irq(0xb00), /* CMT1_CMT10 */
  204. .flags = IORESOURCE_IRQ,
  205. },
  206. };
  207. static struct platform_device cmt10_device = {
  208. .name = "sh_cmt",
  209. .id = 10,
  210. .dev = {
  211. .platform_data = &cmt10_platform_data,
  212. },
  213. .resource = cmt10_resources,
  214. .num_resources = ARRAY_SIZE(cmt10_resources),
  215. };
  216. /* VPU */
  217. static struct uio_info vpu_platform_data = {
  218. .name = "VPU5HG",
  219. .version = "0",
  220. .irq = intcs_evt2irq(0x980),
  221. };
  222. static struct resource vpu_resources[] = {
  223. [0] = {
  224. .name = "VPU",
  225. .start = 0xfe900000,
  226. .end = 0xfe900157,
  227. .flags = IORESOURCE_MEM,
  228. },
  229. };
  230. static struct platform_device vpu_device = {
  231. .name = "uio_pdrv_genirq",
  232. .id = 0,
  233. .dev = {
  234. .platform_data = &vpu_platform_data,
  235. },
  236. .resource = vpu_resources,
  237. .num_resources = ARRAY_SIZE(vpu_resources),
  238. };
  239. /* VEU0 */
  240. static struct uio_info veu0_platform_data = {
  241. .name = "VEU0",
  242. .version = "0",
  243. .irq = intcs_evt2irq(0x700),
  244. };
  245. static struct resource veu0_resources[] = {
  246. [0] = {
  247. .name = "VEU0",
  248. .start = 0xfe920000,
  249. .end = 0xfe9200cb,
  250. .flags = IORESOURCE_MEM,
  251. },
  252. };
  253. static struct platform_device veu0_device = {
  254. .name = "uio_pdrv_genirq",
  255. .id = 1,
  256. .dev = {
  257. .platform_data = &veu0_platform_data,
  258. },
  259. .resource = veu0_resources,
  260. .num_resources = ARRAY_SIZE(veu0_resources),
  261. };
  262. /* VEU1 */
  263. static struct uio_info veu1_platform_data = {
  264. .name = "VEU1",
  265. .version = "0",
  266. .irq = intcs_evt2irq(0x720),
  267. };
  268. static struct resource veu1_resources[] = {
  269. [0] = {
  270. .name = "VEU1",
  271. .start = 0xfe924000,
  272. .end = 0xfe9240cb,
  273. .flags = IORESOURCE_MEM,
  274. },
  275. };
  276. static struct platform_device veu1_device = {
  277. .name = "uio_pdrv_genirq",
  278. .id = 2,
  279. .dev = {
  280. .platform_data = &veu1_platform_data,
  281. },
  282. .resource = veu1_resources,
  283. .num_resources = ARRAY_SIZE(veu1_resources),
  284. };
  285. /* VEU2 */
  286. static struct uio_info veu2_platform_data = {
  287. .name = "VEU2",
  288. .version = "0",
  289. .irq = intcs_evt2irq(0x740),
  290. };
  291. static struct resource veu2_resources[] = {
  292. [0] = {
  293. .name = "VEU2",
  294. .start = 0xfe928000,
  295. .end = 0xfe928307,
  296. .flags = IORESOURCE_MEM,
  297. },
  298. };
  299. static struct platform_device veu2_device = {
  300. .name = "uio_pdrv_genirq",
  301. .id = 3,
  302. .dev = {
  303. .platform_data = &veu2_platform_data,
  304. },
  305. .resource = veu2_resources,
  306. .num_resources = ARRAY_SIZE(veu2_resources),
  307. };
  308. /* VEU3 */
  309. static struct uio_info veu3_platform_data = {
  310. .name = "VEU3",
  311. .version = "0",
  312. .irq = intcs_evt2irq(0x760),
  313. };
  314. static struct resource veu3_resources[] = {
  315. [0] = {
  316. .name = "VEU3",
  317. .start = 0xfe92c000,
  318. .end = 0xfe92c307,
  319. .flags = IORESOURCE_MEM,
  320. },
  321. };
  322. static struct platform_device veu3_device = {
  323. .name = "uio_pdrv_genirq",
  324. .id = 4,
  325. .dev = {
  326. .platform_data = &veu3_platform_data,
  327. },
  328. .resource = veu3_resources,
  329. .num_resources = ARRAY_SIZE(veu3_resources),
  330. };
  331. /* JPU */
  332. static struct uio_info jpu_platform_data = {
  333. .name = "JPU",
  334. .version = "0",
  335. .irq = intcs_evt2irq(0x560),
  336. };
  337. static struct resource jpu_resources[] = {
  338. [0] = {
  339. .name = "JPU",
  340. .start = 0xfe980000,
  341. .end = 0xfe9902d3,
  342. .flags = IORESOURCE_MEM,
  343. },
  344. };
  345. static struct platform_device jpu_device = {
  346. .name = "uio_pdrv_genirq",
  347. .id = 5,
  348. .dev = {
  349. .platform_data = &jpu_platform_data,
  350. },
  351. .resource = jpu_resources,
  352. .num_resources = ARRAY_SIZE(jpu_resources),
  353. };
  354. /* SPU2DSP0 */
  355. static struct uio_info spu0_platform_data = {
  356. .name = "SPU2DSP0",
  357. .version = "0",
  358. .irq = evt2irq(0x1800),
  359. };
  360. static struct resource spu0_resources[] = {
  361. [0] = {
  362. .name = "SPU2DSP0",
  363. .start = 0xfe200000,
  364. .end = 0xfe2fffff,
  365. .flags = IORESOURCE_MEM,
  366. },
  367. };
  368. static struct platform_device spu0_device = {
  369. .name = "uio_pdrv_genirq",
  370. .id = 6,
  371. .dev = {
  372. .platform_data = &spu0_platform_data,
  373. },
  374. .resource = spu0_resources,
  375. .num_resources = ARRAY_SIZE(spu0_resources),
  376. };
  377. /* SPU2DSP1 */
  378. static struct uio_info spu1_platform_data = {
  379. .name = "SPU2DSP1",
  380. .version = "0",
  381. .irq = evt2irq(0x1820),
  382. };
  383. static struct resource spu1_resources[] = {
  384. [0] = {
  385. .name = "SPU2DSP1",
  386. .start = 0xfe300000,
  387. .end = 0xfe3fffff,
  388. .flags = IORESOURCE_MEM,
  389. },
  390. };
  391. static struct platform_device spu1_device = {
  392. .name = "uio_pdrv_genirq",
  393. .id = 7,
  394. .dev = {
  395. .platform_data = &spu1_platform_data,
  396. },
  397. .resource = spu1_resources,
  398. .num_resources = ARRAY_SIZE(spu1_resources),
  399. };
  400. static struct platform_device *sh7377_early_devices[] __initdata = {
  401. &scif0_device,
  402. &scif1_device,
  403. &scif2_device,
  404. &scif3_device,
  405. &scif4_device,
  406. &scif5_device,
  407. &scif6_device,
  408. &scif7_device,
  409. &cmt10_device,
  410. };
  411. static struct platform_device *sh7377_devices[] __initdata = {
  412. &vpu_device,
  413. &veu0_device,
  414. &veu1_device,
  415. &veu2_device,
  416. &veu3_device,
  417. &jpu_device,
  418. &spu0_device,
  419. &spu1_device,
  420. };
  421. void __init sh7377_add_standard_devices(void)
  422. {
  423. platform_add_devices(sh7377_early_devices,
  424. ARRAY_SIZE(sh7377_early_devices));
  425. platform_add_devices(sh7377_devices,
  426. ARRAY_SIZE(sh7377_devices));
  427. }
  428. #define SMSTPCR3 0xe615013c
  429. #define SMSTPCR3_CMT1 (1 << 29)
  430. void __init sh7377_add_early_devices(void)
  431. {
  432. /* enable clock to CMT1 */
  433. __raw_writel(__raw_readl(SMSTPCR3) & ~SMSTPCR3_CMT1, SMSTPCR3);
  434. early_platform_add_devices(sh7377_early_devices,
  435. ARRAY_SIZE(sh7377_early_devices));
  436. /* setup early console here as well */
  437. shmobile_setup_console();
  438. }