setup-r8a7779.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. static struct platform_device *r8a7779_early_devices[] __initdata = {
  212. &scif0_device,
  213. &scif1_device,
  214. &scif2_device,
  215. &scif3_device,
  216. &scif4_device,
  217. &scif5_device,
  218. &tmu00_device,
  219. &tmu01_device,
  220. };
  221. static struct platform_device *r8a7779_late_devices[] __initdata = {
  222. };
  223. void __init r8a7779_add_standard_devices(void)
  224. {
  225. #ifdef CONFIG_CACHE_L2X0
  226. /* Early BRESP enable, Shared attribute override enable, 64K*16way */
  227. l2x0_init((void __iomem __force *)(0xf0100000), 0x40470000, 0x82000fff);
  228. #endif
  229. r8a7779_pm_init();
  230. r8a7779_init_pm_domain(&r8a7779_sh4a);
  231. r8a7779_init_pm_domain(&r8a7779_sgx);
  232. r8a7779_init_pm_domain(&r8a7779_vdp1);
  233. r8a7779_init_pm_domain(&r8a7779_impx3);
  234. platform_add_devices(r8a7779_early_devices,
  235. ARRAY_SIZE(r8a7779_early_devices));
  236. platform_add_devices(r8a7779_late_devices,
  237. ARRAY_SIZE(r8a7779_late_devices));
  238. }
  239. /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
  240. void __init __weak r8a7779_register_twd(void) { }
  241. static void __init r8a7779_earlytimer_init(void)
  242. {
  243. r8a7779_clock_init();
  244. shmobile_earlytimer_init();
  245. r8a7779_register_twd();
  246. }
  247. void __init r8a7779_add_early_devices(void)
  248. {
  249. early_platform_add_devices(r8a7779_early_devices,
  250. ARRAY_SIZE(r8a7779_early_devices));
  251. /* Early serial console setup is not included here due to
  252. * memory map collisions. The SCIF serial ports in r8a7779
  253. * are difficult to entity map 1:1 due to collision with the
  254. * virtual memory range used by the coherent DMA code on ARM.
  255. *
  256. * Anyone wanting to debug early can remove UPF_IOREMAP from
  257. * the sh-sci serial console platform data, adjust mapbase
  258. * to a static M:N virt:phys mapping that needs to be added to
  259. * the mappings passed with iotable_init() above.
  260. *
  261. * Then add a call to shmobile_setup_console() from this function.
  262. *
  263. * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
  264. * command line in case of the marzen board.
  265. */
  266. /* override timer setup with soc-specific code */
  267. shmobile_timer.init = r8a7779_earlytimer_init;
  268. }