Merge tag 'backport/v3.14.24-ltsi-rc1/rcar-du-to-v3.18-rc1' into backport/v3.14.24...
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / arm / mach-shmobile / setup-r8a73a4.c
index b0f2749..eab6296 100644 (file)
 #include <linux/serial_sci.h>
 #include <linux/sh_dma.h>
 #include <linux/sh_timer.h>
-#include <mach/common.h>
-#include <mach/dma-register.h>
-#include <mach/irqs.h>
-#include <mach/r8a73a4.h>
+
 #include <asm/mach/arch.h>
 
+#include "common.h"
+#include "dma-register.h"
+#include "irqs.h"
+#include "r8a73a4.h"
+
 static const struct resource pfc_resources[] = {
        DEFINE_RES_MEM(0xe6050000, 0x9000),
 };
@@ -40,41 +42,39 @@ void __init r8a73a4_pinmux_init(void)
                                        ARRAY_SIZE(pfc_resources));
 }
 
-#define SCIF_COMMON(scif_type, baseaddr, irq)                  \
+#define R8A73A4_SCIF(scif_type, _scscr, index, baseaddr, irq)  \
+static struct plat_sci_port scif##index##_platform_data = {    \
        .type           = scif_type,                            \
-       .mapbase        = baseaddr,                             \
        .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,      \
-       .scbrr_algo_id  = SCBRR_ALGO_4,                         \
-       .irqs           = SCIx_IRQ_MUXED(irq)
-
-#define SCIFA_DATA(index, baseaddr, irq)               \
-[index] = {                                            \
-       SCIF_COMMON(PORT_SCIFA, baseaddr, irq),         \
-       .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0,      \
+       .scscr          = _scscr,                               \
+};                                                             \
+                                                               \
+static struct resource scif##index##_resources[] = {           \
+       DEFINE_RES_MEM(baseaddr, 0x100),                        \
+       DEFINE_RES_IRQ(irq),                                    \
 }
 
-#define SCIFB_DATA(index, baseaddr, irq)       \
-[index] = {                                    \
-       SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
-       .scscr = SCSCR_RE | SCSCR_TE,           \
-}
+#define R8A73A4_SCIFA(index, baseaddr, irq)    \
+       R8A73A4_SCIF(PORT_SCIFA, SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
+                    index, baseaddr, irq)
 
-enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFB3 };
+#define R8A73A4_SCIFB(index, baseaddr, irq)    \
+       R8A73A4_SCIF(PORT_SCIFB, SCSCR_RE | SCSCR_TE, \
+                    index, baseaddr, irq)
 
-static const struct plat_sci_port scif[] = {
-       SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */
-       SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */
-       SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */
-       SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */
-       SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */
-       SCIFB_DATA(SCIFB3, 0xe6cf0000, gic_spi(151)), /* SCIFB3 */
-};
+R8A73A4_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
+R8A73A4_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
+R8A73A4_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
+R8A73A4_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
+R8A73A4_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
+R8A73A4_SCIFB(5, 0xe6cf0000, gic_spi(151)); /* SCIFB3 */
 
-static inline void r8a73a4_register_scif(int idx)
-{
-       platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx],
-                                     sizeof(struct plat_sci_port));
-}
+#define r8a73a4_register_scif(index)                                          \
+       platform_device_register_resndata(&platform_bus, "sh-sci", index,      \
+                                         scif##index##_resources,             \
+                                         ARRAY_SIZE(scif##index##_resources), \
+                                         &scif##index##_platform_data,        \
+                                         sizeof(scif##index##_platform_data))
 
 static const struct renesas_irqc_config irqc0_data = {
        .irq_base = irq_pin(0), /* IRQ0 -> IRQ31 */
@@ -171,20 +171,17 @@ static const struct resource thermal0_resources[] = {
                                        thermal0_resources,             \
                                        ARRAY_SIZE(thermal0_resources))
 
-static struct sh_timer_config cmt10_platform_data = {
-       .name = "CMT10",
-       .timer_bit = 0,
-       .clockevent_rating = 80,
+static struct sh_timer_config cmt1_platform_data = {
+       .channels_mask = 0xff,
 };
 
-static struct resource cmt10_resources[] = {
-       DEFINE_RES_MEM(0xe6130010, 0x0c),
-       DEFINE_RES_MEM(0xe6130000, 0x04),
-       DEFINE_RES_IRQ(gic_spi(120)), /* CMT1_0 */
+static struct resource cmt1_resources[] = {
+       DEFINE_RES_MEM(0xe6130000, 0x1004),
+       DEFINE_RES_IRQ(gic_spi(120)),
 };
 
 #define r8a7790_register_cmt(idx)                                      \
-       platform_device_register_resndata(&platform_bus, "sh_cmt",      \
+       platform_device_register_resndata(&platform_bus, "sh-cmt-48-gen2", \
                                          idx, cmt##idx##_resources,    \
                                          ARRAY_SIZE(cmt##idx##_resources), \
                                          &cmt##idx##_platform_data,    \
@@ -192,13 +189,7 @@ static struct resource cmt10_resources[] = {
 
 void __init r8a73a4_add_dt_devices(void)
 {
-       r8a73a4_register_scif(SCIFA0);
-       r8a73a4_register_scif(SCIFA1);
-       r8a73a4_register_scif(SCIFB0);
-       r8a73a4_register_scif(SCIFB1);
-       r8a73a4_register_scif(SCIFB2);
-       r8a73a4_register_scif(SCIFB3);
-       r8a7790_register_cmt(10);
+       r8a7790_register_cmt(1);
 }
 
 /* DMA */
@@ -275,7 +266,7 @@ static const struct sh_dmae_pdata dma_pdata = {
 
 static struct resource dma_resources[] = {
        DEFINE_RES_MEM(0xe6700020, 0x89e0),
-       DEFINE_RES_IRQ_NAMED(gic_spi(220), "error_irq"),
+       DEFINE_RES_IRQ(gic_spi(220)),
        {
                /* IRQ for channels 0-19 */
                .start  = gic_spi(200),
@@ -292,19 +283,18 @@ static struct resource dma_resources[] = {
 void __init r8a73a4_add_standard_devices(void)
 {
        r8a73a4_add_dt_devices();
+       r8a73a4_register_scif(0);
+       r8a73a4_register_scif(1);
+       r8a73a4_register_scif(2);
+       r8a73a4_register_scif(3);
+       r8a73a4_register_scif(4);
+       r8a73a4_register_scif(5);
        r8a73a4_register_irqc(0);
        r8a73a4_register_irqc(1);
        r8a73a4_register_thermal();
        r8a73a4_register_dmac();
 }
 
-void __init r8a73a4_init_early(void)
-{
-#ifndef CONFIG_ARM_ARCH_TIMER
-       shmobile_setup_delay(1500, 2, 4); /* Cortex-A15 @ 1500MHz */
-#endif
-}
-
 #ifdef CONFIG_USE_OF
 
 static const char *r8a73a4_boards_compat_dt[] __initdata = {
@@ -313,7 +303,8 @@ static const char *r8a73a4_boards_compat_dt[] __initdata = {
 };
 
 DT_MACHINE_START(R8A73A4_DT, "Generic R8A73A4 (Flattened Device Tree)")
-       .init_early     = r8a73a4_init_early,
+       .init_early     = shmobile_init_delay,
+       .init_late      = shmobile_init_late,
        .dt_compat      = r8a73a4_boards_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */