[PATCH 4/6] arm: socfpga: mailbox_s10: keep clock rate in Hz

Michael Tretter m.tretter at pengutronix.de
Wed May 6 02:06:10 PDT 2026


The QSPI reference clock rate is retrieved in Hz from the firmware, but
stored in kHz in a handover register.

Initially, the clock rated is stored as Hz in clk_khz, and later
converted to kHz before printing and storing it. Initially the warning
prints the clock rate in Hz, but prints kHz as unit. This is confusing.

Leave the clock rate in Hz, and convert it to kHz when used.

Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
---
 arch/arm/mach-socfpga/mailbox_s10.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-socfpga/mailbox_s10.c
index 4199c4fb913a..c6ea081165d4 100644
--- a/arch/arm/mach-socfpga/mailbox_s10.c
+++ b/arch/arm/mach-socfpga/mailbox_s10.c
@@ -300,7 +300,7 @@ int socfpga_mailbox_s10_qspi_open(void)
 	u32 resp_buf[1] = {};
 	u32 resp_buf_len = ARRAY_SIZE(resp_buf);
 	u32 reg;
-	u32 clk_khz;
+	u32 clk_rate;
 	int try = 0;
 
 retry:
@@ -331,20 +331,19 @@ int socfpga_mailbox_s10_qspi_open(void)
 	}
 
 	/* Get the QSPI clock from SDM response and save for later use */
-	clk_khz = resp_buf[0];
-	if (clk_khz < 1000) {
-		pr_err("QSPI: Unexpected reference clock rate: %d kHz\n",
-		       clk_khz);
+	clk_rate = resp_buf[0];
+	if (clk_rate < 1000) {
+		pr_err("QSPI: Unexpected reference clock rate: %d Hz\n",
+		       clk_rate);
 		return -EINVAL;
 	}
 
-	clk_khz /= 1000;
-	pr_info("QSPI: reference clock at %d kHz\n", clk_khz);
+	pr_info("QSPI: reference clock at %d kHz\n", clk_rate / 1000);
 
 	reg = (readl(SOCFPGA_SYSMGR_ADDRESS + SYSMGR_SOC64_BOOT_SCRATCH_COLD0)) &
 			~(SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK);
 
-	writel((clk_khz & SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK) | reg,
+	writel(((clk_rate / 1000) & SYSMGR_SCRATCH_REG_0_QSPI_REFCLK_MASK) | reg,
 	       SOCFPGA_SYSMGR_ADDRESS + SYSMGR_SOC64_BOOT_SCRATCH_COLD0);
 
 	return 0;

-- 
2.47.3




More information about the barebox mailing list