riscv: K210: Add a built-in device tree
authorPalmer Dabbelt <palmerdabbelt@google.com>
Tue, 14 Apr 2020 04:43:25 +0000 (13:43 +0900)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Mon, 18 May 2020 18:38:06 +0000 (11:38 -0700)
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>
arch/riscv/Kconfig.socs
arch/riscv/boot/dts/Makefile
arch/riscv/boot/dts/kendryte/Makefile
drivers/soc/kendryte/k210-sysctl.c

index d646332e44f15daa18f6913132f9684d49afec2d..6c88148f1b9b3ff6c02e5b6a6e02b25be26f7f5f 100644 (file)
@@ -24,11 +24,26 @@ config SOC_VIRT
 config SOC_KENDRYTE
        bool "Kendryte K210 SoC"
        depends on !MMU
-       select BUILTIN_DTB
        select SERIAL_SIFIVE if TTY
        select SERIAL_SIFIVE_CONSOLE if TTY
        select SIFIVE_PLIC
        help
          This enables support for Kendryte K210 SoC platform hardware.
 
+config SOC_KENDRYTE_K210_DTB
+       def_bool y
+       depends on SOC_KENDRYTE_K210_DTB_BUILTIN
+
+config SOC_KENDRYTE_K210_DTB_BUILTIN
+       bool "Builtin device tree for the Kendryte K210"
+       depends on SOC_KENDRYTE
+       default y
+       select OF
+       select BUILTIN_DTB
+       select SOC_KENDRYTE_K210_DTB
+       help
+         Builds a device tree for the Kendryte K210 into the Linux image.
+         This option should be selected if no bootloader is being used.
+         If unsure, say Y.
+
 endmenu
index 557f0b519c8ee55d8a3d36f7946c971cf2145d39..ca1f8cbd78c0e3a44bf17753237d7eb517256148 100644 (file)
@@ -1,3 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 subdir-y += sifive
 subdir-y += kendryte
+
+obj-$(CONFIG_BUILTIN_DTB) := $(addsuffix /, $(subdir-y))
index 815444e69e8900f04813d54da9adb55a3e1c5166..1a88e616f18e0dafa7eb54842018fde2de6aaa29 100644 (file)
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-dtb-$(CONFIG_SOC_KENDRYTE) += k210.dtb
+dtb-$(CONFIG_SOC_KENDRYTE_K210_DTB) += k210.dtb
+
+obj-$(CONFIG_SOC_KENDRYTE_K210_DTB_BUILTIN) += $(addsuffix .o, $(dtb-y))
index 4608fbca20e1bad035cf397aa6817842b58098d6..707019223dd81bfa484f2734c724a8783faf0c44 100644 (file)
@@ -246,3 +246,15 @@ static void __init k210_soc_early_init(const void *fdt)
        iounmap(regs);
 }
 SOC_EARLY_INIT_DECLARE(generic_k210, "kendryte,k210", k210_soc_early_init);
+
+#ifdef CONFIG_SOC_KENDRYTE_K210_DTB_BUILTIN
+/*
+ * Generic entry for the default k210.dtb embedded DTB for boards with:
+ *   - Vendor ID: 0x4B5
+ *   - Arch ID: 0xE59889E6A5A04149 (= "Canaan AI" in UTF-8 encoded Chinese)
+ *   - Impl ID:        0x4D41495832303030 (= "MAIX2000")
+ * These values are reported by the SiPEED MAXDUINO, SiPEED MAIX GO and
+ * SiPEED Dan dock boards.
+ */
+SOC_BUILTIN_DTB_DECLARE(k210, 0x4B5, 0xE59889E6A5A04149, 0x4D41495832303030);
+#endif