setup-sh7377.c 12 KB

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