[PATCH] spi: zynqmp_gqspi: Simplify baud_rate_val calculation

Michal Simek michal.simek at xilinx.com
Fri Mar 12 14:53:33 CET 2021


Condition to setup GQSPI_DFLT_BAUD_RATE_VAL(number 2) in case when
baud_rate_val is more then 7 is wrong. There should be really the biggest
possible value which is 7. This can be achieve in easier way by enabling
calculation till GQSPI_MAX_BAUD_RATE_VAL.

Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---

 drivers/spi/zynqmp_gqspi.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c
index f8d13d193e30..900cb2610c7f 100644
--- a/drivers/spi/zynqmp_gqspi.c
+++ b/drivers/spi/zynqmp_gqspi.c
@@ -324,14 +324,10 @@ static int zynqmp_qspi_set_speed(struct udevice *bus, uint speed)
 	if (plat->speed_hz != speed) {
 		/* Set the clock frequency */
 		/* If speed == 0, default to lowest speed */
-		while ((baud_rate_val < 8) &&
-		       ((plat->frequency /
-		       (2 << baud_rate_val)) > speed))
+		while (baud_rate_val < GQSPI_MAX_BAUD_RATE_VAL &&
+		       (plat->frequency / (2 << baud_rate_val)) > speed)
 			baud_rate_val++;
 
-		if (baud_rate_val > GQSPI_MAX_BAUD_RATE_VAL)
-			baud_rate_val = GQSPI_DFLT_BAUD_RATE_VAL;
-
 		plat->speed_hz = plat->frequency / (2 << baud_rate_val);
 
 		confr = readl(&regs->confr);
-- 
2.30.1



More information about the U-Boot mailing list