From patchwork Mon Feb 5 08:48:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1895172 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4TT0Rs5WX6z23hK for ; Mon, 5 Feb 2024 19:49:26 +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=rgyEDDMAN2rWRjRfh7k2R+PDxwyUZq8dWQR+TltZvBk=; b=diF8zltaa9BQcz fNVhzKlz18FYGQRzIuwyyG58S/nRaonJaGkEV6kEeUqNzBkN5b9E4y4SRGkO3ocGx27clhOu35g6K 4KFH5f43z3S5nVGrongJs7jB7Xq91Z13ky3GM0k4qcHAQp+qnECvv9SztsrjKlE/75rE3s3IbSAU6 d+OKDzvUKuwAX7L2DPEPBgrla2IBlHyLOPyUZTnGKyQ9G7bGXURlPndkcnSgGMcQNLcuJz3PzkKXZ mprsnRIALRZqvXiNn8ZSy9vvMt0W2EyCi0sMG3iHYc/Ta7IWflWmzn5xwpZLG1iVx/DtztdzERmo1 D6MRPuA4T/sCwJjZis8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWufF-00000002U8u-43A1; Mon, 05 Feb 2024 08:49:17 +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 1rWufA-00000002U61-0mJY for opensbi@lists.infradead.org; Mon, 05 Feb 2024 08:49:15 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707122950; 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=907NVLOi8Lq5cEjQa6Fx1ad8vwwTZ1ODc7T3J4HOzDU=; b=INuQsttZLSMF9nFEwA3ne1Tpghu2H6cq/mtXGr8EBmyma66DgJpyEuuIXZklp6CWf2lvp3 xh3gyV7vMPTiE/aHSQbjieGMCW4Ju7BRpQaxxmN9wsuRD0J5PW3AHDdUJV7hIgNZoJ1s8Y pvNcQQlfkmk/5y583SWj6pFZG9F7OD6jzdzqWAXoERKC5qOHp+4QfNKh/fPZ+MPAHWdlrR wttalNf30Sqhwrqx/re5Bqhhttu7FfFDJQ/RHD4WJuCnD8tQbWS+tWsFpqe608F43zw/gA ZzXDh/tOcgfmSGtN8FvLrGsQD6/25pnPC4IDx8ObfTWpSNl/uqLB8p05Y6+kYQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707122950; 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=907NVLOi8Lq5cEjQa6Fx1ad8vwwTZ1ODc7T3J4HOzDU=; b=I78qqjz6dNyGRnA//D5mTcVkqMEzDxOJ/8pPfY49+o6VG6ssdI1VSnAd+sl8Pp2Zl2dYYy mzcg90MSdihJNZDg== To: opensbi@lists.infradead.org, Cheehong Ang , Wei Liang Lim , minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v4 1/7] platform: starfive: correct system clock device tree node Date: Mon, 5 Feb 2024 09:48:56 +0100 Message-Id: <063d675dcf59e79892091b0ef085a6a2ca4f6bee.1707122766.git.namcao@linutronix.de> In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_004912_383077_9EEACEA5 X-CRM114-Status: UNSURE ( 9.35 ) 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 --- 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 Mon Feb 5 08:48:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1895173 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4TT0Rv3y9mz23hQ for ; Mon, 5 Feb 2024 19:49:31 +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=zbX8IbuPLDuFI9V4M/brtT1BMHLtZSpUjHHIF/NQ/c4=; b=WRcgWsXcve7A6Q 0cCh+V+tPp7Ex1ziT/gxQgQJQAkFfzz4+UuC7+PhimskTjFBDVG/3hG5D0m048OWaDdRWDbdIbl3T W3YhzYODkz3JWIT8GrHUtHZo1PIS3gSDoUB+sfijm9KsfPE+25MXOw2f9D0B2H7EEWmMZvqSYiRDa zqBURMz3pDFEXLKhqmP1oTmeotZ5jUPKjqX0TREKHIRPEIpZAPGd75rMkdkzf1dm75ZiaRvQMJ6wv cL4hDxLcfFVHedRfOqNOJgzC8tZLmE8ATLt/n14q334cQGUXnl0GuP8v9e8EbXDjJkUbQyVdb+3qq 9hkh9GlOMa4YfvWMpqlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWufM-00000002UB2-0T0g; Mon, 05 Feb 2024 08:49:24 +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 1rWufA-00000002U62-1jry for opensbi@lists.infradead.org; Mon, 05 Feb 2024 08:49:20 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707122951; 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=XS7CkOEvohM6MgvvmlbgOtLy89X+AdIo10PMocPYpkc=; b=OAXoIMWLtdrPEa3UQftNf4Zk9X0oGZTUuOu0vzq0fZLsLE0YuZk0gXe5hroG+8l190DLFA 2QXPs7TamLsP6l7IyBFTau0OyROjmbYUMGXTgyLFlnFnj+ODQqxfiDz8AyWZEgnuyS3zWf +v4cMNnI0lFMWayDzeApKHG8FFzULambdt8xbZcvdZ35WslIzi1lVRtaFEXbe88YgPbgQr inK2x/OHoStiGIAUkkDHm53kSn+9E2OZ500/IOB2ccEydodVcc478xHesuW4VPCHVOwpzo kxbWz5DVgHcOL7sdVPqrz4/Jl3L97kRx0jY0UZ8hgt4zwk62Yjr8l9IODwNIAA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707122951; 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=XS7CkOEvohM6MgvvmlbgOtLy89X+AdIo10PMocPYpkc=; b=sASZIf/IZW6clL+Ha1hqfVbQwY4qeZ4ozZHQ10WbetJ5yv4IwCqN+N2892XkCJp3mj7D1X LcRCvD1NCAnXPoCQ== To: opensbi@lists.infradead.org, Cheehong Ang , Wei Liang Lim , minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v4 2/7] platform: starfive: get I2C offset address from clocks property Date: Mon, 5 Feb 2024 09:48:57 +0100 Message-Id: <3784b87136c66eb78a980d258fad4dd4a8ba483f.1707122766.git.namcao@linutronix.de> In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_004912_633925_379D021C X-CRM114-Status: GOOD ( 14.11 ) 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. Reviewed-by: Minda Chen Signed-off-by: Nam Cao --- 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 Mon Feb 5 08:48:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1895176 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=kDTQffYC; 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=VVAl+eCZ; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=ygwbMUPm; 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 4TT0Ry58GFz23hT for ; Mon, 5 Feb 2024 19:49:34 +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=sQM45uIyoc1DU+htCeXnT5JKt8jKjU6lLRg12IfS/ME=; b=kDTQffYCL0POxM UsimIK2O8vh7A/9EHMVJjXBIlfU1pr5mM4sm8zNuMzFj7MqdjK6rr+Sf6pFTzZCaZZwWA5/2gwkgT 5dhvmU1p6xqoyHJ5CElNzKAhTfl3X4SQZytt9QIe1ExoXlBubWfZC+UTDKHbJ21xk0S9dTVH8MG8W 5o4vplz9wQW0Qv4Tax95b6V4Se6y5kOgB5pw8jasnSCaxRuChexu5uvn2LOys99mYyZXwBU6lxNhK jhBfRTdAqTNa92vKQl6Ko/uRYs7aPXIdFpiVWG09v1DtzLLqoQTe/ScnfWhLdzVBcs5tD7AsEbRSl l5rAWtB/x9j65oDzDpmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWufQ-00000002UDa-0pxI; Mon, 05 Feb 2024 08:49:28 +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 1rWufA-00000002U63-3FLF for opensbi@lists.infradead.org; Mon, 05 Feb 2024 08:49:24 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707122951; 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=sNGyk1icJrjZda04INFGtSwzFZF0AoHMpyix3vIpvVk=; b=VVAl+eCZDyoiu2jnztJJg3KS+5YYbIMQwhAbAWmHASfIMJFrfXNOdQWk9FJ9Th9n0Q7EYW wKjDZ9GxKQH1ydO9hnaDMKLjMtopspAsBbSn7ZFIIy4oeLEndwd/+5a6cNExfeCp40lz+D PXo2NHzaEEH+ARjzzRZkZAQfX2Xz/dzQnN4vjI5MIMk7li1Ujm4Oqqnm0qdeREb73Dpp28 uMgjcXdKLLLorhgU+jFBSMQuoPJI2yJdlqsA9Dg4woeXM77UcDVOKfbw48TQ3u5vGApzog dhxQjsE73IODL59kWQupcZ0JkKdyBb2lghaBrwRjTgdDVd6Kzc/4FNpxS+K0Mg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707122951; 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=sNGyk1icJrjZda04INFGtSwzFZF0AoHMpyix3vIpvVk=; b=ygwbMUPmdP9tZb1l+QQIWbzCxCH/r5rccP+ZM/ZFOLEpAIRf4IGlKdefxq132MaZRw6fOm LAon4Kg1yFeqDMDQ== To: opensbi@lists.infradead.org, Cheehong Ang , Wei Liang Lim , minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v4 3/7] platform: starfive: remove redundant compatibility check in pmic_ops Date: Mon, 5 Feb 2024 09:48:58 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_004912_994833_95F51D59 X-CRM114-Status: UNSURE ( 8.81 ) 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 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 --- platform/generic/starfive/jh7110.c | 36 ++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index 308fe39..1956fd8 100644 --- a/platform/generic/starfive/jh7110.c +++ b/platform/generic/starfive/jh7110.c @@ -133,28 +133,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); - - if (ret) { - sbi_printf("%s: cannot read pmic power register\n", - __func__); - return; - } + 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; + } + 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) From patchwork Mon Feb 5 08:48:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1895174 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=LC10OD4z; 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=o262EjnF; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=P1lcKgki; 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 4TT0Rw5bZsz23hS for ; Mon, 5 Feb 2024 19:49:32 +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=jWK8KXQSMqcT4rqNsk2p/xDHwIn/E5y8/9oxI4fzXNo=; b=LC10OD4z3Z3CZo o+BfXcYhHx5SkzD8nK08fNYMZDYzZ8kzst8xtmt3TOiTwY75IoevjsXw8oA+KmZmY61wCq7MQ+QFV 6qgDgSkeXmjJueYS5Igl6Fa1m4303uCGL+eV0Aore9g8X3juqBiaD4OiL+6/uP19Y1sTdI/cRAgsj e+gJfEG9hrz1bb7YbgUVgHpK5j1ymb/bLLKAexiyNgoEmaVMhKmlKQ1YiNizK5ANupPj7kNzAqdfu p/Yml4OcxV9EcyXY6DVc69Jh4WIsPjhaAWjXZUorcnwqpzHnrRiDIukjIgykQjiCX9jFjHWafIRZe YYfDZwvZ/dvJHCihB1Hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWufO-00000002UD7-0rib; Mon, 05 Feb 2024 08:49:26 +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 1rWufA-00000002U64-3fnu for opensbi@lists.infradead.org; Mon, 05 Feb 2024 08:49:22 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707122951; 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=yDm7QVf2TvdazyoDf3Ajv3aK3I+4QCoW4LcA99uDVU4=; b=o262EjnFzxazU1eO5kPZeCLlzFdeMtm8uBDqEYLje1+I0dklEdw9ivXFNZ69Ms5RMomyC2 AP3inj9dNrHHl7fiOkphbpDBv43dA/biqbvIqm0dvHq1eEo6MV7mfnY5gVZHrjp96jBv5D VNvqDOw61a6nDa2N54LZUVKs43yJ1KomhTFJoVyPhC5iRyHhFuZzE//yJoezW4OZrLv39W B6Mz8sdjFozvTaYJ3MZ4UhTpxIRnz+u3V02mfaL9LhRrL2RhayYStiRZ0jR6o9UrPyjXf3 L/OvWcRj98T87yiQON9xEDoTtljqX/0HpcHy++BdYAAxfMsxjQ8KupAtN9CYxw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707122951; 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=yDm7QVf2TvdazyoDf3Ajv3aK3I+4QCoW4LcA99uDVU4=; b=P1lcKgkiAAxgSzd8gAn8tUWR3uOCPmwk1IfuRCZ6z+vtOqBk3yuUZafCfwST49Slv0I66Z oBTPc85nZsaG+CBg== To: opensbi@lists.infradead.org, Cheehong Ang , Wei Liang Lim , minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v4 4/7] platform: starfive: rename "stf,axp15060-regulator" -> "x-powers,axp15060" Date: Mon, 5 Feb 2024 09:48:59 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_004913_095045_3118E02C X-CRM114-Status: GOOD ( 10.85 ) 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 --- 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 1956fd8..1f7cfe2 100644 --- a/platform/generic/starfive/jh7110.c +++ b/platform/generic/starfive/jh7110.c @@ -223,7 +223,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 Mon Feb 5 08:49:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1895178 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=eBGTsO62; 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=lAg3N8wd; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=CX6+Eq4c; 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 4TT0S20ytdz23hQ for ; Mon, 5 Feb 2024 19:49:38 +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=+DF4Qq6qLI0rXxbJGV4+54hd/buo0ZFMnrUsOGBhGUM=; b=eBGTsO62MmTPQS Xi4DjzKs722G9yDSdIp3rZM3veifq1HBXmIsk9ml+CPZJknbbB2wo8jcOonlFzVVW0RwxwtyRGJb4 O2ss2EtKsQPi4kIVpJnSFtlKv6B0S1B5zybd0VSECA+O/f0JuCsP5PIM08dqygOiN+6vUHFxnNhnf FK0PfY4lPbBZmcZUmwxJ9lw0V7iAuJYoLczEI55MeTOIo5Mordbxp/Lt8LGoiC8WdanMQnB99QP6C YC/bPG+DYFyr9JbvsqCPOYYRwH8e35MkwTcS2pAmqDEHtzd5C8mBUabwdAbIXVyqeopjEgl+HmaQl aDfTrRoUQxiEDphaRg8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWufT-00000002UHP-3OH1; Mon, 05 Feb 2024 08:49:31 +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 1rWufE-00000002U7m-1gY2 for opensbi@lists.infradead.org; Mon, 05 Feb 2024 08:49:28 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707122951; 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=KmbZ6Z+DGjyU4Qc6Pk8p4vrjhpWcABYPw4muEaAGS6U=; b=lAg3N8wdSnRsuTy9cufq4y4VpHsr7UEV+mTXiqDddfAIVpPjeoRHceSATYOecTlRxYoM8J kgt/98uUCFjXDGJuqk8asEt77mRmVLRgfMsDR0H0zeh1i+DouobtjlSac64tov6I+jiv7B Y+jm+IfH+z5WotlDyrVdZu7tmrxze3QLawh9PnNaw17vDVpscmSU8Fdyddc3pLlQ23QjGU 9L+jg33eVAP0D7JCbXogU3gYKY9YNbam7YKOfEniUTI0nrH+qF8DMfkxMSrC7bcIEpl/4C YLo/kEdUsklmfsX8Fy5SSPnDAp9ZXzMM5rU/1gDzjRxNfp38XsXpT8XbkGvFkg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707122951; 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=KmbZ6Z+DGjyU4Qc6Pk8p4vrjhpWcABYPw4muEaAGS6U=; b=CX6+Eq4cbRev/udRkD07WW082f3asBpLTcv1Qc/FokPQiMtl24RpdKrz5mNQO1n1xy940S TZHhLTD2odT7EsAg== To: opensbi@lists.infradead.org, Cheehong Ang , Wei Liang Lim , minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v4 5/7] platform: starfive: drop "compatible" from struct pmic Date: Mon, 5 Feb 2024 09:49:00 +0100 Message-Id: <23b797311f400cd737a7261a4f84fe30291695d0.1707122766.git.namcao@linutronix.de> In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_004916_741576_2A90F75F X-CRM114-Status: UNSURE ( 7.02 ) 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 The member "compatible" of struct pmic is not used. Delete it. Signed-off-by: Nam Cao --- platform/generic/starfive/jh7110.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index 1f7cfe2..b0b1e35 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 { @@ -204,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 Mon Feb 5 08:49:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1895177 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=Dt9y6G0j; 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=ZASyr7es; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=dsdpW9gh; 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 4TT0Rz5yl1z23g7 for ; Mon, 5 Feb 2024 19:49:35 +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=KzVHoblqyKmV3TMFQNB95I7IR0Px7e8rQ7SrvXGkHyk=; b=Dt9y6G0j6vMX9f RBcmpmZx/eX+CxGG74M9HDkMI+MHXFVWRI+ixvKn+1ADVy3xSbYZ/PI9Ggcgvc1SCUt7fWMzNXF+p xlr/TeyUBztqieJfSO3fdU/AZwniv+TVp1kYUt1T69kme3mfjgxKQ2YI7VrmXxxCh8KhiQJGTQDNk eDyyHHgNVsGXKcxyj4rFLokGfVw0IJ2o1l/TsZmi2kKgT0dBOgyHRRanGIjKJwWuK4NtZfsn7Qypz GRWX1o+7uPlY+37jlkaAiQ3IffH03iEdWBgrERDD+lR3bqbYX82K+5pHZ0TjoqaUhafd0+UwGoRB4 rtiXKILznQqms2KFLdWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWufR-00000002UFC-1amL; Mon, 05 Feb 2024 08:49:29 +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 1rWufE-00000002U7n-1jvm for opensbi@lists.infradead.org; Mon, 05 Feb 2024 08:49:24 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707122952; 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=Imk/nC1QLhg4oP/xebCpXuBf+37v8OriidyOrcVloJM=; b=ZASyr7estlIFJA70B2PWG3+XPNF9G6fpAaOOed2szpP25YtOpcwEEYg7Q2FN91tXrKTdI+ 9mJmOJpKIpb8cBCuCPtSmANf3/LQ56Q22AQu0+XuEyJFXpXs4adqa8Sv8znC+KNBYgW5Yp J3hBmdFXovPw5H4UPduoEVhHfrZsM/rFvEjQ9ntRz1/MmVlRUVUebJezeD5CBhok3YBLG8 6/Bi/hgLz66D3bMBNlvDxrjEtO7IF0pVOjbC8S3oMLQS1uJ0Er3vq1aYSdcs6S8zDJiE1t wjeibVyM253uM1zUIWXq5pjvTxGUCp8x0LQB30l7D5uTTzWVXZwJdzCk6ujMfw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707122952; 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=Imk/nC1QLhg4oP/xebCpXuBf+37v8OriidyOrcVloJM=; b=dsdpW9ghcsMI5mlC+Ntsx8QAgZRPULG+O91VZ8AliSyT/bfLtXPsxUhFb4kf/yB3ZueZex ZYbfnMoWfi9ZdNBg== To: opensbi@lists.infradead.org, Cheehong Ang , Wei Liang Lim , minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v4 6/7] platform: starfive: return error if needed devices are not present Date: Mon, 5 Feb 2024 09:49:01 +0100 Message-Id: <6cf247a45ca69412337ee7ff163c530263d5d8ed.1707122766.git.namcao@linutronix.de> In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_004916_689853_1F708488 X-CRM114-Status: UNSURE ( 7.94 ) 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 --- 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 Mon Feb 5 08:49:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1895175 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=ZJeZ3tb7; 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=vircfyvV; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=OaT1G9wd; 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 4TT0S06vRBz23hK for ; Mon, 5 Feb 2024 19:49:36 +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=l55Fpn8SNBsKkrA3njM8mcFgsQnpp6En0WIvNVK5RUw=; b=ZJeZ3tb7ZFfo9S ORAm+GtN77hlmtp49QwuIwEPQGSTg+vx6HwPBguVlw5XKvGIRYmB4xZ4Hr5/5dCt8nhZGkcSSPyNj 6k5Xi/9YW0xXwGku+NlnYp5OWwKy/5y1yYWPm5IntTogNW47nPZRiXxdgOVHIWGU6txNiTVAFbBxC xMD+QRwwGksTH5780HP0Sf9Gp8OFE7452puDdcWAp4L41GTZNQ/fYHh6yGUuylKxbrObm9JgZa+h8 AP72W1x5fs9bSDPrLMvSaoaPP5FtZmTHdD+I/mlkLsulCYjHQ3/kpU6EKfTCs4zvtstq8RR7pNyNM TTPI0qH5JLWSVhaE8fbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWufS-00000002UG9-2DaX; Mon, 05 Feb 2024 08:49:30 +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 1rWufE-00000002U7y-3Daf for opensbi@lists.infradead.org; Mon, 05 Feb 2024 08:49:28 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707122952; 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=JW6PH8OB9JQgF5j8x3rfrsQghcJdT3L6Lo9d+zPd3yU=; b=vircfyvVDTp8lFAEuZTh/zkhKRuAYvsDD3xuax6KFy2bJ5JfgD1sPpwimreS78P8r3wl4Q TpUixPVxQQO7c8FiKgoAfsE7rGaC6s2XVGZwDcLQqyLmsHMtvAzj+f3Yv4FtC9iX8dg9N+ 9vclAy43wuQx0ScxJcQUFZborilQfSBC2Vp3f8BN7wK9hdefgAZwUFht1pt8N9pZdHcjnr e1dvCoY8mGnWxSJUu901FcIZerjXq3BSxP04H7wLTYgiIb28QWWsrYYJUNK/PytOrCvlN2 K/rY/1+BX3tO+O2oh8q7zJHVgFaseIkfELLy0kcuWJBliA1Lps+eMuGWVbKo7g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707122952; 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=JW6PH8OB9JQgF5j8x3rfrsQghcJdT3L6Lo9d+zPd3yU=; b=OaT1G9wdebXxkTfGbi1OoXkuLTrIQpmGElQzBaWxP3P5AH16xD5e/rZJLUHdwtsHCFH9sX wuKk07EzuaqT9ACQ== To: opensbi@lists.infradead.org, Cheehong Ang , Wei Liang Lim , minda.chen@starfivetech.com Cc: Nam Cao Subject: [PATCH v4 7/7] platform: starfive: call starfive_jh7110_inst_init() in pm_reset_init() Date: Mon, 5 Feb 2024 09:49:02 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_004917_391317_10A7652A X-CRM114-Status: GOOD ( 11.04 ) 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;