devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 RESEND 2] gpio-vx855: add device tree binding
@ 2011-09-16 18:12 Daniel Drake
       [not found] ` <20110916181220.E12109D401C-k/4jFdqg8LLlyo9zxV8I99HuzzzSOjJt@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Drake @ 2011-09-16 18:12 UTC (permalink / raw)
  To: grant.likely-s3s/WqlpOiPyB63q8FvJNQ
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

This is needed to enable the HDD LED on the OLPC XO-1.5 laptop,
enabled through devicetree and the gpio-leds driver.

Signed-off-by: Daniel Drake <dsd-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>
---
 .../devicetree/bindings/gpio/gpio_vx855.txt        |   20 ++++++++++++++++++++
 drivers/gpio/gpio-vx855.c                          |    5 +++++
 2 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio_vx855.txt

v2: extended the documentation with information about the pin numbering
scheme, which matches that of the driver.

diff --git a/Documentation/devicetree/bindings/gpio/gpio_vx855.txt b/Documentation/devicetree/bindings/gpio/gpio_vx855.txt
new file mode 100644
index 0000000..17285a5
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio_vx855.txt
@@ -0,0 +1,20 @@
+VIA VX855 GPIO controller
+
+Required properties:
+- compatible : "via,vx855-gpio"
+- #gpio-cells : Should be two. The first cell is the pin number and the
+  second cell is used to specify optional parameters:
+  - bit 0 specifies polarity (0 for normal, 1 for inverted)
+- gpio-controller : Marks the device node as a GPIO controller.
+
+As VIA differentiates between GPI, GPO and GPIO on its 42 available pins,
+with each pin type restarting numbering at 0, the following numbering scheme
+is used in the device tree for the pin number:
+
+PIN NO		VIA NAME
+0..13		GPI 0..13
+14..26		GPO 0..12
+27..41		GPIO 0..14
+
+For example, GPIO 11 (VIA name) is referred to with pin number 38 in the
+device tree.
diff --git a/drivers/gpio/gpio-vx855.c b/drivers/gpio/gpio-vx855.c
index ef5aabd..5b7e9ba 100644
--- a/drivers/gpio/gpio-vx855.c
+++ b/drivers/gpio/gpio-vx855.c
@@ -31,6 +31,7 @@
 #include <linux/platform_device.h>
 #include <linux/pci.h>
 #include <linux/io.h>
+#include <linux/of.h>
 
 #define MODULE_NAME "vx855_gpio"
 
@@ -216,6 +217,10 @@ static void vx855gpio_gpio_setup(struct vx855_gpio *vg)
 	c->ngpio = NR_VX855_GP;
 	c->can_sleep = 0;
 	c->names = vx855gpio_names;
+
+#ifdef CONFIG_OF_GPIO
+	c->of_node = of_find_compatible_node(NULL, NULL, "via,vx855-gpio");
+#endif
 }
 
 /* This platform device is ordinarily registered by the vx855 mfd driver */
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 RESEND 2] gpio-vx855: add device tree binding
       [not found] ` <20110916181220.E12109D401C-k/4jFdqg8LLlyo9zxV8I99HuzzzSOjJt@public.gmane.org>
@ 2011-09-17 15:56   ` Grant Likely
       [not found]     ` <20110917155615.GT3523-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Grant Likely @ 2011-09-17 15:56 UTC (permalink / raw)
  To: Daniel Drake
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Fri, Sep 16, 2011 at 07:12:20PM +0100, Daniel Drake wrote:
> This is needed to enable the HDD LED on the OLPC XO-1.5 laptop,
> enabled through devicetree and the gpio-leds driver.
> 
> Signed-off-by: Daniel Drake <dsd-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>
> ---
>  .../devicetree/bindings/gpio/gpio_vx855.txt        |   20 ++++++++++++++++++++
>  drivers/gpio/gpio-vx855.c                          |    5 +++++
>  2 files changed, 25 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio_vx855.txt
> 
> v2: extended the documentation with information about the pin numbering
> scheme, which matches that of the driver.
> 
> diff --git a/Documentation/devicetree/bindings/gpio/gpio_vx855.txt b/Documentation/devicetree/bindings/gpio/gpio_vx855.txt
> new file mode 100644
> index 0000000..17285a5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/gpio_vx855.txt
> @@ -0,0 +1,20 @@
> +VIA VX855 GPIO controller
> +
> +Required properties:
> +- compatible : "via,vx855-gpio"
> +- #gpio-cells : Should be two. The first cell is the pin number and the
> +  second cell is used to specify optional parameters:
> +  - bit 0 specifies polarity (0 for normal, 1 for inverted)
> +- gpio-controller : Marks the device node as a GPIO controller.
> +
> +As VIA differentiates between GPI, GPO and GPIO on its 42 available pins,
> +with each pin type restarting numbering at 0, the following numbering scheme
> +is used in the device tree for the pin number:
> +
> +PIN NO		VIA NAME
> +0..13		GPI 0..13
> +14..26		GPO 0..12
> +27..41		GPIO 0..14
> +
> +For example, GPIO 11 (VIA name) is referred to with pin number 38 in the
> +device tree.

