Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: imx: remove CLK calculation and check for target mode

In target mode, the clock signal is controlled by the master. Target does
not need to check, calculate and configure the clock frequency division.
The target can directly use the root clock to sample the SCL signal.

Therefore, remove check, calculation and frequency division function of
the clock for target mode.

Signed-off-by: Carlos Song <carlos.song@nxp.com>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20251024055211.408440-1-carlos.song@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Clark Wang and committed by
Mark Brown
55d03b5b 2f538ef9

+18 -10
+18 -10
drivers/spi/spi-imx.c
··· 42 42 "time in us to run a transfer in polling mode\n"); 43 43 44 44 #define MXC_RPM_TIMEOUT 2000 /* 2000ms */ 45 + #define MXC_SPI_DEFAULT_SPEED 500000 /* 500KHz */ 45 46 46 47 #define MXC_CSPIRXDATA 0x00 47 48 #define MXC_CSPITXDATA 0x04 ··· 685 684 /* set clock speed */ 686 685 ctrl &= ~(0xf << MX51_ECSPI_CTRL_POSTDIV_OFFSET | 687 686 0xf << MX51_ECSPI_CTRL_PREDIV_OFFSET); 688 - ctrl |= mx51_ecspi_clkdiv(spi_imx, spi_imx->spi_bus_clk, &clk); 689 - spi_imx->spi_bus_clk = clk; 687 + 688 + if (!spi_imx->target_mode) { 689 + ctrl |= mx51_ecspi_clkdiv(spi_imx, spi_imx->spi_bus_clk, &clk); 690 + spi_imx->spi_bus_clk = clk; 691 + } 690 692 691 693 mx51_configure_cpha(spi_imx, spi); 692 694 ··· 1312 1308 if (!t) 1313 1309 return 0; 1314 1310 1315 - if (!t->speed_hz) { 1316 - if (!spi->max_speed_hz) { 1317 - dev_err(&spi->dev, "no speed_hz provided!\n"); 1318 - return -EINVAL; 1311 + if (!spi_imx->target_mode) { 1312 + if (!t->speed_hz) { 1313 + if (!spi->max_speed_hz) { 1314 + dev_err(&spi->dev, "no speed_hz provided!\n"); 1315 + return -EINVAL; 1316 + } 1317 + dev_dbg(&spi->dev, "using spi->max_speed_hz!\n"); 1318 + spi_imx->spi_bus_clk = spi->max_speed_hz; 1319 + } else { 1320 + spi_imx->spi_bus_clk = t->speed_hz; 1319 1321 } 1320 - dev_dbg(&spi->dev, "using spi->max_speed_hz!\n"); 1321 - spi_imx->spi_bus_clk = spi->max_speed_hz; 1322 - } else 1323 - spi_imx->spi_bus_clk = t->speed_hz; 1322 + } 1324 1323 1325 1324 spi_imx->bits_per_word = t->bits_per_word; 1326 1325 spi_imx->count = t->len; ··· 1838 1831 controller->prepare_message = spi_imx_prepare_message; 1839 1832 controller->unprepare_message = spi_imx_unprepare_message; 1840 1833 controller->target_abort = spi_imx_target_abort; 1834 + spi_imx->spi_bus_clk = MXC_SPI_DEFAULT_SPEED; 1841 1835 controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS | 1842 1836 SPI_MOSI_IDLE_LOW; 1843 1837