]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
spi: pxa2xx: Set minimum transfer speed
authorJarkko Nikula <jarkko.nikula@linux.intel.com>
Fri, 28 Jun 2019 14:07:17 +0000 (17:07 +0300)
committerMark Brown <broonie@kernel.org>
Tue, 2 Jul 2019 11:48:26 +0000 (12:48 +0100)
It is possible to request a transfer with a speed lower than supported
by the HW. This causes silent divider calculation underflow in
ssp_get_clk_div() which leads to a frequency higher than requested. Up to
maximum speed of the controller.

Set the minimum supported transfer speed and let the SPI core to
validate no transfers have speed lower than supported.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-pxa2xx.c

index af3f37ba82c83f26e37c8c93708992734a33c320..259c20f7a542c87be040498c5907de81eb70edec 100644 (file)
@@ -1704,6 +1704,16 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
                goto out_error_dma_irq_alloc;
 
        controller->max_speed_hz = clk_get_rate(ssp->clk);
+       /*
+        * Set minimum speed for all other platforms than Intel Quark which is
+        * able do under 1 Hz transfers.
+        */
+       if (!pxa25x_ssp_comp(drv_data))
+               controller->min_speed_hz =
+                       DIV_ROUND_UP(controller->max_speed_hz, 4096);
+       else if (!is_quark_x1000_ssp(drv_data))
+               controller->min_speed_hz =
+                       DIV_ROUND_UP(controller->max_speed_hz, 512);
 
        /* Load default SSP configuration */
        pxa2xx_spi_write(drv_data, SSCR0, 0);