setup-r8a7779.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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 plat_sci_port scif0_platform_data = {
  61. .mapbase = 0xffe40000,
  62. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  63. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  64. .scbrr_algo_id = SCBRR_ALGO_2,
  65. .type = PORT_SCIF,
  66. .irqs = { gic_spi(88), gic_spi(88),
  67. gic_spi(88), gic_spi(88) },
  68. };
  69. static struct platform_device scif0_device = {
  70. .name = "sh-sci",
  71. .id = 0,
  72. .dev = {
  73. .platform_data = &scif0_platform_data,
  74. },
  75. };
  76. static struct plat_sci_port scif1_platform_data = {
  77. .mapbase = 0xffe41000,
  78. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  79. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  80. .scbrr_algo_id = SCBRR_ALGO_2,
  81. .type = PORT_SCIF,
  82. .irqs = { gic_spi(89), gic_spi(89),
  83. gic_spi(89), gic_spi(89) },
  84. };
  85. static struct platform_device scif1_device = {
  86. .name = "sh-sci",
  87. .id = 1,
  88. .dev = {
  89. .platform_data = &scif1_platform_data,
  90. },
  91. };
  92. static struct plat_sci_port scif2_platform_data = {
  93. .mapbase = 0xffe42000,
  94. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  95. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  96. .scbrr_algo_id = SCBRR_ALGO_2,
  97. .type = PORT_SCIF,
  98. .irqs = { gic_spi(90), gic_spi(90),
  99. gic_spi(90), gic_spi(90) },
  100. };
  101. static struct platform_device scif2_device = {
  102. .name = "sh-sci",
  103. .id = 2,
  104. .dev = {
  105. .platform_data = &scif2_platform_data,
  106. },
  107. };
  108. static struct plat_sci_port scif3_platform_data = {
  109. .mapbase = 0xffe43000,
  110. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  111. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  112. .scbrr_algo_id = SCBRR_ALGO_2,
  113. .type = PORT_SCIF,
  114. .irqs = { gic_spi(91), gic_spi(91),
  115. gic_spi(91), gic_spi(91) },
  116. };
  117. static struct platform_device scif3_device = {
  118. .name = "sh-sci",
  119. .id = 3,
  120. .dev = {
  121. .platform_data = &scif3_platform_data,
  122. },
  123. };
  124. static struct plat_sci_port scif4_platform_data = {
  125. .mapbase = 0xffe44000,
  126. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  127. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  128. .scbrr_algo_id = SCBRR_ALGO_2,
  129. .type = PORT_SCIF,
  130. .irqs = { gic_spi(92), gic_spi(92),
  131. gic_spi(92), gic_spi(92) },
  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. static struct plat_sci_port scif5_platform_data = {
  141. .mapbase = 0xffe45000,
  142. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  143. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  144. .scbrr_algo_id = SCBRR_ALGO_2,
  145. .type = PORT_SCIF,
  146. .irqs = { gic_spi(93), gic_spi(93),
  147. gic_spi(93), gic_spi(93) },
  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. /* TMU */
  157. static struct sh_timer_config tmu00_platform_data = {
  158. .name = "TMU00",
  159. .channel_offset = 0x4,
  160. .timer_bit = 0,
  161. .clockevent_rating = 200,
  162. };
  163. static struct resource tmu00_resources[] = {
  164. [0] = {
  165. .name = "TMU00",
  166. .start = 0xffd80008,
  167. .end = 0xffd80013,
  168. .flags = IORESOURCE_MEM,
  169. },
  170. [1] = {
  171. .start = gic_spi(32),
  172. .flags = IORESOURCE_IRQ,
  173. },
  174. };
  175. static struct platform_device tmu00_device = {
  176. .name = "sh_tmu",
  177. .id = 0,
  178. .dev = {
  179. .platform_data = &tmu00_platform_data,
  180. },
  181. .resource = tmu00_resources,
  182. .num_resources = ARRAY_SIZE(tmu00_resources),
  183. };
  184. static struct sh_timer_config tmu01_platform_data = {
  185. .name = "TMU01",
  186. .channel_offset = 0x10,
  187. .timer_bit = 1,
  188. .clocksource_rating = 200,
  189. };
  190. static struct resource tmu01_resources[] = {
  191. [0] = {
  192. .name = "TMU01",
  193. .start = 0xffd80014,
  194. .end = 0xffd8001f,
  195. .flags = IORESOURCE_MEM,
  196. },
  197. [1] = {
  198. .start = gic_spi(33),
  199. .flags = IORESOURCE_IRQ,
  200. },
  201. };
  202. static struct platform_device tmu01_device = {
  203. .name = "sh_tmu",
  204. .id = 1,
  205. .dev = {
  206. .platform_data = &tmu01_platform_data,
  207. },
  208. .resource = tmu01_resources,
  209. .num_resources = ARRAY_SIZE(tmu01_resources),
  210. };
  211. /* I2C */
  212. static struct resource rcar_i2c0_res[] = {
  213. {
  214. .start = 0xffc70000,
  215. .end = 0xffc70fff,
  216. .flags = IORESOURCE_MEM,
  217. }, {
  218. .start = gic_spi(79),
  219. .flags = IORESOURCE_IRQ,
  220. },
  221. };
  222. static struct platform_device i2c0_device = {
  223. .name = "i2c-rcar",
  224. .id = 0,
  225. .resource = rcar_i2c0_res,
  226. .num_resources = ARRAY_SIZE(rcar_i2c0_res),
  227. };
  228. static struct resource rcar_i2c1_res[] = {
  229. {
  230. .start = 0xffc71000,
  231. .end = 0xffc71fff,
  232. .flags = IORESOURCE_MEM,
  233. }, {
  234. .start = gic_spi(82),
  235. .flags = IORESOURCE_IRQ,
  236. },
  237. };
  238. static struct platform_device i2c1_device = {
  239. .name = "i2c-rcar",
  240. .id = 1,
  241. .resource = rcar_i2c1_res,
  242. .num_resources = ARRAY_SIZE(rcar_i2c1_res),
  243. };
  244. static struct resource rcar_i2c2_res[] = {
  245. {
  246. .start = 0xffc72000,
  247. .end = 0xffc72fff,
  248. .flags = IORESOURCE_MEM,
  249. }, {
  250. .start = gic_spi(80),
  251. .flags = IORESOURCE_IRQ,
  252. },
  253. };
  254. static struct platform_device i2c2_device = {
  255. .name = "i2c-rcar",
  256. .id = 2,
  257. .resource = rcar_i2c2_res,
  258. .num_resources = ARRAY_SIZE(rcar_i2c2_res),
  259. };
  260. static struct resource rcar_i2c3_res[] = {
  261. {
  262. .start = 0xffc73000,
  263. .end = 0xffc73fff,
  264. .flags = IORESOURCE_MEM,
  265. }, {
  266. .start = gic_spi(81),
  267. .flags = IORESOURCE_IRQ,
  268. },
  269. };
  270. static struct platform_device i2c3_device = {
  271. .name = "i2c-rcar",
  272. .id = 3,
  273. .resource = rcar_i2c3_res,
  274. .num_resources = ARRAY_SIZE(rcar_i2c3_res),
  275. };
  276. static struct platform_device *r8a7779_early_devices[] __initdata = {
  277. &scif0_device,
  278. &scif1_device,
  279. &scif2_device,
  280. &scif3_device,
  281. &scif4_device,
  282. &scif5_device,
  283. &tmu00_device,
  284. &tmu01_device,
  285. &i2c0_device,
  286. &i2c1_device,
  287. &i2c2_device,
  288. &i2c3_device,
  289. };
  290. static struct platform_device *r8a7779_late_devices[] __initdata = {
  291. };
  292. void __init r8a7779_add_standard_devices(void)
  293. {
  294. #ifdef CONFIG_CACHE_L2X0
  295. /* Early BRESP enable, Shared attribute override enable, 64K*16way */
  296. l2x0_init(IOMEM(0xf0100000), 0x40470000, 0x82000fff);
  297. #endif
  298. r8a7779_pm_init();
  299. r8a7779_init_pm_domains();
  300. platform_add_devices(r8a7779_early_devices,
  301. ARRAY_SIZE(r8a7779_early_devices));
  302. platform_add_devices(r8a7779_late_devices,
  303. ARRAY_SIZE(r8a7779_late_devices));
  304. }
  305. /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
  306. void __init __weak r8a7779_register_twd(void) { }
  307. static void __init r8a7779_earlytimer_init(void)
  308. {
  309. r8a7779_clock_init();
  310. shmobile_earlytimer_init();
  311. r8a7779_register_twd();
  312. }
  313. void __init r8a7779_add_early_devices(void)
  314. {
  315. early_platform_add_devices(r8a7779_early_devices,
  316. ARRAY_SIZE(r8a7779_early_devices));
  317. /* Early serial console setup is not included here due to
  318. * memory map collisions. The SCIF serial ports in r8a7779
  319. * are difficult to entity map 1:1 due to collision with the
  320. * virtual memory range used by the coherent DMA code on ARM.
  321. *
  322. * Anyone wanting to debug early can remove UPF_IOREMAP from
  323. * the sh-sci serial console platform data, adjust mapbase
  324. * to a static M:N virt:phys mapping that needs to be added to
  325. * the mappings passed with iotable_init() above.
  326. *
  327. * Then add a call to shmobile_setup_console() from this function.
  328. *
  329. * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
  330. * command line in case of the marzen board.
  331. */
  332. /* override timer setup with soc-specific code */
  333. shmobile_timer.init = r8a7779_earlytimer_init;
  334. }