Skip to content

Commit 8bb6617

Browse files
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 <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 2d26825 commit 8bb6617

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

arch/riscv/Kconfig.socs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,26 @@ config SOC_VIRT
2424
config SOC_KENDRYTE
2525
bool "Kendryte K210 SoC"
2626
depends on !MMU
27-
select BUILTIN_DTB
2827
select SERIAL_SIFIVE if TTY
2928
select SERIAL_SIFIVE_CONSOLE if TTY
3029
select SIFIVE_PLIC
3130
help
3231
This enables support for Kendryte K210 SoC platform hardware.
3332

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.
48+
3449
endmenu

arch/riscv/boot/dts/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
22
subdir-y += sifive
33
subdir-y += kendryte
4+
5+
obj-$(CONFIG_BUILTIN_DTB) := $(addsuffix /, $(subdir-y))

arch/riscv/boot/dts/kendryte/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# 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))

drivers/soc/kendryte/k210-sysctl.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,15 @@ static void __init k210_soc_early_init(const void *fdt)
246246
iounmap(regs);
247247
}
248248
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

0 commit comments

Comments
 (0)