setup-r8a7779.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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/r8a7779.h>
  33. #include <mach/common.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/time.h>
  37. #include <asm/mach/map.h>
  38. #include <asm/hardware/cache-l2x0.h>
  39. static struct map_desc r8a7779_io_desc[] __initdata = {
  40. /* 2M entity map for 0xf0000000 (MPCORE) */
  41. {
  42. .virtual = 0xf0000000,
  43. .pfn = __phys_to_pfn(0xf0000000),
  44. .length = SZ_2M,
  45. .type = MT_DEVICE_NONSHARED
  46. },
  47. /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
  48. {
  49. .virtual = 0xfe000000,
  50. .pfn = __phys_to_pfn(0xfe000000),
  51. .length = SZ_16M,
  52. .type = MT_DEVICE_NONSHARED
  53. },
  54. };
  55. void __init r8a7779_map_io(void)
  56. {
  57. iotable_init(r8a7779_io_desc, ARRAY_SIZE(r8a7779_io_desc));
  58. }
  59. static struct plat_sci_port scif0_platform_data = {
  60. .mapbase = 0xffe40000,
  61. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  62. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  63. .scbrr_algo_id = SCBRR_ALGO_2,
  64. .type = PORT_SCIF,
  65. .irqs = { gic_spi(88), gic_spi(88),
  66. gic_spi(88), gic_spi(88) },
  67. };
  68. static struct platform_device scif0_device = {
  69. .name = "sh-sci",
  70. .id = 0,
  71. .dev = {
  72. .platform_data = &scif0_platform_data,
  73. },
  74. };
  75. static struct plat_sci_port scif1_platform_data = {
  76. .mapbase = 0xffe41000,
  77. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  78. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  79. .scbrr_algo_id = SCBRR_ALGO_2,
  80. .type = PORT_SCIF,
  81. .irqs = { gic_spi(89), gic_spi(89),
  82. gic_spi(89), gic_spi(89) },
  83. };
  84. static struct platform_device scif1_device = {
  85. .name = "sh-sci",
  86. .id = 1,
  87. .dev = {
  88. .platform_data = &scif1_platform_data,
  89. },
  90. };
  91. static struct plat_sci_port scif2_platform_data = {
  92. .mapbase = 0xffe42000,
  93. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  94. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  95. .scbrr_algo_id = SCBRR_ALGO_2,
  96. .type = PORT_SCIF,
  97. .irqs = { gic_spi(90), gic_spi(90),
  98. gic_spi(90), gic_spi(90) },
  99. };
  100. static struct platform_device scif2_device = {
  101. .name = "sh-sci",
  102. .id = 2,
  103. .dev = {
  104. .platform_data = &scif2_platform_data,
  105. },
  106. };
  107. static struct plat_sci_port scif3_platform_data = {
  108. .mapbase = 0xffe43000,
  109. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  110. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  111. .scbrr_algo_id = SCBRR_ALGO_2,
  112. .type = PORT_SCIF,
  113. .irqs = { gic_spi(91), gic_spi(91),
  114. gic_spi(91), gic_spi(91) },
  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. static struct plat_sci_port scif4_platform_data = {
  124. .mapbase = 0xffe44000,
  125. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  126. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  127. .scbrr_algo_id = SCBRR_ALGO_2,
  128. .type = PORT_SCIF,
  129. .irqs = { gic_spi(92), gic_spi(92),
  130. gic_spi(92), gic_spi(92) },
  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. static struct plat_sci_port scif5_platform_data = {
  140. .mapbase = 0xffe45000,
  141. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
  142. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
  143. .scbrr_algo_id = SCBRR_ALGO_2,
  144. .type = PORT_SCIF,
  145. .irqs = { gic_spi(93), gic_spi(93),
  146. gic_spi(93), gic_spi(93) },
  147. };
  148. static struct platform_device scif5_device = {
  149. .name = "sh-sci",
  150. .id = 5,
  151. .dev = {
  152. .platform_data = &scif5_platform_data,
  153. },
  154. };
  155. /* TMU */
  156. static struct sh_timer_config tmu00_platform_data = {
  157. .name = "TMU00",
  158. .channel_offset = 0x4,
  159. .timer_bit = 0,
  160. .clockevent_rating = 200,
  161. };
  162. static struct resource tmu00_resources[] = {
  163. [0] = {
  164. .name = "TMU00",
  165. .start = 0xffd80008,
  166. .end = 0xffd80013,
  167. .flags = IORESOURCE_MEM,
  168. },
  169. [1] = {
  170. .start = gic_spi(32),
  171. .flags = IORESOURCE_IRQ,
  172. },
  173. };
  174. static struct platform_device tmu00_device = {
  175. .name = "sh_tmu",
  176. .id = 0,
  177. .dev = {
  178. .platform_data = &tmu00_platform_data,
  179. },
  180. .resource = tmu00_resources,
  181. .num_resources = ARRAY_SIZE(tmu00_resources),
  182. };
  183. static struct sh_timer_config tmu01_platform_data = {
  184. .name = "TMU01",
  185. .channel_offset = 0x10,
  186. .timer_bit = 1,
  187. .clocksource_rating = 200,
  188. };
  189. static struct resource tmu01_resources[] = {
  190. [0] = {
  191. .name = "TMU01",
  192. .start = 0xffd80014,
  193. .end = 0xffd8001f,
  194. .flags = IORESOURCE_MEM,
  195. },
  196. [1] = {
  197. .start = gic_spi(33),
  198. .flags = IORESOURCE_IRQ,
  199. },
  200. };
  201. static struct platform_device tmu01_device = {
  202. .name = "sh_tmu",
  203. .id = 1,
  204. .dev = {
  205. .platform_data = &tmu01_platform_data,
  206. },
  207. .resource = tmu01_resources,
  208. .num_resources = ARRAY_SIZE(tmu01_resources),
  209. };
  210. static struct platform_device *r8a7779_early_devices[] __initdata = {
  211. &scif0_device,
  212. &scif1_device,
  213. &scif2_device,
  214. &scif3_device,
  215. &scif4_device,
  216. &scif5_device,
  217. &tmu00_device,
  218. &tmu01_device,
  219. };
  220. static struct platform_device *r8a7779_late_devices[] __initdata = {
  221. };
  222. void __init r8a7779_add_standard_devices(void)
  223. {
  224. #ifdef CONFIG_CACHE_L2X0
  225. /* Early BRESP enable, Shared attribute override enable, 64K*16way */
  226. l2x0_init((void __iomem __force *)(0xf0100000), 0x40470000, 0x82000fff);
  227. #endif
  228. r8a7779_pm_init();
  229. r8a7779_init_pm_domain(&r8a7779_sh4a);
  230. r8a7779_init_pm_domain(&r8a7779_sgx);
  231. r8a7779_init_pm_domain(&r8a7779_vdp1);
  232. r8a7779_init_pm_domain(&r8a7779_impx3);
  233. platform_add_devices(r8a7779_early_devices,
  234. ARRAY_SIZE(r8a7779_early_devices));
  235. platform_add_devices(r8a7779_late_devices,
  236. ARRAY_SIZE(r8a7779_late_devices));
  237. }
  238. static void __init r8a7779_earlytimer_init(void)
  239. {
  240. r8a7779_clock_init();
  241. shmobile_earlytimer_init();
  242. }
  243. void __init r8a7779_add_early_devices(void)
  244. {
  245. early_platform_add_devices(r8a7779_early_devices,
  246. ARRAY_SIZE(r8a7779_early_devices));
  247. /* Early serial console setup is not included here due to
  248. * memory map collisions. The SCIF serial ports in r8a7779
  249. * are difficult to entity map 1:1 due to collision with the
  250. * virtual memory range used by the coherent DMA code on ARM.
  251. *
  252. * Anyone wanting to debug early can remove UPF_IOREMAP from
  253. * the sh-sci serial console platform data, adjust mapbase
  254. * to a static M:N virt:phys mapping that needs to be added to
  255. * the mappings passed with iotable_init() above.
  256. *
  257. * Then add a call to shmobile_setup_console() from this function.
  258. *
  259. * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
  260. * command line in case of the marzen board.
  261. */
  262. /* override timer setup with soc-specific code */
  263. shmobile_timer.init = r8a7779_earlytimer_init;
  264. }