From: Iurii Konovalenko <iurii.konovale...@globallogic.com> Signed-off-by: Iurii Konovalenko <iurii.konovale...@globallogic.com> --- xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/shmobile.c | 149 +++++++++++++++++++++++++++++++ xen/include/asm-arm/platforms/shmobile.h | 24 +++++ 3 files changed, 174 insertions(+) create mode 100644 xen/arch/arm/platforms/shmobile.c create mode 100644 xen/include/asm-arm/platforms/shmobile.h
diff --git a/xen/arch/arm/platforms/Makefile b/xen/arch/arm/platforms/Makefile index 8f47c16..29e931a 100644 --- a/xen/arch/arm/platforms/Makefile +++ b/xen/arch/arm/platforms/Makefile @@ -4,5 +4,6 @@ obj-$(CONFIG_ARM_32) += exynos5.o obj-$(CONFIG_ARM_32) += midway.o obj-$(CONFIG_ARM_32) += omap5.o obj-$(CONFIG_ARM_32) += sunxi.o +obj-$(CONFIG_ARM_32) += shmobile.o obj-$(CONFIG_ARM_64) += seattle.o obj-$(CONFIG_ARM_64) += xgene-storm.o diff --git a/xen/arch/arm/platforms/shmobile.c b/xen/arch/arm/platforms/shmobile.c new file mode 100644 index 0000000..4c78ed6 --- /dev/null +++ b/xen/arch/arm/platforms/shmobile.c @@ -0,0 +1,149 @@ +/* + * xen/arch/arm/platforms/shmobile.c + * + * Renesas R-Car Gen2 specific settings + * + * Iurii Konovalenko <iurii.konovale...@globallogic.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <asm/p2m.h> +#include <xen/config.h> +#include <xen/device_tree.h> +#include <xen/domain_page.h> +#include <xen/mm.h> +#include <xen/vmap.h> +#include <asm/platforms/shmobile.h> +#include <asm/platform.h> +#include <asm/io.h> + +u32 shmobile_read_mode_pins(void) +{ + static uint32_t mode; + + void __iomem *modemr = ioremap_nocache(SHMOBILE_MODEMR, 4); + if( !modemr ) + { + dprintk( XENLOG_ERR, "Unable to map shmobile Mode MR\n"); + return 0; + } + + mode = readl_relaxed(modemr); + iounmap(modemr); + + return mode; +} + +static int shmobile_init_time(void) +{ + uint32_t freq; + void __iomem *tmu; + int extal_mhz = 0; + uint32_t mode = shmobile_read_mode_pins(); + + /* At Linux boot time the Renesas R-Car Gen2 arch timer comes + * up with the counter disabled. Moreover, it may also report + * a potentially incorrect fixed 13 MHz frequency. To be + * correct these registers need to be updated to use the + * frequency EXTAL / 2 which can be determined by the MD pins. + */ + + switch ( mode & (MD(14) | MD(13)) ) { + case 0: + extal_mhz = 15; + break; + case MD(13): + extal_mhz = 20; + break; + case MD(14): + extal_mhz = 26; + break; + case MD(13) | MD(14): + extal_mhz = 30; + break; + } + + /* The arch timer frequency equals EXTAL / 2 */ + freq = extal_mhz * (1000000 / 2); + + /* Remap "armgcnt address map" space */ + tmu = ioremap_attr(SHMOBILE_ARCH_TIMER_BASE, PAGE_SIZE, + PAGE_HYPERVISOR_NOCACHE); + if ( !tmu ) + { + dprintk(XENLOG_ERR, "Unable to map TMU\n"); + return -ENOMEM; + } + /* + * Update the timer if it is either not running, or is not at the + * right frequency. The timer is only configurable in secure mode + * so this avoids an abort if the loader started the timer and + * entered the kernel in non-secure mode. + */ + + if ( (readl_relaxed(tmu + SHMOBILE_ARCH_TIMER_CNTCR) & 1) == 0 || + readl_relaxed(tmu + SHMOBILE_ARCH_TIMER_CNTFID0) != freq ) { + /* Update registers with correct frequency */ + writel_relaxed(freq, tmu + SHMOBILE_ARCH_TIMER_CNTFID0); + + /* make sure arch timer is started by setting bit 0 of CNTCR */ + writel_relaxed(1, tmu + SHMOBILE_ARCH_TIMER_CNTCR); + } + + iounmap(tmu); + + return 0; +} + +static int __init shmobile_smp_init(void) +{ + void __iomem *p; + /* setup reset vectors */ + p = ioremap_nocache(SHMOBILE_RAM, 0x1000); + if( !p ) + { + dprintk( XENLOG_ERR, "Unable to map shmobile ICRAM\n"); + return -ENOMEM; + } + + writel_relaxed(__pa(init_secondary), p + SHMOBILE_SMP_START_OFFSET); + iounmap(p); + + asm("sev;"); + + return 0; +} + +static const char const *shmobile_dt_compat[] __initdata = +{ + "renesas,lager", + NULL +}; + +PLATFORM_START(shmobile, "Renesas R-Car Gen2") + .compatible = shmobile_dt_compat, + .init_time = shmobile_init_time, + .cpu_up = cpu_up_send_sgi, + .smp_init = shmobile_smp_init, + + .dom0_gnttab_start = 0xc0000000, + .dom0_gnttab_size = 0x20000, +PLATFORM_END + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-arm/platforms/shmobile.h b/xen/include/asm-arm/platforms/shmobile.h new file mode 100644 index 0000000..fd506d7 --- /dev/null +++ b/xen/include/asm-arm/platforms/shmobile.h @@ -0,0 +1,24 @@ +#ifndef __ASM_ARM_PLATFORMS_SHMOBILE_H +#define __ASM_ARM_PLATFORMS_SHMOBILE_H + +#define SHMOBILE_ARCH_TIMER_BASE 0xE6080000 +#define SHMOBILE_ARCH_TIMER_CNTCR 0x0 +#define SHMOBILE_ARCH_TIMER_CNTFID0 0x20 + +#define SHMOBILE_MODEMR 0xE6160060 +#define SHMOBILE_RAM 0xE63C0000 +#define SHMOBILE_SMP_START_OFFSET 0xFFC + +#define MD(nr) BIT(nr) + +#endif /* __ASM_ARM_PLATFORMS_SHMOBILE_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ + -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel