diff mbox series

spi: zynqmp_gqspi: Simplify baud_rate_val calculation

Message ID 6d2c13d27ae54e0721bd6640ae6dc238aa8425e7.1615557211.git.michal.simek@xilinx.com
State New
Delegated to: Michal Simek
Headers show
Series spi: zynqmp_gqspi: Simplify baud_rate_val calculation | expand

Commit Message

Michal Simek March 12, 2021, 1:53 p.m. UTC
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@xilinx.com>
---

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

Comments

Michal Simek March 30, 2021, 7:28 a.m. UTC | #1
pá 12. 3. 2021 v 14:53 odesílatel Michal Simek <michal.simek@xilinx.com> napsal:
>
> 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@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
>

Please ignore this patch because it needs to be changed.

Thanks,
Michal
diff mbox series

Patch

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);