Re: [PATCH v3 2/2] pwm: loongson: Reload PWM configuration through counter reset
From: Keguang Zhang
Date: Sun Sep 13 2026 - 22:46:43 EST
On Thu, Sep 10, 2026 at 9:54 PM Uwe Kleine-König <ukleinek@xxxxxxxxxx> wrote:
>
> Hello,
>
> On Thu, Sep 10, 2026 at 07:58:12PM +0800, Keguang Zhang wrote:
> > On Mon, Sep 7, 2026 at 5:33 PM Uwe Kleine-König <ukleinek@xxxxxxxxxx> wrote:
> > > [...] I wonder if the fix is incomplete. If at driver bind time
> > > LOONGSON_PWM_CTRL_REG_RST isn't set and there are still wrong values in
> > > the shadowed LOW and PERIOD registers the first period will be wrong.
> > >
> > > This would need:
> > >
> > > val = pwm_loongson_readl(ddata, LOONGSON_PWM_REG_CTRL);
> > > +
> > > + /*
> > > + * Ensure that the values of LOW and PERIOD are sampled into
> > > + * the shadow register when the hardware starts running.
> > > + */
> > > + if (!(val & LOONGSON_PWM_CTRL_REG_RST))
> > > + pwm_loongson_writel(ddata, val | LOONGSON_PWM_CTRL_REG_RST, LOONGSON_PWM_REG_CTRL);
> > > +
> > > val &= ~LOONGSON_PWM_CTRL_REG_RST;
> > > val |= LOONGSON_PWM_CTRL_REG_EN;
> > > pwm_loongson_writel(ddata, val, LOONGSON_PWM_REG_CTRL);
> > >
> > > I think.
> >
> > You are right that this patch doesn't handle the initial hardware
> > state when the driver binds.
> > Would you prefer that I submit a follow-up patch to address this, or
> > are you planning to fix it yourself?
>
> I don't have the hardware, so if you do that and test it, that's very
> appreciated.
>
Sure. I'll add this fix in the next version.
> Best regards
> Uwe
--
Best regards,
Keguang Zhang