[PATCH v9 6/6] pwm: airoha: Add support for EN7581 SoC

Benjamin Larsson benjamin.larsson at genexis.eu
Thu Oct 31 13:37:40 PDT 2024


On 31/10/2024 11:53, Uwe Kleine-König wrote:
> Hello Benjamin,
>
> On Wed, Oct 30, 2024 at 11:14:41AM +0100, Benjamin Larsson wrote:
>> On 2024-10-30 08:32, Uwe Kleine-König wrote:
>>>> +	/* Configure frequency divisor */
>>>> +	mask = WAVE_GEN_CYCLE_MASK(index % 4);
>>>> +	val = (period << __ffs(mask)) & mask;
>>> FIELD_PREP please.
>> Per my understanding FIELD_PREP only work on compile time constants.
> Then please create an alternative macro with the same semantic that also
> works when the mask isn't known at compile time instead of open coding
> the same concept several times.
>
> Best regards
> Uwe

Hi, someone did but the code never got merged.

https://lkml.org/lkml/2021/11/22/532

So the current way of doing it seems to be to open coding.

Are you proposing macros like these are added?

#define field_get(_mask, _reg) (((_reg) & (_mask)) >> (ffs(_mask) - 1))
#define field_prep(_mask, _val) (((_val) << (ffs(_mask) - 1)) & (_mask))

MvH

Benjamin Larsson




More information about the Linux-mediatek mailing list