All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/5] Rework OpenFirmware GPIO handling
@ 2009-11-17 15:42 Dmitry Eremin-Solenikov
  2009-11-17 15:42 ` [RFC PATCH 1/5] " Dmitry Eremin-Solenikov
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Dmitry Eremin-Solenikov @ 2009-11-17 15:42 UTC (permalink / raw)
  To: devicetree-discuss, linuxppc-dev; +Cc: David Brownell, Paul Mackerras

This is an RFC serie of patches containing rework of OpenFirmware GPIO binding.

It permits very simple binding of most i2c/spi/etc. GPIO expanders (e.g.
to use pcf8574x driver I had only to patch in support for working w/o platform
data, no OF-specific code at all).

Dmitry Eremin-Solenikov (5):
      Rework OpenFirmware GPIO handling
      mcu_mpc8349emitx: port to new of gpio interface
      mpc8xxx_gpio: port to new of gpio interface
      simple_gpio: port to new of gpio interface
      qe_gpio: port to new of gpio interface

 arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c |   11 +++---
 arch/powerpc/sysdev/mpc8xxx_gpio.c             |    2 +-
 arch/powerpc/sysdev/qe_lib/gpio.c              |    4 +-
 arch/powerpc/sysdev/simple_gpio.c              |    2 +-
 drivers/gpio/gpiolib.c                         |    6 +++
 drivers/of/gpio.c                              |   42 ++++++++++++++++++++---
 include/asm-generic/gpio.h                     |   19 +++++++++++
 include/linux/of_gpio.h                        |   29 +++++++++-------
 8 files changed, 86 insertions(+), 29 deletions(-)

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

* [RFC PATCH 1/5] Rework OpenFirmware GPIO handling
  2009-11-17 15:42 [RFC 0/5] Rework OpenFirmware GPIO handling Dmitry Eremin-Solenikov
@ 2009-11-17 15:42 ` Dmitry Eremin-Solenikov
  2009-11-17 16:12   ` Anton Vorontsov
  2009-11-20 20:37   ` Grant Likely
  2009-11-17 15:42 ` [RFC PATCH 2/5] mcu_mpc8349emitx: port to new of gpio interface Dmitry Eremin-Solenikov
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 16+ messages in thread
From: Dmitry Eremin-Solenikov @ 2009-11-17 15:42 UTC (permalink / raw)
  To: devicetree-discuss, linuxppc-dev; +Cc: David Brownell, Paul Mackerras

This patch improves OF GPIO bindings so, that most non-OF-specific gpio
controllers don't need to call any of OF binding function:

0) Move of_gpio_chip into main gpio_chip structure.
1) Call of_gpio_init/destroy from gpiochip_add/remove.
2) By default supply reasonable defaults for gpio_cells/xlate

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/gpio/gpiolib.c     |    6 ++++++
 drivers/of/gpio.c          |   42 ++++++++++++++++++++++++++++++++++++------
 include/asm-generic/gpio.h |   19 +++++++++++++++++++
 include/linux/of_gpio.h    |   29 ++++++++++++++++-------------
 4 files changed, 77 insertions(+), 19 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 50de0f5..7c998b3 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -10,6 +10,8 @@
 #include <linux/gpio.h>
 #include <linux/idr.h>
 
+#include <linux/of_gpio.h>
+
 
 /* Optional implementation infrastructure for GPIO interfaces.
  *
@@ -963,6 +965,8 @@ unlock:
 	spin_unlock_irqrestore(&gpio_lock, flags);
 	if (status == 0)
 		status = gpiochip_export(chip);
+	if (status == 0)
+		of_gpio_init(chip);
 fail:
 	/* failures here can mean systems won't boot... */
 	if (status)
@@ -994,6 +998,8 @@ int gpiochip_remove(struct gpio_chip *chip)
 		}
 	}
 	if (status == 0) {
+		of_gpio_destroy(chip);
+
 		for (id = chip->base; id < chip->base + chip->ngpio; id++)
 			gpio_desc[id].chip = NULL;
 	}
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
index 6eea601..903e79f 100644
--- a/drivers/of/gpio.c
+++ b/drivers/of/gpio.c
@@ -70,7 +70,7 @@ int of_get_gpio_flags(struct device_node *np, int index,
 	if (ret < 0)
 		goto err1;
 
-	ret += of_gc->gc.base;
+	ret += to_gpio_chip_of(of_gc)->base;
 err1:
 	of_node_put(gc);
 err0:
@@ -140,7 +140,7 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
 		return -EINVAL;
 	}
 
-	if (*gpio > of_gc->gc.ngpio)
+	if (*gpio > to_gpio_chip_of(of_gc)->ngpio)
 		return -EINVAL;
 
 	if (flags)
@@ -176,7 +176,7 @@ int of_mm_gpiochip_add(struct device_node *np,
 {
 	int ret = -ENOMEM;
 	struct of_gpio_chip *of_gc = &mm_gc->of_gc;
-	struct gpio_chip *gc = &of_gc->gc;
+	struct gpio_chip *gc = &mm_gc->gc;
 
 	gc->label = kstrdup(np->full_name, GFP_KERNEL);
 	if (!gc->label)
@@ -188,9 +188,6 @@ int of_mm_gpiochip_add(struct device_node *np,
 
 	gc->base = -1;
 
-	if (!of_gc->xlate)
-		of_gc->xlate = of_gpio_simple_xlate;
-
 	if (mm_gc->save_regs)
 		mm_gc->save_regs(mm_gc);
 
@@ -217,3 +214,36 @@ err0:
 	return ret;
 }
 EXPORT_SYMBOL(of_mm_gpiochip_add);
+
+void of_gpio_init(struct gpio_chip *gc)
+{
+	struct of_gpio_chip *of_gc = &gc->of_gc;
+	struct device_node *np = gc->dev ?
+		dev_archdata_get_node(&gc->dev->archdata) :
+		NULL;
+
+	if (!of_gc->xlate) {
+		if (!of_gc->gpio_cells)
+			of_gc->gpio_cells = 2;
+		of_gc->xlate = of_gpio_simple_xlate;
+	}
+
+	if (np) {
+		of_node_get(np);
+		np->data = of_gc;
+	}
+}
+EXPORT_SYMBOL(of_gpio_init);
+
+void of_gpio_destroy(struct gpio_chip *gc)
+{
+	struct device_node *np = gc->dev ?
+		dev_archdata_get_node(&gc->dev->archdata) :
+		NULL;
+
+	if (np) {
+		np->data = NULL;
+		of_node_put(np);
+	}
+}
+EXPORT_SYMBOL(of_gpio_destroy);
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 66d6106..3a70958 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -31,6 +31,21 @@ static inline int gpio_is_valid(int number)
 struct seq_file;
 struct module;
 
+#ifdef CONFIG_OF_GPIO
+struct device_node;
+enum of_gpio_flags;
+
+/*
+ * Generic OF GPIO chip
+ */
+struct of_gpio_chip {
+	int gpio_cells;
+	int (*xlate)(struct of_gpio_chip *of_gc, struct device_node *np,
+		     const void *gpio_spec, enum of_gpio_flags *flags);
+};
+#endif
+
+
 /**
  * struct gpio_chip - abstract a GPIO controller
  * @label: for diagnostics
@@ -76,6 +91,10 @@ struct gpio_chip {
 	struct device		*dev;
 	struct module		*owner;
 
+#ifdef CONFIG_OF_GPIO
+	struct of_gpio_chip	of_gc;
+#endif
+
 	int			(*request)(struct gpio_chip *chip,
 						unsigned offset);
 	void			(*free)(struct gpio_chip *chip,
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index fc2472c..99cf84f 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -32,25 +32,16 @@ enum of_gpio_flags {
 
 #ifdef CONFIG_OF_GPIO
 
-/*
- * Generic OF GPIO chip
- */
-struct of_gpio_chip {
-	struct gpio_chip gc;
-	int gpio_cells;
-	int (*xlate)(struct of_gpio_chip *of_gc, struct device_node *np,
-		     const void *gpio_spec, enum of_gpio_flags *flags);
-};
-
-static inline struct of_gpio_chip *to_of_gpio_chip(struct gpio_chip *gc)
+static inline struct gpio_chip *to_gpio_chip_of(struct of_gpio_chip *of_gc)
 {
-	return container_of(gc, struct of_gpio_chip, gc);
+	return container_of(of_gc, struct gpio_chip, of_gc);
 }
 
 /*
  * OF GPIO chip for memory mapped banks
  */
 struct of_mm_gpio_chip {
+	struct gpio_chip gc;
 	struct of_gpio_chip of_gc;
 	void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
 	void __iomem *regs;
@@ -58,8 +49,11 @@ struct of_mm_gpio_chip {
 
 static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
 {
-	struct of_gpio_chip *of_gc = to_of_gpio_chip(gc);
+	return container_of(gc, struct of_mm_gpio_chip, gc);
+}
 
+static inline struct of_mm_gpio_chip *to_of_mm_of_chip(struct of_gpio_chip *of_gc)
+{
 	return container_of(of_gc, struct of_mm_gpio_chip, of_gc);
 }
 
@@ -73,6 +67,9 @@ extern int of_gpio_simple_xlate(struct of_gpio_chip *of_gc,
 				struct device_node *np,
 				const void *gpio_spec,
 				enum of_gpio_flags *flags);
+
+extern void of_gpio_init(struct gpio_chip *gc);
+extern void of_gpio_destroy(struct gpio_chip *gc);
 #else
 
 /* Drivers may not strictly depend on the GPIO support, so let them link. */
@@ -87,6 +84,12 @@ static inline unsigned int of_gpio_count(struct device_node *np)
 	return 0;
 }
 
+static inline void of_gpio_init(struct gpio_chip *gc)
+{
+}
+static inline void of_gpio_destroy(struct gpio_chip *gc)
+{
+}
 #endif /* CONFIG_OF_GPIO */
 
 /**
-- 
1.6.5

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

* [RFC PATCH 2/5] mcu_mpc8349emitx: port to new of gpio interface
  2009-11-17 15:42 [RFC 0/5] Rework OpenFirmware GPIO handling Dmitry Eremin-Solenikov
  2009-11-17 15:42 ` [RFC PATCH 1/5] " Dmitry Eremin-Solenikov
