setup-r8a7778.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * r8a7778 processor support
  3. *
  4. * Copyright (C) 2013 Renesas Solutions Corp.
  5. * Copyright (C) 2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  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/io.h>
  22. #include <linux/irqchip/arm-gic.h>
  23. #include <linux/of.h>
  24. #include <linux/of_platform.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/irqchip.h>
  27. #include <linux/serial_sci.h>
  28. #include <linux/sh_timer.h>
  29. #include <mach/irqs.h>
  30. #include <mach/r8a7778.h>
  31. #include <mach/common.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/hardware/cache-l2x0.h>
  34. /* SCIF */
  35. #define SCIF_INFO(baseaddr, irq) \
  36. { \
  37. .mapbase = baseaddr, \
  38. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
  39. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \
  40. .scbrr_algo_id = SCBRR_ALGO_2, \
  41. .type = PORT_SCIF, \
  42. .irqs = SCIx_IRQ_MUXED(irq), \
  43. }
  44. static struct plat_sci_port scif_platform_data[] = {
  45. SCIF_INFO(0xffe40000, gic_iid(0x66)),
  46. SCIF_INFO(0xffe41000, gic_iid(0x67)),
  47. SCIF_INFO(0xffe42000, gic_iid(0x68)),
  48. SCIF_INFO(0xffe43000, gic_iid(0x69)),
  49. SCIF_INFO(0xffe44000, gic_iid(0x6a)),
  50. SCIF_INFO(0xffe45000, gic_iid(0x6b)),
  51. };
  52. /* TMU */
  53. static struct resource sh_tmu0_resources[] = {
  54. DEFINE_RES_MEM(0xffd80008, 12),
  55. DEFINE_RES_IRQ(gic_iid(0x40)),
  56. };
  57. static struct sh_timer_config sh_tmu0_platform_data = {
  58. .name = "TMU00",
  59. .channel_offset = 0x4,
  60. .timer_bit = 0,
  61. .clockevent_rating = 200,
  62. };
  63. static struct resource sh_tmu1_resources[] = {
  64. DEFINE_RES_MEM(0xffd80014, 12),
  65. DEFINE_RES_IRQ(gic_iid(0x41)),
  66. };
  67. static struct sh_timer_config sh_tmu1_platform_data = {
  68. .name = "TMU01",
  69. .channel_offset = 0x10,
  70. .timer_bit = 1,
  71. .clocksource_rating = 200,
  72. };
  73. #define PLATFORM_INFO(n, i) \
  74. { \
  75. .parent = &platform_bus, \
  76. .name = #n, \
  77. .id = i, \
  78. .res = n ## i ## _resources, \
  79. .num_res = ARRAY_SIZE(n ## i ##_resources), \
  80. .data = &n ## i ##_platform_data, \
  81. .size_data = sizeof(n ## i ## _platform_data), \
  82. }
  83. struct platform_device_info platform_devinfo[] = {
  84. PLATFORM_INFO(sh_tmu, 0),
  85. PLATFORM_INFO(sh_tmu, 1),
  86. };
  87. void __init r8a7778_add_standard_devices(void)
  88. {
  89. int i;
  90. #ifdef CONFIG_CACHE_L2X0
  91. void __iomem *base = ioremap_nocache(0xf0100000, 0x1000);
  92. if (base) {
  93. /*
  94. * Early BRESP enable, Shared attribute override enable, 64K*16way
  95. * don't call iounmap(base)
  96. */
  97. l2x0_init(base, 0x40470000, 0x82000fff);
  98. }
  99. #endif
  100. for (i = 0; i < ARRAY_SIZE(scif_platform_data); i++)
  101. platform_device_register_data(&platform_bus, "sh-sci", i,
  102. &scif_platform_data[i],
  103. sizeof(struct plat_sci_port));
  104. for (i = 0; i < ARRAY_SIZE(platform_devinfo); i++)
  105. platform_device_register_full(&platform_devinfo[i]);
  106. }
  107. #define INT2SMSKCR0 0x82288 /* 0xfe782288 */
  108. #define INT2SMSKCR1 0x8228c /* 0xfe78228c */
  109. #define INT2NTSR0 0x00018 /* 0xfe700018 */
  110. #define INT2NTSR1 0x0002c /* 0xfe70002c */
  111. static void __init r8a7778_init_irq_common(void)
  112. {
  113. void __iomem *base = ioremap_nocache(0xfe700000, 0x00100000);
  114. BUG_ON(!base);
  115. /* route all interrupts to ARM */
  116. __raw_writel(0x73ffffff, base + INT2NTSR0);
  117. __raw_writel(0xffffffff, base + INT2NTSR1);
  118. /* unmask all known interrupts in INTCS2 */
  119. __raw_writel(0x08330773, base + INT2SMSKCR0);
  120. __raw_writel(0x00311110, base + INT2SMSKCR1);
  121. iounmap(base);
  122. }
  123. void __init r8a7778_init_irq(void)
  124. {
  125. void __iomem *gic_dist_base;
  126. void __iomem *gic_cpu_base;
  127. gic_dist_base = ioremap_nocache(0xfe438000, PAGE_SIZE);
  128. gic_cpu_base = ioremap_nocache(0xfe430000, PAGE_SIZE);
  129. BUG_ON(!gic_dist_base || !gic_cpu_base);
  130. /* use GIC to handle interrupts */
  131. gic_init(0, 29, gic_dist_base, gic_cpu_base);
  132. r8a7778_init_irq_common();
  133. }
  134. void __init r8a7778_init_delay(void)
  135. {
  136. shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
  137. }
  138. #ifdef CONFIG_USE_OF
  139. void __init r8a7778_init_irq_dt(void)
  140. {
  141. irqchip_init();
  142. r8a7778_init_irq_common();
  143. }
  144. static const struct of_dev_auxdata r8a7778_auxdata_lookup[] __initconst = {
  145. {},
  146. };
  147. void __init r8a7778_add_standard_devices_dt(void)
  148. {
  149. of_platform_populate(NULL, of_default_bus_match_table,
  150. r8a7778_auxdata_lookup, NULL);
  151. }
  152. static const char *r8a7778_compat_dt[] __initdata = {
  153. "renesas,r8a7778",
  154. NULL,
  155. };
  156. DT_MACHINE_START(R8A7778_DT, "Generic R8A7778 (Flattened Device Tree)")
  157. .init_early = r8a7778_init_delay,
  158. .init_irq = r8a7778_init_irq_dt,
  159. .init_machine = r8a7778_add_standard_devices_dt,
  160. .init_time = shmobile_timer_init,
  161. .dt_compat = r8a7778_compat_dt,
  162. MACHINE_END
  163. #endif /* CONFIG_USE_OF */