diff mbox series

clk: en7523: fix rate divider for slic and spi clocks

Message ID c491bdea05d847f1f1294b94f14725d292eb95d0.1718615934.git.lorenzo@kernel.org (mailing list archive)
State Accepted, archived
Headers show
Series clk: en7523: fix rate divider for slic and spi clocks | expand

Commit Message

Lorenzo Bianconi June 17, 2024, 9:25 a.m. UTC
Introduce div_offset field in en_clk_desc struct in order to fix rate
divider estimation in en7523_get_div routine for slic and spi fixed
rate clocks.
Moreover, fix base_shift for crypto clock.

Fixes: 1e6273179190 ("clk: en7523: Add clock driver for Airoha EN7523 SoC")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/clk/clk-en7523.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

AngeloGioacchino Del Regno June 27, 2024, 9:35 a.m. UTC | #1
Il 17/06/24 11:25, Lorenzo Bianconi ha scritto:
> Introduce div_offset field in en_clk_desc struct in order to fix rate
> divider estimation in en7523_get_div routine for slic and spi fixed
> rate clocks.
> Moreover, fix base_shift for crypto clock.
> 
> Fixes: 1e6273179190 ("clk: en7523: Add clock driver for Airoha EN7523 SoC")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Stephen Boyd July 8, 2024, 9:43 p.m. UTC | #2
Quoting Lorenzo Bianconi (2024-06-17 02:25:49)
> Introduce div_offset field in en_clk_desc struct in order to fix rate
> divider estimation in en7523_get_div routine for slic and spi fixed
> rate clocks.
> Moreover, fix base_shift for crypto clock.
> 
> Fixes: 1e6273179190 ("clk: en7523: Add clock driver for Airoha EN7523 SoC")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---

Applied to clk-next
diff mbox series

Patch

diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
index 9757023601c5..9804fce7872d 100644
--- a/drivers/clk/clk-en7523.c
+++ b/drivers/clk/clk-en7523.c
@@ -62,6 +62,7 @@  struct en_clk_desc {
 	u8 div_shift;
 	u16 div_val0;
 	u8 div_step;
+	u8 div_offset;
 };
 
 struct en_clk_gate {
@@ -106,6 +107,7 @@  static const struct en_clk_desc en7523_base_clks[] = {
 		.div_bits = 3,
 		.div_shift = 0,
 		.div_step = 1,
+		.div_offset = 1,
 	}, {
 		.id = EN7523_CLK_EMI,
 		.name = "emi",
@@ -119,6 +121,7 @@  static const struct en_clk_desc en7523_base_clks[] = {
 		.div_bits = 3,
 		.div_shift = 0,
 		.div_step = 1,
+		.div_offset = 1,
 	}, {
 		.id = EN7523_CLK_BUS,
 		.name = "bus",
@@ -132,6 +135,7 @@  static const struct en_clk_desc en7523_base_clks[] = {
 		.div_bits = 3,
 		.div_shift = 0,
 		.div_step = 1,
+		.div_offset = 1,
 	}, {
 		.id = EN7523_CLK_SLIC,
 		.name = "slic",
@@ -172,13 +176,14 @@  static const struct en_clk_desc en7523_base_clks[] = {
 		.div_bits = 3,
 		.div_shift = 0,
 		.div_step = 1,
+		.div_offset = 1,
 	}, {
 		.id = EN7523_CLK_CRYPTO,
 		.name = "crypto",
 
 		.base_reg = REG_CRYPTO_CLKSRC,
 		.base_bits = 1,
-		.base_shift = 8,
+		.base_shift = 0,
 		.base_values = emi_base,
 		.n_base_values = ARRAY_SIZE(emi_base),
 	}
@@ -281,7 +286,7 @@  static u32 en7523_get_div(void __iomem *base, int i)
 	if (!val && desc->div_val0)
 		return desc->div_val0;
 
-	return (val + 1) * desc->div_step;
+	return (val + desc->div_offset) * desc->div_step;
 }
 
 static int en7523_pci_is_enabled(struct clk_hw *hw)