[PATCH v2] driver: pwm: pwm-imx: fix probing on imx6
Heiko Schocher
hs at denx.de
Wed Aug 7 17:53:43 CEST 2024
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.
Fixes: bfc778cb93a3 ("driver: pwm: pwm-imx: get and enable per/ipg clock using dm")
Signed-off-by: Heiko Schocher <hs at denx.de>
---
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(-)
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index 8fbb40cc276..e69684b2167 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -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;
}
--
2.20.1
More information about the U-Boot
mailing list