Skip to content

Commit 3fbaa29

Browse files
jerome-pouillernashif
authored andcommitted
drivers: spi: siwx91x: Drop GSPI_MAX_BAUDRATE_FOR_DYNAMIC_CLOCK
Currently, clk_div_factor is force to 1 if user request more than 110MHz. However, in this case, gspi_siwx91x_get_divider() will never return 2 or more, unless the input clock is >= 220MHz. The si91x is not designed for such high clock frequency. So, this case has never been tested. Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent 0623e6f commit 3fbaa29

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

drivers/spi/spi_silabs_siwx91x_gspi.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
LOG_MODULE_REGISTER(spi_siwx91x_gspi, CONFIG_SPI_LOG_LEVEL);
2525
#include "spi_context.h"
2626

27-
#define GSPI_MAX_BAUDRATE_FOR_DYNAMIC_CLOCK 110000000
2827
#define GSPI_DMA_MAX_DESCRIPTOR_TRANSFER_SIZE 4096
2928
#define SPI_HIGH_BURST_FREQ_THRESHOLD_HZ 10000000
3029

@@ -94,7 +93,6 @@ static int gspi_siwx91x_config(const struct device *dev, const struct spi_config
9493
{
9594
__maybe_unused struct gspi_siwx91x_data *data = dev->data;
9695
const struct gspi_siwx91x_config *cfg = dev->config;
97-
uint32_t clk_div_factor;
9896
uint32_t clock_rate;
9997
int ret;
10098
__maybe_unused int channel_filter;
@@ -124,18 +122,11 @@ static int gspi_siwx91x_config(const struct device *dev, const struct spi_config
124122
}
125123

126124
/* Configure clock divider based on the requested bit rate */
127-
if (spi_cfg->frequency > GSPI_MAX_BAUDRATE_FOR_DYNAMIC_CLOCK) {
128-
clk_div_factor = 1;
129-
} else {
130-
ret = clock_control_get_rate(cfg->clock_dev, cfg->clock_subsys, &clock_rate);
131-
if (ret) {
132-
return ret;
133-
}
134-
clk_div_factor = gspi_siwx91x_get_divider(clock_rate, spi_cfg->frequency);
125+
ret = clock_control_get_rate(cfg->clock_dev, cfg->clock_subsys, &clock_rate);
126+
if (ret) {
127+
return ret;
135128
}
136-
137-
/* Set the clock divider factor */
138-
cfg->reg->GSPI_CLK_DIV = clk_div_factor;
129+
cfg->reg->GSPI_CLK_DIV = gspi_siwx91x_get_divider(clock_rate, spi_cfg->frequency);
139130

140131
/* Configure SPI clock mode */
141132
if ((spi_cfg->operation & (SPI_MODE_CPOL | SPI_MODE_CPHA)) == 0) {

0 commit comments

Comments
 (0)