All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Pargmann <mpa@pengutronix.de>
To: Rob Herring <robh+dt@kernel.org>
Cc: "linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Mark Rutland <mark.rutland@arm.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	linux-samsung-soc <linux-samsung-soc@vger.kernel.org>,
	Pawel Moll <pawel.moll@arm.com>,
	Martyn Welch <martyn.welch@collabora.co.uk>,
	Arnd Bergmann <arnd@arndb.de>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Olof Johansson <olof@lixom.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Johan Hovold <johan@kernel.org>, Kukjin Kim <kgene@kernel.org>,
	Alexandre Courbot <acourbot@nvidia.com>,
	Kumar Gala <galak@codeaurora.org>,
	Michael Welling <mwelling@ieee.org>,
	Russell King <linux@arm.linux.org.uk>
Subject: Re: [PATCH 1/3] Device tree binding documentation for gpio-switch
Date: Mon, 07 Mar 2016 09:26:31 +0100	[thread overview]
Message-ID: <6877420.aKPrAc9Qh5@adelgunde> (raw)
In-Reply-To: <CAL_JsqLX-F=-k83_-5-QL2QZpAArQqOHjE+19c1wvNKWayYfMw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 7898 bytes --]

On Wednesday 02 March 2016 10:03:27 Rob Herring wrote:
> Reviving this thread...
> 
> On Tue, Dec 15, 2015 at 3:09 AM, Markus Pargmann <mpa@pengutronix.de> wrote:
> > Hi,
> >
> > On Monday 14 December 2015 09:45:48 Rob Herring wrote:
> >> On Mon, Dec 14, 2015 at 8:28 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> >> > On Fri, Dec 11, 2015 at 3:06 PM, Rob Herring <robh+dt@kernel.org> wrote:
> >> >> On Fri, Dec 11, 2015 at 6:39 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> >> >>> On Fri, Dec 4, 2015 at 6:31 PM, Martyn Welch
> >> >>> <martyn.welch@collabora.co.uk> wrote:
> >>
> >> [...]
> >>
> >> >>> Markus Pargmann also did a series that add initial values to
> >> >>> hogs, which is the inverse usecase of this, where you want to
> >> >>> *output* something by default, then maybe also make it available
> >> >>> to userspace.
> >> >>>
> >> >>> So what we need to see here is a patch series that does all of these
> >> >>> things:
> >> >>>
> >> >>> - Name lines
> >> >>>
> >> >>> - Sets them to initial values
> >> >>>
> >> >>> - Mark them as read-only
> >> >>>
> >> >>> - Mark them as "not used by the operating system" so that they
> >> >>>   can be default-exported to userspace.
> >> >>
> >> >> No! This should not be a DT property.
> >> >>
> >> >> Whether I want to control a GPIO in the kernel or userspace is not
> >> >> known and can change over time. It could simply depend on kernel
> >> >> config. There is also the case that a GPIO has no connection or kernel
> >> >> driver until some time later when a DT overlay for an expansion board
> >> >> is applied.
> >> >
> >> > That's correct. So from a DT point of view, what really matters is
> >> > to give things a name, and the hogs and initvals syntax already
> >> > has a structure for this that is in use
> >> > (from Documentation/devicetree/bindings/gpio/gpio.txt):
> >> >
> >> >         qe_pio_a: gpio-controller@1400 {
> >> >                 compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank";
> >> >                 reg = <0x1400 0x18>;
> >> >                 gpio-controller;
> >> >                 #gpio-cells = <2>;
> >> >
> >> >                 line_b {
> >> >                         gpio-hog;
> >> >                         gpios = <6 0>;
> >> >                         output-low;
> >> >                         line-name = "foo-bar-gpio";
> >> >                 };
> >> >         };
> >> >
> >> > Markus use this also for initial values. That could easily be used in
> >> > a budget version like this:
> >> >
> >> >                 line_b {
> >> >                         /* Just naming */
> >> >                         gpios = <6 0>;
> >> >                         line-name = "foo-bar-gpio";
> >> >                 };
> >> >
> >> > That could grow kind of big though. Or maybe not? How many
> >> > GPIO lines are actually properly named in a typical system?
> >>
> >> We should limit it to GPIOs with no connection to another node. For
> >> example, I don't want to see a SD card detect in the list as that
> >> should be in the SD host node. However, that is hard to enforce and
> >> can change over time. Removing it would break userspace potentially.
> >> Of course if the kernel starts own a signal that userspace used, then
> >> that potentially breaks userspace regardless of the DT changing. OTOH,
> >> using GPIOs in userspace is kind of use at your own risk.
> >
> > I see this a bit differently. I would really like to see the each GPIO having
> > two different names:
> 
> I think we are saying the same thing...
> 
> > - GPIO label: This is the name of the GPIO line in the schematic for example
> 
> Yes.
> 
> > - GPIO use (this is the current semantic of the GPIO name): The use of a GPIO,
> >   e.g. 'sd-card-detect', 'LED', ...
> 
> This should be determined from the compatible string and/or -gpios
> prefix. This is the what the function is and "label" is which one.
> 
> > I think it would be good to describe all GPIO labels in gpiochip subnodes as
> > gpio-hogging introduced it. This would offer a use-independent naming. The use
> > of the function could be defined in the device node that is using this gpio.
> 
> I think I agree here. You may have a defined function without any
> connection to another node. I also think we should encourage simple
> GPIO bindings like gpio-leds to be child nodes. Having them at the
> top-level is kind of arbitrary. Of course, allowing for both is
> required.
> 
> > As an example perhaps something like this:
> >
> >         &gpiochip {
> >                 some_interrupt {
> >                         gpios = <4 0>;
> >                         line-name = "some_interrupt_line";
> >                 };
> >
> >                 line_b {
> >                         gpios = <6 0>;
> >                         line-name = "line-b";
> >                 };
> >         };
> >
> >         randomswitch {
> >                 compatible = "gpio-switch";
> >                 gpios = <&gpiochip 4 0>;
> >                 use = "action-trigger";
> >                 read-only;
> >         };
> >
> > Also this does seem kind of inconsistent with gpio-hogging and the proposed
> > gpio-initval. gpio-hogging is defined in subnodes of the gpio chip while
> > gpio-switches are not. As "gpio-switch" is not really any kind of device it
> > would perhaps make sense to keep this consistent with gpio-hogging as well and
> > define it in the same subnodes?
> > I would be happy about any consistent way.
> 
> Yes, as well as gpio leds, keys, etc. bindings. The key is you would
> need to be able to start with something minimal and extend it with
> specific compatibles.

