From patchwork Wed Jan 17 11:16:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 1887374 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=HNnxu8EA; 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=Py4V/sbE; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=Wpjb80JS; 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 4TFNdT4sNPz1ygb for ; Wed, 17 Jan 2024 22:17:33 +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=rgyEDDMAN2rWRjRfh7k2R+PDxwyUZq8dWQR+TltZvBk=; b=HNnxu8EANkKUA/ 3dMG+/yW9UbhuHeCYhb9l0fT5YVIPojto5nGb+2xkIjnyM2ld/mPNF5koE7xsBNYXBrKn3W2oWOrK xhG3GsjAJ4Dxk0FBnbnYXMLYxtreqBOABHXsmvGkDG5J4avle7Ne5GDIMq1jSgBqtZz5nirth8vSl 1BGcFmj5kbFQJMco+5ePnTgdOf6NJ1YavGddd2y/wNJO8w9SwtQ4WwG5rs6c2dXQarbrW8k7FqVQr Nk2GWbFp/PotYKjJ1mcoA18/JMMXSlQ1Mv9hqFON8cP1zZvc12E/Yr2K6gbwVpiPtN+feD8kmWk6j 2+mgvHro08GHaz9vrtjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3v1-00FQW6-1r; Wed, 17 Jan 2024 11:17:15 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3uy-00FQTm-2Y for opensbi@lists.infradead.org; Wed, 17 Jan 2024 11:17:14 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1705490222; 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=907NVLOi8Lq5cEjQa6Fx1ad8vwwTZ1ODc7T3J4HOzDU=; b=Py4V/sbEL38w3DnDmHWtOhxj1dlbQCYgAWA22h2pZ+y0qlEK27IhEcBPWZhAeRG7NossMi xfO8XcU5SeC7VjdUrHKet1gTDrft945qR7Z8uj294pdG0R8pXkapoAEQ1ybVp1F/rqfn1J /Ac2y99VOEKg6hbElp6ToS763LNL5Mgq2NMG1iUjooC6zIYpJrH0xztZOdYuVJYAFqpar4 C1qa308At1KI2G8e4mr6lYCkayeLVpYu/NHrqLjYINiyHYrXXVPuaxlCJiR8mP25BsCnsf pDEOXkiayvb12qZSilBHQMNBT1osfp85xQS9EntrT4yUJZjQ/d8yvcoVzw3xjw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705490222; 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=907NVLOi8Lq5cEjQa6Fx1ad8vwwTZ1ODc7T3J4HOzDU=; b=Wpjb80JS5fMLDJP/5EnSfx3eYn3FBsJDkHD4mrUPBPfIi4TRABtp4n5qCUKPZNVV0Ehvpg xMpGI1HggGLJfGDw== To: opensbi@lists.infradead.org Cc: Nam Cao Subject: [PATCH 1/2] platform: starfive: correct system clock device tree node Date: Wed, 17 Jan 2024 12:16:55 +0100 Message-Id: <088ccae83cf0165d1390627d7e2e782d74941e62.1705490088.git.namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_031713_008071_71F8904A X-CRM114-Status: UNSURE ( 9.03 ) 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 [193.142.43.55 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 --- 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 Wed Jan 17 11:16: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: 1887375 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=SkCyzDyL; 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=azoTLLOM; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=LyGZqX+V; 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 4TFNdT5Hx1z23dx for ; Wed, 17 Jan 2024 22:17:33 +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=sif6hCbHH0AluqfVWdvx7WUBe0Yb33Kao9AOuAT7YTg=; b=SkCyzDyLPvV2AP n0tah6av6rNd+8XDqvXEhND+lLtBVU4CiqsVHXm4yK59N5S7tIVpoQJuxmRlIAD0IzgfnoU2eth2g CZUNDlKHS1OydyJUhtnNVSawGAec7duYZ9hzHmYFi/zodXD+IKa4D4428Vbc+nC8uiurZgZwe0Jr8 KAJC8Srr+wBMoCGr2FUDzgskhlTjnQS+PR52FOUB27YMqw7SNu9HV1QiBKlc8R27lLKK+R1nYOzxJ aYUNrzOQBf5AZrkKNm2tAAT8ANFRAi1iMqzwnwiMqjDVUtTn55fK3GYGOhWxUfwCShIaMlntIqJIT HVrEv0FYiIGoitrEqYyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3v2-00FQX1-2Z; Wed, 17 Jan 2024 11:17:16 +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 1rQ3uz-00FQU6-2M for opensbi@lists.infradead.org; Wed, 17 Jan 2024 11:17:15 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1705490226; 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=jFGjokFD901GS3OfOOvV9JF6VaY4EiNBgPX36Q6l3uc=; b=azoTLLOMev2WvP8MtsPqCMDsW1BXM93LYZolA77l7hqbsfqaQLAgM64DKY6X1TMIv4Ehiv 45VEOTnE5Q8MUOiO//pHVfJWLN06GAB5fH3drNxWrLOZ2rzHfxtZBQttMI/Dyr8ulBdk32 v+SRFW4abbOHc0QqxxqJfKaU7E/eXhV9ywPKJE+3SQ4aSvC9UNghjghIcQwxIrlagluafv 9YKTMGYsjcsDC2/szCUEC3Mt6Qy8FOOdgKeszBGsfqjnoBxBJHSmM2PpkcWUPXO5fAiqVl FhVi4DAFgtbquO4ebEsjSU+4yueQA4x09S8/PTjWqngy1rnqBP/hImBN+Eo2gA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705490226; 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=jFGjokFD901GS3OfOOvV9JF6VaY4EiNBgPX36Q6l3uc=; b=LyGZqX+VhVA/K4SMfjjGWgIjsQ3oaOj3dxGM7PavJkzRTJ1gL0MMNOc79wkIWHNCPFtUZ6 cqXhJK2ygpZsD9DQ== To: opensbi@lists.infradead.org Cc: Nam Cao Subject: [PATCH 2/2] platform: starfive: get I2C offset address from clocks property Date: Wed, 17 Jan 2024 12:16:56 +0100 Message-Id: In-Reply-To: <088ccae83cf0165d1390627d7e2e782d74941e62.1705490088.git.namcao@linutronix.de> References: <088ccae83cf0165d1390627d7e2e782d74941e62.1705490088.git.namcao@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_031714_000684_6894D204 X-CRM114-Status: GOOD ( 13.75 ) 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 --- platform/generic/starfive/jh7110.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/platform/generic/starfive/jh7110.c b/platform/generic/starfive/jh7110.c index 4b22175..846b068 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; @@ -163,10 +163,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 +238,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 +259,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; }