diff options
| author | Tom Rini <trini@konsulko.com> | 2024-01-08 12:00:18 -0500 | 
|---|---|---|
| committer | Tom Rini <trini@konsulko.com> | 2024-01-08 12:00:18 -0500 | 
| commit | 93d91e9485d902a1836a22e72d1a545b587adf36 (patch) | |
| tree | f368b4e3c2220e7cd34c83bf192d8b674158d16b /drivers/clk/stm32/clk-stm32f.c | |
| parent | 866ca972d6c3cabeaf6dbac431e8e08bb30b3c8e (diff) | |
| parent | f28a77589e7505535a4eebdc7269df98f67dbe68 (diff) | |
Merge branch 'next'
Diffstat (limited to 'drivers/clk/stm32/clk-stm32f.c')
| -rw-r--r-- | drivers/clk/stm32/clk-stm32f.c | 25 | 
1 files changed, 14 insertions, 11 deletions
| diff --git a/drivers/clk/stm32/clk-stm32f.c b/drivers/clk/stm32/clk-stm32f.c index ed7660196ef..d68c75ed201 100644 --- a/drivers/clk/stm32/clk-stm32f.c +++ b/drivers/clk/stm32/clk-stm32f.c @@ -522,17 +522,20 @@ static ulong stm32_set_rate(struct clk *clk, ulong rate)  	/* get the current PLLSAIR output freq */  	pllsair_rate = stm32_clk_get_pllsai_rate(priv, PLLSAIR); -	best_div = pllsair_rate / rate; - -	/* look into pllsaidivr_table if this divider is available*/ -	for (i = 0 ; i < sizeof(pllsaidivr_table); i++) -		if (best_div == pllsaidivr_table[i]) { -			/* set pll_saidivr with found value */ -			clrsetbits_le32(®s->dckcfgr, -					RCC_DCKCFGR_PLLSAIDIVR_MASK, -					pllsaidivr_table[i]); -			return rate; -		} +	if ((pllsair_rate % rate) == 0) { +		best_div = pllsair_rate / rate; + +		/* look into pllsaidivr_table if this divider is available */ +		for (i = 0 ; i < sizeof(pllsaidivr_table); i++) +			if (best_div == pllsaidivr_table[i]) { +				/* set pll_saidivr with found value */ +				clrsetbits_le32(®s->dckcfgr, +						RCC_DCKCFGR_PLLSAIDIVR_MASK, +						pllsaidivr_table[i] << +						RCC_DCKCFGR_PLLSAIDIVR_SHIFT); +				return rate; +			} +	}  	/*  	 * As no pllsaidivr value is suitable to obtain requested freq, | 
