On Fri, Aug 15, 2025 at 11:09 AM Bartosz Golaszewski <brgl@xxxxxxxx> wrote: > Problem: when pinctrl core binds pins to a consumer device and the > pinmux ops of the underlying driver are marked as strict, the pin in > question can no longer be requested as a GPIO using the GPIO descriptor > API. It will result in the following error: > > [ 5.095688] sc8280xp-tlmm f100000.pinctrl: pin GPIO_25 already requested by regulator-edp-3p3; cannot claim for f100000.pinctrl:570 > [ 5.107822] sc8280xp-tlmm f100000.pinctrl: error -EINVAL: pin-25 (f100000.pinctrl:570) > > This typically makes sense except when the pins are muxed to a function > that actually says "GPIO". Of course, the function name is just a string > so it has no meaning to the pinctrl subsystem. > > We have many Qualcomm SoCs (and I can imagine it's a common pattern in > other platforms as well) where we mux a pin to "gpio" function using the > `pinctrl-X` property in order to configure bias or drive-strength and > then access it using the gpiod API. This makes it impossible to mark the > pin controller module as "strict". > > This series proposes to introduce a concept of a sub-category of > pinfunctions: GPIO functions where the above is not true and the pin > muxed as a GPIO can still be accessed via the GPIO consumer API even for > strict pinmuxers. > > To that end: we first clean up the drivers that use struct function_desc > and make them use the smaller struct pinfunction instead - which is the > correct structure for drivers to describe their pin functions with. We > also rework pinmux core to not duplicate memory used to store the > pinfunctions unless they're allocated dynamically. > > First: provide the kmemdup_const() helper which only duplicates memory > if it's not in the .rodata section. Then rework all pinctrl drivers that > instantiate objects of type struct function_desc as they should only be > created by pinmux core. Next constify the return value of the accessor > used to expose these structures to users and finally convert the > pinfunction object within struct function_desc to a pointer and use > kmemdup_const() to assign it. With this done proceed to add > infrastructure for the GPIO pin function category and use it in Qualcomm > drivers. At the very end: make the Qualcomm pinmuxer strict. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> (...) > Bartosz Golaszewski (15): > devres: provide devm_kmemdup_const() > pinctrl: ingenic: use struct pinfunction instead of struct function_desc > pinctrl: airoha: replace struct function_desc with struct pinfunction > pinctrl: mediatek: mt7988: use PINCTRL_PIN_FUNCTION() > pinctrl: mediatek: moore: replace struct function_desc with struct pinfunction > pinctrl: imx: don't access the pin function radix tree directly > pinctrl: keembay: release allocated memory in detach path > pinctrl: keembay: use a dedicated structure for the pinfunction description > pinctrl: constify pinmux_generic_get_function() > pinctrl: make struct pinfunction a pointer in struct function_desc > pinctrl: qcom: use generic pin function helpers > pinctrl: allow to mark pin functions as requestable GPIOs I applied these 12 patches as a starter so they can stabilize in linux-next. > pinctrl: qcom: add infrastructure for marking pin functions as GPIOs > pinctrl: qcom: mark the `gpio` and `egpio` pins function as non-strict functions > pinctrl: qcom: make the pinmuxing strict Neil reports of regressions on qcom platforms so I assume it's something in the last three patches that's causing it and I hold these three off until you have time to look at it (and focus at just the final qcom pieces). Yours, Linus Walleij