Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp648659lqs; Tue, 5 Mar 2024 12:04:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUsW2kQsR/2Uqs2xErhDPZSFWNMijl74Ga+l0kketVqAvKUZP5ZgEMLgStzs+6MZYSxIfYJJ1tRoFw45r8LdStobIP77EG6pDoMv1pSSg== X-Google-Smtp-Source: AGHT+IH5zJM1iwtDJPdB87H+JyZFdJUkpi5cXA85DRaObUFFKtsQpnqvcaz7SdPYHgDx+EQH7KEP X-Received: by 2002:a17:906:2f06:b0:a45:9008:ca1b with SMTP id v6-20020a1709062f0600b00a459008ca1bmr3044843eji.1.1709669061148; Tue, 05 Mar 2024 12:04:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709669061; cv=pass; d=google.com; s=arc-20160816; b=eTxXmQ+XGKYYx/a1dHzek2G9xXBJj3fyifgzoTB+uaBT8fjgp17iVnWBGe1qktS3zw +dcT+ZroYIShe99Tycatnm4R6HsbPXCwl/lDOGTQZBD6qVey6iq5uiFyd8cZqRQxjKAL MBF13Z+gc+C72UeXy7QOTasuErb84sZo0ZQYI+V4Emk1ypn5SyFGMvhpZjwCLIfXb8G2 LBdC1quLRkF+rfJQ6d6hgkpIJ57yFINgQlgb0C9JK2f3b+rvVihRtCAl9N6jIr5e+MvE NblOyAXWbdPb4gAPLW3nsJsG7K0BEjBEoy6AmwubhXKOuQaOOJo5/Ohttz+uyVDq80yB Ni4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:date :subject:cc:to:from:message-id:dkim-signature; bh=LpEDS/Af9KjONJACVhHWTSm0TreYjD8rxr2ELJhjNqc=; fh=TFpRczVpCj1VKrdi5nTgmifufla0PMfzaqJ5jtnWufY=; b=x03XOmJG/yN4bIRwdJgUUKb+ikCHQFTuNy925GHMzs7a1mKitVOY1dczoSgeNXLT5N aMRpDvveIF7KGIpuB25e7Oqy8hbuV7j09KHsSPEkZX0FDmTUiKDO37hQ6THOWv2y8GAM /wojgLe9R/RJFs2L4oHLwDVnFHCP/xliTKirSOLItV6ERngXVe/Dd1ZZJlSE0FQLObBZ yDxJZmxV414QeGPXgg+bAchiUdnQzl4gVy2E2xMhHpt+4+Hai34IXvXp28oTFdRVqdwf 9JcNK/DncdeyRssq2TBWGHDaibhVJccW2bXHF13utQwCuOGeeZyI854RvvMYCKZ0Vdz0 bTxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=KUkfAkU8; arc=pass (i=1 dkim=pass dkdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-92930-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92930-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k16-20020a1709065fd000b00a442ff37168si5232886ejv.178.2024.03.05.12.04.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 12:04:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92930-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=KUkfAkU8; arc=pass (i=1 dkim=pass dkdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-92930-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92930-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A94D31F28505 for ; Tue, 5 Mar 2024 20:04:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0EFC12BF0F; Tue, 5 Mar 2024 20:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="KUkfAkU8" Received: from out203-205-221-192.mail.qq.com (out203-205-221-192.mail.qq.com [203.205.221.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C26B129A99 for ; Tue, 5 Mar 2024 20:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.205.221.192 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709669006; cv=none; b=EwGUXSWvAQSWr9AO891FyhcbENLGCjySaFkbyoBd6s32NPEEu1DMjnyCfdigP5UgctjQ9I8O0VTdI2H033/CcEbjD2KI/bXFfbYltQohAflYnygW2GqlDi0WqhJcclMt4kcOEC3Cy8XMN/mRjYOuJpT8yL0BI0sDn+4Mm4xFzDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709669006; c=relaxed/simple; bh=1NHojaWJsWEQuL4VS28ciXpxXkJhSUHZ8497cVMNRg4=; h=Message-ID:From:To:Cc:Subject:Date:In-Reply-To:References: MIME-Version; b=kCqV662SDjSEUR2JUQ/ZsAMVlTeCkCU2p1EdX7Wp5GFgDGq77WAmSeGB5zhvjQBEXbek5g0z7qBzlikmu8jk1tLgyrqc/c1prKyjwppBi52gVgV67tTlJ5VkuZ3w8L9PUlKQPOe2fKqczYCxF0cc9lW4sWja8yFD0r2Busenvag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cyyself.name; spf=none smtp.mailfrom=cyyself.name; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b=KUkfAkU8; arc=none smtp.client-ip=203.205.221.192 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cyyself.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=cyyself.name DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1709669001; bh=LpEDS/Af9KjONJACVhHWTSm0TreYjD8rxr2ELJhjNqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KUkfAkU8X9o9RnQP7PodJSHEddSb5ELUe7fyP88PBEm4Ykf/aGNEMR1GkXiUGkeYz 7rqCIRJDicn83f0I5W/2CFcjoYUV4etZFFATAuvq2LHfF7zVbm8dpY26VyybGDLwM8 cxkhWAPw4MSG/io/chG1ar6RModdXdrYnlOpjUyw= Received: from cyy-pc.lan ([240e:379:2267:e200:bd8:e8f9:fb59:de48]) by newxmesmtplogicsvrsza1-0.qq.com (NewEsmtp) with SMTP id C898283; Wed, 06 Mar 2024 04:03:08 +0800 X-QQ-mid: xmsmtpt1709668999t83a6g81j Message-ID: X-QQ-XMAILINFO: NLyuYVg5FLlyw92kABxndIEDyj4FxO1KS3bSBxtMNrO5cZyKlUWkIiTySqGKH9 sJh3m5qIfjWVLIBp9Ki1nwXMSyNYRJ2cI49/Qn+03NmdWNQRThCDWcdCQxz7xrEhvoR3C1Avk1NN G9s0BHqnV0P6n9PGuKxiw2xgm5JSbL2Z1GZLN0tuwr7w6hrMjtzwTv+8A/HklS0ie2Mr1xP73Axo oTlYrf3g50SWxs8Ux6NHV8bUKtp9gsdTdnvLAqColYaNvPoSM2kTCiUgP8N2h+oXIRpzmv9/vPFH /h4THIp8vMDKMVOZIKWZJqu6evcUV975SVR6YD1H8bBfMSYd6tThnwuNt48NcepG1peYUa+3SbM6 9HBPCzKFdPNBJGo2r1mo0z+DNR9n2kMxWuSVon5eRoNv1bP3vwOkBvi7NRgVHaSy8NBoimVpf1fu UWXtln8U8syyivoc3qzxvHv3aeSDtqlhXuswxanqFFYwZEZu41dAqNtBEyYxgwBI60aAHWSEVLKC KHzjsUzhsB9J/eHuN8it+gu2Bl1lBOWvmVI3Ov+nynrKrz5biqa68DD7+tSQPgmn8AldKvtRcMQw qESBat5pu4y0I0zS//OCeBcIiksJGmpLM4I3bgs/Kfz0cBGYL9n6ZDrW8qyCytkIZZ1Dnjs7vy4Q VLByMWPBW3eEzdGJJ9rF/bxdbbbB6c7HhBPLWVsoK6ZyySEBn8j+BtgcuRQwOtZlOj0FfZVYDLoo UyQ//bi0VBDEr2HGM0RliV/7elIECYzyRUiKgUAculLuKNBE+TfUe+Hf3tXkVGD+clIY0/pYMuvK BCywf09H29gk8clzTX5KIaq2T+QXOT00nwdsXgoKZ57Enp1nXKVggFn5z33ZZUi5H9at1+Cs3hBm /rjdTJuAaKevEBl6TAEszFu0/FafOH6lNB5UIgdPvc73/tbWBnYdPG0bOoYVQSfj6Ujjr0wMYDpM QoQIkZBkfYiM1fOqMIkWDeCpzVOfqakgfXX0hLSbenqNwnxyInfYqMPaKfx2fyOYVu4FZwjnT/Xj Zfi9RlRRcs0tHXxRjpetPEW6Z3zHjaFRHLWOm5tiOJcwzKK5gkSNugoNyiBCAMW4VTDjBUpMI8V8 mxY/bjf3dhtUzfCbw= X-QQ-XMRINFO: OWPUhxQsoeAVDbp3OJHYyFg= From: Yangyu Chen To: linux-riscv@lists.infradead.org Cc: Conor Dooley , Damien Le Moal , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Yangyu Chen Subject: [PATCH v5 6/7] riscv: dts: add initial canmv-k230 and k230-evb dts Date: Wed, 6 Mar 2024 04:03:01 +0800 X-OQ-MSGID: <20240305200302.1093082-6-cyy@cyyself.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add initial dts for CanMV-K230 and K230-EVB powered by Canaan Kendryte K230 SoC [1]. Some key consideration: - Only place BigCore which is 1.6GHz RV64GCBV The existence of cache coherence between the two cores remains unknown since they have dedicated L2 caches. And the factory SDK uses it for other OS by default. I don't know whether the two CPUs on K230 SoC can be used in one system. So only place BigCore here. Meanwhile, although docs from Canaan said 1.6GHz Core with Vector is CPU1, the csr.mhartid of this core is 0. - Support for "zba" "zbb" "zbc" "zbs" are tested by hand The user manual of C908 from T-Head does not document it specifically. It just said it supports B extension V1.0. [2] I have tested it by using this [3] which attempts to execute "add.uw", "andn", "clmulr", "bclr" and they doesn't traps on K230. But on JH7110, "clmulr" and "bclr" will trap. - Support for "zicbom" is tested by hand Have tested with some out-of-tree drivers from [4] that need DMA and they do not come to the dts currently. - Cache parameters are inferred from T-Head docs [2] and Canaan docs [1] L1i: 32KB, VIPT 4-Way set-associative, 64B Cacheline L1d: 32KB, VIPT 4-Way set-associative, 64B Cacheline L2: 256KB, PIPT 16-way set-associative, 64B Cacheline The numbers of cache sets are calculated from these parameters. - MMU only supports Sv39 Since T-Head docs [2] say C908 should support Sv48. However, it will fail during the kernel probe when running Linux on K230. I also tested it by hand on M-Mode software, writing Sv48 to satp.mode will not trap but will leave the csr unchanged. While writing Sv39 it will take effect. It shows that this CPU does not support Sv48. - Svpbmt and T-Head MAEE both supported T-Head C908 does support both Svpbmt and T-Head MAEE for page-based memory attributes and is controlled by csr.mxstatus. If the kernel wants to use svpbmt, the m-mode software should set BIT(21) of csr.mxstatus to zero before entering the s-mode kernel. Otherwise, the kernel will not boot as 0 on T-Head MAEE represent to NonCachable Memory and it will lose dirty cache lines modification that haven't been written back to the memory. [1] https://developer.canaan-creative.com/k230/dev/zh/00_hardware/K230_datasheet.html#chapter-1-introduction [2] https://occ-intl-prod.oss-ap-southeast-1.aliyuncs.com/resource//1699268369347/XuanTie-C908-UserManual.pdf [3] https://github.com/cyyself/rvb_test [4] https://github.com/cyyself/linux/tree/k230-mainline Signed-off-by: Yangyu Chen --- arch/riscv/boot/dts/canaan/Makefile | 2 + arch/riscv/boot/dts/canaan/k230-canmv.dts | 24 ++++ arch/riscv/boot/dts/canaan/k230-evb.dts | 24 ++++ arch/riscv/boot/dts/canaan/k230.dtsi | 140 ++++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 arch/riscv/boot/dts/canaan/k230-canmv.dts create mode 100644 arch/riscv/boot/dts/canaan/k230-evb.dts create mode 100644 arch/riscv/boot/dts/canaan/k230.dtsi diff --git a/arch/riscv/boot/dts/canaan/Makefile b/arch/riscv/boot/dts/canaan/Makefile index 987d1f0c41f0..7d54ea5c6f3d 100644 --- a/arch/riscv/boot/dts/canaan/Makefile +++ b/arch/riscv/boot/dts/canaan/Makefile @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 dtb-$(CONFIG_ARCH_CANAAN) += canaan_kd233.dtb dtb-$(CONFIG_ARCH_CANAAN) += k210_generic.dtb +dtb-$(CONFIG_ARCH_CANAAN) += k230-canmv.dtb +dtb-$(CONFIG_ARCH_CANAAN) += k230-evb.dtb dtb-$(CONFIG_ARCH_CANAAN) += sipeed_maix_bit.dtb dtb-$(CONFIG_ARCH_CANAAN) += sipeed_maix_dock.dtb dtb-$(CONFIG_ARCH_CANAAN) += sipeed_maix_go.dtb diff --git a/arch/riscv/boot/dts/canaan/k230-canmv.dts b/arch/riscv/boot/dts/canaan/k230-canmv.dts new file mode 100644 index 000000000000..3ab5c8de11a8 --- /dev/null +++ b/arch/riscv/boot/dts/canaan/k230-canmv.dts @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Copyright (C) 2024 Yangyu Chen + */ + +#include "k230.dtsi" + +/ { + model = "Canaan CanMV-K230"; + compatible = "canaan,canmv-k230", "canaan,kendryte-k230"; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + ddr: memory@0 { + device_type = "memory"; + reg = <0x0 0x0 0x0 0x1fdff000>; + }; +}; + +&uart0 { + status = "okay"; +}; diff --git a/arch/riscv/boot/dts/canaan/k230-evb.dts b/arch/riscv/boot/dts/canaan/k230-evb.dts new file mode 100644 index 000000000000..42720113c566 --- /dev/null +++ b/arch/riscv/boot/dts/canaan/k230-evb.dts @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Copyright (C) 2024 Yangyu Chen + */ + +#include "k230.dtsi" + +/ { + model = "Kendryte K230 EVB"; + compatible = "canaan,k230-usip-lp3-evb", "canaan,kendryte-k230"; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + ddr: memory@0 { + device_type = "memory"; + reg = <0x0 0x0 0x0 0x1fdff000>; + }; +}; + +&uart0 { + status = "okay"; +}; diff --git a/arch/riscv/boot/dts/canaan/k230.dtsi b/arch/riscv/boot/dts/canaan/k230.dtsi new file mode 100644 index 000000000000..0bcff67b78a8 --- /dev/null +++ b/arch/riscv/boot/dts/canaan/k230.dtsi @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Copyright (C) 2024 Yangyu Chen + */ + +#include + +/dts-v1/; +/ { + #address-cells = <2>; + #size-cells = <2>; + compatible = "canaan,kendryte-k230"; + + aliases { + serial0 = &uart0; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + timebase-frequency = <27000000>; + + cpu@0 { + compatible = "thead,c908", "riscv"; + device_type = "cpu"; + reg = <0>; + riscv,isa = "rv64imafdcv_zba_zbb_zbc_zbs_zicbom_svpbmt"; + riscv,isa-base = "rv64i"; + riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "v", "zba", "zbb", + "zbc", "zbs", "zicbom", "zicntr", "zicsr", + "zifencei", "zihpm", "svpbmt"; + riscv,cbom-block-size = <64>; + d-cache-block-size = <64>; + d-cache-sets = <128>; + d-cache-size = <32768>; + i-cache-block-size = <64>; + i-cache-sets = <128>; + i-cache-size = <32768>; + next-level-cache = <&l2_cache>; + mmu-type = "riscv,sv39"; + + cpu0_intc: interrupt-controller { + compatible = "riscv,cpu-intc"; + interrupt-controller; + #interrupt-cells = <1>; + }; + }; + + l2_cache: l2-cache { + compatible = "cache"; + cache-block-size = <64>; + cache-level = <2>; + cache-size = <262144>; + cache-sets = <256>; + cache-unified; + }; + }; + + apb_clk: apb-clk-clock { + compatible = "fixed-clock"; + clock-frequency = <50000000>; + clock-output-names = "apb_clk"; + #clock-cells = <0>; + }; + + soc { + compatible = "simple-bus"; + interrupt-parent = <&plic>; + #address-cells = <2>; + #size-cells = <2>; + dma-noncoherent; + ranges; + + plic: interrupt-controller@f00000000 { + compatible = "canaan,k230-plic" ,"thead,c900-plic"; + reg = <0xf 0x00000000 0x0 0x04000000>; + interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>; + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <2>; + riscv,ndev = <208>; + }; + + clint: timer@f04000000 { + compatible = "canaan,k230-clint", "thead,c900-clint"; + reg = <0xf 0x04000000 0x0 0x04000000>; + interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>; + }; + + uart0: serial@91400000 { + compatible = "snps,dw-apb-uart"; + reg = <0x0 0x91400000 0x0 0x1000>; + clocks = <&apb_clk>; + interrupts = <16 IRQ_TYPE_LEVEL_HIGH>; + reg-io-width = <4>; + reg-shift = <2>; + status = "disabled"; + }; + + uart1: serial@91401000 { + compatible = "snps,dw-apb-uart"; + reg = <0x0 0x91401000 0x0 0x1000>; + clocks = <&apb_clk>; + interrupts = <17 IRQ_TYPE_LEVEL_HIGH>; + reg-io-width = <4>; + reg-shift = <2>; + status = "disabled"; + }; + + uart2: serial@91402000 { + compatible = "snps,dw-apb-uart"; + reg = <0x0 0x91402000 0x0 0x1000>; + clocks = <&apb_clk>; + interrupts = <18 IRQ_TYPE_LEVEL_HIGH>; + reg-io-width = <4>; + reg-shift = <2>; + status = "disabled"; + }; + + uart3: serial@91403000 { + compatible = "snps,dw-apb-uart"; + reg = <0x0 0x91403000 0x0 0x1000>; + clocks = <&apb_clk>; + interrupts = <19 IRQ_TYPE_LEVEL_HIGH>; + reg-io-width = <4>; + reg-shift = <2>; + status = "disabled"; + }; + + uart4: serial@91404000 { + compatible = "snps,dw-apb-uart"; + reg = <0x0 0x91404000 0x0 0x1000>; + clocks = <&apb_clk>; + interrupts = <20 IRQ_TYPE_LEVEL_HIGH>; + reg-io-width = <4>; + reg-shift = <2>; + status = "disabled"; + }; + }; +}; -- 2.43.0