@ 2009-11-17 15:42 ` Dmitry Eremin-Solenikov
       [not found]   ` <1258472546-31343-3-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2009-11-17 15:42 ` [RFC PATCH 3/5] mpc8xxx_gpio: " Dmitry Eremin-Solenikov
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Dmitry Eremin-Solenikov @ 2009-11-17 15:42 UTC (permalink / raw)
  To: devicetree-discuss, linuxppc-dev; +Cc: David Brownell, Paul Mackerras

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
index 82a9bcb..4ba8b16 100644
--- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
+++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
@@ -36,7 +36,7 @@ struct mcu {
 	struct mutex lock;
 	struct device_node *np;
 	struct i2c_client *client;
-	struct of_gpio_chip of_gc;
+	struct gpio_chip gc;
 	u8 reg_ctrl;
 };
 
@@ -55,8 +55,7 @@ static void mcu_power_off(void)
 
 static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 {
-	struct of_gpio_chip *of_gc = to_of_gpio_chip(gc);
-	struct mcu *mcu = container_of(of_gc, struct mcu, of_gc);
+	struct mcu *mcu = container_of(gc, struct mcu, gc);
 	u8 bit = 1 << (4 + gpio);
 
 	mutex_lock(&mcu->lock);
@@ -78,8 +77,8 @@ static int mcu_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 static int mcu_gpiochip_add(struct mcu *mcu)
 {
 	struct device_node *np;
-	struct of_gpio_chip *of_gc = &mcu->of_gc;
-	struct gpio_chip *gc = &of_gc->gc;
+	struct gpio_chip *gc = &mcu->gc;
+	struct of_gpio_chip *of_gc = &gc->of_gc;
 	int ret;
 
 	np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx");
@@ -113,7 +112,7 @@ static int mcu_gpiochip_remove(struct mcu *mcu)
 {
 	int ret;
 
-	ret = gpiochip_remove(&mcu->of_gc.gc);
+	ret = gpiochip_remove(&mcu->gc);
 	if (ret)
 		return ret;
 	of_node_put(mcu->np);
-- 
1.6.5

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

* [RFC PATCH 3/5] mpc8xxx_gpio: port to new of gpio interface
  2009-11-17 15:42 [RFC 0/5] Rework OpenFirmware GPIO handling Dmitry Eremin-Solenikov
  2009-11-17 15:42 ` [RFC PATCH 1/5] " Dmitry Eremin-Solenikov
  2009-11-17 15:42 ` [RFC PATCH 2/5] mcu_mpc8349emitx: port to new of gpio interface Dmitry Eremin-Solenikov
@ 2009-11-17 15:42 ` Dmitry Eremin-Solenikov
  2009-11-17 15:42 ` [RFC PATCH 4/5] simple_gpio: " Dmitry Eremin-Solenikov
  2009-11-17 15:42 ` [RFC PATCH 5/5] qe_gpio: " Dmitry Eremin-Solenikov
  4 siblings, 0 replies; 16+ messages in thread
