From patchwork Wed Jun 24 10:41:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1316048 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=j1SImwv8; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49sKTW1Kjfz9sQt for ; Wed, 24 Jun 2020 20:42:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0ECE082022; Wed, 24 Jun 2020 12:41:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="j1SImwv8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5AA9782015; Wed, 24 Jun 2020 12:41:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 037AF81FF6 for ; Wed, 24 Jun 2020 12:41:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x743.google.com with SMTP id q198so1346327qka.2 for ; Wed, 24 Jun 2020 03:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2gN8e6Gyx+hApaYvgrGhY26Vi4OpFIJLB5Lq1BN1V3A=; b=j1SImwv8BKZzNCySgHn2iu3qQyYNkq4hSW7gHDAMO2kLhP7YICgNxtWQN4A/9aqqDZ PpPbvwjvBX8zZyFi4g2UviZyEIAxl/+K8h05Q400yfxfr+1s0sKPppdKUjDXl/UzltlX /eaou0x0C7kl6TaFFhx5jq3bZTlZh0x+hCIPTNwIRblCwNrpv/ZTxHsfHfN/hAxozfVM pqYnFtGsy3+Y8mlrWcTCg9ylJW5/kR0Lk1GfugLq2wpXRVYR1yw8CqiYM1NgFPbd8cfO loRu8yn7hnNvnBVeCPZUYS+7WNu1vPxz3WCKKs1T4lLu7GFWD0wHHgkj4wbtZ5JGYfm4 DoaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2gN8e6Gyx+hApaYvgrGhY26Vi4OpFIJLB5Lq1BN1V3A=; b=VnuQyF94yomJu7cgSmDLswa0uYBg4QLsgsdB/Cyf5WEwxKkVTrOi/SApee8VYnfBis KeQVWMr7t8uFYeINj5ng8GjVyb1kSLZCH1f2LFJ9NwcyODwk0aqi3m2f90fifGcNxcKX Tx7Gzx8ovcx+r3dGJ0IHuPjcgW1Zv4PNlRHAsFZKlEP/VdBYJMY+hwO23MGIn3MY+61i aGsZQpCrZkePnVrOV9jSVlajfhsYa5h46x63Hl5kjDd7UXDWwTxn6TePitNNhyep42sh p7E2eExDlsr1N3YYVZyO7kBGb1L5an6DniopyDRVW0WlczgGxuXb2plQfEkaC+p59Xkt w6WQ== X-Gm-Message-State: AOAM530eBp5l/P4FGlxbgPFl4Z6dunwGeobAHhQT3kijhoxAE9ROl280 aekxlGuwmAVLoY5E7Zwjo/pgv1X1zgEYHw== X-Google-Smtp-Source: ABdhPJzlYGCvLzI72H8FPyJ6gRNgKypTW8SZdQI1SYydLT4diw09JkB7XJ/z3J6hsGpuXiy84f3Fsw== X-Received: by 2002:a37:4d16:: with SMTP id a22mr24581489qkb.392.1592995310321; Wed, 24 Jun 2020 03:41:50 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id y40sm3438464qtc.29.2020.06.24.03.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 03:41:48 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Rick Chen , Bin Meng , Sean Anderson , Lukas Auer , Lukasz Majewski , Simon Glass , Tom Rini Subject: [PATCH v14 00/20] riscv: Add Sipeed Maix support Date: Wed, 24 Jun 2020 06:41:05 -0400 Message-Id: <20200624104125.363509-1-seanga2@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean This patch series adds support for Sipeed Maix boards and the Kendryte K210 CPU. Currently, only the Maix Bit V2.0 is supported, however other models are similar. Complete passing CI: https://travis-ci.org/github/Forty-Bot/u-boot/builds/689529599 Known Bugs/Limitations: - Accessing the AI ram hangs, limiting available ram to 6M - Trying to boot an image with bootm fails with ERROR: Failed to allocate 0x7d60 bytes below 0x80000000. To flash u-boot to a maix bit, run kflash -tp /dev/ -B bit_mic u-boot-dtb.bin Boot output should look like the following: U-Boot 2020.04-rc2-00087-g2221cc09c1-dirty (Feb 28 2020 - 13:53:09 -0500) DRAM: 8 MiB In: serial@38000000 Out: serial@38000000 Err: serial@38000000 => Changes for v14: - Drop [PATCH 03/21] clk: Unconditionally recursively en-/dis-able clocks, as it is no longer necessary for this series. - Rebase onto upstream/next Changes for v13: - Fix warnings/errors in CI Changes for v12: - Remove sanity check in IPI Changes for v11: - Fix hang in SPL because the IPI was not initialized Changes for v10: - Fix warnings when casting fdt_addr_t - Fix warnings about const functions Changes for v9: - Fix error in Andes PLIC - Update MAINTAINERS - Mark dts blocks in documentation as "none" highlighting Changes for v8: - Removed dependency on the patch "clk: Add functions to register CCF clock structs". Hopefully this will make reviewing easier. Changes for v7: - Split documentation from other board support - Split IPI clear from other IPI cleanup - Rebased onto a clean upstream. Hopefully this fixes any patching problems. Changes for v6: - Remove spi, pinmux, gpio, led, and wdt support --- to be added in separate patches - Rebase onto master - Clear IPIs before enabling them - Reorganize code so checkpatch errors less Changes for v5: - Rebase onto master - Add pinconf support - Add gpio support - Store environment in spi flash - Group patches by prefix - Add additional documentation - Add SMP support - Add WDT support Changes for v4: - Linted several patches - Updated the copyright year for several files - Added tests for syscon-reset, simple-pm-bus, and the pll calc_rate function - Added/updated documentation - Fixed SPI for the nor flash - Fixed PLLs not enabling/setting rate properly - RISCV_PRIV_1_9_1 now (un)defines all diferring CSRs, and also disables VM - More devicetree changes Changes for v3: - Remove patch to set RV64I as default - Remove patch for a separate sysctl driver - Split off cpu frequency patch into its own series - Reorder support/devicetree patches to come last - Add patch for reset driver - Add simple-pm-bus for busses with their own clocks - Add additional documentation - Reword mcounteren patch to refer to the RISC-V priv spec 1.9.1 - Many devicetree changes - Switch to "make savedefconfig" to generate the config Changes for v2: - Many bugfixes for the device tree - Modify the config to build without errors - Add support for keeping internal PLL frequencies in-range - Fix several rebase-induced artifacts Sean Anderson (20): clk: Always use the supplied struct clk clk: Check that ops of composite clock components exist before calling clk: Fix clk_get_by_* handling of index clk: Add K210 pll support clk: Add a bypass clock for K210 clk: Add K210 clock support dm: Add support for simple-pm-bus dm: Fix error handling for dev_read_addr_ptr reset: Add generic reset driver lib: Always set errno in hcreate_r riscv: Add headers for asm/global_data.h riscv: Clear pending interrupts before enabling IPIs riscv: Clean up IPI initialization code riscv: Add option to support RISC-V privileged spec 1.9 riscv: Allow use of reset drivers riscv: Try to get cpu frequency from a "clocks" node if it exists riscv: Enable cpu clock if it is present riscv: Add device tree for K210 and Sipeed Maix BitM doc: riscv: Add documentation for Sipeed Maix Bit riscv: Add Sipeed Maix support MAINTAINERS | 7 + arch/riscv/Kconfig | 14 + arch/riscv/cpu/cpu.c | 15 + arch/riscv/cpu/start.S | 2 + arch/riscv/dts/Makefile | 1 + arch/riscv/dts/k210-maix-bit.dts | 47 ++ arch/riscv/dts/k210.dtsi | 594 ++++++++++++++++ arch/riscv/include/asm/csr.h | 40 ++ arch/riscv/include/asm/global_data.h | 2 + arch/riscv/include/asm/smp.h | 43 ++ arch/riscv/lib/andes_plic.c | 34 +- arch/riscv/lib/reset.c | 2 + arch/riscv/lib/sbi_ipi.c | 5 + arch/riscv/lib/sifive_clint.c | 33 +- arch/riscv/lib/smp.c | 49 +- arch/sandbox/dts/test.dts | 21 + arch/sandbox/include/asm/clk.h | 1 + board/sipeed/maix/Kconfig | 47 ++ board/sipeed/maix/MAINTAINERS | 11 + board/sipeed/maix/Makefile | 5 + board/sipeed/maix/maix.c | 41 ++ common/spl/spl_opensbi.c | 5 + configs/sandbox_defconfig | 3 + configs/sipeed_maix_bitm_defconfig | 8 + doc/board/index.rst | 1 + doc/board/sipeed/index.rst | 9 + doc/board/sipeed/maix.rst | 298 ++++++++ .../bus/simple-pm-bus.txt | 44 ++ .../mfd/kendryte,k210-sysctl.txt | 33 + .../reset/syscon-reset.txt | 36 + doc/imx/clk/ccf.txt | 63 +- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/clk-composite.c | 64 +- drivers/clk/clk-divider.c | 6 +- drivers/clk/clk-fixed-factor.c | 3 +- drivers/clk/clk-gate.c | 6 +- drivers/clk/clk-mux.c | 12 +- drivers/clk/clk-uclass.c | 8 +- drivers/clk/imx/clk-gate2.c | 4 +- drivers/clk/imx/clk-imx8mp.c | 2 +- drivers/clk/kendryte/Kconfig | 12 + drivers/clk/kendryte/Makefile | 1 + drivers/clk/kendryte/bypass.c | 270 +++++++ drivers/clk/kendryte/clk.c | 663 ++++++++++++++++++ drivers/clk/kendryte/pll.c | 601 ++++++++++++++++ drivers/core/Kconfig | 7 + drivers/core/Makefile | 1 + drivers/core/read.c | 2 +- drivers/core/simple-pm-bus.c | 56 ++ drivers/cpu/riscv_cpu.c | 39 +- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 2 +- drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 +- drivers/reset/Kconfig | 5 + drivers/reset/Makefile | 1 + drivers/reset/reset-syscon.c | 81 +++ include/configs/sipeed-maix.h | 24 + include/dm/read.h | 4 +- include/dt-bindings/clock/k210-sysctl.h | 59 ++ include/dt-bindings/mfd/k210-sysctl.h | 38 + include/dt-bindings/reset/k210-sysctl.h | 38 + include/kendryte/bypass.h | 31 + include/kendryte/clk.h | 35 + include/kendryte/pll.h | 57 ++ include/test/export.h | 16 + lib/hashtable.c | 8 +- test/dm/Makefile | 3 + test/dm/k210_pll.c | 96 +++ test/dm/simple-pm-bus.c | 45 ++ test/dm/syscon-reset.c | 59 ++ 70 files changed, 3706 insertions(+), 171 deletions(-) create mode 100644 arch/riscv/dts/k210-maix-bit.dts create mode 100644 arch/riscv/dts/k210.dtsi create mode 100644 board/sipeed/maix/Kconfig create mode 100644 board/sipeed/maix/MAINTAINERS create mode 100644 board/sipeed/maix/Makefile create mode 100644 board/sipeed/maix/maix.c create mode 100644 configs/sipeed_maix_bitm_defconfig create mode 100644 doc/board/sipeed/index.rst create mode 100644 doc/board/sipeed/maix.rst create mode 100644 doc/device-tree-bindings/bus/simple-pm-bus.txt create mode 100644 doc/device-tree-bindings/mfd/kendryte,k210-sysctl.txt create mode 100644 doc/device-tree-bindings/reset/syscon-reset.txt create mode 100644 drivers/clk/kendryte/Kconfig create mode 100644 drivers/clk/kendryte/Makefile create mode 100644 drivers/clk/kendryte/bypass.c create mode 100644 drivers/clk/kendryte/clk.c create mode 100644 drivers/clk/kendryte/pll.c create mode 100644 drivers/core/simple-pm-bus.c create mode 100644 drivers/reset/reset-syscon.c create mode 100644 include/configs/sipeed-maix.h create mode 100644 include/dt-bindings/clock/k210-sysctl.h create mode 100644 include/dt-bindings/mfd/k210-sysctl.h create mode 100644 include/dt-bindings/reset/k210-sysctl.h create mode 100644 include/kendryte/bypass.h create mode 100644 include/kendryte/clk.h create mode 100644 include/kendryte/pll.h create mode 100644 include/test/export.h create mode 100644 test/dm/k210_pll.c create mode 100644 test/dm/simple-pm-bus.c create mode 100644 test/dm/syscon-reset.c