From patchwork Fri May 31 05:21:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Zong-You Xie X-Patchwork-Id: 1941934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Oe3lHfAo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VrBLJ3hKKz20Pb for ; Fri, 31 May 2024 15:21:28 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ie4Ax8lViFNyMIeCFWGQfkVavhvP0OKS0jFB/gcT9DI=; b=Oe3lHfAoIBjJk8 1g8UQSXe94AwXUxONCV/lSzxZ417vOyJXTtPebGdAG6lQ1vrzUZE1yusivj2eRB2nuXReiQbbGU0K i6nX4Q03F3oHba8lYxvjGYd/GqdpZnx0trzOeWUTgYTQfFSWaqgmdRNDwlXMdT444/PinXiTrL8K0 Uumlei1EegUjitsJXhDOXO2teqr42Q7zjkdRETT9i0qPLqiln9DA/xjCXWC7tHZnkjQi8ounXbS1U bAyKNpX03td8bioFXUVop4UJSZsQvhI34laGhAwKRgct97z9YhgjuxH5O70pe4ITc4W+GO9Gb/w8Z 9HGVnRjF7CXp6CMI8xdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCuhd-00000009H48-0BIB; Fri, 31 May 2024 05:21:21 +0000 Received: from 60-248-80-70.hinet-ip.hinet.net ([60.248.80.70] helo=Atcsqr.andestech.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCuha-00000009H3h-09wk for opensbi@lists.infradead.org; Fri, 31 May 2024 05:21:19 +0000 Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 44V5LAj5001741 for ; Fri, 31 May 2024 13:21:10 +0800 (+08) (envelope-from ben717@andestech.com) Received: from atctrx.andestech.com (10.0.15.190) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Fri, 31 May 2024 13:21:10 +0800 From: Ben Zong-You Xie To: CC: Ben Zong-You Xie Subject: [PATCH] platform: generic: andes: Add support for RV32 to set up PMA Date: Fri, 31 May 2024 13:21:08 +0800 Message-ID: <20240531052108.3124699-1-ben717@andestech.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.0.15.190] X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: Atcsqr.andestech.com 44V5LAj5001741 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_222118_374116_729496EC X-CRM114-Status: UNSURE ( 7.99 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Like PMP, the behaviors to configure PMA will be different from RV64 and RV32. RV64 uses two Andes custom CSRs, pmacfg0 and pmacfg2, but RV32 uses four Andes custom CSRs, pmacfg0 ~ pmacfg3. This patch [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 TVD_RCVD_IP Message was received from an IP address 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Like PMP, the behaviors to configure PMA will be different from RV64 and RV32. RV64 uses two Andes custom CSRs, pmacfg0 and pmacfg2, but RV32 uses four Andes custom CSRs, pmacfg0 ~ pmacfg3. This patch adds support to PMA for RV32. Signed-off-by: Ben Zong-You Xie Reviewed-by: Anup Patel --- platform/generic/andes/andes_pma.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/generic/andes/andes_pma.c b/platform/generic/andes/andes_pma.c index 321074a..9c37720 100644 --- a/platform/generic/andes/andes_pma.c +++ b/platform/generic/andes/andes_pma.c @@ -109,10 +109,17 @@ static unsigned long andes_pma_setup(const struct andes_pma_region *pma_region, !(pma_region->flags & ANDES_PMACFG_ETYP_NAPOT)) return SBI_EINVAL; +#if __riscv_xlen == 64 pma_cfg_addr = CSR_PMACFG0 + ((entry_id / 8) ? 2 : 0); pmacfg_val = andes_pma_read_num(pma_cfg_addr); pmaxcfg = (char *)&pmacfg_val + (entry_id % 8); - *pmaxcfg = 0; +#elif __riscv_xlen == 32 + pma_cfg_addr = CSR_PMACFG0 + (entry_id / 4); + pmacfg_val = andes_pma_read_num(pma_cfg_addr); + pmaxcfg = (char *)&pmacfg_val + (entry_id % 4); +#else +#error "Unexpected __riscv_xlen" +#endif *pmaxcfg = pma_region->flags; andes_pma_write_num(pma_cfg_addr, pmacfg_val);