Message ID | 20240124074527.48869-1-krzysztof.kozlowski@linaro.org |
---|---|
Headers | show |
Series | reset: gpio: ASoC: shared GPIO resets | expand |
On 24/01/2024 08:45, Krzysztof Kozlowski wrote: > Devices sharing a reset GPIO could use the reset framework for > coordinated handling of that shared GPIO line. We have several cases of > such needs, at least for Devicetree-based platforms. > > If Devicetree-based device requests a reset line, while "resets" > Devicetree property is missing but there is a "reset-gpios" one, > instantiate a new "reset-gpio" platform device which will handle such > reset line. This allows seamless handling of such shared reset-gpios > without need of changing Devicetree binding [1]. > > To avoid creating multiple "reset-gpio" platform devices, store the > Devicetree "reset-gpios" GPIO specifiers used for new devices on a > linked list. Later such Devicetree GPIO specifier (phandle to GPIO > controller, GPIO number and GPIO flags) is used to check if reset > controller for given GPIO was already registered. > > If two devices have conflicting "reset-gpios" property, e.g. with > different ACTIVE_xxx flags, this would allow to spawn two separate > "reset-gpio" devices, where the second would fail probing on busy GPIO > request. > > Link: https://lore.kernel.org/all/YXi5CUCEi7YmNxXM@robh.at.kernel.org/ [1] > Cc: Bartosz Golaszewski <brgl@bgdev.pl> > Cc: Chris Packham <chris.packham@alliedtelesis.co.nz> > Cc: Sean Anderson <sean.anderson@seco.com> > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > > --- > > Depends on previous of change. > --- > drivers/reset/core.c | 215 +++++++++++++++++++++++++++++-- > include/linux/reset-controller.h | 4 + > 2 files changed, 206 insertions(+), 13 deletions(-) > LKP reported issue when building !GPIOLIB: https://lore.kernel.org/oe-kbuild-all/202401250958.YksQmnWj-lkp@intel.com/ but I intend to solve it providing the stubs. Therefore this patch will not change. Best regards, Krzysztof
On Thu, Jan 25, 2024 at 9:02 AM Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote: > > On 24/01/2024 08:45, Krzysztof Kozlowski wrote: > > Devices sharing a reset GPIO could use the reset framework for > > coordinated handling of that shared GPIO line. We have several cases of > > such needs, at least for Devicetree-based platforms. > > > > If Devicetree-based device requests a reset line, while "resets" > > Devicetree property is missing but there is a "reset-gpios" one, > > instantiate a new "reset-gpio" platform device which will handle such > > reset line. This allows seamless handling of such shared reset-gpios > > without need of changing Devicetree binding [1]. > > > > To avoid creating multiple "reset-gpio" platform devices, store the > > Devicetree "reset-gpios" GPIO specifiers used for new devices on a > > linked list. Later such Devicetree GPIO specifier (phandle to GPIO > > controller, GPIO number and GPIO flags) is used to check if reset > > controller for given GPIO was already registered. > > > > If two devices have conflicting "reset-gpios" property, e.g. with > > different ACTIVE_xxx flags, this would allow to spawn two separate > > "reset-gpio" devices, where the second would fail probing on busy GPIO > > request. > > > > Link: https://lore.kernel.org/all/YXi5CUCEi7YmNxXM@robh.at.kernel.org/ [1] > > Cc: Bartosz Golaszewski <brgl@bgdev.pl> > > Cc: Chris Packham <chris.packham@alliedtelesis.co.nz> > > Cc: Sean Anderson <sean.anderson@seco.com> > > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > > > > --- > > > > Depends on previous of change. > > --- > > drivers/reset/core.c | 215 +++++++++++++++++++++++++++++-- > > include/linux/reset-controller.h | 4 + > > 2 files changed, 206 insertions(+), 13 deletions(-) > > > > LKP reported issue when building !GPIOLIB: > https://lore.kernel.org/oe-kbuild-all/202401250958.YksQmnWj-lkp@intel.com/ > > but I intend to solve it providing the stubs. Therefore this patch will > not change. > > Best regards, > Krzysztof > Ah, so this is why you sent the patches. I don't like stubs in gpio/driver.h but I get why they're needed here. Maybe we should consider adding gpio/misc.h for that kind of stuff. Bart
On Mi, 2024-01-24 at 16:07 -0600, Rob Herring wrote: > On Wed, Jan 24, 2024 at 08:45:22AM +0100, Krzysztof Kozlowski wrote: > > Add a helper comparing two "struct of_phandle_args" to avoid > > reinventing the wheel. > > > > Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> > > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > > --- > > > > Dependency of cpufreq and reset change. > > --- > > include/linux/of.h | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > Acked-by: Rob Herring <robh@kernel.org> > > I've wanted to write this series for some time. Great work. How would you prefer this to be merged? Stable tag from the devicetree tree? Go through the reset tree as part of this series? regards Philipp
On Mi, 2024-01-24 at 08:45 +0100, Krzysztof Kozlowski wrote: > Devices sharing a reset GPIO could use the reset framework for > coordinated handling of that shared GPIO line. We have several cases of > such needs, at least for Devicetree-based platforms. > > If Devicetree-based device requests a reset line, while "resets" > Devicetree property is missing but there is a "reset-gpios" one, > instantiate a new "reset-gpio" platform device which will handle such > reset line. This allows seamless handling of such shared reset-gpios > without need of changing Devicetree binding [1]. > > To avoid creating multiple "reset-gpio" platform devices, store the > Devicetree "reset-gpios" GPIO specifiers used for new devices on a > linked list. Later such Devicetree GPIO specifier (phandle to GPIO > controller, GPIO number and GPIO flags) is used to check if reset > controller for given GPIO was already registered. > > If two devices have conflicting "reset-gpios" property, e.g. with > different ACTIVE_xxx flags, this would allow to spawn two separate > "reset-gpio" devices, where the second would fail probing on busy GPIO > request. > > Link: https://lore.kernel.org/all/YXi5CUCEi7YmNxXM@robh.at.kernel.org/ [1] > Cc: Bartosz Golaszewski <brgl@bgdev.pl> > Cc: Chris Packham <chris.packham@alliedtelesis.co.nz> > Cc: Sean Anderson <sean.anderson@seco.com> > Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> regards Philipp
On 25/01/2024 09:27, neil.armstrong@linaro.org wrote: > On 24/01/2024 08:45, Krzysztof Kozlowski wrote: >> Devices sharing a reset GPIO could use the reset framework for >> coordinated handling of that shared GPIO line. We have several cases of >> such needs, at least for Devicetree-based platforms. >> >> If Devicetree-based device requests a reset line, while "resets" >> Devicetree property is missing but there is a "reset-gpios" one, >> instantiate a new "reset-gpio" platform device which will handle such >> reset line. This allows seamless handling of such shared reset-gpios >> without need of changing Devicetree binding [1]. >> >> To avoid creating multiple "reset-gpio" platform devices, store the >> Devicetree "reset-gpios" GPIO specifiers used for new devices on a >> linked list. Later such Devicetree GPIO specifier (phandle to GPIO >> controller, GPIO number and GPIO flags) is used to check if reset >> controller for given GPIO was already registered. >> >> If two devices have conflicting "reset-gpios" property, e.g. with >> different ACTIVE_xxx flags, this would allow to spawn two separate >> "reset-gpio" devices, where the second would fail probing on busy GPIO >> request. >> >> Link: https://lore.kernel.org/all/YXi5CUCEi7YmNxXM@robh.at.kernel.org/ [1] >> Cc: Bartosz Golaszewski <brgl@bgdev.pl> >> Cc: Chris Packham <chris.packham@alliedtelesis.co.nz> >> Cc: Sean Anderson <sean.anderson@seco.com> >> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >> >> --- >> >> Depends on previous of change. >> --- >> drivers/reset/core.c | 215 +++++++++++++++++++++++++++++-- >> include/linux/reset-controller.h | 4 + >> 2 files changed, 206 insertions(+), 13 deletions(-) >> >> diff --git a/drivers/reset/core.c b/drivers/reset/core.c >> index 4d5a78d3c085..60a8a33c4419 100644 >> --- a/drivers/reset/core.c >> +++ b/drivers/reset/core.c > > <snip> > >> + } >> + >> + ret = __reset_add_reset_gpio_lookup(id, args->np, args->args[0], >> + args->args[1]); > > What would happen with gpio controllers using #gpio-cells = <3> (or more) like allwinner,sun4i-a10-pinctrl.yaml ? > > On this example the flags are args->args[2] so this would probably fail. > > This would also fails badly with #gpio-cells = <1>, args->args[1] value would be undefined. > > You should probably limit to args->args_count == 2 for now. Hm, good point. Both cells are actually possible, so I need to check it. Thanks. Best regards, Krzysztof