From patchwork Thu Jan 18 09:20:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1887830 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=FYJPTDHb; 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=cf85eCLn; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=ZVTLQ1B0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.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 [198.137.202.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 4TFy0L74zTz1yPJ for ; Thu, 18 Jan 2024 20:20:50 +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: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=sldodUsALfrLsL13VDZBQdJv5eWUZ+fI2u/wJOtc9io=; b=FYJPTDHb9YUeKx pxxtYY3eOZXncK5wBgwciEBYObvz6msz7GkaJi1bTTE7LH013gUPRQmZ7YpEGEQ7czqpL6PvtPUIN zGrEFesPZlsxW5HYTEH8qlE3UtgNJXBfc1IyFsbr7bsu9fsiWUjYbEQYoAl908Kkut6O1QIlhdBW5 CcKgFlgcjo2wqeYC8sUVdj/8lHzLmNAx+EvVMUh43Ie/VunoNjWzF63l43yJYZllvUK79Ypksvriq Lc6RjiSOJHgHb3a3x3ytpEAG7+BtrENwQt5JIlmTcz9Zoi27Lriei+zaTlnb+vRejpf77mMyLY0g0 6kOVm07zNdwbw11Kkbyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQOZU-002Ftx-2A; Thu, 18 Jan 2024 09:20:24 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQOZS-002Ft9-0R for opensbi@lists.infradead.org; Thu, 18 Jan 2024 09:20:23 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1705569619; 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; bh=6P61YSyz5XOL/RUq/CsVdW75XXnzppbqdztsYxhwoVA=; b=cf85eCLn4jjfDBMR7R9WjUxAP/yZi85N485iHyuTe7lXFnwG6PZ31NJy5EGb0zmejdkcLU MdsC+l1aa28qO8+PdezibZyGVNQYUXFJT49O3L2L1/hUf5nbQoK1rSBAhNwelZmaXXZYx6 O0BZQ2TeiSilzmPukrjGaGahQYutabDjy0ECRCIPBtRwE7b/BiO7vHmodgKuoUKbOxeJm7 Q0MtNnZR4nDOgpZfbULRH4L+ntKGEq/Dxmgtu5/8mMxXppBcz75SWbFjBgw/EbmhPcl+g+ LrJf+B/szgtsaHb8AGconiGyH5eIPqlUCibiutfnuDP661wb+sKL+nRcLehvhg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705569619; 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; bh=6P61YSyz5XOL/RUq/CsVdW75XXnzppbqdztsYxhwoVA=; b=ZVTLQ1B0kBCED1//l/9GAgsq58OSHnmAuyHvlQH9zxQ+cG1h8ZCnvEl/FIQi1Tcvxm8wQB ndApBessQxlnfXCA== To: Xiang W , opensbi@lists.infradead.org Cc: Nam Cao Subject: [PATCH v2 1/2] platform: starfive: correct system clock device tree node Date: Thu, 18 Jan 2024 10:20:09 +0100 Message-Id: <55183c9a19dc5fc4dd9152c0055016b076ac9c23.1705569454.git.namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240118_012022_320464_A994B17B X-CRM114-Status: UNSURE ( 8.83 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.5 (--) 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: 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" [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [2a0a:51c0:0:12e:550:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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 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 --- v2: no change. 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 Jan 18 09:20:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1887831 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=jb05cV6N; 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=O2w59Kt/; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=/sqMfxkC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.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 [198.137.202.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 4TFy0M02f0z23dx for ; Thu, 18 Jan 2024 20:20:50 +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=k5MWXs+KiRhkUn3Ptq6Q+h8x8pb0kRwNYgSUJlzu/ZY=; b=jb05cV6NR2pQvd gRKO1oNfdR7P0/Q8jeAJQPxVuujW7IDsZxjCGX7Ve3UbNZzqebva+C+3OvvOLmp4VZfqHZMFNCI+v TiUrJ2jrk0ye6Zklzf3adj0DVBCt93DMpxqrzAAT3TiRkYLv5CSrnHMDXVNDuhRAXTqVDbjl8pmAh +ZtfN4xXLTBC2LJUDzmAvL94KT3iSUXkjdB19LCMtKL/RkLTNe9ad49/7VqgkJz5ipc0T0GAWMPAf knpdky4Pw0T/9+zxBYC/fQeDB7HfK4mdRAYZb0aP6yHYn4UPdh2f0qdq85FR05HI/EcTp1OH+ZX+b NZ/rlShErUx40PtuuIHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQOZV-002Fu8-0Q; Thu, 18 Jan 2024 09:20:25 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQOZS-002FtD-0f for opensbi@lists.infradead.org; Thu, 18 Jan 2024 09:20:23 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1705569620; 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=7pcTgRF8givB1jgzQ8eO20ERFNmSyMFdLX8SBlVGzVg=; b=O2w59Kt/HgxabMtwUpCrLwd7KCEmrk623vNnLXo+q5jglXQ1lsmVzwqy9V4nf4ysEzEntw JsjD2R7aWt6wKANilexxgJzC1a+wyFMZFGCRqzW2ul7HypYOkfo1isZCkfLSGiJQlKOmJW 0+wYFj6nEedss+xEpcoJWdb1V8ORGKXSnbhX4Cqijz/gAFyl/wIu2aa+TuRQsgZJ75TTPp QDoHpiUl3j/p7Cz1QgWRmhPSNvpMoqObE1PKHbfwWosNchUY3bInMJd+vvyCSAAlHXa4rq kXif7s/TsVaoCSve9aAeQMvQcnUxydffwbxOsxmVGTCdFe+rX7IyW+2JDHCzxA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705569620; 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=7pcTgRF8givB1jgzQ8eO20ERFNmSyMFdLX8SBlVGzVg=; b=/sqMfxkCk3t0sX3ekFxuWNST0+1BiUuC/sdnUc0YbpRvsXNuPI7CtTJ5oS0MNK8LSY/iZU zqS0ejAGYGODjWCA== To: Xiang W , opensbi@lists.infradead.org Cc: Nam Cao Subject: [PATCH v2 2/2] platform: starfive: get I2C offset address from "clocks" property Date: Thu, 18 Jan 2024 10:20:10 +0100 Message-Id: <3ddf6f902297c6e673a6abe517a1cc5497d03294.1705569454.git.namcao@linutronix.de> In-Reply-To: <55183c9a19dc5fc4dd9152c0055016b076ac9c23.1705569454.git.namcao@linutronix.de> References: <55183c9a19dc5fc4dd9152c0055016b076ac9c23.1705569454.git.namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240118_012022_391685_079A2779 X-CRM114-Status: GOOD ( 14.48 ) X-Spam-Score: -2.5 (--) 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 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 de [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [2a0a:51c0:0:12e:550:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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 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 --- v2: - also remove the now unused macro I2C_APB_CLK_OFFSET (Xiang W) 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; }