From patchwork Thu Sep 9 02:08:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1526060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=qbQsLVu/; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm3 header.b=arfjmfVd; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=Lde52Qcg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H4j952fyTz9sW8 for ; Thu, 9 Sep 2021 12:08:40 +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=I5Q6IDVH8V+Yjh7m/gQrWdgQ2uSrirwGcjbhR+RjQbA=; b=qbQsLVu/wYsYYA Lx6pr15DAUaQj3XYuwxCDPY/1BPbhZX9vpeccGHHys+lvVhYZ4A5vI6CNPvUylOegnfQkJqUTa/eD WnlLBBPtQAIDFgoKamXc0wEYW5KuoNigxHTI6khCp/9BLd6LfnOAWpgKtexsdPu4wSc4TuM8IuZVC 5J7XyadcxBq04U+eRwOBJcMXAPR86Yv+R+PKuyh4l8C+aXrX+PlMSg3XmsX7PLuTACZ1CBno4bW6R 7AgDYkvDaMk5O2/iHmolKLwm9MVZ13aDfHAkM5nbe1mYYnfVVG3YsMvZDQZ2yfxAnn5qMnUhsQuFu 4/LA22WX/SVzK/Bmb+BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mO9UN-0083wE-2z; Thu, 09 Sep 2021 02:08:31 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mO9UJ-0083vn-GI for opensbi@lists.infradead.org; Thu, 09 Sep 2021 02:08:29 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 6A65C5C014E; Wed, 8 Sep 2021 22:08:23 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 08 Sep 2021 22:08:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm3; bh=kJejasK3XX7tVu9ScRpWxVtWC1 a5+2yi+nzNcxWF1Oo=; b=arfjmfVdhDIwdfssAkKvV/26OnXdbDdEjVpUfl8rQE 95n1xU7aPAtDICkqRV81e9dB5gxHaMM0fVUnF333T0+Ns/QFVbOUYPyoXw6h75Vp es7HVbv06I3yX6iXnZNkkSrz9ypx6PbNzM6FiEyCwPUTKiplUs5d9LuIoxRRRH1R /Xnr43bUp82UVOU+Exn4BTPWhgH7YW7HDtdu/2v5EiZpJBkidyWRqOBlWcgUfhDa t+nTJMmx0qFBhaVP0umtNN09DBG9/85yqAYo3FlduSwDTioFvvIv8m/3tMKBuHOX K38TkrAo5rOPeWDiXywI8x7hu+twbMUoIv1rJ2G0lYDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=kJejasK3XX7tVu9Sc RpWxVtWC1a5+2yi+nzNcxWF1Oo=; b=Lde52Qcg7EYrARmT6iX91d4sgXDPIkoNT 9XGZw/8YWA6qwBhpFfJRCTKhI5Mq99SwXnK8TKQ/kTYS1vLze/FCBEvI8SvFWvVW tVMHtRIPBMIGA/F1tWYl9kp4Bwgo4NKuEFTS51388d94e8HpIRRDrSQYxi2zMFBY MZS7/BO3+tBB9mEE1KE4lYPhaP28d2+QjKpWnFNxPl9muRFA/J8jG238D2vBkPDe 7de21W2RoLfY6Nm/w1H/KsVR4w95BU6fTR9G9oLN45LSLhErS7udbw76BJO6cb+H QuJunMFf8qMn7j4P6jrWPr6hL8DLKJpEv8ov3y2q89rJKinMEEYLw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudefkedgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgvlhcu jfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtffrrg htthgvrhhnpeeiteekhfehuddugfeltddufeejjeefgeevheekueffhffhjeekheeiffdt vedtveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Sep 2021 22:08:22 -0400 (EDT) From: Samuel Holland To: opensbi@lists.infradead.org Cc: Guo Ren , Samuel Holland Subject: [PATCH] lib: utils/irqchip: Automatically delegate T-HEAD PLIC access Date: Wed, 8 Sep 2021 21:08:21 -0500 Message-Id: <20210909020821.29431-1-samuel@sholland.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210908_190827_720159_2A309FC2 X-CRM114-Status: GOOD ( 11.56 ) X-Spam-Score: -0.9 (/) 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: The T-HEAD PLIC implementation requires setting a delegation bit to allow access from S-mode. For the D1 SoC, let's set this bit automatically from the PLIC driver, instead of relying on another drive [...] Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [66.111.4.26 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [66.111.4.26 listed in list.dnswl.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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 The T-HEAD PLIC implementation requires setting a delegation bit to allow access from S-mode. For the D1 SoC, let's set this bit automatically from the PLIC driver, instead of relying on another driver reaching into the PLIC's MMIO space. Signed-off-by: Samuel Holland --- docs/platform/thead-c9xx.md | 8 ++------ lib/utils/irqchip/fdt_irqchip_plic.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/platform/thead-c9xx.md b/docs/platform/thead-c9xx.md index c0daeb7..125edf4 100644 --- a/docs/platform/thead-c9xx.md +++ b/docs/platform/thead-c9xx.md @@ -51,11 +51,6 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) compatible = "simple-bus"; ranges; - reset: reset-sample { - compatible = "thead,reset-sample"; - plic-delegate = <0x0 0x101ffffc>; - }; - clint0: clint@14000000 { compatible = "riscv,clint0"; interrupts-extended = < @@ -67,7 +62,8 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) intc: interrupt-controller@10000000 { #interrupt-cells = <1>; - compatible = "riscv,plic0"; + compatible = "allwinner,sun20i-d1-plic", + "riscv,plic0"; interrupt-controller; interrupts-extended = < &cpu0_intc 0xffffffff &cpu0_intc 9 diff --git a/lib/utils/irqchip/fdt_irqchip_plic.c b/lib/utils/irqchip/fdt_irqchip_plic.c index 18d2797..b044b28 100644 --- a/lib/utils/irqchip/fdt_irqchip_plic.c +++ b/lib/utils/irqchip/fdt_irqchip_plic.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -91,6 +92,13 @@ static int irqchip_plic_cold_init(void *fdt, int nodeoff, if (rc) return rc; + if (match->data) { + int (*plic_plat_init)(struct plic_data *) = match->data; + rc = plic_plat_init(pd); + if (rc) + return rc; + } + rc = plic_cold_irqchip_init(pd); if (rc) return rc; @@ -106,7 +114,18 @@ static int irqchip_plic_cold_init(void *fdt, int nodeoff, return irqchip_plic_update_hartid_table(fdt, nodeoff, pd); } +#define THEAD_PLIC_CTRL_REG 0x1ffffc + +static int thead_plic_plat_init(struct plic_data *pd) +{ + writel_relaxed(BIT(0), (void *)pd->addr + THEAD_PLIC_CTRL_REG); + + return 0; +} + static const struct fdt_match irqchip_plic_match[] = { + { .compatible = "allwinner,sun20i-d1-plic", + .data = thead_plic_plat_init }, { .compatible = "riscv,plic0" }, { .compatible = "sifive,plic-1.0.0" }, { },