Skip to contentSkip to conversation

spi: cadence_qspi: Probe fail if QSPI clock is not set

PATCH New Chee Hong Ang 3 participants 3 messages Aug 5, 2020 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: cadence_qspi: Probe fail if QSPI clock is not set

If the QSPI clock is not set (read as 0), QSPI driver probe shall fail and prevent further QSPI access.

---
 drivers/spi/cadence_qspi.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/cadence_qspi.c +3 -0
index 1e85749209..3bb5c7031d 100644
@@ -170,6 +170,9 @@ static int cadence_spi_probe(struct udevice *bus)
 	struct clk clk;
 	int ret;
 
+	if (!CONFIG_CQSPI_REF_CLK)
+		return -ENODEV;
+
 	priv->regbase = plat->regbase;
 	priv->ahbbase = plat->ahbbase;
 
Signature · 1 line
2.19.0
#1 lore raw

PATCH 1/1 spi: cadence_qspi: Probe fail if QSPI clock is not set

Hi,

Quoted 13 lines · Chee Hong Ang

If the QSPI clock is not set (read as 0), QSPI driver probe shall fail and prevent further QSPI access.

---
  drivers/spi/cadence_qspi.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/spi/cadence_qspi.c +0 -0
index 1e85749209..3bb5c7031d 100644

drivers/spi/cadence_qspi.c static int cadence_spi_probe(struct udevice *bus) · line 175

Quoted 6 lines
drivers/spi/cadence_qspi.c +3 -0
@@ -170,6 +170,9 @@ static int cadence_spi_probe(struct udevice *bus)
  	struct clk clk;
  	int ret;
 
+	if (!CONFIG_CQSPI_REF_CLK)
+		return -ENODEV;
+

This seems broken to me...

Most platforms have moved away from passing clk freq via CONFIG_ and are using more scalable DT or platdata approach where freq is obtained via clk_get_*() APIs... See few lines below:

         if (plat->ref_clk_hz == 0) {
                 ret = clk_get_by_index(bus, 0, &clk);
                 if (ret) {
#ifdef CONFIG_CQSPI_REF_CLK
                         plat->ref_clk_hz = CONFIG_CQSPI_REF_CLK;
#else
                         return ret;
#endif
                 } else {
                         plat->ref_clk_hz = clk_get_rate(&clk);
                         clk_free(&clk);
                         if (IS_ERR_VALUE(plat->ref_clk_hz))
                                 return plat->ref_clk_hz;
                 }
         }

So there is no need to make CONFIG_CQSPI_REF_CLK mandatory. Probe may fail only when CONFIG_CQSPI_REF_CLK is undefined and there is no reference to a valid clk device either.

drivers/spi/cadence_qspi.c static int cadence_spi_probe(struct udevice *bus) · line 178

Quoted 4 lines
drivers/spi/cadence_qspi.c +0 -0
  	priv->regbase = plat->regbase;
  	priv->ahbbase = plat->ahbbase;
 

Regards
Vignesh

#2 lore raw

PATCH 1/1 spi: cadence_qspi: Probe fail if QSPI clock is not set

Quoted 19 lines

Hi,

Quoted 16 lines · Chee Hong Ang

If the QSPI clock is not set (read as 0), QSPI driver probe shall fail and prevent further QSPI access.

---
  drivers/spi/cadence_qspi.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/spi/cadence_qspi.c +0 -0
index 1e85749209..3bb5c7031d 100644
@@ -170,6 +170,9 @@ static int cadence_spi_probe(struct udevice *bus)
  	struct clk clk;
  	int ret;
 
Quoted 8 lines

drivers/spi/cadence_qspi.c static int cadence_spi_probe(struct udevice *bus) · line 175

Quoted 3 lines
drivers/spi/cadence_qspi.c +3 -0
+	if (!CONFIG_CQSPI_REF_CLK)
+		return -ENODEV;
+

This seems broken to me...

Most platforms have moved away from passing clk freq via CONFIG_ and are using more scalable DT or platdata approach where freq is obtained via

I think the proper way to resolve this is to change our clock driver to DM. Thanks.

Quoted 29 lines

clk_get_*() APIs... See few lines below:

         if (plat->ref_clk_hz == 0) {
                 ret = clk_get_by_index(bus, 0, &clk);
                 if (ret) {
#ifdef CONFIG_CQSPI_REF_CLK
                         plat->ref_clk_hz = CONFIG_CQSPI_REF_CLK; #else
                         return ret;
#endif
                 } else {
                         plat->ref_clk_hz = clk_get_rate(&clk);
                         clk_free(&clk);
                         if (IS_ERR_VALUE(plat->ref_clk_hz))
                                 return plat->ref_clk_hz;
                 }
         }

So there is no need to make CONFIG_CQSPI_REF_CLK mandatory. Probe may fail only when CONFIG_CQSPI_REF_CLK is undefined and there is no reference to a valid clk device either.

drivers/spi/cadence_qspi.c static int cadence_spi_probe(struct udevice *bus) · line 178

Quoted 4 lines
drivers/spi/cadence_qspi.c +0 -0
  	priv->regbase = plat->regbase;
  	priv->ahbbase = plat->ahbbase;
 

Regards
Vignesh