[PATCH v4 0/1] Change PWM-controlled LED pin active mode and algorithm
Conor Dooley
conor.dooley at microchip.com
Fri Aug 4 02:09:27 PDT 2023
On Fri, Aug 04, 2023 at 02:54:33PM +0800, Nylon Chen wrote:
> Hi Conor,
>
> Thank you for patiently giving me advice. I appreciate your help.
>
> Not long ago, I said, "This patch needs to be accompanied by
> modifications to the pwm_sifive_apply() function to make sense."
>
> I recently reviewed the v3 version, and after discussing it with Emil,
> there are several areas that require modification. I will provide the
> necessary changes for each of them:
>
> 1. polarity check. (Suggestion from Uwe)
> - if (state->polarity != PWM_POLARITY_INVERSED)
> + if (state->polarity != PWM_POLARITY_NORMAL)
> 2. avoid using old periodperiod, not state->period
> - period = max(state->period, ddata->approx_period);
> - frac = DIV64_U64_ROUND_CLOSEST(num, state->period);
> + frac = DIV64_U64_ROUND_CLOSEST(num, period);
> 3. add a conditional check can be added in the code to set
> ddata->approx_period to state->period when state->period is smaller
> than ddata->approx_period
> if (state->period != ddata->approx_period) {
> ...
> + if (state->period < ddata->approx_period) {
> + ddata->approx_period = state->period;
> + }
> - ddata->approx_period = state->period;
> + period = ddata->approx_period;
>
> I will use 'unmatched' on my end to verify again. If there are any
> other errors, feel free to point them out. Thank you.
I'm not sure of the driver details without going and looking into the
code itself, but this sounds like it makes a lot more sense than just
flipping the polarity in the dts. Thanks for taking another look!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20230804/7e4023a2/attachment.sig>
More information about the linux-riscv
mailing list