From: Dmitry Eremin-Solenikov @ 2009-11-17 15:42 UTC (permalink / raw)
  To: devicetree-discuss, linuxppc-dev; +Cc: David Brownell, Paul Mackerras

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/sysdev/mpc8xxx_gpio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c
index 103eace..9e8f4b4 100644
--- a/arch/powerpc/sysdev/mpc8xxx_gpio.c
+++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c
@@ -129,7 +129,7 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
 
 	mm_gc = &mpc8xxx_gc->mm_gc;
 	of_gc = &mm_gc->of_gc;
-	gc = &of_gc->gc;
+	gc = &mm_gc->gc;
 
 	mm_gc->save_regs = mpc8xxx_gpio_save_regs;
 	of_gc->gpio_cells = 2;
-- 
1.6.5

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

* [RFC PATCH 4/5] simple_gpio: port to new of gpio interface
  2009-11-17 15:42 [RFC 0/5] Rework OpenFirmware GPIO handling Dmitry Eremin-Solenikov
                   ` (2 preceding siblings ...)
  2009-11-17 15:42 ` [RFC PATCH 3/5] mpc8xxx_gpio: " Dmitry Eremin-Solenikov
@ 2009-11-17 15:42 ` Dmitry Eremin-Solenikov
  2009-11-17 15:42 ` [RFC PATCH 5/5] qe_gpio: " Dmitry Eremin-Solenikov
  4 siblings, 0 replies; 16+ messages in thread