So if I understand you right it would be better to handle most
distinctions using compatibles? Something like this?

	&gpiochip {
		some_led {
			compatible = "gpio-leds";
			default-state = "on";
			gpios = <3 0>;
			line-name = "leda";
		};

		some_switch {
			compatible = "gpio-switch", "gpio-initval";
			gpios = <4 0>;
			line-name = "switch1";

			/* This is used by gpio-initval in case gpio-switch is not implemented */
			output-low;
		};

		some_interrupt {
			gpios = <5 0>;
			line-name = "some_interrupt_line";
		};

		line_b {
			gpios = <6 0>;
			line-name = "line-b";
		};
	};

	randomcomponent {
		gpios = <&gpiochip 5 0>;
		read-only;
	};

In this case there is a gpio-led embedded within the gpiochip node. Also
'some_switch' is a gpio-switch and falls back to being gpio-initval.
This way we can replace it at some point with a real driver. But if it
doesn't exist we can at least initialize the GPIO properly.

As you suggested this would open up the possibilities for all
compatibles and drivers for single gpios.

Best Regards,

Markus

> 
> [...]
> 
> >> We also have to consider how to handle add-on boards. We probably need
> >> a connector node which can remap connector signals to host signals in
> >> order to have overlays independent of the host board DT. For GPIOs
> >> this is probably a gpio-map property similar to interrupt-map. The
> >> complicated part will be connectors that require pinmux setup of the
> >> host.
> >
> > Also what about hotplugging gpio-chips? Is there any mechanism to let the
> > 'gpio-switch' know that the GPIO is not there anymore?
> 
> There are certainly issues around hotplug and GPIOs. If the
> gpio-switch device is a child of the gpio controller, then it should
> be possible.
> 
> Rob
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Markus Pargmann <mpa-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: "linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Krzysztof Kozlowski
	<k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	linux-samsung-soc
	<linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
	Martyn Welch
	<martyn.welch-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Ian Campbell
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	Olof Johansson <olof-nZhT3qVonbNeoWH0uzbU5w@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Johan Hovold <johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Kukjin Kim <kgene-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Alexandre Courbot
	<acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Michael Welling <mwelling-EkmVulN54Sk@public.gmane.org>,
	Russell King <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
