All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Create an of_i2c_gpiochip_add()
@ 2010-01-06  3:51 Bill Gatliff
  2010-01-06  3:51 ` [PATCH 1/2] Create a struct of_i2c_gpio_chip, for i2c-based GPIO devices Bill Gatliff
  2010-01-06 20:07 ` [PATCH 0/2] " Bill Gatliff
  0 siblings, 2 replies; 6+ messages in thread
From: Bill Gatliff @ 2010-01-06  3:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Bill Gatliff

This patch series creates an of_i2c_gpiochip_add() function, to allow
i2c-based GPIO expanders to work with device tree gpio specifications.

Bill Gatliff (2):
  Create a struct of_i2c_gpio_chip, for i2c-based GPIO devices
  Create an of_i2c_gpiochip_add()

 drivers/of/gpio.c       |   55 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of_gpio.h |   23 +++++++++++++++++++
 2 files changed, 78 insertions(+), 0 deletions(-)

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

* [PATCH 1/2] Create a struct of_i2c_gpio_chip, for i2c-based GPIO devices
  2010-01-06  3:51 [PATCH 0/2] Create an of_i2c_gpiochip_add() Bill Gatliff
@ 2010-01-06  3:51 ` Bill Gatliff
  2010-01-06  3:51   ` [PATCH 2/2] Create an of_i2c_gpiochip_add() Bill Gatliff
  2010-01-06 20:07 ` [PATCH 0/2] " Bill Gatliff
  1 sibling, 1 reply; 6+ messages in thread
From: Bill Gatliff @ 2010-01-06  3:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Bill Gatliff


Signed-off-by: Bill Gatliff <bgat@billgatliff.com>
---
 include/linux/of_gpio.h |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index fc2472c..0c39242 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -102,4 +102,27 @@ static inline int of_get_gpio(struct device_node *np, int index)
 	return of_get_gpio_flags(np, index, NULL);
 }
 
+
+
+
+/*
+ * OF GPIO chip for I2C-based devices
+ */
+struct of_i2c_gpio_chip {
+	struct of_gpio_chip of_gc;
+};
+
+static inline struct of_i2c_gpio_chip *to_of_i2c_gpio_chip(struct gpio_chip *gc)
+{
+	struct of_gpio_chip *of_gc = to_of_gpio_chip(gc);
+
+	return container_of(of_gc, struct of_i2c_gpio_chip, of_gc);
+}
+
+extern int of_i2c_gpiochip_add(struct device_node *np,
+			       struct of_i2c_gpio_chip *gc);
+
+
+
+
 #endif /* __LINUX_OF_GPIO_H */
-- 
1.6.5

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

* [PATCH 2/2] Create an of_i2c_gpiochip_add()
  2010-01-06  3:51 ` [PATCH 1/2] Create a struct of_i2c_gpio_chip, for i2c-based GPIO devices Bill Gatliff
@ 2010-01-06  3:51   ` Bill Gatliff
  0 siblings, 0 replies; 6+ messages in thread
From: Bill Gatliff @ 2010-01-06  3:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Bill Gatliff


Signed-off-by: Bill Gatliff <bgat@billgatliff.com>
---
 drivers/of/gpio.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
index 6eea601..56b438a 100644
--- a/drivers/of/gpio.c
+++ b/drivers/of/gpio.c
@@ -217,3 +217,58 @@ err0:
 	return ret;
 }
 EXPORT_SYMBOL(of_mm_gpiochip_add);
+
+/**
+ * of_i2c_gpiochip_add - Add memory I2C-based GPIO chip
+ * @np:		device node of the GPIO chip
+ * @gc:		pointer to the of_i2c_gpio_chip allocated structure
+ *
+ * To use this function you should allocate and fill gc with:
+ *
+ * 1) In the gpio_chip structure:
+ *    - all the callbacks
+ *
+ * 2) In the of_gpio_chip structure:
+ *    - gpio_cells
+ *    - xlate callback (optional)
+ *
+ * If succeeded, this function will do something useful...
+ */
+int of_i2c_gpiochip_add(struct device_node *np,
+			struct of_i2c_gpio_chip *i2c_gc)
+{
+	int ret = -ENOMEM;
+	struct of_gpio_chip *of_gc = &i2c_gc->of_gc;
+	struct gpio_chip *gc = &of_gc->gc;
+
+	gc->label = kstrdup(np->full_name, GFP_KERNEL);
+	if (!gc->label)
+		goto err0;
+
+	gc->base = -1;
+
+	if (!of_gc->xlate)
+		of_gc->xlate = of_gpio_simple_xlate;
+
+	np->data = of_gc;
+
+	ret = gpiochip_add(gc);
+	if (ret)
+		goto err2;
+
+	/* We don't want to lose the node and its ->data */
+	of_node_get(np);
+
+	pr_debug("%s: registered as generic GPIO chip, base is %d\n",
+		 np->full_name, gc->base);
+	return 0;
+err2:
+	np->data = NULL;
+err1:
+	kfree(gc->label);
+err0:
+	pr_err("%s: GPIO chip registration failed with status %d\n",
+	       np->full_name, ret);
+	return ret;
+}
+EXPORT_SYMBOL(of_i2c_gpiochip_add);
-- 
1.6.5

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

* Re: [PATCH 0/2] Create an of_i2c_gpiochip_add()
  2010-01-06  3:51 [PATCH 0/2] Create an of_i2c_gpiochip_add() Bill Gatliff
  2010-01-06  3:51 ` [PATCH 1/2] Create a struct of_i2c_gpio_chip, for i2c-based GPIO devices Bill Gatliff
