Skip to content

Commit 9a96a0c

Browse files
danieldegrassehenrikbrixandersen
authored andcommitted
soc: arm: nxp_imx: fix flexspi frequency setting for iMXRT11xx SOC
Commit a10fee2 (drivers: clock_control: ccm_rev2: add support for reclocking FlexSPI) introduced the ability to set the FlexSPI clock frequency at runtime on RT11xx series SOCs. However, this implementation resulted in the clock frequency being rounded up, not down. This can result in flash clock frequency violations on some flash parts, causing the system to crash when running in XIP mode. Fixes #69088 Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 5a3c77e commit 9a96a0c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

soc/arm/nxp_imx/rt/flexspi_rt11xx.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@ uint32_t flexspi_clock_set_freq(uint32_t clock_name, uint32_t rate)
3838
CLOCK_GetRootClockMux(flexspi_clk));
3939
/* Get clock root frequency */
4040
root_rate = CLOCK_GetFreq(root);
41-
/* Select a divider based on root frequency */
42-
divider = MIN((root_rate / rate), CCM_CLOCK_ROOT_CONTROL_DIV_MASK);
41+
/* Select a divider based on root clock frequency. We round the
42+
* divider up, so that the resulting clock frequency is lower than
43+
* requested when we can't output the exact requested frequency
44+
*/
45+
divider = ((root_rate + (rate - 1)) / rate);
46+
/* Cap divider to max value */
47+
divider = MIN(divider, CCM_CLOCK_ROOT_CONTROL_DIV_MASK);
4348

4449
while (FLEXSPI_GetBusIdleStatus(flexspi) == false) {
4550
/* Spin */

0 commit comments

Comments
 (0)