Binding looks good.

> diff --git a/drivers/gpio/gpio-vx855.c b/drivers/gpio/gpio-vx855.c
> index ef5aabd..5b7e9ba 100644
> --- a/drivers/gpio/gpio-vx855.c
> +++ b/drivers/gpio/gpio-vx855.c
> @@ -31,6 +31,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/pci.h>
>  #include <linux/io.h>
> +#include <linux/of.h>
>  
>  #define MODULE_NAME "vx855_gpio"
>  
> @@ -216,6 +217,10 @@ static void vx855gpio_gpio_setup(struct vx855_gpio *vg)
>  	c->ngpio = NR_VX855_GP;
>  	c->can_sleep = 0;
>  	c->names = vx855gpio_names;
> +
> +#ifdef CONFIG_OF_GPIO
> +	c->of_node = of_find_compatible_node(NULL, NULL, "via,vx855-gpio");
> +#endif

drivers/mfd/vx855.c should be modified to assign pdev->of_node, which
can be used here for setting up c->of_node.  Also, if there is any
possibility of more than one of these being in a system, then you
should use something like of_find_matching_node_by_address() for
additional safety.

g.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 RESEND 2] gpio-vx855: add device tree binding
       [not found]     ` <20110917155615.GT3523-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
@ 2011-09-19  9:27       ` Daniel Drake
       [not found]         ` <CAMLZHHQqqs6k2i-RCSJ0YkZ2keVNPNQV9EbVccxUW1kjUq6f_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Drake @ 2011-09-19  9:27 UTC (permalink / raw)
  To: Grant Likely
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hi Grant,

Thanks for looking at this.

On Sat, Sep 17, 2011 at 4:56 PM, Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
> drivers/mfd/vx855.c should be modified to assign pdev->of_node, which
> can be used here for setting up c->of_node.

There doesn't seem to be any obvious place in mfd/vx855.c to insert
this. All the platform device creation and addition is done inside the
mfd layer (e.g. mfd_add_device()). Should I look at extending the MFD
API to allow for of_nodes to be passed in?

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 RESEND 2] gpio-vx855: add device tree binding
       [not found]         ` <CAMLZHHQqqs6k2i-RCSJ0YkZ2keVNPNQV9EbVccxUW1kjUq6f_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-09-22 17:41           ` Grant Likely
  0 siblings, 0 replies; 4+ messages in thread
From: Grant Likely @ 2011-09-22 17:41 UTC (permalink / raw)
  To: Daniel Drake
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Mon, Sep 19, 2011 at 10:27:07AM +0100, Daniel Drake wrote:
> Hi Grant,
> 
> Thanks for looking at this.
> 
> On Sat, Sep 17, 2011 at 4:56 PM, Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
> > drivers/mfd/vx855.c should be modified to assign pdev->of_node, which
> > can be used here for setting up c->of_node.
> 
> There doesn't seem to be any obvious place in mfd/vx855.c to insert
> this. All the platform device creation and addition is done inside the
> mfd layer (e.g. mfd_add_device()). Should I look at extending the MFD
> API to allow for of_nodes to be passed in?

yes.

g.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-22 17:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-16 18:12 [PATCH v2 RESEND 2] gpio-vx855: add device tree binding Daniel Drake
     [not found] ` <20110916181220.E12109D401C-k/4jFdqg8LLlyo9zxV8I99HuzzzSOjJt@public.gmane.org>
2011-09-17 15:56   ` Grant Likely
     [not found]     ` <20110917155615.GT3523-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-09-19  9:27       ` Daniel Drake
     [not found]         ` <CAMLZHHQqqs6k2i-RCSJ0YkZ2keVNPNQV9EbVccxUW1kjUq6f_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-22 17:41           ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).