@ 2010-01-06 20:07 ` Bill Gatliff
  2010-01-06 20:17   ` Wolfram Sang
  1 sibling, 1 reply; 6+ messages in thread
From: Bill Gatliff @ 2010-01-06 20:07 UTC (permalink / raw)
  To: linuxppc-dev

Bill Gatliff wrote:
> This patch series creates an of_i2c_gpiochip_add() function, to allow
> i2c-based GPIO expanders to work with device tree gpio specifications.
>   

So nobody has any yays or nays on this?  I was expecting at least
_something_!  :)

Does the lack of response mean I'll be seeing these in an upcoming
kernel release?  I'd like to, because then I could more easily push
through related updates to a few i2c device drivers that I have in my
local repo.


b.g.

-- 
Bill Gatliff
Embedded systems training and consulting
http://billgatliff.com
bgat@billgatliff.com

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

* Re: [PATCH 0/2] Create an of_i2c_gpiochip_add()
  2010-01-06 20:07 ` [PATCH 0/2] " Bill Gatliff
@ 2010-01-06 20:17   ` Wolfram Sang
  2010-01-06 20:31     ` Bill Gatliff
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2010-01-06 20:17 UTC (permalink / raw)
  To: Bill Gatliff; +Cc: linuxppc-dev

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

> Does the lack of response mean I'll be seeing these in an upcoming
> kernel release?  I'd like to, because then I could more easily push

As long as nobody said "I picked it up", it will probably not. Patches
regarding GPIO sometimes need a bit of time. Also, of_platform was in the
discussion of being removed, this might complicate things, too.

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 0/2] Create an of_i2c_gpiochip_add()
  2010-01-06 20:17   ` Wolfram Sang
@ 2010-01-06 20:31     ` Bill Gatliff
  0 siblings, 0 replies; 6+ messages in thread
From: Bill Gatliff @ 2010-01-06 20:31 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linuxppc-dev

Wolfram Sang wrote:
>> Does the lack of response mean I'll be seeing these in an upcoming
>> kernel release?  I'd like to, because then I could more easily push
>>     
>
> As long as nobody said "I picked it up", it will probably not. Patches
> regarding GPIO sometimes need a bit of time. Also, of_platform was in the
> discussion of being removed, this might complicate things, too.
>   

Is this the right mailing list for such patches, though?


b.g.

-- 
Bill Gatliff
Embedded systems training and consulting
http://billgatliff.com
bgat@billgatliff.com

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

end of thread, other threads:[~2010-01-06 20:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-06  3:51 [PATCH 0/2] Create an of_i2c_gpiochip_add() Bill Gatliff
2010-01-06  3:51 ` [PATCH 1/2] Create a struct of_i2c_gpio_chip, for i2c-based GPIO devices Bill Gatliff
2010-01-06  3:51   ` [PATCH 2/2] Create an of_i2c_gpiochip_add() Bill Gatliff
2010-01-06 20:07 ` [PATCH 0/2] " Bill Gatliff
2010-01-06 20:17   ` Wolfram Sang
2010-01-06 20:31     ` Bill Gatliff

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.