clk: at91: clk-master: Add check for divide by 3
Subsystems (2)
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
@@ -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
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 forMASTER_PRES_MAXwill ensure the correct decimal value is stored in the system.Signed-off-by Ryan Wanner <[email protected]>
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@@ -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)); }
Nicolas Ferre
maintainerQuoted 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 forMASTER_PRES_MAXwill ensure the correct decimal value is stored in the system.Signed-off-by Ryan Wanner <[email protected]>Acked-by Nicolas Ferre <[email protected]>
Added to clk-microchip, on its way upstream.
Thanks, regards,
Nicolas
Quoted 22 lines
Thanks Ryan, regards,
NicolasQuoted 18 lines
--- drivers/clk/at91/clk-master.c | 3 +++ 1 file changed, 3 insertions(+)drivers/clk/at91/clk-master.c +3
-0@@ -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)); }