Subject: Re: [PATCH 1/3] Device tree binding documentation for gpio-switch
Date: Mon, 07 Mar 2016 09:26:31 +0100	[thread overview]
Message-ID: <6877420.aKPrAc9Qh5@adelgunde> (raw)
In-Reply-To: <CAL_JsqLX-F=-k83_-5-QL2QZpAArQqOHjE+19c1wvNKWayYfMw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 7976 bytes --]

On Wednesday 02 March 2016 10:03:27 Rob Herring wrote:
> Reviving this thread...
> 
> On Tue, Dec 15, 2015 at 3:09 AM, Markus Pargmann <mpa-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> wrote:
> > Hi,
> >
> > On Monday 14 December 2015 09:45:48 Rob Herring wrote:
> >> On Mon, Dec 14, 2015 at 8:28 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> >> > On Fri, Dec 11, 2015 at 3:06 PM, Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> >> >> On Fri, Dec 11, 2015 at 6:39 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> >> >>> On Fri, Dec 4, 2015 at 6:31 PM, Martyn Welch
> >> >>> <martyn.welch-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org> wrote:
> >>
> >> [...]
> >>
> >> >>> Markus Pargmann also did a series that add initial values to
> >> >>> hogs, which is the inverse usecase of this, where you want to
> >> >>> *output* something by default, then maybe also make it available
> >> >>> to userspace.
> >> >>>
> >> >>> So what we need to see here is a patch series that does all of these
> >> >>> things:
> >> >>>
> >> >>> - Name lines
> >> >>>
> >> >>> - Sets them to initial values
> >> >>>
> >> >>> - Mark them as read-only
> >> >>>
> >> >>> - Mark them as "not used by the operating system" so that they
> >> >>>   can be default-exported to userspace.
> >> >>
> >> >> No! This should not be a DT property.
> >> >>
> >> >> Whether I want to control a GPIO in the kernel or userspace is not
> >> >> known and can change over time. It could simply depend on kernel
> >> >> config. There is also the case that a GPIO has no connection or kernel
> >> >> driver until some time later when a DT overlay for an expansion board
> >> >> is applied.
> >> >
> >> > That's correct. So from a DT point of view, what really matters is
> >> > to give things a name, and the hogs and initvals syntax already
> >> > has a structure for this that is in use
> >> > (from Documentation/devicetree/bindings/gpio/gpio.txt):
> >> >
> >> >         qe_pio_a: gpio-controller@1400 {
> >> >                 compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank";
> >> >                 reg = <0x1400 0x18>;
> >> >                 gpio-controller;
> >> >                 #gpio-cells = <2>;
> >> >
> >> >                 line_b {
> >> >                         gpio-hog;
> >> >                         gpios = <6 0>;
> >> >                         output-low;
> >> >                         line-name = "foo-bar-gpio";
> >> >                 };
> >> >         };
> >> >
> >> > Markus use this also for initial values. That could easily be used in
> >> > a budget version like this:
> >> >
> >> >                 line_b {
> >> >                         /* Just naming */
> >> >                         gpios = <6 0>;
> >> >                         line-name = "foo-bar-gpio";
> >> >                 };
> >> >
> >> > That could grow kind of big though. Or maybe not? How many
> >> > GPIO lines are actually properly named in a typical system?
> >>
> >> We should limit it to GPIOs with no connection to another node. For
> >> example, I don't want to see a SD card detect in the list as that
> >> should be in the SD host node. However, that is hard to enforce and
> >> can change over time. Removing it would break userspace potentially.
> >> Of course if the kernel starts own a signal that userspace used, then
> >> that potentially breaks userspace regardless of the DT changing. OTOH,
> >> using GPIOs in userspace is kind of use at your own risk.
> >
> > I see this a bit differently. I would really like to see the each GPIO having
> > two different names:
> 
> I think we are saying the same thing...
> 
> > - GPIO label: This is the name of the GPIO line in the schematic for example
> 
> Yes.
> 
> > - GPIO use (this is the current semantic of the GPIO name): The use of a GPIO,
> >   e.g. 'sd-card-detect', 'LED', ...
> 
> This should be determined from the compatible string and/or -gpios
> prefix. This is the what the function is and "label" is which one.
> 
> > I think it would be good to describe all GPIO labels in gpiochip subnodes as
> > gpio-hogging introduced it. This would offer a use-independent naming. The use
> > of the function could be defined in the device node that is using this gpio.
> 
> I think I agree here. You may have a defined function without any
> connection to another node. I also think we should encourage simple
> GPIO bindings like gpio-leds to be child nodes. Having them at the
> top-level is kind of arbitrary. Of course, allowing for both is
> required.
> 
> > As an example perhaps something like this:
> >
> >         &gpiochip {
> >                 some_interrupt {
> >                         gpios = <4 0>;
> >                         line-name = "some_interrupt_line";
> >                 };
> >
> >                 line_b {
> >                         gpios = <6 0>;
> >                         line-name = "line-b";
> >                 };
> >         };
> >
> >         randomswitch {
> >                 compatible = "gpio-switch";
> >                 gpios = <&gpiochip 4 0>;
> >                 use = "action-trigger";
> >                 read-only;
> >         };
> >
> > Also this does seem kind of inconsistent with gpio-hogging and the proposed
> > gpio-initval. gpio-hogging is defined in subnodes of the gpio chip while
> > gpio-switches are not. As "gpio-switch" is not really any kind of device it
> > would perhaps make sense to keep this consistent with gpio-hogging as well and
> > define it in the same subnodes?
> > I would be happy about any consistent way.
> 
> Yes, as well as gpio leds, keys, etc. bindings. The key is you would
> need to be able to start with something minimal and extend it with
> specific compatibles.

