spi: Fixes for v6.11

A few SPI fixes since the merge window, clock rate calculation fixes for
 the Kunpeng and lpsi drivers and a missing registration of a device ID
 for spidev (which had only been updated for DT cases, causing warnings).
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAma2p1kACgkQJNaLcl1U
 h9Ab6Qf+Je5sY16uPQXVSVtKw/X5qonsXRaZxCqExxOvsPdtcEdsNsqub9WMvy0B
 HOU8sHZQH+/Jkywof69EtNEv8gYJJ2el8Wc9MLTG8HoJDwSYsNbnkIEaTaiNwC+B
 ELCPocwHglM28b91DX5umnvPj8vosEwO7eutxDqsArDAG43ZQAQ0EdbZx8N4f9/M
 LhFtFiNE16sjoN5e28VBAwaQlwH6CEeZo4RJvGangYa7Mc1x/1/Jh2/qsPOqQnxU
 AXmUp71VMjENe/PBZ3RwRUdxbTot6Sa7bSeQk8Irars1T/bF3h6qeF8We55KY8Ij
 WTKcUCZS/3iCDfUZb+DnvGZpByzE5Q==
 =kGYC
 -----END PGP SIGNATURE-----

Merge tag 'spi-fix-v6.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi fixes from Mark Brown:
 "A few SPI fixes: clock rate calculation fixes for the Kunpeng and lpsi
  drivers and a missing registration of a device ID for spidev (which
  had only been updated for DT cases, causing warnings)"

* tag 'spi-fix-v6.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
  spi: spi-fsl-lpspi: Fix scldiv calculation
  spi: spidev: Add missing spi_device_id for bh2228fv
  spi: hisi-kunpeng: Add verification for the max_frequency provided by the firmware
  spi: hisi-kunpeng: Add validation for the minimum value of speed_hz
This commit is contained in:
Linus Torvalds 2024-08-09 21:26:50 -07:00
commit 57b935eb8c
3 changed files with 9 additions and 2 deletions

View File

@ -296,7 +296,7 @@ static void fsl_lpspi_set_watermark(struct fsl_lpspi_data *fsl_lpspi)
static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
{
struct lpspi_config config = fsl_lpspi->config;
unsigned int perclk_rate, scldiv;
unsigned int perclk_rate, scldiv, div;
u8 prescale;
perclk_rate = clk_get_rate(fsl_lpspi->clk_per);
@ -313,8 +313,10 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
return -EINVAL;
}
div = DIV_ROUND_UP(perclk_rate, config.speed_hz);
for (prescale = 0; prescale < 8; prescale++) {
scldiv = perclk_rate / config.speed_hz / (1 << prescale) - 2;
scldiv = div / (1 << prescale) - 2;
if (scldiv < 256) {
fsl_lpspi->config.prescale = prescale;
break;

View File

@ -481,6 +481,9 @@ static int hisi_spi_probe(struct platform_device *pdev)
return -EINVAL;
}
if (host->max_speed_hz == 0)
return dev_err_probe(dev, -EINVAL, "spi-max-frequency can't be 0\n");
ret = device_property_read_u16(dev, "num-cs",
&host->num_chipselect);
if (ret)
@ -495,6 +498,7 @@ static int hisi_spi_probe(struct platform_device *pdev)
host->transfer_one = hisi_spi_transfer_one;
host->handle_err = hisi_spi_handle_err;
host->dev.fwnode = dev->fwnode;
host->min_speed_hz = DIV_ROUND_UP(host->max_speed_hz, CLK_DIV_MAX);
hisi_spi_hw_init(hs);

View File

@ -700,6 +700,7 @@ static const struct class spidev_class = {
};
static const struct spi_device_id spidev_spi_ids[] = {
{ .name = "bh2228fv" },
{ .name = "dh2228fv" },
{ .name = "ltc2488" },
{ .name = "sx1301" },