From: Theodore Oviguian <[email protected]>
eHRPWM driver was disabling the module clock at every channel disable, thats a bad idea because if the other chanel is enabled that froze it. Signed-off-by: Theodore Oviguian <[email protected]> Cc: Tom Rini <[email protected]> Cc: Lukasz Majewski <[email protected]> --- drivers/pwm/pwm-ti-ehrpwm.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-ti-ehrpwm.c b/drivers/pwm/pwm-ti-ehrpwm.c index 135ea3b4321..82422f85a7c 100644 --- a/drivers/pwm/pwm-ti-ehrpwm.c +++ b/drivers/pwm/pwm-ti-ehrpwm.c @@ -101,6 +101,7 @@ struct ti_ehrpwm_priv { struct clk tbclk; unsigned long period_cycles[TI_EHRPWM_NUM_CHANNELS]; bool polarity_reversed[TI_EHRPWM_NUM_CHANNELS]; + bool enabled[TI_EHRPWM_NUM_CHANNELS]; }; static void ti_ehrpwm_modify(u16 val, u16 mask, fdt_addr_t reg) @@ -333,6 +334,15 @@ static int ti_ehrpwm_disable(struct udevice *dev, uint channel) ti_ehrpwm_modify(aqcsfrc_val, aqcsfrc_mask, priv->regs + TI_EHRPWM_AQCSFRC); + /* + * Disabling TBCLK on PWM disable + * Only if all channels are disabled + */ + priv->enabled[channel] = false; + for (uint i = 0; i < TI_EHRPWM_NUM_CHANNELS; i++) { + if (priv->enabled[i]) + return 0; + } /* Disabling TBCLK on PWM disable */ err = clk_disable(&priv->tbclk); if (err) { @@ -377,7 +387,7 @@ static int ti_ehrpwm_enable(struct udevice *dev, uint channel) dev_err(dev, "failed to enable tbclk\n"); return err; } - + priv->enabled[channel] = true; return 0; } @@ -399,7 +409,7 @@ static int ti_ehrpwm_of_to_plat(struct udevice *dev) return -EINVAL; } - dev_dbg(dev, "regs=0x%08x\n", priv->regs); + dev_dbg(dev, "regs=0x%08llx\n", priv->regs); return 0; } @@ -439,6 +449,9 @@ static int ti_ehrpwm_probe(struct udevice *dev) return err; } + for (uint i = 0; i < TI_EHRPWM_NUM_CHANNELS; i++) + priv->enabled[i] = false; + return 0; } -- 2.43.0

