From patchwork Thu Feb 22 08:16:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1902603 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=TolDNSwb; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=GyfC8sD/; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=9t9zJ/mS; 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 4TgQwG2PXPz23cl for ; Thu, 22 Feb 2024 19:16:46 +1100 (AEDT) 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:References:In-Reply-To: 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: List-Owner; bh=PWW8W2Yj4U1kT6KMDX1Rfk3o4FPL/eoUAbjXxZGVYeQ=; b=TolDNSwbb2k9ur j7t/5WlRez+fvU2y+J+OZkvcq2cutdef1s0U2LOUiPOwXjGS/e4/pEgF+zYIdOZ6osAiqDd/il9oW /VeqW8INsJ7DwUeV4e7sNW/U4NIkyqesI3Mjb5y1xNMtdZa0n1ANW4h/S/D76beJIaC7mfZIENC2y 5qqgCXR6slFCI1bEg5AEXmKZNsD56AyKV8q5aCq1Eh9daG/xStKhwVD/vMErCsu6xO+yKOoeBpUhf EcIeKnPyUQVek5HKqkSOOngwJfs1H4iKrcPxjMx6Tvau2eYd0wUVCeAlMGHhgpzTncFEeiydXyt9Y tZJ8byuZCUQJiQzbdK6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4Fw-00000003y36-3dqk; Thu, 22 Feb 2024 08:16:36 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4Fq-00000003y09-3Ikl for opensbi@lists.infradead.org; Thu, 22 Feb 2024 08:16:34 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708589784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sy5P2TuMSN0ChqhBtME3NbgfbYOfKGLHLmtt4MUvcAU=; b=GyfC8sD/NmbbuJk5ZkMg/mggC+L3g4jW6+IKYp6oANXORAD2DfmoCqXeLoQfldfPUrCd0w FKUVJyEKowgw2YTdOo5D5hXtLRbnpX0A8w9oFwm2ktiO+VxORHUR3oeXG8SY+GONaG07Ay bCDV+VHLVmAMzh0ph44ttUSZfjRCCeEKTgzwVaTURF9mC+5gj0UVW3RxAHxTMgfbu394Va au8w3liqds1xz2196dOSTxrQJo/DRxCjXvI/bdV3PIfoTTh5xDscQWqxyDi+go16uSckGy GA2SCzMwJ4Lhau00mBC6r/F3SSSr6339enPxMuAwsYL6oSM008V2KGXoHnL67w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708589784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sy5P2TuMSN0ChqhBtME3NbgfbYOfKGLHLmtt4MUvcAU=; b=9t9zJ/mSg5zlhT2AD7dx8H43vlhWJ9+v6vhihWllEz26VCqp7adN6Nz9NXkp7TFZUgi+fo 9i5/BY3HPsRI0ADA== To: opensbi@lists.infradead.org, cheehong.ang@starfivetech.com, weiliang.lim@starfivetech.com, minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v5 1/6] platform: starfive: correct system clock device tree node Date: Thu, 22 Feb 2024 09:16:14 +0100 Message-Id: <20240222081619.275869-2-namcao@linutronix.de> In-Reply-To: <20240222081619.275869-1-namcao@linutronix.de> References: <20240222081619.275869-1-namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_001630_997394_1A486558 X-CRM114-Status: UNSURE ( 9.31 ) X-CRM114-Notice: Please train this message. X-Spam-Note: SpamAssassin invocation failed 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 Starfive names the system clock device tree node "starfive,jh7110-clkgen" in all their git repositories. However, a different name is used in upstream U-Boot (and also Linux): "starfive,jh7110-syscrg". Since OpenSBI gets the device tree from U-Boot, this inconsistency leads the problem that OpenSBI doesn't know the system clock device exists. Correct this name to keep the consistency. Signed-off-by: Nam Cao Acked-by: Minda Chen Tested-by: Minda Chen --- platform/generic/starfive/jh7110.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index dcd6306..4b22175 100644 --- a/platform/generic/starfive/jh7110.c +++ b/platform/generic/starfive/jh7110.c @@ -252,7 +252,7 @@ static int starfive_jh7110_inst_init(void *fdt) jh7110_inst.pmu_reg_base = addr; } - noff = fdt_node_offset_by_compatible(fdt, -1, "starfive,jh7110-clkgen"); + noff = fdt_node_offset_by_compatible(fdt, -1, "starfive,jh7110-syscrg"); if (-1 < noff) { rc = fdt_get_node_addr_size(fdt, noff, 0, &addr, NULL); if (rc) From patchwork Thu Feb 22 08:16:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1902602 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=a+aFhoMR; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=W4c0zBQE; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=UDhsLyCA; 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 4TgQwG2wLSz23hc for ; Thu, 22 Feb 2024 19:16:46 +1100 (AEDT) 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:References:In-Reply-To: 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: List-Owner; bh=7J2B1E/6r+G70B2gXdIZ8N4xZ7dkTwIdXqbD9DhreUs=; b=a+aFhoMR+uBKgs NUSsgmgKR8eriC+HckrMDW1Kk5pZSXKbbqA4bLjFbK+aRk4iF2XKLYE0AZjxTuI7mcOlcBKjO/Vcl VcoY7UAQJahVcKgUktLeGZMnMRzM8sLT25ciScTR9X0jNxwkuEtHTAagVGXQ1yXvHZKuk73R22eog d7lY4taKdlUpmmDZdF4uGoKDE1hDOX7EiWovrXycsmTt60FEyzaLhLdnWL/jhwAxG5aDZAUmo7Myf 05DrNHRsA8O5UdrxQQSI4dhBrCmvhfVd7Bh0XdEgKnDKZ9OtpTdx02coxcNuY3l6O4qPuTW7U6DAb g8ibRZplG/P+VDiBp1Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4Fw-00000003y2w-0rCk; Thu, 22 Feb 2024 08:16:36 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4Fq-00000003y07-2N62 for opensbi@lists.infradead.org; Thu, 22 Feb 2024 08:16:33 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708589785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtZr+RvP46FVWNcZaqjUWvZvzqVH8KZ9b14duSRmAus=; b=W4c0zBQEvaW75FLLosFLXecf4UPbW1yJ+g0ogjnXlPmutFihxaRjiyr3EnWnGZ/bDI2hYP uMojoxRvMtbn6GVrLOVGaIsV5r2O7N5kMx7f2pQy57YBRLbc/8E7wasfBdVvqM+jGbnrXJ sGmg+NhvbSEk5KVTTmgEGGacKk2lb4CDqWLxhW/T2kHmr9St9qFhjM+kniFNdSKxOdRmnN E7r4XEimjZ7FfFl7ryG7MLK8g15P8oevr2UQuNI6ZqIAL7uFboXMaSbcepF4apujMy8whK Jh4aFPAoNk2DSMosqlqwcJb+drPH6zgH48Yga4SPgOZMskEuueH/gvZHTl2I5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708589785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtZr+RvP46FVWNcZaqjUWvZvzqVH8KZ9b14duSRmAus=; b=UDhsLyCA3s9O/7TYytYYDKDulc7OapWaWVOW9wd3woUecBQCNkOtKq2EfnBElmuxkrytpN 9lYIkvFQZJzesoBA== To: opensbi@lists.infradead.org, cheehong.ang@starfivetech.com, weiliang.lim@starfivetech.com, minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v5 2/6] platform: starfive: get I2C offset address from clocks property Date: Thu, 22 Feb 2024 09:16:15 +0100 Message-Id: <20240222081619.275869-3-namcao@linutronix.de> In-Reply-To: <20240222081619.275869-1-namcao@linutronix.de> References: <20240222081619.275869-1-namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_001630_768729_F5EBE5D4 X-CRM114-Status: GOOD ( 14.07 ) X-Spam-Note: SpamAssassin invocation failed 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 current code gets the I2C offset address using the device tree node name: it get the I2C device index from the 4th character in the node name (for example, "i2c5" -> i2c device 5). However, the device tree node's name in U-Boot is actually just "i2c" without the number, so the current code cannot be used with the device tree from U-Boot. Get the I2C offset address from the "clocks" property instead. Signed-off-by: Nam Cao Reviewed-by: Minda Chen Tested-by: Minda Chen --- platform/generic/starfive/jh7110.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index 4b22175..308fe39 100644 --- a/platform/generic/starfive/jh7110.c +++ b/platform/generic/starfive/jh7110.c @@ -29,7 +29,7 @@ struct pmic { struct jh7110 { u64 pmu_reg_base; u64 clk_reg_base; - u32 i2c_index; + u32 i2c_clk_offset; }; static struct pmic pmic_inst; @@ -67,7 +67,6 @@ static u32 selected_hartid = -1; #define AXP15060_POWER_OFF_BIT BIT(7) #define AXP15060_RESET_BIT BIT(6) -#define I2C_APB_CLK_OFFSET 0x228 #define I2C_APB_CLK_ENABLE_BIT BIT(31) static int pm_system_reset_check(u32 type, u32 reason) @@ -163,10 +162,7 @@ static void pmic_i2c_clk_enable(void) unsigned long clock_base; unsigned int val; - clock_base = jh7110_inst.clk_reg_base + - I2C_APB_CLK_OFFSET + - (jh7110_inst.i2c_index << 2); - + clock_base = jh7110_inst.clk_reg_base + jh7110_inst.i2c_clk_offset; val = readl((void *)clock_base); if (!val) @@ -241,7 +237,8 @@ static struct fdt_reset fdt_reset_pmic = { static int starfive_jh7110_inst_init(void *fdt) { int noff, rc = 0; - const char *name; + const fdt32_t *val; + int len; u64 addr; noff = fdt_node_offset_by_compatible(fdt, -1, "starfive,jh7110-pmu"); @@ -261,9 +258,12 @@ static int starfive_jh7110_inst_init(void *fdt) } if (pmic_inst.adapter) { - name = fdt_get_name(fdt, pmic_inst.adapter->id, NULL); - if (!sbi_strncmp(name, "i2c", 3)) - jh7110_inst.i2c_index = name[3] - '0'; + val = fdt_getprop(fdt, pmic_inst.adapter->id, "clocks", &len); + /* The clocks property looks like this: clocks = <&syscrg JH7110_SYSCLK_I2C5_APB>; + * So check that the length is 8 bytes, and get the offset from the second value + */ + if (val && len == 8) + jh7110_inst.i2c_clk_offset = fdt32_to_cpu(val[1]) << 2; else rc = SBI_EINVAL; } From patchwork Thu Feb 22 08:16:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1902605 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=NPcvoG5C; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=dy2iepsB; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=+bf34jLk; 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 4TgQwM1Zsnz23cl for ; Thu, 22 Feb 2024 19:16:51 +1100 (AEDT) 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:References:In-Reply-To: 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: List-Owner; bh=SKhzgJ8H2L8mgqocye8wbzoKLdrr2ippJD/y1LVUWCU=; b=NPcvoG5CBZMt6/ myQretJaNMijRWqD0Iq4Qic49P3KnGztvPu5ybO/mfmaM7vli635K9snJsHTqwUiICpjVAnlgWaV+ xc+tzOKarvXNfRGxEOujEQFZUn4xZYVO8kRQJSFW+G5lcRt1jAnjyC3IHjjxa4rk0Oc+Qoob793gV VFN2lapJtjms7Hq9JlyxE9uVOJDOCnponhN03hpHcHtMmS8Zlbcx21i03ZTTrqdaLFaTLM9EQl5fw YT/W3oR4ED2JtrazdVH14lYDLaOqcd+/fKd3J7mdJX04toQWrmoGUnha+3eFEmQADltn1fyPUkG8b j+g0UXQCH/qX4xVux4Xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4G3-00000003y68-1L7b; Thu, 22 Feb 2024 08:16:43 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4Fq-00000003y0B-3wqm for opensbi@lists.infradead.org; Thu, 22 Feb 2024 08:16:41 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708589785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iuovGM8U11HksW2k2kvxpT7oie44qTbk8JX5dxTcbFw=; b=dy2iepsBrUk3LFImI5VFZdm1OlfUlASBF6DFmT1yy5ShDQ5gRwtD+yzQUx8/QwMLJ0X5qf 5I26Jk8vNk/2KBFls5roR35MV4fVxyP0D1uZ256ZmZ4KUXfGSl6tNGktjdqFpriCNFjmns bGXWLp2ypo/wIQKcUbjT5LQ6s9shGXzwazyf12j/37ZtwyuLt64qDaahMewg3vUgA/uEVa PbMtkIhk3bJN8reZmvRktsgd/1gOqlyIHmR3UkJjgQkGtNKn6V/3h6CUcMg/IJlNjOloBh ALNS5qWeLtczF1zQW+rGRPHavUp076ITwB1bTj+CVZq36NkqHuTvThZbBIyR0Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708589785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iuovGM8U11HksW2k2kvxpT7oie44qTbk8JX5dxTcbFw=; b=+bf34jLkfPSwjtLN7D0TC9bFWGKvt3DPwbFnzDoo6NOvyxtHkmvtNRFVWbZfMTBBNU8rg2 R5axPIH78GkYGyBQ== To: opensbi@lists.infradead.org, cheehong.ang@starfivetech.com, weiliang.lim@starfivetech.com, minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v5 3/6] platform: starfive: remove redundant compatibility check in pmic_ops Date: Thu, 22 Feb 2024 09:16:16 +0100 Message-Id: <20240222081619.275869-4-namcao@linutronix.de> In-Reply-To: <20240222081619.275869-1-namcao@linutronix.de> References: <20240222081619.275869-1-namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_001631_194974_248A0B23 X-CRM114-Status: GOOD ( 10.81 ) X-Spam-Note: SpamAssassin invocation failed 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 pmic_ops() is only called if a compatible device is found in device tree. It is redundant for this function to check the compability again. Remove this check. Signed-off-by: Nam Cao Tested-by: Minda Chen --- platform/generic/starfive/jh7110.c | 36 +++++++++++++----------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index 308fe39..3161bf1 100644 --- a/platform/generic/starfive/jh7110.c +++ b/platform/generic/starfive/jh7110.c @@ -23,7 +23,6 @@ struct pmic { struct i2c_adapter *adapter; u32 dev_addr; - const char *compatible; }; struct jh7110 { @@ -133,28 +132,26 @@ static void pmic_ops(struct pmic *pmic, int type) if (ret) return; - if (!sbi_strcmp("stf,axp15060-regulator", pmic->compatible)) { - ret = i2c_adapter_reg_read(pmic->adapter, pmic->dev_addr, - AXP15060_POWER_REG, &val); + ret = i2c_adapter_reg_read(pmic->adapter, pmic->dev_addr, + AXP15060_POWER_REG, &val); - if (ret) { - sbi_printf("%s: cannot read pmic power register\n", - __func__); - return; - } + if (ret) { + sbi_printf("%s: cannot read pmic power register\n", + __func__); + return; + } + val |= AXP15060_POWER_OFF_BIT; + if (type == SBI_SRST_RESET_TYPE_SHUTDOWN) val |= AXP15060_POWER_OFF_BIT; - if (type == SBI_SRST_RESET_TYPE_SHUTDOWN) - val |= AXP15060_POWER_OFF_BIT; - else - val |= AXP15060_RESET_BIT; + else + val |= AXP15060_RESET_BIT; - ret = i2c_adapter_reg_write(pmic->adapter, pmic->dev_addr, - AXP15060_POWER_REG, val); - if (ret) - sbi_printf("%s: cannot write pmic power register\n", - __func__); - } + ret = i2c_adapter_reg_write(pmic->adapter, pmic->dev_addr, + AXP15060_POWER_REG, val); + if (ret) + sbi_printf("%s: cannot write pmic power register\n", + __func__); } static void pmic_i2c_clk_enable(void) @@ -206,7 +203,6 @@ static int pm_reset_init(void *fdt, int nodeoff, return rc; pmic_inst.dev_addr = addr; - pmic_inst.compatible = match->compatible; i2c_bus = fdt_parent_offset(fdt, nodeoff); if (i2c_bus < 0) From patchwork Thu Feb 22 08:16:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1902606 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=AZdsIpxe; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=y89kXzyP; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=RFJZ0YhN; 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 4TgQwM5HQVz23hc for ; Thu, 22 Feb 2024 19:16:51 +1100 (AEDT) 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:References:In-Reply-To: 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: List-Owner; bh=TlVKT3LS8oOk5aOZxcpvdpWt4EM96pg6BagjY0fwmxg=; b=AZdsIpxeQqyHPX BRUOM67hok1RLGSvUjRWXO0EktaOmzvSKlNawffx8J08gbVezBej1EbqS09FS4RSMQUUoz7NNhQlT 5O6JhvQaRNPbeQ2EYR8LZSWowa3Nrbd1KECKgso7jAAN70ZeuGiVZk2U7oOjex+ucCgF7r4w0Q+Ve yhJTxsgJ353kiSch/KFkmZGwX0NnVlLdYMNyDOWBQsBkJm+OaySJygoURxUlxHioe4bLR4hijDym5 +XrOxzaiLtL/3FlypGdm3woLo/iAnGQn6/huRtzDZZWu6kVGn3Cr5BoEJwxkW19CJnG1uhMPq7kEd dv9UG8eI+HjwbGnvJ34Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4G4-00000003y6p-115h; Thu, 22 Feb 2024 08:16:44 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4Fq-00000003y08-3rhh for opensbi@lists.infradead.org; Thu, 22 Feb 2024 08:16:41 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708589785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xvTPF+na0S6MyZ3v4DXT6cILC82uSzCAE1ag3swLq0A=; b=y89kXzyPKuWAxW5BZ6pn7D6Bdz3QkcU9DzZF+mqQQWyz7Wu03pbRBlS3KTZF6RDNg0lIkd AaainJA+w6xenuVtEXhJY2pLwZ0TYLr6Q1TNJ242OsN6TLbx8hhbc90xGfnRl+eWyACMul d7FYqqQYOTEiGEoMYrF9i40WHsbvIyF0um1R5J4NPoBjojt+6IvNquRGt4HHWPHlgOJ05C rlgjj5J+7ReLbcvvMjWq5XOb1IHra7ZUum+uwJzkPnqSrhjcBLVfMW2GkP6KJe/ZypagtL 0GxGo/ui3FR1ITcOpk/E1k+7utb6pS/lxcZYfWmeUWmshKiM8/DPKpAdfE9WZA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708589785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xvTPF+na0S6MyZ3v4DXT6cILC82uSzCAE1ag3swLq0A=; b=RFJZ0YhNmudXLvugHcEos2L5Ns9wmNcub0T9ZQix7U6m/ZYbjO6lOmRGRi4WQx7/Xoy81x 8WOXj5WssV0p83Cg== To: opensbi@lists.infradead.org, cheehong.ang@starfivetech.com, weiliang.lim@starfivetech.com, minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v5 4/6] platform: starfive: rename "stf,axp15060-regulator" -> "x-powers,axp15060" Date: Thu, 22 Feb 2024 09:16:17 +0100 Message-Id: <20240222081619.275869-5-namcao@linutronix.de> In-Reply-To: <20240222081619.275869-1-namcao@linutronix.de> References: <20240222081619.275869-1-namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_001631_163340_81D03A00 X-CRM114-Status: GOOD ( 10.73 ) X-Spam-Note: SpamAssassin invocation failed 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 OpenSBI uses the device tree compatible string "stf,axp15060-regulator" for the regulator node. However, the string used by U-Boot (and Linux) is actually "x-powers,axp15060". As OpenSBI gets the device tree from U-Boot, this causes the regulator device to be undetected, and OpenSBI does not use this device to perform board reset/shutdown. Rename this device tree compatible string to match U-Boot (and Linux). Signed-off-by: Nam Cao Acked-by: Minda Chen Tested-by: Minda Chen --- platform/generic/starfive/jh7110.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index 3161bf1..b0b1e35 100644 --- a/platform/generic/starfive/jh7110.c +++ b/platform/generic/starfive/jh7110.c @@ -221,7 +221,7 @@ static int pm_reset_init(void *fdt, int nodeoff, } static const struct fdt_match pm_reset_match[] = { - { .compatible = "stf,axp15060-regulator", .data = (void *)true }, + { .compatible = "x-powers,axp15060", .data = (void *)true }, { }, }; From patchwork Thu Feb 22 08:16:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1902607 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=K5JJvgBa; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=lmfCH9SI; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=JLcxUOUJ; 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 4TgQwN25j6z23cl for ; Thu, 22 Feb 2024 19:16:52 +1100 (AEDT) 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:References:In-Reply-To: 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: List-Owner; bh=stq/JQc4dze0zwMYFKknGVfWElGr6hF47ieD0O2EpD0=; b=K5JJvgBaKNhk09 7gX46Y+yLqb83CyXuc52rzTKurzPfbWjeQ6tqW5QXipEEWFy8s6Ql/zekatuLWVd8Hs/2FJTlwh+6 Qd2qzB91ZKYd0A4ikMCL6uPz/DqQBIwr/tvGqu0do0n61r82gUa5dkHzADdFOWtRmgp8T7RlNWL37 fkQoWyQRaeauXs8iVwNoImEPzCCEJW7emYSz4fqsRwJlmoiQQpiCbR7xBx8f2QUfEKqm1KPVJbFBf 5tj3lZHFONAIa3FXI8ym/tNVEnOjSE0d4j7ISZ08UTa+4Xd63eI2z1I/lLIuUtirfjWatTdfrmS0r +2Zb1ksV0DE3sMbTtgSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4G5-00000003y7V-0XsG; Thu, 22 Feb 2024 08:16:45 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4Fv-00000003y1z-1f4f for opensbi@lists.infradead.org; Thu, 22 Feb 2024 08:16:41 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708589785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IojOq1JFjnDjkUHPO5fu3YWWsotjIagcezEfOcKhSws=; b=lmfCH9SIWN5D1WE0z0xVbkDN2QU9rJ5rx2l/rE20d330TryK+nzLdXr8bv7h4+TLot1d3A /0lfx7yg1xRu5vIVOoNKMYbmB4GxJliqnpZKHelcYEpqiD+xGYj1v4EFs1KyDp6xvh5+Cv DXbAvpLS+8L0pfaH/fQL/uQe2+wRy0V2C9WlZGkf53qX4pCtnKNbwo0O7juICdjnlpnp1i Hk/Ncx6B5tZSLsDExDUGiZyt4lYyvJ3+iZ/vvX938GeHAxzVpO+yJyV9WT+5DyQX9QkW43 o/QATEYzlaztJdmQ+vjwxM0UTpCe++U68TAQ4GLN8g3KZ6/4ErBHWV05UNkRcg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708589785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IojOq1JFjnDjkUHPO5fu3YWWsotjIagcezEfOcKhSws=; b=JLcxUOUJb90bYT9egy7k//V6uVAklEzIj0N0QcVMnjdwqgngPhbfin3JrY9OB1liwlrmfu NXV9r3VTGWSPLEDw== To: opensbi@lists.infradead.org, cheehong.ang@starfivetech.com, weiliang.lim@starfivetech.com, minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v5 5/6] platform: starfive: return error if needed devices are not present Date: Thu, 22 Feb 2024 09:16:18 +0100 Message-Id: <20240222081619.275869-6-namcao@linutronix.de> In-Reply-To: <20240222081619.275869-1-namcao@linutronix.de> References: <20240222081619.275869-1-namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_001635_636433_E20256FE X-CRM114-Status: UNSURE ( 7.91 ) X-CRM114-Notice: Please train this message. X-Spam-Note: SpamAssassin invocation failed 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 Jh7110's reset driver needs power management device and clock controller device to work. Currently, the driver proceed anyway without these devices, and invalid addresses (jh7110_inst.pmu_reg_base and jh7110_inst.clk_reg_base) are used during reboot, which causes unpredictable broken behaviors. If these devices are not present, return -SBI_ENODEV. Signed-off-by: Nam Cao Tested-by: Minda Chen --- platform/generic/starfive/jh7110.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index b0b1e35..6990425 100644 --- a/platform/generic/starfive/jh7110.c +++ b/platform/generic/starfive/jh7110.c @@ -243,6 +243,8 @@ static int starfive_jh7110_inst_init(void *fdt) if (rc) goto err; jh7110_inst.pmu_reg_base = addr; + } else { + return -SBI_ENODEV; } noff = fdt_node_offset_by_compatible(fdt, -1, "starfive,jh7110-syscrg"); @@ -251,6 +253,8 @@ static int starfive_jh7110_inst_init(void *fdt) if (rc) goto err; jh7110_inst.clk_reg_base = addr; + } else { + return -SBI_ENODEV; } if (pmic_inst.adapter) { From patchwork Thu Feb 22 08:16:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1902608 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=YHTIIfVJ; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=BCbQrPpA; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=hkN2VLWG; 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 4TgQwQ6mWvz23cl for ; Thu, 22 Feb 2024 19:16:54 +1100 (AEDT) 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:References:In-Reply-To: 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: List-Owner; bh=U276nJkElpQqJvxpNLrqYQ0fXlU8hhNbPEzDZ7l0Nv8=; b=YHTIIfVJ4oHRHM HWm5Sb92P40dTb2r8cI01pWrwzLWf6d46BZbQ3I/zPTTzdo+fvvxNfrg+vk3SzZsiMR/p9CzOgRF0 v0FkPV0EjnVsJz3W+lVH4LnR88nxnw8hsrMkZozfs2d7WvNyHxOAuPtuo1PSC82E5NdELaAIoQlSr qnOxp3XNAvUi10Kw5JR9Xk1iPmH6sgZFtTkcxjFsfLZAsi+9oeJz/U716ZWPmFVBJrI9uXSDz9e2u lkAZFR49SxnDP6Jw0hsIZ3TC5YM9yVM4psd9UU9KknHbNVyqyJhROBGqBTc3p24zRuO5GdJRlKyVX LFANaf32WmFNUhULas1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4G7-00000003y9P-2FB2; Thu, 22 Feb 2024 08:16:47 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rd4Fv-00000003y1y-1gCr for opensbi@lists.infradead.org; Thu, 22 Feb 2024 08:16:43 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708589786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HDPFnYPMK3QFB/MzVfovgFSIF63OuU03XcagLi20GVU=; b=BCbQrPpAyTLZYu2gh5i6hp77EGKK+yJUzSQMs7BNzYWnyDrWghYR/atvDtSlj9unoO/FP6 niGOpVTRv3rCA8Aed8Z5znj/U4qQaQuKUwLOXEHOqUcsZOZTZq83Ij1PYRpu2x4dfxVwPJ nWjsdVGxiwfq9DU3Gst5UOe53QhFDxLpyUM4bZNKQDWc8A72jrmzFNmwgh3ElLrbpGvU4q TvRrXe3RpZxJpQTnuJ/HruVXyCqvjkgLZYrS/i/Flg2fHklgrZE2Xw1I0UtpgAGE/1FBEO v+JkzFn4DDV5mbYpLr4A8iBM+2hnlTMZUOToont/SklwZyt5VpBzxkBpngd+Dg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708589786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HDPFnYPMK3QFB/MzVfovgFSIF63OuU03XcagLi20GVU=; b=hkN2VLWGZiTFqLmccAQQDjIa7Jbqqq2mvdWg7X3KcXsDOY3Z1eBcpNUklyAHp5tBHuMFSL ImKjapfUskAlq8Ag== To: opensbi@lists.infradead.org, cheehong.ang@starfivetech.com, weiliang.lim@starfivetech.com, minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v5 6/6] platform: starfive: call starfive_jh7110_inst_init() in pm_reset_init() Date: Thu, 22 Feb 2024 09:16:19 +0100 Message-Id: <20240222081619.275869-7-namcao@linutronix.de> In-Reply-To: <20240222081619.275869-1-namcao@linutronix.de> References: <20240222081619.275869-1-namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_001635_646286_C4DBBE98 X-CRM114-Status: GOOD ( 10.91 ) X-Spam-Note: SpamAssassin invocation failed 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 function starfive_jh7110_inst_init() initialize some power management unit address and clock addresses, needed for the reset driver. It doesn't do anything else, and also the reset driver doesn't work without calling this function. Thus, it does not make much sense that this function is independent from pm_reset_init(). Delete the separate call to starfive_jh7110_inst_init(), and instead just call this function inside pm_reset_init(). Doing this also fixes another problem: if starfive_jh7110_inst_init() returns an error code, it gets propagated to final_init() and OpenSBI hangs. This hang is not necessary, because failures within starfive_jh7110_inst_init() only mean OpenSBI cannot perform reboot or shutdown, but the system can still function normally. Signed-off-by: Nam Cao Tested-by: Minda Chen --- platform/generic/starfive/jh7110.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index 6990425..c25e645 100644 --- a/platform/generic/starfive/jh7110.c +++ b/platform/generic/starfive/jh7110.c @@ -190,6 +190,8 @@ static struct sbi_system_reset_device pm_reset = { .system_reset = pm_system_reset }; +static int starfive_jh7110_inst_init(void *fdt); + static int pm_reset_init(void *fdt, int nodeoff, const struct fdt_match *match) { @@ -215,6 +217,10 @@ static int pm_reset_init(void *fdt, int nodeoff, pmic_inst.adapter = adapter; + rc = starfive_jh7110_inst_init(fdt); + if (rc) + return rc; + sbi_system_reset_add_device(&pm_reset); return 0; @@ -278,7 +284,6 @@ static int starfive_jh7110_final_init(bool cold_boot, if (cold_boot) { fdt_reset_driver_init(fdt, &fdt_reset_pmic); - return starfive_jh7110_inst_init(fdt); } return 0;