So if I understand you right it would be better to handle most
distinctions using compatibles? Something like this?

	&gpiochip {
		some_led {
			compatible = "gpio-leds";
			default-state = "on";
			gpios = <3 0>;
			line-name = "leda";
		};

		some_switch {
			compatible = "gpio-switch", "gpio-initval";
			gpios = <4 0>;
			line-name = "switch1";

			/* This is used by gpio-initval in case gpio-switch is not implemented */
			output-low;
		};

		some_interrupt {
			gpios = <5 0>;
			line-name = "some_interrupt_line";
		};

		line_b {
			gpios = <6 0>;
			line-name = "line-b";
		};
	};

	randomcomponent {
		gpios = <&gpiochip 5 0>;
		read-only;
	};

In this case there is a gpio-led embedded within the gpiochip node. Also
'some_switch' is a gpio-switch and falls back to being gpio-initval.
This way we can replace it at some point with a real driver. But if it
doesn't exist we can at least initialize the GPIO properly.

As you suggested this would open up the possibilities for all
compatibles and drivers for single gpios.

Best Regards,

Markus

> 
> [...]
> 
> >> We also have to consider how to handle add-on boards. We probably need
> >> a connector node which can remap connector signals to host signals in
> >> order to have overlays independent of the host board DT. For GPIOs
> >> this is probably a gpio-map property similar to interrupt-map. The
> >> complicated part will be connectors that require pinmux setup of the
> >> host.
> >
> > Also what about hotplugging gpio-chips? Is there any mechanism to let the
> > 'gpio-switch' know that the GPIO is not there anymore?
> 
> There are certainly issues around hotplug and GPIOs. If the
> gpio-switch device is a child of the gpio controller, then it should
> be possible.
> 
> Rob
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: mpa@pengutronix.de (Markus Pargmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] Device tree binding documentation for gpio-switch
Date: Mon, 07 Mar 2016 09:26:31 +0100	[thread overview]
Message-ID: <6877420.aKPrAc9Qh5@adelgunde> (raw)
In-Reply-To: <CAL_JsqLX-F=-k83_-5-QL2QZpAArQqOHjE+19c1wvNKWayYfMw@mail.gmail.com>

