Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

riscv: K210: Add a built-in device tree

The K210's bootloader does not provide a device tree. Give the ability
to providea builtin one with the SOC_KENDRYTE_K210_BUILTIN_DTB option.
If selected, this option result in the definition of a builtin DTB
entry in the k210 sysctl driver.

If defined, the builtin DTB entry points to the default k210.dts device
tree file and is keyed with the vendor ID 0x4B5, the arch ID
0xE59889E6A5A04149 ("Canaan AI" in UTF-8 coded Chinese) and the impl ID
0x4D41495832303030 ("MAIX200"). These values are reported by the SiPEED
MAIXDUINO board, the SiPEED MAIX Go board and the SiPEED Dan Dock board.

[Thanks to Damien for the K210 IDs]
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>

+33 -2
+16 -1
arch/riscv/Kconfig.socs
··· 24 24 config SOC_KENDRYTE 25 25 bool "Kendryte K210 SoC" 26 26 depends on !MMU 27 - select BUILTIN_DTB 28 27 select SERIAL_SIFIVE if TTY 29 28 select SERIAL_SIFIVE_CONSOLE if TTY 30 29 select SIFIVE_PLIC 31 30 help 32 31 This enables support for Kendryte K210 SoC platform hardware. 32 + 33 + config SOC_KENDRYTE_K210_DTB 34 + def_bool y 35 + depends on SOC_KENDRYTE_K210_DTB_BUILTIN 36 + 37 + config SOC_KENDRYTE_K210_DTB_BUILTIN 38 + bool "Builtin device tree for the Kendryte K210" 39 + depends on SOC_KENDRYTE 40 + default y 41 + select OF 42 + select BUILTIN_DTB 43 + select SOC_KENDRYTE_K210_DTB 44 + help 45 + Builds a device tree for the Kendryte K210 into the Linux image. 46 + This option should be selected if no bootloader is being used. 47 + If unsure, say Y. 33 48 34 49 endmenu
+2
arch/riscv/boot/dts/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 subdir-y += sifive 3 3 subdir-y += kendryte 4 + 5 + obj-$(CONFIG_BUILTIN_DTB) := $(addsuffix /, $(subdir-y))
+3 -1
arch/riscv/boot/dts/kendryte/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - dtb-$(CONFIG_SOC_KENDRYTE) += k210.dtb 2 + dtb-$(CONFIG_SOC_KENDRYTE_K210_DTB) += k210.dtb 3 + 4 + obj-$(CONFIG_SOC_KENDRYTE_K210_DTB_BUILTIN) += $(addsuffix .o, $(dtb-y))
+12
drivers/soc/kendryte/k210-sysctl.c
··· 246 246 iounmap(regs); 247 247 } 248 248 SOC_EARLY_INIT_DECLARE(generic_k210, "kendryte,k210", k210_soc_early_init); 249 + 250 + #ifdef CONFIG_SOC_KENDRYTE_K210_DTB_BUILTIN 251 + /* 252 + * Generic entry for the default k210.dtb embedded DTB for boards with: 253 + * - Vendor ID: 0x4B5 254 + * - Arch ID: 0xE59889E6A5A04149 (= "Canaan AI" in UTF-8 encoded Chinese) 255 + * - Impl ID: 0x4D41495832303030 (= "MAIX2000") 256 + * These values are reported by the SiPEED MAXDUINO, SiPEED MAIX GO and 257 + * SiPEED Dan dock boards. 258 + */ 259 + SOC_BUILTIN_DTB_DECLARE(k210, 0x4B5, 0xE59889E6A5A04149, 0x4D41495832303030); 260 + #endif