From: Dmitry Eremin-Solenikov @ 2009-11-17 15:42 UTC (permalink / raw)
  To: devicetree-discuss, linuxppc-dev; +Cc: David Brownell, Paul Mackerras

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/sysdev/simple_gpio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/sysdev/simple_gpio.c b/arch/powerpc/sysdev/simple_gpio.c
index 43c4569..5ad1e23 100644
--- a/arch/powerpc/sysdev/simple_gpio.c
+++ b/arch/powerpc/sysdev/simple_gpio.c
@@ -101,7 +101,7 @@ static int __init u8_simple_gpiochip_add(struct device_node *np)
 
 	mm_gc = &u8_gc->mm_gc;
 	of_gc = &mm_gc->of_gc;
-	gc = &of_gc->gc;
+	gc = &mm_gc->gc;
 
 	mm_gc->save_regs = u8_gpio_save_regs;
 	of_gc->gpio_cells = 2;
-- 
1.6.5

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

* [RFC PATCH 5/5] qe_gpio: port to new of gpio interface
  2009-11-17 15:42 [RFC 0/5] Rework OpenFirmware GPIO handling Dmitry Eremin-Solenikov
                   ` (3 preceding siblings ...)
  2009-11-17 15:42 ` [RFC PATCH 4/5] simple_gpio: " Dmitry Eremin-Solenikov
@ 2009-11-17 15:42 ` Dmitry Eremin-Solenikov
  4 siblings, 0 replies; 16+ messages in thread
From: Dmitry Eremin-Solenikov @ 2009-11-17 15:42 UTC (permalink / raw)
  To: devicetree-discuss, linuxppc-dev; +Cc: David Brownell, Paul Mackerras

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/sysdev/qe_lib/gpio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c
index 8e7a776..b85eab8 100644
--- a/arch/powerpc/sysdev/qe_lib/gpio.c
+++ b/arch/powerpc/sysdev/qe_lib/gpio.c
@@ -187,7 +187,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
 	if (err < 0)
 		goto err1;
 
-	mm_gc = to_of_mm_gpio_chip(&of_gc->gc);
+	mm_gc = to_of_mm_of_chip(of_gc);
 	qe_gc = to_qe_gpio_chip(mm_gc);
 
 	spin_lock_irqsave(&qe_gc->lock, flags);
@@ -319,7 +319,7 @@ static int __init qe_add_gpiochips(void)
 
 		mm_gc = &qe_gc->mm_gc;
 		of_gc = &mm_gc->of_gc;
-		gc = &of_gc->gc;
+		gc = &mm_gc->gc;
 
 		mm_gc->save_regs = qe_gpio_save_regs;
 		of_gc->gpio_cells = 2;
-- 
1.6.5

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

* Re: [RFC PATCH 1/5] Rework OpenFirmware GPIO handling
  2009-11-17 15:42 ` [RFC PATCH 1/5] " Dmitry Eremin-Solenikov
