@@ -196,6 +196,14 @@ config RISCV_RDTIME
standard rdtime instruction. This is the case for S-mode U-Boot, and
is useful for processors that support rdtime in M-mode too.
+config K210_SYSCTL
+ bool
+ select SYSCON
+ select SPL_SYSCON if SPL
+ help
+ The K210 sysctl block holds memory-mapped control and status
+ registers associated with clocks, resets, power, and dma handshakes.
+
config SYS_MALLOC_F_LEN
default 0x1000
@@ -240,4 +248,7 @@ config STACK_SIZE_SHIFT
config SPL_LDSCRIPT
default "arch/riscv/cpu/u-boot-spl.lds"
+config ARCH_K210
+ bool "Support Kendryte K210 SOCs"
+
endmenu
new file mode 100644
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
+ */
+
+#ifndef K210_SYSCTL_H
+#define K210_SYSCTL_H
+
+#include <linux/compiler.h>
+
+/*
+ * sysctl registers
+ * Taken from kendryte-standalone-sdk/lib/drivers/include/sysctl.h
+ */
+struct k210_sysctl {
+ u32 git_id;
+ u32 clk_freq;
+ u32 pll0;
+ u32 pll1;
+ u32 pll2;
+ u32 resv5;
+ u32 pll_lock;
+ u32 rom_error;
+ u32 clk_sel[2];
+ u32 clk_en_cent;
+ u32 clk_en_peri;
+ u32 soft_reset;
+ u32 peri_reset;
+ u32 clk_thr[7];
+ u32 misc;
+ u32 peri;
+ u32 spi_sleep;
+ u32 reset_status;
+ u32 dma_sel0;
+ u32 dma_sel1;
+ u32 power_sel;
+ u32 resv28;
+ u32 resv29;
+ u32 resv30;
+ u32 resv31;
+} __packed;
+
+#endif /* K210_SYSCTL_H */
@@ -14,6 +14,7 @@ ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y)
obj-$(CONFIG_SIFIVE_CLINT) += sifive_clint.o
obj-$(CONFIG_ANDES_PLIC) += andes_plic.o
obj-$(CONFIG_ANDES_PLMT) += andes_plmt.o
+obj-$(CONFIG_K210_SYSCTL) += k210_sysctl.o
else
obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
obj-$(CONFIG_SBI_IPI) += sbi_ipi.o
new file mode 100644
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Sean Anderson <seanga2 at gmail.com>
+ */
+#include <asm/k210_sysctl.h>
+
+#include <dm.h>
+
+static const struct udevice_id k210_sysctl_ids[] = {
+ { .compatible = "kendryte,k210-sysctl", },
+ { }
+};
+
+U_BOOT_DRIVER(k210_sysctl) = {
+ .name = "k210_sysctl",
+ .id = UCLASS_SYSCON,
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
+ .bind = dm_scan_fdt_dev,
+#endif
+ .of_match = k210_sysctl_ids,
+};
@@ -36,6 +36,7 @@ config BOARD_SPECIFIC_OPTIONS
select ENV_IS_NOWHERE
select SYS_RISCV_NOCOUNTER
imply SIFIVE_CLINT
+ imply K210_SYSCTL
imply SPI
imply DM_GPIO
imply CMD_GPIO
This driver does nothing but load its children for the moment. Should it be using regmap? I'm not sure how that fits into everything. Signed-off-by: Sean Anderson <seanga2 at gmail.com> --- Changes for v2: Removed spurious references to mach-k210. Don't load pre-relocation. arch/riscv/Kconfig | 11 +++++++ arch/riscv/include/asm/k210_sysctl.h | 43 ++++++++++++++++++++++++++++ arch/riscv/lib/Makefile | 1 + arch/riscv/lib/k210_sysctl.c | 21 ++++++++++++++ board/sipeed/maix/Kconfig | 1 + 5 files changed, 77 insertions(+) create mode 100644 arch/riscv/include/asm/k210_sysctl.h create mode 100644 arch/riscv/lib/k210_sysctl.c