Commit 57b935eb authored by Linus Torvalds's avatar Linus Torvalds

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
parents 15833fea 730bbfaf
...@@ -296,7 +296,7 @@ static void fsl_lpspi_set_watermark(struct fsl_lpspi_data *fsl_lpspi) ...@@ -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) static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
{ {
struct lpspi_config config = fsl_lpspi->config; struct lpspi_config config = fsl_lpspi->config;
unsigned int perclk_rate, scldiv; unsigned int perclk_rate, scldiv, div;
u8 prescale; u8 prescale;
perclk_rate = clk_get_rate(fsl_lpspi->clk_per); 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) ...@@ -313,8 +313,10 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
return -EINVAL; return -EINVAL;
} }
div = DIV_ROUND_UP(perclk_rate, config.speed_hz);
for (prescale = 0; prescale < 8; prescale++) { for (prescale = 0; prescale < 8; prescale++) {
scldiv = perclk_rate / config.speed_hz / (1 << prescale) - 2; scldiv = div / (1 << prescale) - 2;
if (scldiv < 256) { if (scldiv < 256) {
fsl_lpspi->config.prescale = prescale; fsl_lpspi->config.prescale = prescale;
break; break;
......
...@@ -481,6 +481,9 @@ static int hisi_spi_probe(struct platform_device *pdev) ...@@ -481,6 +481,9 @@ static int hisi_spi_probe(struct platform_device *pdev)
return -EINVAL; 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", ret = device_property_read_u16(dev, "num-cs",
&host->num_chipselect); &host->num_chipselect);
if (ret) if (ret)
...@@ -495,6 +498,7 @@ static int hisi_spi_probe(struct platform_device *pdev) ...@@ -495,6 +498,7 @@ static int hisi_spi_probe(struct platform_device *pdev)
host->transfer_one = hisi_spi_transfer_one; host->transfer_one = hisi_spi_transfer_one;
host->handle_err = hisi_spi_handle_err; host->handle_err = hisi_spi_handle_err;
host->dev.fwnode = dev->fwnode; host->dev.fwnode = dev->fwnode;
host->min_speed_hz = DIV_ROUND_UP(host->max_speed_hz, CLK_DIV_MAX);
hisi_spi_hw_init(hs); hisi_spi_hw_init(hs);
......
...@@ -700,6 +700,7 @@ static const struct class spidev_class = { ...@@ -700,6 +700,7 @@ static const struct class spidev_class = {
}; };
static const struct spi_device_id spidev_spi_ids[] = { static const struct spi_device_id spidev_spi_ids[] = {
{ .name = "bh2228fv" },
{ .name = "dh2228fv" }, { .name = "dh2228fv" },
{ .name = "ltc2488" }, { .name = "ltc2488" },
{ .name = "sx1301" }, { .name = "sx1301" },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment