]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
qspi: zynqmp: Restrict baud rate value to max value
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Wed, 14 Sep 2016 06:37:14 +0000 (12:07 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 21 Sep 2016 06:46:32 +0000 (08:46 +0200)
Restrict baud rate disvisor value to max possible
baud rate value. This fixes the baud rate value overflow
condition which results in programming the incorrect baud
rate divisor value.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/spi/zynqmp_qspi.c

index c4810346b344a64c4ec60105c047bf3c3620a700..8e7c745389bb3dd7734bbcf7215200d5bde97a28 100644 (file)
@@ -85,6 +85,7 @@
 #define SPI_XFER_ON_UPPER      2
 
 #define ZYNQMP_QSPI_DMA_ALIGN  0x4
+#define ZYNQMP_QSPI_MAX_BAUD_RATE_VAL  7
 
 /* QSPI register offsets */
 struct zynqmp_qspi_regs {
@@ -286,6 +287,9 @@ static int zynqmp_qspi_set_speed(struct udevice *bus, uint speed)
                       (2 << baud_rate_val)) > speed))
                        baud_rate_val++;
 
+               if (baud_rate_val > ZYNQMP_QSPI_MAX_BAUD_RATE_VAL)
+                       baud_rate_val = ZYNQMP_QSPI_MAX_BAUD_RATE_VAL;
+
                plat->speed_hz = speed / (2 << baud_rate_val);
        }
        confr &= ~ZYNQMP_QSPI_BAUD_DIV_MASK;