@ 2009-11-17 16:12   ` Anton Vorontsov
       [not found]     ` <20091117161244.GA6849-wnGakbxT3iijyJ0x5qLZdcN33GVbZNy3@public.gmane.org>
  2009-11-20 20:37   ` Grant Likely
  1 sibling, 1 reply; 16+ messages in thread
From: Anton Vorontsov @ 2009-11-17 16:12 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov
  Cc: linuxppc-dev, devicetree-discuss, David Brownell, Paul Mackerras

On Tue, Nov 17, 2009 at 06:42:22PM +0300, Dmitry Eremin-Solenikov wrote:
> This patch improves OF GPIO bindings so, that most non-OF-specific gpio
> controllers don't need to call any of OF binding function:
> 
> 0) Move of_gpio_chip into main gpio_chip structure.
> 1) Call of_gpio_init/destroy from gpiochip_add/remove.
> 2) By default supply reasonable defaults for gpio_cells/xlate

Heh.. you didn't google before writing the code, did you? ;-)

I don't really think that David will like this approach, just as
he didn't like the previous one (which was even less intrusive,
but still wrong):

http://lkml.org/lkml/2008/10/16/248 (a huge thread, but worth reading)

Both of the approaches do not solve the pdata issue.

There are some of David's [absolutely legitimate] comments:
http://lkml.org/lkml/2008/10/20/43

Some more thoughts:
http://lkml.org/lkml/2008/10/20/182

And it turned out that the only sane solution is to write
OF-pdata-hooks for the each driver (that we do for many drivers
already):

http://lkml.org/lkml/2008/10/22/471

And for this, you'll need the patches that I sent to you
yesterday.

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* Re: [RFC PATCH 1/5] Rework OpenFirmware GPIO handling
  2009-11-17 16:12   ` Anton Vorontsov
@ 2009-11-17 20:08         ` Wolfram Sang
  0 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2009-11-17 20:08 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Dmitry Eremin-Solenikov, linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, David Brownell


[-- Attachment #1.1: Type: text/plain, Size: 356 bytes --]

> And it turned out that the only sane solution is to write
> OF-pdata-hooks for the each driver (that we do for many drivers
> already):

Or to support Grant in getting rid of of_platform :)

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

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

[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

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

* Re: [RFC PATCH 1/5] Rework OpenFirmware GPIO handling
@ 2009-11-17 20:08         ` Wolfram Sang
  0 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2009-11-17 20:08 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Dmitry Eremin-Solenikov, linuxppc-dev, devicetree-discuss,
	David Brownell, Paul Mackerras

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

> And it turned out that the only sane solution is to write
> OF-pdata-hooks for the each driver (that we do for many drivers
> already):

Or to support Grant in getting rid of of_platform :)

-- 
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] 16+ messages in thread

* Re: [RFC PATCH 1/5] Rework OpenFirmware GPIO handling
  2009-11-17 20:08         ` Wolfram Sang
  (?)
@ 2009-11-17 20:18         ` Anton Vorontsov
  -1 siblings, 0 replies; 16+ messages in thread
From: Anton Vorontsov @ 2009-11-17 20:18 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: David Brownell, Dmitry Eremin-Solenikov, devicetree-discuss,
	linuxppc-dev, Paul Mackerras

On Tue, Nov 17, 2009 at 09:08:21PM +0100, Wolfram Sang wrote:
> > And it turned out that the only sane solution is to write
> > OF-pdata-hooks for the each driver (that we do for many drivers
> > already):
> 
> Or to support Grant in getting rid of of_platform :)

