spi: cadence_qspi: support DM_CLK
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Support loading clk speed via DM instead of requiring ad-hoc code.
---
Changes in v3:
- load ref_clk_hz only once in cadence_spi_ofdata_to_platdata instead of loading it every time in cadence_spi_write_speed
Changes in v2:
- check return value of clk_get_rate for error
drivers/spi/cadence_qspi.c | 21 +++++++++++++++++++-- drivers/spi/cadence_qspi.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/spi/cadence_qspi.c +19 -2
@@ -5,6 +5,7 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <fdtdec.h> #include <malloc.h>
@@ -24,10 +25,10 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz)struct cadence_spi_priv *priv =dev_get_priv (bus);cadence_qspi_apb_config_baudrate_div (priv->regbase, -CONFIG_CQSPI_REF_CLK , hz); + plat->ref_clk_hz, hz);/* Reconfigure delay timing if speed is changed. */ -cadence_qspi_apb_delay (priv->regbase,CONFIG_CQSPI_REF_CLK , hz, +cadence_qspi_apb_delay (priv->regbase, plat->ref_clk_hz, hz, plat->tshsl_ns, plat->tsd2d_ns, plat->tchsh_ns, plat->tslch_ns);
@@ -294,6 +295,8 @@ 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_index (bus,1 );
@@ -325,6 +328,20 @@ 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);
drivers/spi/cadence_qspi.h +1 -0
@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase;
Signature · 1 line
2.20.1
Tan
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 64 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:43 AM
To: Jagan Teki <[email protected]>
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; Vignesh Raghavendra <[email protected]>; Simon Goldschmidt <[email protected]>; u-boot at lists.denx.de
Subject: [PATCH v3] spi:cadence_qspi: supportDM_CLKSupport loading clk speed via DM instead of requiring ad-hoc code.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v3:
- loadref_clk_hzonly once incadence_spi_ofdata_to_platdatainstead of loading it every time incadence_spi_write_speedChanges in v2:
- check return value ofclk_get_ratefor errordrivers/spi/cadence_qspi.c | 21 +++++++++++++++++++-- drivers/spi/cadence_qspi.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)drivers/spi/cadence_qspi.c index renamed from drivers/spi/cadence_qspi.c +0
-0
e2e54cd277..8fd23a7702100644drivers/spi/cadence_qspi.c +6
-2@@ -5,6 +5,7 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <fdtdec.h> #include <malloc.h> @@ -24,10 +25,10 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz)struct cadence_spi_priv *priv =dev_get_priv (bus);cadence_qspi_apb_config_baudrate_div (priv->regbase, -CONFIG_CQSPI_REF_CLK , hz); + plat->ref_clk_hz, hz);/* Reconfigure delay timing if speed is changed. */ -cadence_qspi_apb_delay (priv->regbase,CONFIG_CQSPI_REF_CLK , hz, +cadence_qspi_apb_delay (priv->regbase, plat->ref_clk_hz, hz, plat->tshsl_ns, plat->tsd2d_ns, plat->tchsh_ns, plat->tslch_ns);@@ -294,6 +295,8 @@ 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_index(bus, 1); @@ -325,6 +328,20 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) plat->tchsh_ns = ofnode_read_u32_default(subnode, "cdns,tchsh-ns",
Quoted 4 lines
20);
plat->tslch_ns= ofnode_read_u32_default(subnode, "cdns,tslch-ns",
20);
Did you compile this with platform without clock DM before? Eg: Stratix10. You need add check for CONFIG_CLK enabled to call clock DM functions here.
Regards
Ley Foon
Quoted 31 lines
drivers/spi/cadence_qspi.c +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
drivers/spi/cadence_qspi.c +0
-0__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);drivers/spi/cadence_qspi.h index renamed from drivers/spi/cadence_qspi.h +0
-0
20cceca239..99dee75bbd100644drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 61 lines · Ley Foon
Quoted 61 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:43 AM
To: Jagan Teki <[email protected]>
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; Vignesh Raghavendra <[email protected]>; Simon Goldschmidt <[email protected]>; u-boot at lists.denx.de
Subject: [PATCH v3] spi:cadence_qspi: supportDM_CLKSupport loading clk speed via DM instead of requiring ad-hoc code.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v3:
- loadref_clk_hzonly once incadence_spi_ofdata_to_platdatainstead of loading it every time incadence_spi_write_speedChanges in v2:
- check return value ofclk_get_ratefor errordrivers/spi/cadence_qspi.c | 21 +++++++++++++++++++-- drivers/spi/cadence_qspi.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)drivers/spi/cadence_qspi.c index renamed from drivers/spi/cadence_qspi.c +0
-0
e2e54cd277..8fd23a7702100644drivers/spi/cadence_qspi.c +5
-2@@ -5,6 +5,7 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <fdtdec.h> #include <malloc.h> @@ -24,10 +25,10 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz)struct cadence_spi_priv *priv =dev_get_priv (bus);cadence_qspi_apb_config_baudrate_div (priv->regbase, -CONFIG_CQSPI_REF_CLK , hz); + plat->ref_clk_hz, hz);/* Reconfigure delay timing if speed is changed. */ -cadence_qspi_apb_delay (priv->regbase,CONFIG_CQSPI_REF_CLK , hz, +cadence_qspi_apb_delay (priv->regbase, plat->ref_clk_hz, hz, plat->tshsl_ns, plat->tsd2d_ns, plat->tchsh_ns, plat->tslch_ns);@@ -294,6 +295,8 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) {struct cadence_spi_platdata *plat = bus->platdata;ofnode subnode; +struct clk clk; +int ret;
Quoted 10 lines
Quoted 8 lines
drivers/spi/cadence_qspi.c +1
-0plat->regbase = (void *)devfdt_get_addr_index (bus,0 ); plat->ahbbase = (void *)devfdt_get_addr_index(bus, 1); @@ -325,6 +328,20 @@ 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);
Did you compile this with platform without clock DM before? Eg: Stratix10. You need add check for
CONFIG_CLKenabled to call clock DM functions here.
Unless I'm mistaken, those functions are prototyped when CLK is not enabled:
https://elixir.bootlin.com/u-boot/latest/source/include/clk.h#L172
That should be enough, no? And yes, I did test this on the current state of gen5 which does not have a CLK driver, yet.
Regards,
Simon
Quoted 36 lines
Regards
Ley FoonQuoted 31 lines
drivers/spi/cadence_qspi.c +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);drivers/spi/cadence_qspi.h index renamed from drivers/spi/cadence_qspi.h +0
-0
20cceca239..99dee75bbd100644drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 73 lines · Simon Goldschmidt
Quoted 61 lines · Ley Foon
Quoted 61 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:43 AM
To: Jagan Teki <[email protected]>
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; Vignesh Raghavendra <[email protected]>; Simon Goldschmidt <[email protected]>; u-boot at lists.denx.de
Subject: [PATCH v3] spi:cadence_qspi: supportDM_CLKSupport loading clk speed via DM instead of requiring ad-hoc code.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v3:
- loadref_clk_hzonly once incadence_spi_ofdata_to_platdatainstead of loading it every time incadence_spi_write_speedChanges in v2:
- check return value ofclk_get_ratefor errordrivers/spi/cadence_qspi.c | 21 +++++++++++++++++++-- drivers/spi/cadence_qspi.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)drivers/spi/cadence_qspi.c index renamed from drivers/spi/cadence_qspi.c +0
-0
e2e54cd277..8fd23a7702100644drivers/spi/cadence_qspi.c +5
-2@@ -5,6 +5,7 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <fdtdec.h> #include <malloc.h> @@ -24,10 +25,10 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz)struct cadence_spi_priv *priv =dev_get_priv (bus);cadence_qspi_apb_config_baudrate_div (priv->regbase, -CONFIG_CQSPI_REF_CLK , hz); + plat->ref_clk_hz, hz);/* Reconfigure delay timing if speed is changed. */ -cadence_qspi_apb_delay (priv->regbase,CONFIG_CQSPI_REF_CLK , hz, +cadence_qspi_apb_delay (priv->regbase, plat->ref_clk_hz, hz, plat->tshsl_ns, plat->tsd2d_ns, plat->tchsh_ns, plat->tslch_ns);@@ -294,6 +295,8 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) {struct cadence_spi_platdata *plat = bus->platdata;ofnode subnode; +struct clk clk; +int ret;Quoted 10 lines
Quoted 8 lines
drivers/spi/cadence_qspi.c +1
-0plat->regbase = (void *)devfdt_get_addr_index (bus,0 ); plat->ahbbase = (void *)devfdt_get_addr_index(bus, 1); @@ -325,6 +328,20 @@ 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);
Did you compile this with platform without clock DM before? Eg: Stratix10. You need add check for
CONFIG_CLKenabled to call clock DM functions here.
Quoted 4 lines
Unless I'm mistaken, those functions are prototyped when CLK is not enabled:
https://elixir.bootlin.com/u-boot/latest/source/include/clk.h#L172
But, unfortunately, such stub does not exists for clk_get_rate(). So on platforms w/o CONFIG_CLK set:
arm-linux-gnueabihf-ld.bfd: drivers/spi/built-in.o: in function `cadence_spi_probe':/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184: undefined reference to `clk_get_rate' Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1
Regards
Vignesh
Quoted 42 lines
That should be enough, no? And yes, I did test this on the current state of gen5 which does not have a CLK driver, yet.
Regards,
SimonQuoted 36 lines
Regards
Ley FoonQuoted 31 lines
drivers/spi/cadence_qspi.c +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);drivers/spi/cadence_qspi.h index renamed from drivers/spi/cadence_qspi.h +0
-0
20cceca239..99dee75bbd100644drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 82 lines · Vignesh Raghavendra
Quoted 73 lines · Simon Goldschmidt
Quoted 61 lines · Ley Foon
Quoted 61 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:43 AM
To: Jagan Teki <[email protected]>
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; Vignesh Raghavendra <[email protected]>; Simon Goldschmidt <[email protected]>; u-boot at lists.denx.de
Subject: [PATCH v3] spi:cadence_qspi: supportDM_CLKSupport loading clk speed via DM instead of requiring ad-hoc code.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v3:
- loadref_clk_hzonly once incadence_spi_ofdata_to_platdatainstead of loading it every time incadence_spi_write_speedChanges in v2:
- check return value ofclk_get_ratefor errordrivers/spi/cadence_qspi.c | 21 +++++++++++++++++++-- drivers/spi/cadence_qspi.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)drivers/spi/cadence_qspi.c index renamed from drivers/spi/cadence_qspi.c +0
-0
e2e54cd277..8fd23a7702100644drivers/spi/cadence_qspi.c +5
-2@@ -5,6 +5,7 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <fdtdec.h> #include <malloc.h> @@ -24,10 +25,10 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz)struct cadence_spi_priv *priv =dev_get_priv (bus);cadence_qspi_apb_config_baudrate_div (priv->regbase, -CONFIG_CQSPI_REF_CLK , hz); + plat->ref_clk_hz, hz);/* Reconfigure delay timing if speed is changed. */ -cadence_qspi_apb_delay (priv->regbase,CONFIG_CQSPI_REF_CLK , hz, +cadence_qspi_apb_delay (priv->regbase, plat->ref_clk_hz, hz, plat->tshsl_ns, plat->tsd2d_ns, plat->tchsh_ns, plat->tslch_ns);@@ -294,6 +295,8 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) {struct cadence_spi_platdata *plat = bus->platdata;ofnode subnode; +struct clk clk; +int ret;Quoted 10 lines
Quoted 8 lines
drivers/spi/cadence_qspi.c +1
-0plat->regbase = (void *)devfdt_get_addr_index (bus,0 ); plat->ahbbase = (void *)devfdt_get_addr_index(bus, 1); @@ -325,6 +328,20 @@ 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);
Did you compile this with platform without clock DM before? Eg: Stratix10. You need add check for
CONFIG_CLKenabled to call clock DM functions here.Quoted 4 lines
Unless I'm mistaken, those functions are prototyped when CLK is not enabled:
https://elixir.bootlin.com/u-boot/latest/source/include/clk.h#L172
Quoted 7 lines
But, unfortunately, such stub does not exists for
clk_get_rate(). So on platforms w/oCONFIG_CLKset:arm-linux-gnueabihf-ld.bfd:
drivers/spi/built-in.o: in function `cadence_spi_probe':/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184: undefined reference to `clk_get_rate' Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1
So why did it compile for me? Probably because the linker knows it doesn't need 'clk_get_rate' since this branch will never be executed?
Regards,
Simon
Quoted 46 lines
Regards
VigneshQuoted 42 lines
That should be enough, no? And yes, I did test this on the current state of gen5 which does not have a CLK driver, yet.
Regards,
SimonQuoted 36 lines
Regards
Ley FoonQuoted 31 lines
drivers/spi/cadence_qspi.c +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);drivers/spi/cadence_qspi.h index renamed from drivers/spi/cadence_qspi.h +0
-0
20cceca239..99dee75bbd100644drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1
Tan
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 109 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:27 PM
To: Vignesh Raghavendra <[email protected]>
Cc: Tan, Ley Foon <[email protected]>; Jagan Teki <[email protected]>; Marek Vasut <[email protected]>; u- boot at lists.denx.de
Subject: Re: [PATCH v3] spi:cadence_qspi: supportDM_CLKQuoted 5 lines · Vignesh Raghavendra
Quoted 1 line · Simon Goldschmidt
On Tue, Nov 12, 2019 at 9:59 AM Tan, Ley Foon <[email protected]>
Quoted 46 lines · wrote:
Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:43 AM
To: Jagan Teki <[email protected]>
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; Vignesh Raghavendra <[email protected]>; Simon Goldschmidt <[email protected]>; u-boot at lists.denx.de
Subject: [PATCH v3] spi:cadence_qspi: supportDM_CLKSupport loading clk speed via DM instead of requiring ad-hoc code.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v3:
- loadref_clk_hzonly once incadence_spi_ofdata_to_platdatainstead of loading it every time incadence_spi_write_speedChanges in v2:
- check return value ofclk_get_ratefor errordrivers/spi/cadence_qspi.c | 21 +++++++++++++++++++-- drivers/spi/cadence_qspi.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/spi/cadence_qspi.cindexe2e54cd277..8fd23a7702100644drivers/spi/cadence_qspi.c +1
-0@@ -5,6 +5,7 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <fdtdec.h> #include <malloc.h> @@ -24,10 +25,10 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz)struct cadence_spi_priv *priv =dev_get_priv (bus);Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/cadence_qspi.c static int cadence_spi_write_speed(struct udevice *bus, uint hz)
Quoted 6 lines
drivers/spi/cadence_qspi.c +1
-2cadence_qspi_apb_config_baudrate_div (priv->regbase, -CONFIG_CQSPI_REF_CLK , hz); + plat->ref_clk_hz, hz);/* Reconfigure delay timing if speed is changed. */ - cadence_qspi_apb_delay(priv->regbase, CONFIG_CQSPI_REF_CLK,hz,
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/spi/cadence_qspi.c +1
-0+cadence_qspi_apb_delay (priv->regbase, plat->ref_clk_hz, hz, plat->tshsl_ns, plat->tsd2d_ns, plat->tchsh_ns, plat->tslch_ns);@@ -294,6 +295,8 @@ static intcadence_spi_ofdata_to_platdata(struct
udevice *bus) { struct cadence_spi_platdata *plat = bus->platdata; ofnode subnode;drivers/spi/cadence_qspi.c +2
-0+struct clk clk; +int ret;Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
plat->regbase = (void *)devfdt_get_addr_index(bus, 0); plat->ahbbase = (void *)devfdt_get_addr_index(bus, 1); @@ -325,6 +328,20 @@ 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);
Did you compile this with platform without clock DM before? Eg:
Stratix10.
Quoted 1 line
Quoted 1 line
Quoted 1 line
You need add check for
CONFIG_CLKenabled to call clock DM functionshere.
Quoted 2 lines
Quoted 2 lines
Unless I'm mistaken, those functions are prototyped when CLK is not
enabled:
Quoted 8 lines
But, unfortunately, such stub does not exists for
clk_get_rate(). So on platforms w/oCONFIG_CLKset:arm-linux-gnueabihf-ld.bfd:
drivers/spi/built-in.o: in function
Quoted 8 lines
`cadence_spi_probe':
Quoted 1 line
/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184:undefined reference to `clk_get_rate'
Quoted 2 lines
Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1So why did it compile for me? Probably because the linker knows it doesn't need '
clk_get_rate' since this branch will never be executed?
Maybe you can try compile from clean build. Run "make mrproper" before compile.
Regards
Ley Foon
Quoted 51 lines
Regards,
SimonQuoted 47 lines
Regards
VigneshQuoted 43 lines
That should be enough, no? And yes, I did test this on the current state of
gen5 which does not have a CLK driver, yet.Regards,
SimonQuoted 36 lines
Regards
Ley FoonQuoted 31 lines
drivers/spi/cadence_qspi.c +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);(quoted diff) +0
-0
b/drivers/spi/cadence_qspi.hindex20cceca239..99dee75bbd100644drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 111 lines · Ley Foon
Quoted 111 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:27 PM
To: Vignesh Raghavendra <[email protected]>
Cc: Tan, Ley Foon <[email protected]>; Jagan Teki <[email protected]>; Marek Vasut <[email protected]>; u- boot at lists.denx.de
Subject: Re: [PATCH v3] spi:cadence_qspi: supportDM_CLKQuoted 5 lines · Vignesh Raghavendra
Quoted 1 line · Simon Goldschmidt
On Tue, Nov 12, 2019 at 9:59 AM Tan, Ley Foon <[email protected]>
Quoted 46 lines · wrote:
Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:43 AM
To: Jagan Teki <[email protected]>
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; Vignesh Raghavendra <[email protected]>; Simon Goldschmidt <[email protected]>; u-boot at lists.denx.de
Subject: [PATCH v3] spi:cadence_qspi: supportDM_CLKSupport loading clk speed via DM instead of requiring ad-hoc code.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v3:
- loadref_clk_hzonly once incadence_spi_ofdata_to_platdatainstead of loading it every time incadence_spi_write_speedChanges in v2:
- check return value ofclk_get_ratefor errordrivers/spi/cadence_qspi.c | 21 +++++++++++++++++++-- drivers/spi/cadence_qspi.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/spi/cadence_qspi.cindexe2e54cd277..8fd23a7702100644drivers/spi/cadence_qspi.c +1
-0@@ -5,6 +5,7 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <fdtdec.h> #include <malloc.h> @@ -24,10 +25,10 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz)struct cadence_spi_priv *priv =dev_get_priv (bus);Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/spi/cadence_qspi.c static int cadence_spi_write_speed(struct udevice *bus, uint hz)
Quoted 6 lines
drivers/spi/cadence_qspi.c +1
-2cadence_qspi_apb_config_baudrate_div (priv->regbase, -CONFIG_CQSPI_REF_CLK , hz); + plat->ref_clk_hz, hz);/* Reconfigure delay timing if speed is changed. */ - cadence_qspi_apb_delay(priv->regbase, CONFIG_CQSPI_REF_CLK,hz,
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/spi/cadence_qspi.c +1
-0+cadence_qspi_apb_delay (priv->regbase, plat->ref_clk_hz, hz, plat->tshsl_ns, plat->tsd2d_ns, plat->tchsh_ns, plat->tslch_ns);@@ -294,6 +295,8 @@ static intcadence_spi_ofdata_to_platdata(struct
udevice *bus) { struct cadence_spi_platdata *plat = bus->platdata; ofnode subnode;drivers/spi/cadence_qspi.c +2
-0+struct clk clk; +int ret;Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
plat->regbase = (void *)devfdt_get_addr_index(bus, 0); plat->ahbbase = (void *)devfdt_get_addr_index(bus, 1); @@ -325,6 +328,20 @@ 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);
Did you compile this with platform without clock DM before? Eg:
Stratix10.
Quoted 1 line
Quoted 1 line
Quoted 1 line
You need add check for
CONFIG_CLKenabled to call clock DM functionshere.
Quoted 2 lines
Quoted 2 lines
Unless I'm mistaken, those functions are prototyped when CLK is not
enabled:
Quoted 8 lines
But, unfortunately, such stub does not exists for
clk_get_rate(). So on platforms w/oCONFIG_CLKset:arm-linux-gnueabihf-ld.bfd:
drivers/spi/built-in.o: in function`cadence_spi_probe':
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184:undefined reference to `clk_get_rate'
Quoted 2 lines
Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1So why did it compile for me? Probably because the linker knows it doesn't need '
clk_get_rate' since this branch will never be executed?Maybe you can try compile from clean build. Run "make mrproper" before compile.
Of course I did that, and I just did it again. It *does* compile.
Can anyone tell me a config/setup where it doesn't compile? Or does this complain only come from reading the sources?
Regards,
Simon
Quoted 54 lines
Regards
Ley FoonQuoted 51 lines
Regards,
SimonQuoted 47 lines
Regards
VigneshQuoted 43 lines
That should be enough, no? And yes, I did test this on the current state of
gen5 which does not have a CLK driver, yet.Regards,
SimonQuoted 36 lines
Regards
Ley FoonQuoted 31 lines
drivers/spi/cadence_qspi.c +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);(quoted diff) +0
-0
b/drivers/spi/cadence_qspi.hindex20cceca239..99dee75bbd100644drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 2 lines · Simon Goldschmidt
Quoted 1 line · Ley Foon
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
But, unfortunately, such stub does not exists for
clk_get_rate(). So on platforms w/oCONFIG_CLKset:arm-linux-gnueabihf-ld.bfd:
drivers/spi/built-in.o: in function`cadence_spi_probe':
Quoted 1 line
/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184:undefined reference to `clk_get_rate'
Quoted 2 lines
Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1
Quoted 9 lines
Quoted 3 lines
Quoted 2 lines
So why did it compile for me? Probably because the linker knows it doesn't need '
clk_get_rate' since this branch will never be executed?Maybe you can try compile from clean build. Run "make mrproper" before compile.
Of course I did that, and I just did it again. It *does* compile.
Can anyone tell me a config/setup where it doesn't compile? Or does this complain only come from reading the sources?
I see above error with k2g_evm_defconfig and compiler is:
arm-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0
Regards
Vignesh
Quoted 57 lines
Regards,
SimonQuoted 54 lines
Regards
Ley FoonQuoted 51 lines
Regards,
SimonQuoted 47 lines
Regards
VigneshQuoted 43 lines
That should be enough, no? And yes, I did test this on the current state of
gen5 which does not have a CLK driver, yet.Regards,
SimonQuoted 36 lines
Regards
Ley FoonQuoted 31 lines
(quoted diff) +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);(quoted diff) +0
-0
b/drivers/spi/cadence_qspi.hindex20cceca239..99dee75bbd100644drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1
Signature · 2 lines
Regards Vignesh
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 21 lines · Vignesh Raghavendra
Quoted 2 lines · Simon Goldschmidt
Quoted 1 line · Ley Foon
[...]
Quoted 14 lines
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
But, unfortunately, such stub does not exists for
clk_get_rate(). So on platforms w/oCONFIG_CLKset:arm-linux-gnueabihf-ld.bfd:
drivers/spi/built-in.o: in functionQuoted 8 lines
`cadence_spi_probe':
Quoted 1 line
/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184:undefined reference to `clk_get_rate'
Quoted 2 lines
Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1So why did it compile for me? Probably because the linker knows it doesn't need '
clk_get_rate' since this branch will never be executed?Maybe you can try compile from clean build. Run "make mrproper" before compile.
Quoted 7 lines
Quoted 5 lines
Of course I did that, and I just did it again. It *does* compile.
Can anyone tell me a config/setup where it doesn't compile? Or does this complain only come from reading the sources?
I see above error with
k2g_evm_defconfigand compiler is:
Ok, just tested that config and it works for me :-(
Quoted 3 lines
arm-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0
I'm using 6.3.0 from debian stretch, but have also tested my patch with newest Ubuntu (which has a 9.x cross compiler).
So while I think that difference is disturbing, Maybe it's really best to inline-define all clock functions as you mentioned to Patrick in the other thread...
Regards,
Simon
Quoted 66 lines
Regards
VigneshQuoted 57 lines
Regards,
SimonQuoted 54 lines
Regards
Ley FoonQuoted 51 lines
Regards,
SimonQuoted 47 lines
Regards
VigneshQuoted 43 lines
That should be enough, no? And yes, I did test this on the current state of
gen5 which does not have a CLK driver, yet.Regards,
SimonQuoted 36 lines
Regards
Ley FoonQuoted 31 lines
(quoted diff) +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);(quoted diff) +0
-0
b/drivers/spi/cadence_qspi.hindex20cceca239..99dee75bbd100644drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1
--
Regards
Vignesh
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Marek,
Am 12.11.2019 um 12:57 schrieb Simon Goldschmidt:
Quoted 24 lines · Vignesh Raghavendra
Quoted 23 lines · Simon Goldschmidt
Quoted 2 lines · Ley Foon
Quoted 1 line
[...]
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
But, unfortunately, such stub does not exists for
clk_get_rate(). So on platforms w/oCONFIG_CLKset:arm-linux-gnueabihf-ld.bfd:
drivers/spi/built-in.o: in function`cadence_spi_probe':
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184:undefined reference to `clk_get_rate'
Quoted 2 lines
Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1So why did it compile for me? Probably because the linker knows it doesn't need '
clk_get_rate' since this branch will never be executed?Maybe you can try compile from clean build. Run "make mrproper" before compile.
Of course I did that, and I just did it again. It *does* compile.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Can anyone tell me a config/setup where it doesn't compile? Or does this complain only come from reading the sources?
I see above error with
k2g_evm_defconfigand compiler is:Ok, just tested that config and it works for me :-(
After having a successful travis run for this on top of u-boot-socfpga/master, could you take this and re-send the PR of last week?
Travis run is here:
https://travis-ci.org/goldsimon/u-boot/builds/614187977
Regards,
Simon
Quoted 81 lines
Quoted 4 lines
arm-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0
I'm using 6.3.0 from debian stretch, but have also tested my patch with newest Ubuntu (which has a 9.x cross compiler).
So while I think that difference is disturbing, Maybe it's really best to inline-define all clock functions as you mentioned to Patrick in the other thread...
Regards,
SimonQuoted 66 lines
Regards
VigneshQuoted 57 lines
Regards,
SimonQuoted 54 lines
Regards
Ley FoonQuoted 51 lines
Regards,
SimonQuoted 47 lines
Regards
VigneshQuoted 43 lines
That should be enough, no? And yes, I did test this on the current state of
gen5 which does not have a CLK driver, yet.Regards,
SimonQuoted 36 lines
Regards
Ley FoonQuoted 31 lines
(quoted diff) +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);(quoted diff) +0
-0
b/drivers/spi/cadence_qspi.hindex20cceca239..99dee75bbd100644drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1
--
Regards
Vignesh
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 37 lines · Simon Goldschmidt
Marek,
Am 12.11.2019 um 12:57 schrieb Simon Goldschmidt:
Quoted 34 lines
Quoted 31 lines · Vignesh Raghavendra
Quoted 3 lines · Simon Goldschmidt
Quoted 1 line · Ley Foon
[...]
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines
But, unfortunately, such stub does not exists for
clk_get_rate(). So on platforms w/oCONFIG_CLKset:arm-linux-gnueabihf-ld.bfd:
drivers/spi/built-in.o: in function`cadence_spi_probe':
Quoted 1 line
/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184:undefined reference to `clk_get_rate'
Quoted 2 lines
Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1So why did it compile for me? Probably because the linker knows it doesn't
need 'clk_get_rate' since this branch will never be executed?Quoted 8 lines
Quoted 2 lines
Maybe you can try compile from clean build. Run "make mrproper" before compile.
Of course I did that, and I just did it again. It *does* compile.
Can anyone tell me a config/setup where it doesn't compile? Or does this complain only come from reading the sources?
I see above error with
k2g_evm_defconfigand compiler is:
Quoted 8 lines
Quoted 1 line
Ok, just tested that config and it works for me :-(
After having a successful travis run for this on top of u-boot-socfpga/master, could you take this and re-send the PR of last week?
Travis run is here:
Wait, so that PR was good all along ?
Also, can you just resend this one ?
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Am 20.11.2019 um 21:51 schrieb Marek Vasut:
Quoted 40 lines · Simon Goldschmidt
Quoted 39 lines
Marek,
Am 12.11.2019 um 12:57 schrieb Simon Goldschmidt:
Quoted 35 lines
Quoted 24 lines · Vignesh Raghavendra
Quoted 3 lines · Simon Goldschmidt
Quoted 1 line · Ley Foon
[...]
Quoted 16 lines
Quoted 15 lines
Quoted 5 lines
Quoted 4 lines
But, unfortunately, such stub does not exists for
clk_get_rate(). So on platforms w/oCONFIG_CLKset:arm-linux-gnueabihf-ld.bfd:
drivers/spi/built-in.o: in function`cadence_spi_probe':
Quoted 8 lines
Quoted 1 line
/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184:undefined reference to `clk_get_rate'
Quoted 2 lines
Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1So why did it compile for me? Probably because the linker knows it doesn't
need 'clk_get_rate' since this branch will never be executed?Maybe you can try compile from clean build. Run "make mrproper" before compile.
Quoted 7 lines
Quoted 5 lines
Of course I did that, and I just did it again. It *does* compile.
Can anyone tell me a config/setup where it doesn't compile? Or does this complain only come from reading the sources?
I see above error with
k2g_evm_defconfigand compiler is:Ok, just tested that config and it works for me :-(
Quoted 8 lines
Quoted 6 lines
After having a successful travis run for this on top of u-boot-socfpga/master, could you take this and re-send the PR of last week?
Travis run is here:
Wait, so that PR was good all along ?
D'oh, no, sorry I phrased that wrong, sorry. That PR had v2 and this is v3. I meant use this one instead v2 and send another PR.
Quoted 2 lines
Also, can you just resend this one ?
Yes, I'll do that.
Regards,
Simon
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
Quoted 51 lines · Simon Goldschmidt
Am 20.11.2019 um 21:51 schrieb Marek Vasut:
Quoted 44 lines · Simon Goldschmidt
Quoted 43 lines
Marek,
Am 12.11.2019 um 12:57 schrieb Simon Goldschmidt:
Quoted 28 lines
Quoted 26 lines · Vignesh Raghavendra
Quoted 3 lines · Simon Goldschmidt
Quoted 1 line · Ley Foon
[...]
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
But, unfortunately, such stub does not exists for
clk_get_rate(). So on platforms w/oCONFIG_CLKset:arm-linux-gnueabihf-ld.bfd:
drivers/spi/built-in.o: in function`cadence_spi_probe':
Quoted 1 line
/home/a0132425/workspace/u-boot/drivers/spi/cadence_qspi.c:184:undefined reference to `clk_get_rate'
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Makefile:1647: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1So why did it compile for me? Probably because the linker knows it doesn't
need 'clk_get_rate' since this branch will never be executed?Maybe you can try compile from clean build. Run "make mrproper" before compile.
Of course I did that, and I just did it again. It *does* compile.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Can anyone tell me a config/setup where it doesn't compile? Or does this complain only come from reading the sources?
I see above error with
k2g_evm_defconfigand compiler is:Ok, just tested that config and it works for me :-(
After having a successful travis run for this on top of u-boot-socfpga/master, could you take this and re-send the PR of last week?
Quoted 5 lines
Quoted 3 lines
Travis run is here:
Wait, so that PR was good all along ?
Quoted 7 lines
D'oh, no, sorry I phrased that wrong, sorry. That PR had v2 and this is v3. I meant use this one instead v2 and send another PR.
Quoted 2 lines
Also, can you just resend this one ?
Yes, I'll do that.
OK, thanks.
Tan
PATCH v3 1/1 spi: cadence_qspi: support DM_CLK
In reply to Simon GoldschmidtQuoted 88 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:14 PM
To: Tan, Ley Foon <[email protected]>
Cc: Jagan Teki <[email protected]>; Marek Vasut <[email protected]>; Vignesh Raghavendra <[email protected]>; u- boot at lists.denx.de
Subject: Re: [PATCH v3] spi:cadence_qspi: supportDM_CLKQuoted 63 lines · Ley Foon
Quoted 63 lines
-----Original Message-----
From: Simon Goldschmidt <[email protected]>
Sent: Tuesday, November 12, 2019 5:43 AM
To: Jagan Teki <[email protected]>
Cc: Marek Vasut <[email protected]>; Tan, Ley Foon <[email protected]>; Vignesh Raghavendra <[email protected]>; Simon Goldschmidt <[email protected]>; u-boot at lists.denx.de
Subject: [PATCH v3] spi:cadence_qspi: supportDM_CLKSupport loading clk speed via DM instead of requiring ad-hoc code.
Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v3:
- loadref_clk_hzonly once incadence_spi_ofdata_to_platdatainstead of loading it every time incadence_spi_write_speedChanges in v2:
- check return value ofclk_get_ratefor errordrivers/spi/cadence_qspi.c | 21 +++++++++++++++++++-- drivers/spi/cadence_qspi.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)drivers/spi/cadence_qspi.c +0
-0index
e2e54cd277..8fd23a7702100644drivers/spi/cadence_qspi.c +5
-2@@ -5,6 +5,7 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <fdtdec.h> #include <malloc.h> @@ -24,10 +25,10 @@ static int cadence_spi_write_speed(struct udevice *bus, uint hz)struct cadence_spi_priv *priv =dev_get_priv (bus);cadence_qspi_apb_config_baudrate_div (priv->regbase, -CONFIG_CQSPI_REF_CLK , hz); + plat->ref_clk_hz, hz);/* Reconfigure delay timing if speed is changed. */ -cadence_qspi_apb_delay (priv->regbase,CONFIG_CQSPI_REF_CLK , hz, +cadence_qspi_apb_delay (priv->regbase, plat->ref_clk_hz, hz, plat->tshsl_ns, plat->tsd2d_ns, plat->tchsh_ns, plat->tslch_ns);@@ -294,6 +295,8 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus) {struct cadence_spi_platdata *plat = bus->platdata;ofnode subnode; +struct clk clk; +int ret;Quoted 12 lines
Quoted 10 lines
drivers/spi/cadence_qspi.c +2
-1plat->regbase = (void *)devfdt_get_addr_index (bus,0 ); plat->ahbbase = (void *)devfdt_get_addr_index(bus, 1); @@ -325,6 +328,20 @@ 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);
Did you compile this with platform without clock DM before? Eg: Stratix10. You need add check for
CONFIG_CLKenabled to call clock DM functions
Quoted 9 lines
here.
Unless I'm mistaken, those functions are prototyped when CLK is not enabled:
https://elixir.bootlin.com/u-boot/latest/source/include/clk.h#L172
That should be enough, no? And yes, I did test this on the current state of gen5 which does not have a CLK driver, yet.
I also saw related clock issue in another patch review: https://patchwork.ozlabs.org/cover/1191936/
Some functions in clock DM doesn't have non-DM version functions wrapper, eg: clk_get_rate
Regards
Ley Foon
Quoted 37 lines
Quoted 37 lines
Regards
Ley FoonQuoted 31 lines
drivers/spi/cadence_qspi.c +13
-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; + } + debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
__func__, plat->regbase, plat->ahbbase, plat->max_hz, plat->page_size);drivers/spi/cadence_qspi.h +1
-1@@ -16,6 +16,7 @@#define CQSPI_READ_CAPTURE_MAX_DELAY 16struct cadence_spi_platdata { +unsigned int ref_clk_hz;unsigned int max_hz;void *regbase;void *ahbbase; --2.20.1