mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
spi: dw: Clamp the minimum clock speed
The DW SPI interface has a 16-bit clock divider, where the bottom bit of the divisor must be 0. Limit how low the clock speed can go to prevent the clock divider from being truncated, as that could lead to a much higher clock rate than requested. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
This commit is contained in:
@@ -397,7 +397,7 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi,
|
|||||||
dw_writel(dws, DW_SPI_CTRLR1, cfg->ndf ? cfg->ndf - 1 : 0);
|
dw_writel(dws, DW_SPI_CTRLR1, cfg->ndf ? cfg->ndf - 1 : 0);
|
||||||
|
|
||||||
/* Note DW APB SSI clock divider doesn't support odd numbers */
|
/* Note DW APB SSI clock divider doesn't support odd numbers */
|
||||||
clk_div = (DIV_ROUND_UP(dws->max_freq, cfg->freq) + 1) & 0xfffe;
|
clk_div = min(DIV_ROUND_UP(dws->max_freq, cfg->freq) + 1, 0xfffe) & 0xfffe;
|
||||||
speed_hz = dws->max_freq / clk_div;
|
speed_hz = dws->max_freq / clk_div;
|
||||||
|
|
||||||
if (dws->current_freq != speed_hz) {
|
if (dws->current_freq != speed_hz) {
|
||||||
|
|||||||
Reference in New Issue
Block a user