[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190905054647.1235-1-james.tai@realtek.com>
Date: Thu, 5 Sep 2019 13:46:47 +0800
From: jamestai.sky@...il.com
To: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: Russell King <linux@...linux.org.uk>,
Arnd Bergmann <arnd@...db.de>,
Linus Walleij <linus.walleij@...aro.org>,
Paul Burton <paul.burton@...s.com>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
Mike Rapoport <rppt@...ux.ibm.com>,
Doug Anderson <armlinux@...isordat.com>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
Benjamin Gaignard <benjamin.gaignard@...aro.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Stefan Agner <stefan@...er.ch>,
Nicolas Pitre <nico@...xnic.net>,
Thierry Reding <treding@...dia.com>,
"Jason A . Donenfeld" <Jason@...c4.com>,
Rob Herring <robh@...nel.org>, CY_Huang <cy.huang@...ltek.com>,
Phinex Hung <phinex@...ltek.com>,
"james.tai" <james.tai@...ltek.com>
Subject: [PATCH] ARM: Add support for Realtek SOC
From: "james.tai" <james.tai@...ltek.com>
This patch adds the basic machine file for
the Realtek RTD16XX platform.
Signed-off-by: james.tai <james.tai@...ltek.com>
---
arch/arm/Kconfig | 2 +
arch/arm/Makefile | 2 +
arch/arm/mach-realtek/Kconfig | 32 ++++++++++++
arch/arm/mach-realtek/Makefile | 3 ++
arch/arm/mach-realtek/platsmp.c | 91 +++++++++++++++++++++++++++++++++
arch/arm/mach-realtek/platsmp.h | 7 +++
arch/arm/mach-realtek/realtek.c | 78 ++++++++++++++++++++++++++++
7 files changed, 215 insertions(+)
create mode 100644 arch/arm/mach-realtek/Kconfig
create mode 100644 arch/arm/mach-realtek/Makefile
create mode 100644 arch/arm/mach-realtek/platsmp.c
create mode 100644 arch/arm/mach-realtek/platsmp.h
create mode 100644 arch/arm/mach-realtek/realtek.c
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 33b00579beff..c7c9a3662eb7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -836,6 +836,8 @@ source "arch/arm/mach-zx/Kconfig"
source "arch/arm/mach-zynq/Kconfig"
+source "arch/arm/mach-realtek/Kconfig"
+
# ARMv7-M architecture
config ARCH_EFM32
bool "Energy Micro efm32"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index c3624ca6c0bc..1f0926449d47 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -148,6 +148,7 @@ endif
textofs-$(CONFIG_ARCH_MSM8X60) := 0x00208000
textofs-$(CONFIG_ARCH_MSM8960) := 0x00208000
textofs-$(CONFIG_ARCH_MESON) := 0x00208000
+textofs-$(CONFIG_ARCH_REALTEK) := 0x00208000
textofs-$(CONFIG_ARCH_AXXIA) := 0x00308000
# Machine directory name. This list is sorted alphanumerically
@@ -225,6 +226,7 @@ machine-$(CONFIG_ARCH_VT8500) += vt8500
machine-$(CONFIG_ARCH_W90X900) += w90x900
machine-$(CONFIG_ARCH_ZX) += zx
machine-$(CONFIG_ARCH_ZYNQ) += zynq
+machine-$(CONFIG_ARCH_REALTEK) += realtek
machine-$(CONFIG_PLAT_SPEAR) += spear
# Platform directory name. This list is sorted alphanumerically
diff --git a/arch/arm/mach-realtek/Kconfig b/arch/arm/mach-realtek/Kconfig
new file mode 100644
index 000000000000..a8269964dbdb
--- /dev/null
+++ b/arch/arm/mach-realtek/Kconfig
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: GPL-2.0-only
+menuconfig ARCH_REALTEK
+ bool "Realtek SoCs"
+ select ARM_GLOBAL_TIMER
+ select CLKDEV_LOOKUP
+ select HAVE_SMP
+ select HAVE_MACH_CLKDEV
+ select GENERIC_CLOCKEVENTS
+ select HAVE_SCHED_CLOCK
+ select ARCH_HAS_CPUFREQ
+ select CLKSRC_OF
+ select ARCH_REQUIRE_GPIOLIB
+ select GENERIC_IRQ_CHIP
+ select IRQ_DOMAIN
+ select PINCTRL
+ select COMMON_CLK
+ select ARCH_HAS_BARRIERS
+ select SPARSE_IRQ
+ select PM_OPP
+ select ARM_HAS_SG_CHAIN
+ select ARM_PATCH_PHYS_VIRT
+ select AUTO_ZRELADDR
+ select MIGHT_HAVE_PCI
+ select MULTI_IRQ_HANDLER
+ select PCI_DOMAINS if PCI
+ select USE_OF
+
+config ARCH_RTD16XX
+ bool "Enable support for RTD1619"
+ depends on ARCH_REALTEK
+ select ARM_GIC_V3
+ select ARM_PSCI
diff --git a/arch/arm/mach-realtek/Makefile b/arch/arm/mach-realtek/Makefile
new file mode 100644
index 000000000000..9cdc1f1f2917
--- /dev/null
+++ b/arch/arm/mach-realtek/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_ARCH_REALTEK) += realtek.o
+obj-$(CONFIG_SMP) += platsmp.o
diff --git a/arch/arm/mach-realtek/platsmp.c b/arch/arm/mach-realtek/platsmp.c
new file mode 100644
index 000000000000..5c4368fe1520
--- /dev/null
+++ b/arch/arm/mach-realtek/platsmp.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ * Copyright (c) 2019 Realtek Semiconductor Corp.
+ */
+
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/jiffies.h>
+#include <linux/io.h>
+#include <linux/memory.h>
+#include <linux/smp.h>
+#include <linux/of.h>
+#include <linux/arm-smccc.h>
+#include <asm/smp_plat.h>
+#include <asm/cacheflush.h>
+#include <asm/cp15.h>
+#include <asm/barrier.h>
+
+#define BL31_CMD 0x8400ff04
+#define BL31_DAT 0x00001619
+#define CPUID 28
+#define CORE_PWRDN_EN 0x1
+
+#define CPUPWRCTLR __ACCESS_CP15(c15, 0, c2, 7)
+
+static u32 __iomem *cpu_release_virt;
+
+static int rtk_boot_secondary(unsigned int cpu, struct task_struct *idle)
+{
+ unsigned long entry_pa = __pa_symbol(secondary_startup);
+
+ writel_relaxed(entry_pa | (cpu << CPUID), cpu_release_virt);
+
+ arch_send_wakeup_ipi_mask(cpumask_of(cpu));
+
+ return 0;
+}
+
+void rtk_prepare_cpus(unsigned int max_cpus)
+{
+ struct device_node *np;
+ u32 release_phys;
+ int cpu;
+
+ for_each_possible_cpu(cpu) {
+
+ np = of_get_cpu_node(cpu, NULL);
+ if (!np)
+ continue;
+
+ if (of_property_read_u32(np, "cpu-release-addr", &release_phys))
+ continue;
+
+ cpu_release_virt = ioremap(release_phys, sizeof(u32));
+
+ set_cpu_present(cpu, true);
+ }
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+
+static void rtk_cpu_die(unsigned int cpu)
+{
+ struct arm_smccc_res res;
+ unsigned int cpu_pwr_ctrl;
+
+ writel_relaxed(0x0, cpu_release_virt);
+
+ /* notify BL31 cpu hotplug */
+ arm_smccc_smc(BL31_CMD, BL31_DAT, 0, 0, 0, 0, 0, 0, &res);
+ v7_exit_coherency_flush(louis);
+
+ cpu_pwr_ctrl = read_sysreg(CPUPWRCTLR);
+ cpu_pwr_ctrl |= CORE_PWRDN_EN;
+ write_sysreg(cpu_pwr_ctrl, CPUPWRCTLR);
+
+ dsb(sy);
+
+ for (;;)
+ wfi();
+}
+#endif
+
+struct smp_operations rtk_smp_ops __initdata = {
+ .smp_prepare_cpus = rtk_prepare_cpus,
+ .smp_boot_secondary = rtk_boot_secondary,
+#ifdef CONFIG_HOTPLUG_CPU
+ .cpu_die = rtk_cpu_die,
+#endif
+};
diff --git a/arch/arm/mach-realtek/platsmp.h b/arch/arm/mach-realtek/platsmp.h
new file mode 100644
index 000000000000..9c411d097c14
--- /dev/null
+++ b/arch/arm/mach-realtek/platsmp.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/*
+ * Copyright (c) 2019 Realtek Semiconductor Corp.
+ */
+
+extern struct smp_operations rtk_smp_ops;
diff --git a/arch/arm/mach-realtek/realtek.c b/arch/arm/mach-realtek/realtek.c
new file mode 100644
index 000000000000..d248e19f4c1d
--- /dev/null
+++ b/arch/arm/mach-realtek/realtek.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ * Copyright (c) 2019 Realtek Semiconductor Corp.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/clocksource.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/irqchip.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+#include <linux/io.h>
+#include <linux/memblock.h>
+#include <linux/delay.h>
+#include <linux/clockchips.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/system_misc.h>
+#include <asm/system_info.h>
+
+#include "platsmp.h"
+
+#define RBUS_BASE_PHYS (0x98000000)
+#define RBUS_BASE_VIRT (0xfe000000)
+#define RBUS_BASE_SIZE (0x00100000)
+
+static struct map_desc rtk_io_desc[] __initdata = {
+ {
+ .virtual = (unsigned long) IOMEM(RBUS_BASE_VIRT),
+ .pfn = __phys_to_pfn(RBUS_BASE_PHYS),
+ .length = RBUS_BASE_SIZE,
+ .type = MT_DEVICE,
+ },
+};
+
+void __init rtk_map_io(void)
+{
+ debug_ll_io_init();
+ iotable_init(rtk_io_desc, ARRAY_SIZE(rtk_io_desc));
+}
+
+static void __init rtk_dt_init(void)
+{
+ of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+}
+
+static void __init rtk_timer_init(void)
+{
+#ifdef CONFIG_COMMON_CLK
+ of_clk_init(NULL);
+#endif
+ timer_probe();
+ tick_setup_hrtimer_broadcast();
+}
+
+bool __init rtk_smp_init_ops(void)
+{
+ smp_set_ops(smp_ops(rtk_smp_ops));
+
+ return true;
+}
+
+static const char *const rtd16xx_board_dt_compat[] = {
+ "realtek,rtd1619",
+ NULL,
+};
+
+DT_MACHINE_START(RTD16XX, "Realtek rtd16xx platform")
+ .map_io = rtk_map_io,
+ .init_machine = rtk_dt_init,
+ .init_time = rtk_timer_init,
+ .dt_compat = rtd16xx_board_dt_compat,
+ .smp = smp_ops(rtk_smp_ops),
+ .smp_init = smp_init_ops(rtk_smp_init_ops),
+MACHINE_END
--
2.17.1
Powered by blists - more mailing lists