On Wednesday 02 March 2016 10:03:27 Rob Herring wrote:
> Reviving this thread...
> 
> On Tue, Dec 15, 2015 at 3:09 AM, Markus Pargmann <mpa@pengutronix.de> wrote:
> > Hi,
> >
> > On Monday 14 December 2015 09:45:48 Rob Herring wrote:
> >> On Mon, Dec 14, 2015 at 8:28 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> >> > On Fri, Dec 11, 2015 at 3:06 PM, Rob Herring <robh+dt@kernel.org> wrote:
> >> >> On Fri, Dec 11, 2015 at 6:39 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> >> >>> On Fri, Dec 4, 2015 at 6:31 PM, Martyn Welch
> >> >>> <martyn.welch@collabora.co.uk> wrote:
> >>
> >> [...]
> >>
> >> >>> Markus Pargmann also did a series that add initial values to
> >> >>> hogs, which is the inverse usecase of this, where you want to
> >> >>> *output* something by default, then maybe also make it available
> >> >>> to userspace.
> >> >>>
> >> >>> So what we need to see here is a patch series that does all of these
> >> >>> things:
> >> >>>
> >> >>> - Name lines
> >> >>>
> >> >>> - Sets them to initial values
> >> >>>
> >> >>> - Mark them as read-only
> >> >>>
> >> >>> - Mark them as "not used by the operating system" so that they
> >> >>>   can be default-exported to userspace.
> >> >>
> >> >> No! This should not be a DT property.
> >> >>
> >> >> Whether I want to control a GPIO in the kernel or userspace is not
> >> >> known and can change over time. It could simply depend on kernel
> >> >> config. There is also the case that a GPIO has no connection or kernel
> >> >> driver until some time later when a DT overlay for an expansion board
> >> >> is applied.
> >> >
> >> > That's correct. So from a DT point of view, what really matters is
> >> > to give things a name, and the hogs and initvals syntax already
> >> > has a structure for this that is in use
> >> > (from Documentation/devicetree/bindings/gpio/gpio.txt):
> >> >
> >> >         qe_pio_a: gpio-controller at 1400 {
> >> >                 compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank";
> >> >                 reg = <0x1400 0x18>;
> >> >                 gpio-controller;
> >> >                 #gpio-cells = <2>;
> >> >
> >> >                 line_b {
> >> >                         gpio-hog;
> >> >                         gpios = <6 0>;
> >> >                         output-low;
> >> >                         line-name = "foo-bar-gpio";
> >> >                 };
> >> >         };
> >> >
> >> > Markus use this also for initial values. That could easily be used in
> >> > a budget version like this:
> >> >
> >> >                 line_b {
> >> >                         /* Just naming */
> >> >                         gpios = <6 0>;
> >> >                         line-name = "foo-bar-gpio";
> >> >                 };
> >> >
> >> > That could grow kind of big though. Or maybe not? How many
> >> > GPIO lines are actually properly named in a typical system?
> >>
> >> We should limit it to GPIOs with no connection to another node. For
> >> example, I don't want to see a SD card detect in the list as that
> >> should be in the SD host node. However, that is hard to enforce and
> >> can change over time. Removing it would break userspace potentially.
> >> Of course if the kernel starts own a signal that userspace used, then
> >> that potentially breaks userspace regardless of the DT changing. OTOH,
> >> using GPIOs in userspace is kind of use at your own risk.
> >
> > I see this a bit differently. I would really like to see the each GPIO having
> > two different names:
> 
> I think we are saying the same thing...
> 
> > - GPIO label: This is the name of the GPIO line in the schematic for example
> 
> Yes.
> 
> > - GPIO use (this is the current semantic of the GPIO name): The use of a GPIO,
> >   e.g. 'sd-card-detect', 'LED', ...
> 
> This should be determined from the compatible string and/or -gpios
> prefix. This is the what the function is and "label" is which one.
> 
> > I think it would be good to describe all GPIO labels in gpiochip subnodes as
> > gpio-hogging introduced it. This would offer a use-independent naming. The use
> > of the function could be defined in the device node that is using this gpio.
> 
> I think I agree here. You may have a defined function without any
> connection to another node. I also think we should encourage simple
> GPIO bindings like gpio-leds to be child nodes. Having them at the
> top-level is kind of arbitrary. Of course, allowing for both is
> required.
> 
> > As an example perhaps something like this:
> >
> >         &gpiochip {
> >                 some_interrupt {
> >                         gpios = <4 0>;
> >                         line-name = "some_interrupt_line";
> >                 };
> >
> >                 line_b {
> >                         gpios = <6 0>;
> >                         line-name = "line-b";
> >                 };
> >         };
> >
> >         randomswitch {
> >                 compatible = "gpio-switch";
> >                 gpios = <&gpiochip 4 0>;
> >                 use = "action-trigger";
> >                 read-only;
> >         };
> >
> > Also this does seem kind of inconsistent with gpio-hogging and the proposed
> > gpio-initval. gpio-hogging is defined in subnodes of the gpio chip while
> > gpio-switches are not. As "gpio-switch" is not really any kind of device it
> > would perhaps make sense to keep this consistent with gpio-hogging as well and
> > define it in the same subnodes?
> > I would be happy about any consistent way.
> 
> Yes, as well as gpio leds, keys, etc. bindings. The key is you would
> need to be able to start with something minimal and extend it with
> specific compatibles.

