spi: cadence-qspi: Move ref clock calculation to probe
PATCH 1/1 spi: cadence-qspi: Move ref clock calculation to probe
"assigned-clock-parents" and "assigned-clock-rates" DT properties take effect only after ofdata_to_platdata() when clk_set_defaults() is called in device_probe(). Therefore clk get rate() would return a wrong value in ofdata_to_platdata() when compared with probe. Hence it needs to be moved to probe.
Tested on u-boot-ti/next.
--- drivers/spi/cadence_qspi.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/spi/cadence_qspi.c +17 -16
@@ -166,11 +166,28 @@ static int cadence_spi_probe(struct udevice *bus) {struct cadence_spi_platdata *plat = bus->platdata;struct cadence_spi_priv *priv =dev_get_priv (bus); +struct clk clk;int ret; priv->regbase = plat->regbase; priv->ahbbase = plat->ahbbase; +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; + } + } + ret =reset_get_bulk (bus, &priv->resets);if (ret)dev_warn (bus,"Can't get reset: %d\n" , ret);
@@ -268,8 +285,6 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) {struct cadence_spi_platdata *plat = bus->platdata;ofnode subnode; -struct clk clk; -int ret; plat->regbase = (void *)devfdt_get_addr_index (bus,0 ); plat->ahbbase = (void *)devfdt_get_addr_size_index(bus, 1,
@@ -305,20 +320,6 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) plat->tchsh_ns =ofnode_read_u32_default (subnode,"cdns,tchsh-ns" ,20 ); plat->tslch_ns =ofnode_read_u32_default (subnode,"cdns,tslch-ns" ,20 ); - 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; - } -debug ("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n" , __func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);
Signature · 1 line
2.25.0
PATCH 1/1 spi: cadence-qspi: Move ref clock calculation to probe
+Simon who converted driver to use clk_get* APIs
Quoted 8 lines · Pratyush Yadav
"assigned-clock-parents" and "assigned-clock-rates" DT properties take effect only after
ofdata_to_platdata()whenclk_set_defaults()is called indevice_probe(). Therefore clk getrate()would return a wrong value inofdata_to_platdata()when compared with probe. Hence it needs to be moved to probe.Tested on u-boot-ti/next.
Regards
Vignesh
Quoted 69 lines
Signed-off-by Pratyush Yadav <[email protected]>--- drivers/spi/cadence_qspi.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)drivers/spi/cadence_qspi.c +17
-16@@ -166,11 +166,28 @@ static int cadence_spi_probe(struct udevice *bus) {struct cadence_spi_platdata *plat = bus->platdata;struct cadence_spi_priv *priv =dev_get_priv (bus); +struct clk clk;int ret; priv->regbase = plat->regbase; priv->ahbbase = plat->ahbbase; +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; + } + } + ret =reset_get_bulk (bus, &priv->resets);if (ret)dev_warn (bus,"Can't get reset: %d\n" , ret);@@ -268,8 +285,6 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) {struct cadence_spi_platdata *plat = bus->platdata;ofnode subnode; -struct clk clk; -int ret; plat->regbase = (void *)devfdt_get_addr_index (bus,0 ); plat->ahbbase = (void *)devfdt_get_addr_size_index(bus, 1,@@ -305,20 +320,6 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) plat->tchsh_ns =ofnode_read_u32_default (subnode,"cdns,tchsh-ns" ,20 ); plat->tslch_ns =ofnode_read_u32_default (subnode,"cdns,tslch-ns" ,20 ); - 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; - } -debug ("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n" , __func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);
PATCH 1/1 spi: cadence-qspi: Move ref clock calculation to probe
Vignesh Raghavendra <[email protected]> schrieb am Mi., 26. Feb. 2020, 08:29:
Quoted 9 lines
+Simon who converted driver to use clk_get* APIs
Quoted 6 lines · Pratyush Yadav
"assigned-clock-parents" and "assigned-clock-rates" DT properties take effect only after
ofdata_to_platdata()whenclk_set_defaults()is called indevice_probe(). Therefore clk getrate()would return a wrong value inofdata_to_platdata()when compared with probe. Hence it needs to be moved to probe.
Quoted 5 lines
Quoted 2 lines
Tested on u-boot-ti/next.
Fine by me. I actually moved it there after someone requested me to :-) I first had it in the set_rate function...
Quoted 80 lines
Regards
Vigneshdrivers/spi/cadence_qspi.c static int cadence_spi_ofdata_to_platdata(struct
Quoted 39 lines
Signed-off-by Pratyush Yadav <[email protected]>--- drivers/spi/cadence_qspi.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)drivers/spi/cadence_qspi.c +17
-0@@ -166,11 +166,28 @@ static int cadence_spi_probe(struct udevice *bus) {struct cadence_spi_platdata *plat = bus->platdata;struct cadence_spi_priv *priv =dev_get_priv (bus); +struct clk clk;int ret; priv->regbase = plat->regbase; priv->ahbbase = plat->ahbbase; +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; + } + } + ret =reset_get_bulk (bus, &priv->resets);if (ret)dev_warn (bus,"Can't get reset: %d\n" , ret);@@ -268,8 +285,6 @@ static int cadence_spi_ofdata_to_platdata(structudevice *bus)
drivers/spi/cadence_qspi.c static int cadence_spi_ofdata_to_platdata(struct
Quoted 9 lines
drivers/spi/cadence_qspi.c +0
-2{struct cadence_spi_platdata *plat = bus->platdata;ofnode subnode; -struct clk clk; -int ret; plat->regbase = (void *)devfdt_get_addr_index (bus,0 ); plat->ahbbase = (void *)devfdt_get_addr_size_index(bus, 1,@@ -305,20 +320,6 @@ static int cadence_spi_ofdata_to_platdata(structudevice *bus)
drivers/spi/cadence_qspi.c static int cadence_spi_ofdata_to_platdata(struct · line 320
Quoted 1 line
drivers/spi/cadence_qspi.c +0
-0plat->tchsh_ns = ofnode_read_u32_default(subnode, "cdns,tchsh-ns",20);
drivers/spi/cadence_qspi.c static int cadence_spi_ofdata_to_platdata(struct · line 321
Quoted 1 line
drivers/spi/cadence_qspi.c +0
-0plat->tslch_ns = ofnode_read_u32_default(subnode, "cdns,tslch-ns",20);
Quoted 19 lines
drivers/spi/cadence_qspi.c +0
-14- 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; - } -debug ("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n" , __func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);
PATCH 1/1 spi: cadence-qspi: Move ref clock calculation to probe
Quoted 17 lines · Simon Goldschmidt
Vignesh Raghavendra <[email protected]> schrieb am Mi., 26. Feb. 2020, 08:29:
Quoted 13 lines
+Simon who converted driver to use clk_get* APIs
Quoted 8 lines · Pratyush Yadav
"assigned-clock-parents" and "assigned-clock-rates" DT properties take effect only after
ofdata_to_platdata()whenclk_set_defaults()is called indevice_probe(). Therefore clk getrate()would return a wrong value inofdata_to_platdata()when compared with probe. Hence it needs to be moved to probe.Tested on u-boot-ti/next.
Quoted 6 lines
Quoted 1 line
Fine by me. I actually moved it there after someone requested me to :-) I first had it in the
set_ratefunction...
So, does this fixing something or will it work even for wrong value? I'm thinking of picking it up for release, if associated boards got tested.
Jagan.
PATCH 1/1 spi: cadence-qspi: Move ref clock calculation to probe
In reply to Pratyush YadavQuoted 11 lines · Pratyush Yadav
"assigned-clock-parents" and "assigned-clock-rates" DT properties take effect only after
ofdata_to_platdata()whenclk_set_defaults()is called indevice_probe(). Therefore clk getrate()would return a wrong value inofdata_to_platdata()when compared with probe. Hence it needs to be moved to probe.Tested on u-boot-ti/next.
Signed-off-by Pratyush Yadav <[email protected]>---
Applied to u-boot-spi/master