driver: pwm: pwm-imx: fix probing on imx6
Subsystems (2)
PATCH v2 1/1 driver: pwm: pwm-imx: fix probing on imx6
U-Boot 2024.07 drops on aristainetos2 board the following warning:
Failed to enable per_clk
and bootlogo is not seen on LVDS display.
This patch uses old behaviour for systems without clock framework if CONFIG_CLK is not enabled.
---
Changes in v2:
use CONFIG_IS_ENABLED instead of IS_ENABLED
as Anatolij suggested.
drivers/pwm/pwm-imx.c | 56 ++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 25 deletions(-)
drivers/pwm/pwm-imx.c +31 -25
@@ -160,7 +160,11 @@ int pwm_dm_imx_get_parms(struct imx_pwm_priv *priv, int period_ns, {unsigned long long c; - c =clk_get_rate (&priv->per_clk); +if (CONFIG_IS_ENABLED (CLK )) + c =clk_get_rate (&priv->per_clk); +else + c =CFG_IMX6_PWM_PER_CLK ; + c = c * period_ns;do_div (c,1000000000 ); *period_c = c;
@@ -227,43 +231,45 @@ static int imx_pwm_set_enable(struct udevice *dev, uint channel, bool enable)static int imx_pwm_of_to_plat (struct udevice *dev) { -int ret; +int __maybe_unused ret;struct imx_pwm_priv *priv =dev_get_priv (dev); priv->regs =dev_read_addr_ptr (dev); - ret =clk_get_by_name (dev,"per" , &priv->per_clk); -if (ret) { -printf ("Failed to get per_clk\n" ); -return ret; - } - - ret =clk_get_by_name (dev,"ipg" , &priv->ipg_clk); -if (ret) { -printf ("Failed to get ipg_clk\n" ); -return ret; +if (CONFIG_IS_ENABLED (CLK )) { + ret =clk_get_by_name (dev,"per" , &priv->per_clk); +if (ret) { +printf ("Failed to get per_clk\n" ); +return ret; + } + + ret =clk_get_by_name (dev,"ipg" , &priv->ipg_clk); +if (ret) { +printf ("Failed to get ipg_clk\n" ); +return ret; + } } -return 0 ; }static int imx_pwm_probe (struct udevice *dev) { -int ret; +int __maybe_unused ret;struct imx_pwm_priv *priv =dev_get_priv (dev); - ret =clk_enable (&priv->per_clk); -if (ret) { -printf ("Failed to enable per_clk\n" ); -return ret; - } - - ret =clk_enable (&priv->ipg_clk); -if (ret) { -printf ("Failed to enable ipg_clk\n" ); -return ret; +if (CONFIG_IS_ENABLED (CLK )) { + ret =clk_enable (&priv->per_clk); +if (ret) { +printf ("Failed to enable per_clk\n" ); +return ret; + } + + ret =clk_enable (&priv->ipg_clk); +if (ret) { +printf ("Failed to enable ipg_clk\n" ); +return ret; + } } -return 0 ; }
Signature · 1 line
2.20.1
Fabio Estevam
reviewerHi Heiko,
Quoted 11 lines · Heiko Schocher
U-Boot 2024.07 drops on aristainetos2 board the following warning:
Failed to enable
per_clkand bootlogo is not seen on LVDS display.
This patch uses old behaviour for systems without clock framework if
CONFIG_CLKis not enabled.
Quoted 8 lines
Fixes bfc778cb93a3 ("driver: pwm: pwm-imx: get and enable per/ipg clock using dm")Signed-off-by Heiko Schocher <[email protected]>---
Changes in v2:
useCONFIG_IS_ENABLEDinstead ofIS_ENABLED
as Anatolij suggested.
This causes build failures:
https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/887503
Please fix and resend.
Thanks
Hello Fabio, Tom,
Quoted 23 lines · Fabio Estevam
Hi Heiko,
Quoted 11 lines · Heiko Schocher
U-Boot 2024.07 drops on aristainetos2 board the following warning:
Failed to enable
per_clkand bootlogo is not seen on LVDS display.
This patch uses old behaviour for systems without clock framework if
CONFIG_CLKis not enabled.Quoted 8 lines
Fixes bfc778cb93a3 ("driver: pwm: pwm-imx: get and enable per/ipg clock using dm")Signed-off-by Heiko Schocher <[email protected]>---
Changes in v2:
useCONFIG_IS_ENABLEDinstead ofIS_ENABLED
as Anatolij suggested.
Quoted 5 lines
This causes build failures:
https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/887503
Please fix and resend.
Hmm... yes ... I work/worked on aristainetos2 board update for 2024.07 (or later) ... and saw this
Failed to enable per_clk
warning when 2024.07 boots ... and bootlogo did not work anymore, as backlight is pwm driven on this hardware...
I bet, for all the boards which fail in the azure run with this patch, PWM do not work anymore... because CONFIG_CLK is not enabled for them!
I am really unhappy, that I have no automated U-Boot runtime tests anymore running on real hardware... setup with tbot was very easy, but had no time for looking at the bugs poping up...
Hmm... looking in git history, there comes this commit in my eyes:
commit 4eea76574062e9079b6a267229962d6ec0be910a
Author: Tom Rini <[email protected]> Date: Sat Nov 19 18:45:18 2022 -0500
pwm: imx: Remove unused references to CONFIG_IMX6_PWM_PER_CLK
On platforms that use DM_PWM, we do not need to define this value anymore, so remove it from config files.
which exactly removes for all breaking boards this define...
Should we revert this patch?
I just can say for the aristianetos2 board, that I readded exactly this define in my work for the port to currentmainline ... and with my patch, pwm and so bootlogo works again ...
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Quoted 60 lines · Heiko Schocher
Hello Fabio, Tom,
Quoted 23 lines · Fabio Estevam
Hi Heiko,
Quoted 11 lines · Heiko Schocher
U-Boot 2024.07 drops on aristainetos2 board the following warning:
Failed to enable
per_clkand bootlogo is not seen on LVDS display.
This patch uses old behaviour for systems without clock framework if
CONFIG_CLKis not enabled.Quoted 8 lines
Fixes bfc778cb93a3 ("driver: pwm: pwm-imx: get and enable per/ipg clock using dm")Signed-off-by Heiko Schocher <[email protected]>---
Changes in v2:
useCONFIG_IS_ENABLEDinstead ofIS_ENABLED
as Anatolij suggested.Quoted 5 lines
This causes build failures:
https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/887503
Please fix and resend.
Hmm... yes ... I work/worked on aristainetos2 board update for 2024.07 (or later) ... and saw this
Failed to enable
per_clkwarning when 2024.07 boots ... and bootlogo did not work anymore, as backlight is pwm driven on this hardware...
I bet, for all the boards which fail in the azure run with this patch, PWM do not work anymore... because
CONFIG_CLKis not enabled for them!I am really unhappy, that I have no automated U-Boot runtime tests anymore running on real hardware... setup with tbot was very easy, but had no time for looking at the bugs poping up...
Hmm... looking in git history, there comes this commit in my eyes:
commit
4eea76574062e9079b6a267229962d6ec0be910aAuthor: Tom Rini <[email protected]> Date: Sat Nov 19 18:45:18 2022 -0500pwm: imx: Remove unused references to
CONFIG_IMX6_PWM_PER_CLKOn platforms that use
DM_PWM, we do not need to define this value anymore, so remove it from config files.Signed-off-by Tom Rini <[email protected]>
Quoted 7 lines
which exactly removes for all breaking boards this define...
Should we revert this patch?
I just can say for the aristianetos2 board, that I readded exactly this define in my work for the port to currentmainline ... and with my patch, pwm and so bootlogo works again ...
We can't do a strict revert, no, the symbol is now CFG_IMX6_PWM_PER_CLK. But also, isn't this board using DM_PWM? And if so, that value isn't used?
Signature · 1 line
Tom
Hello Tom,
Quoted 65 lines · Tom Rini
Quoted 64 lines · Heiko Schocher
Hello Fabio, Tom,
Quoted 23 lines · Fabio Estevam
Hi Heiko,
Quoted 11 lines · Heiko Schocher
U-Boot 2024.07 drops on aristainetos2 board the following warning:
Failed to enable
per_clkand bootlogo is not seen on LVDS display.
This patch uses old behaviour for systems without clock framework if
CONFIG_CLKis not enabled.Quoted 8 lines
Fixes bfc778cb93a3 ("driver: pwm: pwm-imx: get and enable per/ipg clock using dm")Signed-off-by Heiko Schocher <[email protected]>---
Changes in v2:
useCONFIG_IS_ENABLEDinstead ofIS_ENABLED
as Anatolij suggested.Quoted 5 lines
This causes build failures:
https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/887503
Please fix and resend.
Hmm... yes ... I work/worked on aristainetos2 board update for 2024.07 (or later) ... and saw this
Failed to enable
per_clkwarning when 2024.07 boots ... and bootlogo did not work anymore, as backlight is pwm driven on this hardware...
I bet, for all the boards which fail in the azure run with this patch, PWM do not work anymore... because
CONFIG_CLKis not enabled for them!I am really unhappy, that I have no automated U-Boot runtime tests anymore running on real hardware... setup with tbot was very easy, but had no time for looking at the bugs poping up...
Hmm... looking in git history, there comes this commit in my eyes:
commit
4eea76574062e9079b6a267229962d6ec0be910aAuthor: Tom Rini <[email protected]> Date: Sat Nov 19 18:45:18 2022 -0500pwm: imx: Remove unused references to
CONFIG_IMX6_PWM_PER_CLKOn platforms that use
DM_PWM, we do not need to define this value anymore, so remove it from config files.Signed-off-by Tom Rini <[email protected]>which exactly removes for all breaking boards this define...
Should we revert this patch?
Quoted 7 lines
Quoted 3 lines
I just can say for the aristianetos2 board, that I readded exactly this define in my work for the port to currentmainline ... and with my patch, pwm and so bootlogo works again ...
We can't do a strict revert, no, the symbol is now
CFG_IMX6_PWM_PER_CLK. But also, isn't this board usingDM_PWM? And if so, that value isn't used?
Yes, of course, simple revert does not work.
Yes, the failing boards are converted to DM_PWM, but they do not work anymore as bfc778cb93a3 intrdocued clk framework functions, and the failing boards have no clk framwork enabled. So my patch simply readded the define for DM_PWM case.
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Quoted 76 lines · Heiko Schocher
Hello Tom,
Quoted 65 lines · Tom Rini
Quoted 64 lines · Heiko Schocher
Hello Fabio, Tom,
Quoted 23 lines · Fabio Estevam
Hi Heiko,
Quoted 11 lines · Heiko Schocher
U-Boot 2024.07 drops on aristainetos2 board the following warning:
Failed to enable
per_clkand bootlogo is not seen on LVDS display.
This patch uses old behaviour for systems without clock framework if
CONFIG_CLKis not enabled.Quoted 8 lines
Fixes bfc778cb93a3 ("driver: pwm: pwm-imx: get and enable per/ipg clock using dm")Signed-off-by Heiko Schocher <[email protected]>---
Changes in v2:
useCONFIG_IS_ENABLEDinstead ofIS_ENABLED
as Anatolij suggested.Quoted 5 lines
This causes build failures:
https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/887503
Please fix and resend.
Hmm... yes ... I work/worked on aristainetos2 board update for 2024.07 (or later) ... and saw this
Failed to enable
per_clkwarning when 2024.07 boots ... and bootlogo did not work anymore, as backlight is pwm driven on this hardware...
I bet, for all the boards which fail in the azure run with this patch, PWM do not work anymore... because
CONFIG_CLKis not enabled for them!I am really unhappy, that I have no automated U-Boot runtime tests anymore running on real hardware... setup with tbot was very easy, but had no time for looking at the bugs poping up...
Hmm... looking in git history, there comes this commit in my eyes:
commit
4eea76574062e9079b6a267229962d6ec0be910aAuthor: Tom Rini <[email protected]> Date: Sat Nov 19 18:45:18 2022 -0500pwm: imx: Remove unused references to
CONFIG_IMX6_PWM_PER_CLKOn platforms that use
DM_PWM, we do not need to define this value anymore, so remove it from config files.Signed-off-by Tom Rini <[email protected]>which exactly removes for all breaking boards this define...
Should we revert this patch?
Quoted 7 lines
Quoted 3 lines
I just can say for the aristianetos2 board, that I readded exactly this define in my work for the port to currentmainline ... and with my patch, pwm and so bootlogo works again ...
We can't do a strict revert, no, the symbol is now
CFG_IMX6_PWM_PER_CLK. But also, isn't this board usingDM_PWM? And if so, that value isn't used?
Quoted 6 lines
Yes, of course, simple revert does not work.
Yes, the failing boards are converted to
DM_PWM, but they do not work anymore asbfc778cb93a3intrdocued clk framework functions, and the failing boards have no clk framwork enabled. So my patch simply readded the define forDM_PWMcase.
OK. And why don't we just fix the missing clock migration next?
Signature · 1 line
Tom
Fabio Estevam
reviewerHi Heiko,
Quoted 5 lines · Heiko Schocher
Should we revert this patch?
I just can say for the aristianetos2 board, that I readded exactly this define in my work for the port to currentmainline ... and with my patch, pwm and so bootlogo works again ...
What about the change below on top of your patch?
drivers/pwm/pwm-imx.c +2 -0
@@ -14,6 +14,8 @@#include <asm/io.h> #include <clk.h> +#define IMX6_PWM_PER_CLK 66000000 +int pwm_config_internal (struct pwm_regs *pwm,unsigned long period_cycles,unsigned long duty_cycles,unsigned long prescale) {
@@ -75,7 +77,7 @@ int pwm_imx_get_parms(int period_ns, int duty_ns,
unsigned long *period_c,
* value here as a define. Replace it when we have the clock
* framework.
*/
- c = CFG_IMX6_PWM_PER_CLK;
+ c = IMX6_PWM_PER_CLK;
c = c * period_ns;
do_div(c, 1000000000);
*period_c = c;
@@ -162,7 +164,7 @@ int pwm_dm_imx_get_parms(struct imx_pwm_priv
*priv, int period_ns,
if (CONFIG_IS_ENABLED(CLK))
c = clk_get_rate(&priv->per_clk);
else- c = CFG_IMX6_PWM_PER_CLK;
+ c = IMX6_PWM_PER_CLK;
c = c * period_ns;
do_div(c, 1000000000);Hello Fabio,
Quoted 42 lines · Fabio Estevam
Hi Heiko,
Quoted 5 lines · Heiko Schocher
Should we revert this patch?
I just can say for the aristianetos2 board, that I readded exactly this define in my work for the port to currentmainline ... and with my patch, pwm and so bootlogo works again ...
What about the change below on top of your patch?
drivers/pwm/pwm-imx.c +3
-1@@ -14,6 +14,8 @@#include <asm/io.h> #include <clk.h> +#define IMX6_PWM_PER_CLK 66000000 +int pwm_config_internal (struct pwm_regs *pwm,unsigned long period_cycles,unsigned long duty_cycles,unsigned long prescale) {@@ -75,7 +77,7 @@ int pwm_imx_get_parms(int period_ns, int duty_ns,unsigned long *period_c, * value here as a define. Replace it when we have the clock * framework. */ - c =CFG_IMX6_PWM_PER_CLK ; + c =IMX6_PWM_PER_CLK ; c = c * period_ns;do_div (c,1000000000 );*period_c = c;drivers/pwm/pwm-imx.c +1
-1@@ -162,7 +164,7 @@ int pwm_dm_imx_get_parms(struct imx_pwm_priv *priv, int period_ns, if (CONFIG_IS_ENABLED(CLK)) c =clk_get_rate (&priv->per_clk); else - c =CFG_IMX6_PWM_PER_CLK ; + c =IMX6_PWM_PER_CLK ; c = c * period_ns;
Quoted 1 line
do_div(c, 1000000000);
Hmm.. yes, setting a default value is a good option, so I would add a check, if define is not set yet?
And we should simply let the name "CFG_IMX6_PWM_PER_CLK" ?
If okay, I can make a v3 if you want?
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Fabio Estevam
reviewerHi Heiko,
Quoted 4 lines · Heiko Schocher
Hmm.. yes, setting a default value is a good option, so I would add a check, if define is not set yet?
And we should simply let the name "
CFG_IMX6_PWM_PER_CLK" ?
Yes, that is OK.
Quoted 1 line
If okay, I can make a v3 if you want?
Yes, please send a v3.
Thanks,
Fabio Estevam