No, of_platform is completely other stuff. This won't help I2C/SPI
drivers.

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* Re: [RFC PATCH 1/5] Rework OpenFirmware GPIO handling
  2009-11-17 15:42 ` [RFC PATCH 1/5] " Dmitry Eremin-Solenikov
  2009-11-17 16:12   ` Anton Vorontsov
@ 2009-11-20 20:37   ` Grant Likely
       [not found]     ` <fa686aa40911201237y4a41dd63wee3fb4e0a5858e87-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 16+ messages in thread
From: Grant Likely @ 2009-11-20 20:37 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov
  Cc: linuxppc-dev, devicetree-discuss, Paul Mackerras, David Brownell

On Tue, Nov 17, 2009 at 8:42 AM, Dmitry Eremin-Solenikov
<dbaryshkov@gmail.com> wrote:
> This patch improves OF GPIO bindings so, that most non-OF-specific gpio
> controllers don't need to call any of OF binding function:
>
> 0) Move of_gpio_chip into main gpio_chip structure.
> 1) Call of_gpio_init/destroy from gpiochip_add/remove.
> 2) By default supply reasonable defaults for gpio_cells/xlate

I think this change approaches the problem from the wrong way around.
It is not appropriate to try and build OF hooks into gpiolib. gpiolib
should be completely agnostic to any layers around them used to get
data about how they are configured up.  If anything, OF helpers should
wrap around the gpiolib functions so that drivers can use them if it
is useful to do so.

g.

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

* Re: [RFC PATCH 1/5] Rework OpenFirmware GPIO handling
  2009-11-20 20:37   ` Grant Likely
@ 2009-11-20 21:12         ` Grant Likely
  0 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2009-11-20 21:12 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Anton Vorontsov,
	David Brownell

On Fri, Nov 20, 2009 at 1:37 PM, Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
> On Tue, Nov 17, 2009 at 8:42 AM, Dmitry Eremin-Solenikov
> <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> This patch improves OF GPIO bindings so, that most non-OF-specific gpio
>> controllers don't need to call any of OF binding function:
>>
>> 0) Move of_gpio_chip into main gpio_chip structure.
>> 1) Call of_gpio_init/destroy from gpiochip_add/remove.
>> 2) By default supply reasonable defaults for gpio_cells/xlate
>
> I think this change approaches the problem from the wrong way around.
> It is not appropriate to try and build OF hooks into gpiolib. gpiolib
> should be completely agnostic to any layers around them used to get
> data about how they are configured up.  If anything, OF helpers should
> wrap around the gpiolib functions so that drivers can use them if it
> is useful to do so.

Hmmm... okay, I didn't read your patch closely enough the first time
around.  I understand what you're trying to do now.  I appreciate
wanting to make GPIO binding transparent to GPIO providers.  However,
I'm still leery of inserting OF hooks into gpiolib.  I'm not convinced
that it is the correct approach.  What *might* work is to add a
notifier API to GPIOLIB so that interested subsystems (like OF) can
register hooks to be told when GPIO pins are added and removed.  That
keeps things all the OF implementation details abstracted away from
gpiolib.

Cheers,
g.

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

* Re: [RFC PATCH 1/5] Rework OpenFirmware GPIO handling
@ 2009-11-20 21:12         ` Grant Likely
  0 siblings, 0 replies; 16+ messages in thread
From: Grant Likely @ 2009-11-20 21:12 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov
  Cc: linuxppc-dev, devicetree-discuss, Paul Mackerras, David Brownell

On Fri, Nov 20, 2009 at 1:37 PM, Grant Likely <grant.likely@secretlab.ca> w=
rote:
> On Tue, Nov 17, 2009 at 8:42 AM, Dmitry Eremin-Solenikov
> <dbaryshkov@gmail.com> wrote:
>> This patch improves OF GPIO bindings so, that most non-OF-specific gpio
>> controllers don't need to call any of OF binding function:
>>
>> 0) Move of_gpio_chip into main gpio_chip structure.
>> 1) Call of_gpio_init/destroy from gpiochip_add/remove.
>> 2) By default supply reasonable defaults for gpio_cells/xlate
>
> I think this change approaches the problem from the wrong way around.
> It is not appropriate to try and build OF hooks into gpiolib. gpiolib
> should be completely agnostic to any layers around them used to get
> data about how they are configured up. =A0If anything, OF helpers should
> wrap around the gpiolib functions so that drivers can use them if it
> is useful to do so.

Hmmm... okay, I didn't read your patch closely enough the first time
around.  I understand what you're trying to do now.  I appreciate
wanting to make GPIO binding transparent to GPIO providers.  However,
I'm still leery of inserting OF hooks into gpiolib.  I'm not convinced
that it is the correct approach.  What *might* work is to add a
notifier API to GPIOLIB so that interested subsystems (like OF) can
register hooks to be told when GPIO pins are added and removed.  That
keeps things all the OF implementation details abstracted away from
gpiolib.

Cheers,
g.

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

* Re: [RFC PATCH 2/5] mcu_mpc8349emitx: port to new of gpio interface
  2009-11-17 15:42 ` [RFC PATCH 2/5] mcu_mpc8349emitx: port to new of gpio interface Dmitry Eremin-Solenikov
