[PATCH 2/2] pinctrl: zynqmp: Support muxing individual pins
Sean Anderson
sean.anderson at linux.dev
Mon May 6 12:39:47 PDT 2024
On 5/6/24 15:38, Sean Anderson wrote:
> On 5/6/24 15:26, Andy Shevchenko wrote:
>> Fri, May 03, 2024 at 12:22:17PM -0400, Sean Anderson kirjoitti:
>>> While muxing groups of pins at once can be convenient for large
>>> interfaces, it can also be rigid. This is because the group is set to
>>> all pins which support a particular function, even though not all pins
>>> may be used. For example, the sdhci0 function may be used with a 8-bit
>>> eMMC, 4-bit SD card, or even a 1-bit SD card. In these cases, the extra
>>> pins may be repurposed for other uses, but this is not currently
>>> allowed.
>>>
>>> Add a new group for each pin which can be muxed. These groups are part
>>> of each function the pin can be muxed to. We treat group selectors
>>> beyond the number of groups as "pin" groups. To set this up, we
>>> initialize groups before functions, and then create a bitmap of used
>>> pins for each function. These used pins are appended to the function's
>>> list of groups.
>>
>> ...
>>
>>> + for (pin = 0; pin < groups[resp[i]].npins; pin++)
>>> + set_bit(groups[resp[i]].pins[pin], used_pins);
>>
>> Why atomic bit operation?
>
> The name was easier to remember. I can make it non-atomic.
>
>> ...
>>
>>> + fgroups = devm_kcalloc(dev, func->ngroups + npins, sizeof(*fgroups),
>>
>> size_add() from overflow.h.
>
> OK
>
>>> + GFP_KERNEL);
>>> + if (!fgroups)
>>> + return -ENOMEM;
>>
>> ...
>>
>>> + for (i = 0; i < func->ngroups; i++) {
>>> + fgroups[i] = devm_kasprintf(dev, GFP_KERNEL, "%s_%d_grp",
>>> + func->name, i);
>>> + if (!fgroups[i])
>>> + return -ENOMEM;
>>> + }
>>
>> Hmm... Can this benefit from devm_kasprintf_strarray()?
>>
>
> I don't think so, since the prefix is different for each group.
Sorry, the prefix is the same, but we have to use this format as to not
break the devicetree ABI.
--Sean
More information about the linux-arm-kernel
mailing list