Skip to contentSkip to conversation

clk: at91: clk-master: Add check for divide by 3

PATCH In review [email protected] 2 participants 3 messages Sep 8, 2025 – Sep 15, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: at91: clk-master: Add check for divide by 3

From: Ryan Wanner <[email protected]>

A potential divider for the master clock is div/3. The register configuration for div/3 is MASTER_PRES_MAX. The current bit shifting method does not work for this case. Checking for MASTER_PRES_MAX will ensure the correct decimal value is stored in the system.

---
 drivers/clk/at91/clk-master.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/clk/at91/clk-master.c +3 -0
index 7a544e429d34..d5ea2069ec83 100644
@@ -580,6 +580,9 @@ clk_sama7g5_master_recalc_rate(struct clk_hw *hw,
 {
 	struct clk_master *master = to_clk_master(hw);
 
+	if (master->div == MASTER_PRES_MAX)
+		return DIV_ROUND_CLOSEST_ULL(parent_rate, 3);
+
 	return DIV_ROUND_CLOSEST_ULL(parent_rate, (1 << master->div));
 }
 
Signature · 1 line
2.43.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · On 08/09/2025 at 22:07, [email protected] wrote:

From: Ryan Wanner <[email protected]>

A potential divider for the master clock is div/3. The register configuration for div/3 is MASTER_PRES_MAX. The current bit shifting method does not work for this case. Checking for MASTER_PRES_MAX will ensure the correct decimal value is stored in the system.

Thanks Ryan, regards,
Nicolas

Quoted 18 lines
---
  drivers/clk/at91/clk-master.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/clk/at91/clk-master.c +3 -0
index 7a544e429d34..d5ea2069ec83 100644
@@ -580,6 +580,9 @@ clk_sama7g5_master_recalc_rate(struct clk_hw *hw,
  {
  	struct clk_master *master = to_clk_master(hw);
 
+	if (master->div == MASTER_PRES_MAX)
+		return DIV_ROUND_CLOSEST_ULL(parent_rate, 3);
+
  	return DIV_ROUND_CLOSEST_ULL(parent_rate, (1 << master->div));
  }
 
maintainer
#2 lore raw
Quoted 11 lines · Nicolas Ferre
Quoted 8 lines · On 08/09/2025 at 22:07, [email protected] wrote:

From: Ryan Wanner <[email protected]>

A potential divider for the master clock is div/3. The register configuration for div/3 is MASTER_PRES_MAX. The current bit shifting method does not work for this case. Checking for MASTER_PRES_MAX will ensure the correct decimal value is stored in the system.

Added to clk-microchip, on its way upstream.
Thanks, regards,
Nicolas

Quoted 22 lines

Thanks Ryan, regards,
Nicolas

Quoted 18 lines
---
   drivers/clk/at91/clk-master.c | 3 +++
   1 file changed, 3 insertions(+)
drivers/clk/at91/clk-master.c +3 -0
index 7a544e429d34..d5ea2069ec83 100644
@@ -580,6 +580,9 @@ clk_sama7g5_master_recalc_rate(struct clk_hw *hw,
   {
   	struct clk_master *master = to_clk_master(hw);
 
+	if (master->div == MASTER_PRES_MAX)
+		return DIV_ROUND_CLOSEST_ULL(parent_rate, 3);
+
   	return DIV_ROUND_CLOSEST_ULL(parent_rate, (1 << master->div));
   }