@ 2009-12-09 21:16       ` Kumar Gala
  0 siblings, 0 replies; 16+ messages in thread
From: Kumar Gala @ 2009-12-09 21:16 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Dmitry Eremin-Solenikov, Linuxppc-dev Development,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, David Brownell


On Nov 17, 2009, at 9:42 AM, Dmitry Eremin-Solenikov wrote:

> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c |   11 +++++------
> 1 files changed, 5 insertions(+), 6 deletions(-)

Minding reviewing for me.

- k

> 
> diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
> index 82a9bcb..4ba8b16 100644
> --- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
> +++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
> @@ -36,7 +36,7 @@ struct mcu {
> 	struct mutex lock;
> 	struct device_node *np;
> 	struct i2c_client *client;
> -	struct of_gpio_chip of_gc;
> +	struct gpio_chip gc;
> 	u8 reg_ctrl;
> };
> 
> @@ -55,8 +55,7 @@ static void mcu_power_off(void)
> 
> static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
> {
> -	struct of_gpio_chip *of_gc = to_of_gpio_chip(gc);
> -	struct mcu *mcu = container_of(of_gc, struct mcu, of_gc);
> +	struct mcu *mcu = container_of(gc, struct mcu, gc);
> 	u8 bit = 1 << (4 + gpio);
> 
> 	mutex_lock(&mcu->lock);
> @@ -78,8 +77,8 @@ static int mcu_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
> static int mcu_gpiochip_add(struct mcu *mcu)
> {
> 	struct device_node *np;
> -	struct of_gpio_chip *of_gc = &mcu->of_gc;
> -	struct gpio_chip *gc = &of_gc->gc;
> +	struct gpio_chip *gc = &mcu->gc;
> +	struct of_gpio_chip *of_gc = &gc->of_gc;
> 	int ret;
> 
> 	np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx");
> @@ -113,7 +112,7 @@ static int mcu_gpiochip_remove(struct mcu *mcu)
> {
> 	int ret;
> 
> -	ret = gpiochip_remove(&mcu->of_gc.gc);
> +	ret = gpiochip_remove(&mcu->gc);
> 	if (ret)
> 		return ret;
> 	of_node_put(mcu->np);
> -- 
> 1.6.5
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* Re: [RFC PATCH 2/5] mcu_mpc8349emitx: port to new of gpio interface
@ 2009-12-09 21:16       ` Kumar Gala
  0 siblings, 0 replies; 16+ messages in thread
From: Kumar Gala @ 2009-12-09 21:16 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Dmitry Eremin-Solenikov, Linuxppc-dev Development,
	devicetree-discuss, David Brownell, Paul Mackerras


On Nov 17, 2009, at 9:42 AM, Dmitry Eremin-Solenikov wrote:

> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
> arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c |   11 +++++------
> 1 files changed, 5 insertions(+), 6 deletions(-)

Minding reviewing for me.

- k