So if I understand you right it would be better to handle most
distinctions using compatibles? Something like this?

	&gpiochip {
		some_led {
			compatible = "gpio-leds";
			default-state = "on";
			gpios = <3 0>;
			line-name = "leda";
		};

		some_switch {
			compatible = "gpio-switch", "gpio-initval";
			gpios = <4 0>;
			line-name = "switch1";

			/* This is used by gpio-initval in case gpio-switch is not implemented */
			output-low;
		};

		some_interrupt {
			gpios = <5 0>;
			line-name = "some_interrupt_line";
		};

		line_b {
			gpios = <6 0>;
			line-name = "line-b";
		};
	};

	randomcomponent {
		gpios = <&gpiochip 5 0>;
		read-only;
	};

In this case there is a gpio-led embedded within the gpiochip node. Also
'some_switch' is a gpio-switch and falls back to being gpio-initval.
This way we can replace it at some point with a real driver. But if it
doesn't exist we can at least initialize the GPIO properly.

As you suggested this would open up the possibilities for all
compatibles and drivers for single gpios.

Best Regards,

Markus

> 
> [...]
> 
> >> We also have to consider how to handle add-on boards. We probably need
> >> a connector node which can remap connector signals to host signals in
> >> order to have overlays independent of the host board DT. For GPIOs
> >> this is probably a gpio-map property similar to interrupt-map. The
> >> complicated part will be connectors that require pinmux setup of the
> >> host.
> >
> > Also what about hotplugging gpio-chips? Is there any mechanism to let the
> > 'gpio-switch' know that the GPIO is not there anymore?
> 
> There are certainly issues around hotplug and GPIOs. If the
> gpio-switch device is a child of the gpio controller, then it should
> be possible.
> 
> Rob
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160307/f8d05808/attachment.sig>

  reply	other threads:[~2016-03-07  8:27 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-04 17:31 Add support for monitoring gpio switches Martyn Welch
2015-12-04 17:31 ` Martyn Welch
2015-12-04 17:31 ` Martyn Welch
2015-12-04 17:31 ` [PATCH 1/3] Device tree binding documentation for gpio-switch Martyn Welch
2015-12-04 17:31   ` Martyn Welch
2015-12-07 17:37   ` Rob Herring
2015-12-07 17:37     ` Rob Herring
2015-12-07 21:10     ` Martyn Welch
2015-12-07 21:10       ` Martyn Welch
2015-12-11 12:39   ` Linus Walleij
2015-12-11 12:39     ` Linus Walleij
2015-12-11 12:39     ` Linus Walleij
2015-12-11 14:06     ` Rob Herring
2015-12-11 14:06       ` Rob Herring
2015-12-11 14:06       ` Rob Herring
2015-12-14 14:28       ` Linus Walleij
2015-12-14 14:28         ` Linus Walleij
2015-12-14 14:28         ` Linus Walleij
2015-12-14 15:45         ` Rob Herring
2015-12-14 15:45           ` Rob Herring
2015-12-14 15:45           ` Rob Herring
2015-12-15  9:09           ` Markus Pargmann
2015-12-15  9:09             ` Markus Pargmann
2016-03-02 16:03             ` Rob Herring
2016-03-02 16:03               ` Rob Herring
2016-03-02 16:03               ` Rob Herring
2016-03-07  8:26               ` Markus Pargmann [this message]
2016-03-07  8:26                 ` Markus Pargmann
2016-03-07  8:26                 ` Markus Pargmann
2015-12-04 17:31 ` [PATCH 2/3] Add support for monitoring gpio switches Martyn Welch
2015-12-04 17:31   ` Martyn Welch
2015-12-04 17:31   ` Martyn Welch
2015-12-04 18:14   ` [PATCH] fix noderef.cocci warnings kbuild test robot
2015-12-04 18:14     ` kbuild test robot
2015-12-04 18:14     ` kbuild test robot
2015-12-04 18:14   ` [PATCH 2/3] Add support for monitoring gpio switches kbuild test robot
2015-12-04 18:14     ` kbuild test robot
2015-12-04 18:14     ` kbuild test robot
2015-12-04 18:57   ` Greg Kroah-Hartman
2015-12-04 18:57     ` Greg Kroah-Hartman
2015-12-05 10:42     ` Martyn Welch
2015-12-05 10:42       ` Martyn Welch
2015-12-11  9:08   ` Linus Walleij
2015-12-11  9:08     ` Linus Walleij
2015-12-11  9:08     ` Linus Walleij
2015-12-16 10:11     ` Martyn Welch
2015-12-16 10:11       ` Martyn Welch
2015-12-16 10:11       ` Martyn Welch
2015-12-22  9:25       ` Linus Walleij
2015-12-22  9:25         ` Linus Walleij
2015-12-22  9:25         ` Linus Walleij
2015-12-04 17:31 ` [PATCH 3/3] ARM: dts: Addition of binding for gpio switches on peach-pi Martyn Welch
2015-12-04 17:31   ` Martyn Welch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6877420.aKPrAc9Qh5@adelgunde \
    --to=mpa@pengutronix.de \
    --cc=acourbot@nvidia.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=johan@kernel.org \
    --cc=k.kozlowski@samsung.com \
    --cc=kgene@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=martyn.welch@collabora.co.uk \
    --cc=mwelling@ieee.org \
    --cc=olof@lixom.net \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.