setup-r8a7779.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. /*
  2. * r8a7779 processor support
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Magnus Damm
  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/delay.h>
  26. #include <linux/input.h>
  27. #include <linux/io.h>
  28. #include <linux/serial_sci.h>
  29. #include <linux/sh_intc.h>
  30. #include <linux/sh_timer.h>
  31. #include <mach/hardware.h>
  32. #include <mach/irqs.h>
  33. #include <mach/r8a7779.h>
  34. #include <mach/common.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/time.h>
  38. #include <asm/mach/map.h>
  39. #include <asm/hardware/cache-l2x0.h>
  40. static struct map_desc r8a7779_io_desc[] __initdata = {
  41. /* 2M entity map for 0xf0000000 (MPCORE) */
  42. {
  43. .virtual = 0xf0000000,
  44. .pfn = __phys_to_pfn(0xf0000000),
  45. .length = SZ_2M,
  46. .type = MT_DEVICE_NONSHARED
  47. },
  48. /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
  49. {
  50. .virtual = 0xfe000000,
  51. .pfn = __phys_to_pfn(0xfe000000),
  52. .length = SZ_16M,
  53. .type = MT_DEVICE_NONSHARED
  54. },
  55. };
  56. void __init r8a7779_map_io(void)
  57. {
  58. iotable_init(r8a7779_io_desc, ARRAY_SIZE(r8a7779_io_desc));
  59. }
  60. static struct resource r8a7779_pfc_resources[] = {
  61. [0] = {
  62. .start = 0xfffc0000,
  63. .end = 0xfffc023b,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. [1] = {
  67. .start = 0xffc40000,
  68. .end = 0xffc46fff,
  69. .flags = IORESOURCE_MEM,
  70. }
  71. };
  72. static struct platform_device r8a7779_pfc_device = {
  73. .name = "pfc-r8a7779",
  74. .id = -1,
  75. .resource = r8a7779_pfc_resources,
  76. .num_resources = ARRAY_SIZE(r8a7779_pfc_resources),
  77. };
  78. void __init r8a7779_pinmux_init(void)
  79. {
  80. platform_device_register(&r8a7779_pfc_device);
  81. }
  82. static struct plat_sci_port scif0_platform_data = {
  83. .mapbase = 0xffe40000,
  84. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  85. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  86. .scbrr_algo_id = SCBRR_ALGO_2,
  87. .type = PORT_SCIF,
  88. .irqs = { gic_spi(88), gic_spi(88),
  89. gic_spi(88), gic_spi(88) },
  90. };
  91. static struct platform_device scif0_device = {
  92. .name = "sh-sci",
  93. .id = 0,
  94. .dev = {
  95. .platform_data = &scif0_platform_data,
  96. },
  97. };
  98. static struct plat_sci_port scif1_platform_data = {
  99. .mapbase = 0xffe41000,
  100. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  101. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  102. .scbrr_algo_id = SCBRR_ALGO_2,
  103. .type = PORT_SCIF,
  104. .irqs = { gic_spi(89), gic_spi(89),
  105. gic_spi(89), gic_spi(89) },
  106. };
  107. static struct platform_device scif1_device = {
  108. .name = "sh-sci",
  109. .id = 1,
  110. .dev = {
  111. .platform_data = &scif1_platform_data,
  112. },
  113. };
  114. static struct plat_sci_port scif2_platform_data = {
  115. .mapbase = 0xffe42000,
  116. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  117. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  118. .scbrr_algo_id = SCBRR_ALGO_2,
  119. .type = PORT_SCIF,
  120. .irqs = { gic_spi(90), gic_spi(90),
  121. gic_spi(90), gic_spi(90) },
  122. };
  123. static struct platform_device scif2_device = {
  124. .name = "sh-sci",
  125. .id = 2,
  126. .dev = {
  127. .platform_data = &scif2_platform_data,
  128. },
  129. };
  130. static struct plat_sci_port scif3_platform_data = {
  131. .mapbase = 0xffe43000,
  132. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  133. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  134. .scbrr_algo_id = SCBRR_ALGO_2,
  135. .type = PORT_SCIF,
  136. .irqs = { gic_spi(91), gic_spi(91),
  137. gic_spi(91), gic_spi(91) },
  138. };
  139. static struct platform_device scif3_device = {
  140. .name = "sh-sci",
  141. .id = 3,
  142. .dev = {
  143. .platform_data = &scif3_platform_data,
  144. },
  145. };
  146. static struct plat_sci_port scif4_platform_data = {
  147. .mapbase = 0xffe44000,
  148. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  149. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  150. .scbrr_algo_id = SCBRR_ALGO_2,
  151. .type = PORT_SCIF,
  152. .irqs = { gic_spi(92), gic_spi(92),
  153. gic_spi(92), gic_spi(92) },
  154. };
  155. static struct platform_device scif4_device = {
  156. .name = "sh-sci",
  157. .id = 4,
  158. .dev = {
  159. .platform_data = &scif4_platform_data,
  160. },
  161. };
  162. static struct plat_sci_port scif5_platform_data = {
  163. .mapbase = 0xffe45000,
  164. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  165. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  166. .scbrr_algo_id = SCBRR_ALGO_2,
  167. .type = PORT_SCIF,
  168. .irqs = { gic_spi(93), gic_spi(93),
  169. gic_spi(93), gic_spi(93) },
  170. };
  171. static struct platform_device scif5_device = {
  172. .name = "sh-sci",
  173. .id = 5,
  174. .dev = {
  175. .platform_data = &scif5_platform_data,
  176. },
  177. };
  178. /* TMU */
  179. static struct sh_timer_config tmu00_platform_data = {
  180. .name = "TMU00",
  181. .channel_offset = 0x4,
  182. .timer_bit = 0,
  183. .clockevent_rating = 200,
  184. };
  185. static struct resource tmu00_resources[] = {
  186. [0] = {
  187. .name = "TMU00",
  188. .start = 0xffd80008,
  189. .end = 0xffd80013,
  190. .flags = IORESOURCE_MEM,
  191. },
  192. [1] = {
  193. .start = gic_spi(32),
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. };
  197. static struct platform_device tmu00_device = {
  198. .name = "sh_tmu",
  199. .id = 0,
  200. .dev = {
  201. .platform_data = &tmu00_platform_data,
  202. },
  203. .resource = tmu00_resources,
  204. .num_resources = ARRAY_SIZE(tmu00_resources),
  205. };
  206. static struct sh_timer_config tmu01_platform_data = {
  207. .name = "TMU01",
  208. .channel_offset = 0x10,
  209. .timer_bit = 1,
  210. .clocksource_rating = 200,
  211. };
  212. static struct resource tmu01_resources[] = {
  213. [0] = {
  214. .name = "TMU01",
  215. .start = 0xffd80014,
  216. .end = 0xffd8001f,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. [1] = {
  220. .start = gic_spi(33),
  221. .flags = IORESOURCE_IRQ,
  222. },
  223. };
  224. static struct platform_device tmu01_device = {
  225. .name = "sh_tmu",
  226. .id = 1,
  227. .dev = {
  228. .platform_data = &tmu01_platform_data,
  229. },
  230. .resource = tmu01_resources,
  231. .num_resources = ARRAY_SIZE(tmu01_resources),
  232. };
  233. /* I2C */
  234. static struct resource rcar_i2c0_res[] = {
  235. {
  236. .start = 0xffc70000,
  237. .end = 0xffc70fff,
  238. .flags = IORESOURCE_MEM,
  239. }, {
  240. .start = gic_spi(79),
  241. .flags = IORESOURCE_IRQ,
  242. },
  243. };
  244. static struct platform_device i2c0_device = {
  245. .name = "i2c-rcar",
  246. .id = 0,
  247. .resource = rcar_i2c0_res,
  248. .num_resources = ARRAY_SIZE(rcar_i2c0_res),
  249. };
  250. static struct resource rcar_i2c1_res[] = {
  251. {
  252. .start = 0xffc71000,
  253. .end = 0xffc71fff,
  254. .flags = IORESOURCE_MEM,
  255. }, {
  256. .start = gic_spi(82),
  257. .flags = IORESOURCE_IRQ,
  258. },
  259. };
  260. static struct platform_device i2c1_device = {
  261. .name = "i2c-rcar",
  262. .id = 1,
  263. .resource = rcar_i2c1_res,
  264. .num_resources = ARRAY_SIZE(rcar_i2c1_res),
  265. };
  266. static struct resource rcar_i2c2_res[] = {
  267. {
  268. .start = 0xffc72000,
  269. .end = 0xffc72fff,
  270. .flags = IORESOURCE_MEM,
  271. }, {
  272. .start = gic_spi(80),
  273. .flags = IORESOURCE_IRQ,
  274. },
  275. };
  276. static struct platform_device i2c2_device = {
  277. .name = "i2c-rcar",
  278. .id = 2,
  279. .resource = rcar_i2c2_res,
  280. .num_resources = ARRAY_SIZE(rcar_i2c2_res),
  281. };
  282. static struct resource rcar_i2c3_res[] = {
  283. {
  284. .start = 0xffc73000,
  285. .end = 0xffc73fff,
  286. .flags = IORESOURCE_MEM,
  287. }, {
  288. .start = gic_spi(81),
  289. .flags = IORESOURCE_IRQ,
  290. },
  291. };
  292. static struct platform_device i2c3_device = {
  293. .name = "i2c-rcar",
  294. .id = 3,
  295. .resource = rcar_i2c3_res,
  296. .num_resources = ARRAY_SIZE(rcar_i2c3_res),
  297. };
  298. static struct platform_device *r8a7779_early_devices[] __initdata = {
  299. &scif0_device,
  300. &scif1_device,
  301. &scif2_device,
  302. &scif3_device,
  303. &scif4_device,
  304. &scif5_device,
  305. &tmu00_device,
  306. &tmu01_device,
  307. &i2c0_device,
  308. &i2c1_device,
  309. &i2c2_device,
  310. &i2c3_device,
  311. };
  312. static struct platform_device *r8a7779_late_devices[] __initdata = {
  313. };
  314. void __init r8a7779_add_standard_devices(void)
  315. {
  316. #ifdef CONFIG_CACHE_L2X0
  317. /* Early BRESP enable, Shared attribute override enable, 64K*16way */
  318. l2x0_init(IOMEM(0xf0100000), 0x40470000, 0x82000fff);
  319. #endif
  320. r8a7779_pm_init();
  321. r8a7779_init_pm_domains();
  322. platform_add_devices(r8a7779_early_devices,
  323. ARRAY_SIZE(r8a7779_early_devices));
  324. platform_add_devices(r8a7779_late_devices,
  325. ARRAY_SIZE(r8a7779_late_devices));
  326. }
  327. /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
  328. void __init __weak r8a7779_register_twd(void) { }
  329. static void __init r8a7779_earlytimer_init(void)
  330. {
  331. r8a7779_clock_init();
  332. shmobile_earlytimer_init();
  333. r8a7779_register_twd();
  334. }
  335. void __init r8a7779_add_early_devices(void)
  336. {
  337. early_platform_add_devices(r8a7779_early_devices,
  338. ARRAY_SIZE(r8a7779_early_devices));
  339. /* Early serial console setup is not included here due to
  340. * memory map collisions. The SCIF serial ports in r8a7779
  341. * are difficult to entity map 1:1 due to collision with the
  342. * virtual memory range used by the coherent DMA code on ARM.
  343. *
  344. * Anyone wanting to debug early can remove UPF_IOREMAP from
  345. * the sh-sci serial console platform data, adjust mapbase
  346. * to a static M:N virt:phys mapping that needs to be added to
  347. * the mappings passed with iotable_init() above.
  348. *
  349. * Then add a call to shmobile_setup_console() from this function.
  350. *
  351. * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
  352. * command line in case of the marzen board.
  353. */
  354. /* override timer setup with soc-specific code */
  355. shmobile_timer.init = r8a7779_earlytimer_init;
  356. }