>=20
> diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c =
b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
> index 82a9bcb..4ba8b16 100644
> --- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
> +++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
> @@ -36,7 +36,7 @@ struct mcu {
> 	struct mutex lock;
> 	struct device_node *np;
> 	struct i2c_client *client;
> -	struct of_gpio_chip of_gc;
> +	struct gpio_chip gc;
> 	u8 reg_ctrl;
> };
>=20
> @@ -55,8 +55,7 @@ static void mcu_power_off(void)
>=20
> static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int =
val)
> {
> -	struct of_gpio_chip *of_gc =3D to_of_gpio_chip(gc);
> -	struct mcu *mcu =3D container_of(of_gc, struct mcu, of_gc);
> +	struct mcu *mcu =3D container_of(gc, struct mcu, gc);
> 	u8 bit =3D 1 << (4 + gpio);
>=20
> 	mutex_lock(&mcu->lock);
> @@ -78,8 +77,8 @@ static int mcu_gpio_dir_out(struct gpio_chip *gc, =
unsigned int gpio, int val)
> static int mcu_gpiochip_add(struct mcu *mcu)
> {
> 	struct device_node *np;
> -	struct of_gpio_chip *of_gc =3D &mcu->of_gc;
> -	struct gpio_chip *gc =3D &of_gc->gc;
> +	struct gpio_chip *gc =3D &mcu->gc;
> +	struct of_gpio_chip *of_gc =3D &gc->of_gc;
> 	int ret;
>=20
> 	np =3D of_find_compatible_node(NULL, NULL, =
"fsl,mcu-mpc8349emitx");
> @@ -113,7 +112,7 @@ static int mcu_gpiochip_remove(struct mcu *mcu)
> {
> 	int ret;
>=20
> -	ret =3D gpiochip_remove(&mcu->of_gc.gc);
> +	ret =3D gpiochip_remove(&mcu->gc);
> 	if (ret)
> 		return ret;
> 	of_node_put(mcu->np);
> --=20
> 1.6.5
>=20
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* Re: [RFC PATCH 2/5] mcu_mpc8349emitx: port to new of gpio interface
  2009-12-09 21:16       ` Kumar Gala
  (?)
@ 2009-12-09 21:32       ` Anton Vorontsov
  -1 siblings, 0 replies; 16+ messages in thread
From: Anton Vorontsov @ 2009-12-09 21:32 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Dmitry Eremin-Solenikov, Linuxppc-dev Development,
	devicetree-discuss, David Brownell, Paul Mackerras

On Wed, Dec 09, 2009 at 03:16:37PM -0600, Kumar Gala wrote:
> On Nov 17, 2009, at 9:42 AM, Dmitry Eremin-Solenikov wrote:
> 
> > Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> > ---
> > arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c |   11 +++++------
> > 1 files changed, 5 insertions(+), 6 deletions(-)
> 
> Minding reviewing for me.

The whole approach was reviewed, and rejected.

http://lists.ozlabs.org/pipermail/devicetree-discuss/2009-November/001330.html
and
http://lists.ozlabs.org/pipermail/devicetree-discuss/2009-November/001328.html

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

end of thread, other threads:[~2009-12-09 21:32 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-17 15:42 [RFC 0/5] Rework OpenFirmware GPIO handling Dmitry Eremin-Solenikov
2009-11-17 15:42 ` [RFC PATCH 1/5] " Dmitry Eremin-Solenikov
2009-11-17 16:12   ` Anton Vorontsov
     [not found]     ` <20091117161244.GA6849-wnGakbxT3iijyJ0x5qLZdcN33GVbZNy3@public.gmane.org>
2009-11-17 20:08       ` Wolfram Sang
2009-11-17 20:08         ` Wolfram Sang
2009-11-17 20:18         ` Anton Vorontsov
2009-11-20 20:37   ` Grant Likely
     [not found]     ` <fa686aa40911201237y4a41dd63wee3fb4e0a5858e87-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-11-20 21:12       ` Grant Likely
2009-11-20 21:12         ` Grant Likely
2009-11-17 15:42 ` [RFC PATCH 2/5] mcu_mpc8349emitx: port to new of gpio interface Dmitry Eremin-Solenikov
     [not found]   ` <1258472546-31343-3-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-12-09 21:16     ` Kumar Gala
2009-12-09 21:16       ` Kumar Gala
2009-12-09 21:32       ` Anton Vorontsov
2009-11-17 15:42 ` [RFC PATCH 3/5] mpc8xxx_gpio: " Dmitry Eremin-Solenikov
2009-11-17 15:42 ` [RFC PATCH 4/5] simple_gpio: " Dmitry Eremin-Solenikov
2009-11-17 15:42 ` [RFC PATCH 5/5] qe_gpio: " Dmitry Eremin-Solenikov

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.