]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spi: zynq_qspi: Add a check for baudrate and set default if not in limits
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Mon, 31 Jan 2022 05:22:39 +0000 (22:22 -0700)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 4 Feb 2022 12:20:28 +0000 (13:20 +0100)
Add a check afer baudrate calculation to see if the resultant value
falls within the range, else set it to default baudrate value.

Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
Link: https://lore.kernel.org/r/20220131052240.23403-4-ashok.reddy.soma@xilinx.com
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/spi/zynq_qspi.c

index aa060d7940aae30efe59e01893f760d8f50f320e..2963f48bb028d5cf7c84e2d10afc711bb08fb1f3 100644 (file)
@@ -49,6 +49,9 @@ DECLARE_GLOBAL_DATA_PTR;
 #define ZYNQ_QSPI_CR_BAUD_SHIFT                3       /* Baud rate divisor shift */
 #define ZYNQ_QSPI_CR_SS_SHIFT          10      /* Slave select shift */
 
+#define ZYNQ_QSPI_MAX_BAUD_RATE                0x7
+#define ZYNQ_QSPI_DEFAULT_BAUD_RATE    0x2
+
 #define ZYNQ_QSPI_FIFO_DEPTH           63
 #define ZYNQ_QSPI_WAIT                 (CONFIG_SYS_HZ / 100)   /* 10 ms */
 
@@ -621,6 +624,9 @@ static int zynq_qspi_set_speed(struct udevice *bus, uint speed)
                       (2 << baud_rate_val)) > speed))
                        baud_rate_val++;
 
+               if (baud_rate_val > ZYNQ_QSPI_MAX_BAUD_RATE)
+                       baud_rate_val = ZYNQ_QSPI_DEFAULT_BAUD_RATE;
+
                plat->speed_hz = speed / (2 << baud_rate_val);
        }
        confr &= ~ZYNQ_QSPI_CR_BAUD_MASK;