setup-sh7377.c 11 KB

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