On Tue, Sep 2, 2025 at 4:31 PM Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote: > > On Tue, Sep 02, 2025 at 01:59:22PM +0200, Bartosz Golaszewski wrote: > > > > The name of the pin function has no real meaning to pinctrl core and is > > there only for human readability of device properties. Some pins are > > muxed as GPIOs but for "strict" pinmuxers it's impossible to request > > them as GPIOs if they're bound to a devide - even if their function name > > explicitly says "gpio". Add a new field to struct pinfunction that > > allows to pass additional flags to pinctrl core. > > Which I disagree with. The pin control _knows_ about itself. If one needs > to request a pin as GPIO it can be done differently (perhaps with a new, > special callback or with the existing ones, I need to dive to this). What? Why? Makes no sense, there already is a function for requesting a pin as GPIO, it's called pinctrl_gpio_request(). And it's affected by this series because otherwise we fail as explained in the cover letter. > On a brief view this can be done in the same way as valid_mask in GPIO, > actually this is exactly what should be (re-)used in my opinion here. > Except that the valid_mask is very unclear and IMO it's much cleaner to have a flag for that. > > While we could go with > > a boolean "is_gpio" field, a flags field is more future-proof. > > This sentence is probably extra in the commit message and can be omitted. > > > If the PINFUNCTION_FLAG_GPIO is set for a given function, the pin muxed > > to it can be requested as GPIO even on strict pin controllers. > > So. this changes the contract between pin control (mux) core and drivers. Yes, that's allowed in the kernel. The current contract is wrong and the reason why we can for instance confuse debug UARTs by requesting its pins as GPIOs from user-space whereas a strict pinmuxer will not allow it. But to convert pinmuxers to "strict" we need to change the behavior. > Why? How is it supposed to work on the really strict controllers, please? > Like what I explained several times? You have pins used by a device. User-space comes around and requests them and fiddles with them and now the state of your device is undefined/broken. With a strict pinmuxer user-space will fail to request the pins muxed to a non-GPIO function. > > Add a new callback to struct pinmux_ops - function_is_gpio() - that allows > > pinmux core to inspect a function and see if it's a GPIO one. Provide a > > generic implementation of this callback. Bartosz