linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] gpio: etraxfs: fix set register flag
@ 2015-07-22 13:05 Rabin Vincent
  2015-07-22 13:05 ` [PATCH 2/3] gpio: generic: support input-only chips Rabin Vincent
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Rabin Vincent @ 2015-07-22 13:05 UTC (permalink / raw)
  To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel, Rabin Vincent

BGPIO_F_UNREADABLE_REG_SET is incorrect, since the set register _is_
readable.  What's really required is BGPIO_F_READ_OUTPUT_REG_SET:
reading the set register reads the set output value.

Signed-off-by: Rabin Vincent <rabin@rab.in>
---
 drivers/gpio/gpio-etraxfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-etraxfs.c b/drivers/gpio/gpio-etraxfs.c
index 28071f4..c1ce80d 100644
--- a/drivers/gpio/gpio-etraxfs.c
+++ b/drivers/gpio/gpio-etraxfs.c
@@ -140,7 +140,7 @@ static int etraxfs_gpio_probe(struct platform_device *pdev)
 				 NULL,			/* clr */
 				 regs + port->oe,	/* dirout */
 				 NULL,			/* dirin */
-				 BGPIOF_UNREADABLE_REG_SET);
+				 BGPIOF_READ_OUTPUT_REG_SET);
 		if (ret)
 			return ret;
 
-- 
2.1.4

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

* [PATCH 2/3] gpio: generic: support input-only chips
  2015-07-22 13:05 [PATCH 1/3] gpio: etraxfs: fix set register flag Rabin Vincent
@ 2015-07-22 13:05 ` Rabin Vincent
  2015-07-27 13:01   ` Linus Walleij
  2015-07-22 13:05 ` [PATCH 3/3] gpio: etraxfs: add support for ARTPEC-3 Rabin Vincent
  2015-07-27 12:59 ` [PATCH 1/3] gpio: etraxfs: fix set register flag Linus Walleij
  2 siblings, 1 reply; 6+ messages in thread
From: Rabin Vincent @ 2015-07-22 13:05 UTC (permalink / raw)
  To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel, Rabin Vincent

Allow chips to indicates that they are input-only and thus cannot set
the output value.  This will be used by the gpio-etraxfs driver.

Signed-off-by: Rabin Vincent <rabin@rab.in>
---
 drivers/gpio/gpio-generic.c     | 23 ++++++++++++++++++++---
 include/linux/basic_mmio_gpio.h |  1 +
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index 9bda372..b3debbf 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -153,6 +153,10 @@ static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
 	return !!(bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio));
 }
 
+static void bgpio_set_none(struct gpio_chip *gc, unsigned int gpio, int val)
+{
+}
+
 static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 {
 	struct bgpio_chip *bgc = to_bgpio_chip(gc);
@@ -279,6 +283,12 @@ static int bgpio_simple_dir_in(struct gpio_chip *gc, unsigned int gpio)
 	return 0;
 }
 
+static int bgpio_dir_out_err(struct gpio_chip *gc, unsigned int gpio,
+				int val)
+{
+	return -EINVAL;
+}
+
 static int bgpio_simple_dir_out(struct gpio_chip *gc, unsigned int gpio,
 				int val)
 {
@@ -444,6 +454,9 @@ static int bgpio_setup_io(struct bgpio_chip *bgc,
 		bgc->reg_set = set;
 		bgc->gc.set = bgpio_set_set;
 		bgc->gc.set_multiple = bgpio_set_multiple_set;
+	} else if (flags & BGPIOF_NO_OUTPUT) {
+		bgc->gc.set = bgpio_set_none;
+		bgc->gc.set_multiple = NULL;
 	} else {
 		bgc->gc.set = bgpio_set;
 		bgc->gc.set_multiple = bgpio_set_multiple;
@@ -460,7 +473,8 @@ static int bgpio_setup_io(struct bgpio_chip *bgc,
 
 static int bgpio_setup_direction(struct bgpio_chip *bgc,
 				 void __iomem *dirout,
-				 void __iomem *dirin)
+				 void __iomem *dirin,
+				 unsigned long flags)
 {
 	if (dirout && dirin) {
 		return -EINVAL;
@@ -473,7 +487,10 @@ static int bgpio_setup_direction(struct bgpio_chip *bgc,
 		bgc->gc.direction_output = bgpio_dir_out_inv;
 		bgc->gc.direction_input = bgpio_dir_in_inv;
 	} else {
-		bgc->gc.direction_output = bgpio_simple_dir_out;
+		if (flags & BGPIOF_NO_OUTPUT)
+			bgc->gc.direction_output = bgpio_dir_out_err;
+		else
+			bgc->gc.direction_output = bgpio_simple_dir_out;
 		bgc->gc.direction_input = bgpio_simple_dir_in;
 	}
 
@@ -525,7 +542,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,
 	if (ret)
 		return ret;
 
-	ret = bgpio_setup_direction(bgc, dirout, dirin);
+	ret = bgpio_setup_direction(bgc, dirout, dirin, flags);
 	if (ret)
 		return ret;
 
diff --git a/include/linux/basic_mmio_gpio.h b/include/linux/basic_mmio_gpio.h
index 14eea94..ed3768f 100644
--- a/include/linux/basic_mmio_gpio.h
+++ b/include/linux/basic_mmio_gpio.h
@@ -75,5 +75,6 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,
 #define BGPIOF_UNREADABLE_REG_DIR	BIT(2) /* reg_dir is unreadable */
 #define BGPIOF_BIG_ENDIAN_BYTE_ORDER	BIT(3)
 #define BGPIOF_READ_OUTPUT_REG_SET     BIT(4) /* reg_set stores output value */
+#define BGPIOF_NO_OUTPUT		BIT(5) /* only input */
 
 #endif /* __BASIC_MMIO_GPIO_H */
-- 
2.1.4

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

* [PATCH 3/3] gpio: etraxfs: add support for ARTPEC-3
  2015-07-22 13:05 [PATCH 1/3] gpio: etraxfs: fix set register flag Rabin Vincent
  2015-07-22 13:05 ` [PATCH 2/3] gpio: generic: support input-only chips Rabin Vincent
@ 2015-07-22 13:05 ` Rabin Vincent
  2015-07-27 13:03   ` Linus Walleij
  2015-07-27 12:59 ` [PATCH 1/3] gpio: etraxfs: fix set register flag Linus Walleij
  2 siblings, 1 reply; 6+ messages in thread
From: Rabin Vincent @ 2015-07-22 13:05 UTC (permalink / raw)
  To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel, Rabin Vincent, devicetree

Add support for the GIO block in the ARTPEC-3 SoC.  The basic
functionality is essentialy the same as the version in the ETRAX FS,
except for a different set of ports, including a read-only port.

Cc: devicetree@vger.kernel.org
Signed-off-by: Rabin Vincent <rabin@rab.in>
---
 .../devicetree/bindings/gpio/gpio-etraxfs.txt      |  3 +-
 drivers/gpio/gpio-etraxfs.c                        | 66 ++++++++++++++++++++--
 2 files changed, 62 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/gpio/gpio-etraxfs.txt b/Documentation/devicetree/bindings/gpio/gpio-etraxfs.txt
index abf4db7..170194a 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-etraxfs.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-etraxfs.txt
@@ -2,8 +2,9 @@ Axis ETRAX FS General I/O controller bindings
 
 Required properties:
 
-- compatible:
+- compatible: one of:
   - "axis,etraxfs-gio"
+  - "axis,artpec3-gio"
 - reg: Physical base address and length of the controller's registers.
 - #gpio-cells: Should be 3
   - The first cell is the gpio offset number.
diff --git a/drivers/gpio/gpio-etraxfs.c b/drivers/gpio/gpio-etraxfs.c
index c1ce80d..7276891 100644
--- a/drivers/gpio/gpio-etraxfs.c
+++ b/drivers/gpio/gpio-etraxfs.c
@@ -26,6 +26,17 @@
 #define ETRAX_FS_r_pe_din	84
 #define ETRAX_FS_rw_pe_oe	88
 
+#define ARTPEC3_r_pa_din	0
+#define ARTPEC3_rw_pa_dout	4
+#define ARTPEC3_rw_pa_oe	8
+#define ARTPEC3_r_pb_din	44
+#define ARTPEC3_rw_pb_dout	48
+#define ARTPEC3_rw_pb_oe	52
+#define ARTPEC3_r_pc_din	88
+#define ARTPEC3_rw_pc_dout	92
+#define ARTPEC3_rw_pc_oe	96
+#define ARTPEC3_r_pd_din	116
+
 struct etraxfs_gpio_port {
 	const char *label;
 	unsigned int oe;
@@ -82,6 +93,40 @@ static const struct etraxfs_gpio_info etraxfs_gpio_etraxfs = {
 	.ports = etraxfs_gpio_etraxfs_ports,
 };
 
+static const struct etraxfs_gpio_port etraxfs_gpio_artpec3_ports[] = {
+	{
+		.label	= "A",
+		.ngpio	= 32,
+		.oe	= ARTPEC3_rw_pa_oe,
+		.dout	= ARTPEC3_rw_pa_dout,
+		.din	= ARTPEC3_r_pa_din,
+	},
+	{
+		.label	= "B",
+		.ngpio	= 32,
+		.oe	= ARTPEC3_rw_pb_oe,
+		.dout	= ARTPEC3_rw_pb_dout,
+		.din	= ARTPEC3_r_pb_din,
+	},
+	{
+		.label	= "C",
+		.ngpio	= 16,
+		.oe	= ARTPEC3_rw_pc_oe,
+		.dout	= ARTPEC3_rw_pc_dout,
+		.din	= ARTPEC3_r_pc_din,
+	},
+	{
+		.label	= "D",
+		.ngpio	= 32,
+		.din	= ARTPEC3_r_pd_din,
+	},
+};
+
+static const struct etraxfs_gpio_info etraxfs_gpio_artpec3 = {
+	.num_ports = ARRAY_SIZE(etraxfs_gpio_artpec3_ports),
+	.ports = etraxfs_gpio_artpec3_ports,
+};
+
 static int etraxfs_gpio_of_xlate(struct gpio_chip *gc,
 			       const struct of_phandle_args *gpiospec,
 			       u32 *flags)
@@ -101,6 +146,10 @@ static const struct of_device_id etraxfs_gpio_of_table[] = {
 		.compatible = "axis,etraxfs-gio",
 		.data = &etraxfs_gpio_etraxfs,
 	},
+	{
+		.compatible = "axis,artpec3-gio",
+		.data = &etraxfs_gpio_artpec3,
+	},
 	{},
 };
 
@@ -133,14 +182,19 @@ static int etraxfs_gpio_probe(struct platform_device *pdev)
 	for (i = 0; i < info->num_ports; i++) {
 		struct bgpio_chip *bgc = &chips[i];
 		const struct etraxfs_gpio_port *port = &info->ports[i];
+		unsigned long flags = BGPIOF_READ_OUTPUT_REG_SET;
+		void __iomem *dat = regs + port->din;
+		void __iomem *set = regs + port->dout;
+		void __iomem *dirout = regs + port->oe;
+
+		if (dirout == set) {
+			dirout = set = NULL;
+			flags = BGPIOF_NO_OUTPUT;
+		}
 
 		ret = bgpio_init(bgc, dev, 4,
-				 regs + port->din,	/* dat */
-				 regs + port->dout,	/* set */
-				 NULL,			/* clr */
-				 regs + port->oe,	/* dirout */
-				 NULL,			/* dirin */
-				 BGPIOF_READ_OUTPUT_REG_SET);
+				 dat, set, NULL, dirout, NULL,
+				 flags);
 		if (ret)
 			return ret;
 
-- 
2.1.4

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

* Re: [PATCH 1/3] gpio: etraxfs: fix set register flag
  2015-07-22 13:05 [PATCH 1/3] gpio: etraxfs: fix set register flag Rabin Vincent
  2015-07-22 13:05 ` [PATCH 2/3] gpio: generic: support input-only chips Rabin Vincent
  2015-07-22 13:05 ` [PATCH 3/3] gpio: etraxfs: add support for ARTPEC-3 Rabin Vincent
@ 2015-07-27 12:59 ` Linus Walleij
  2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2015-07-27 12:59 UTC (permalink / raw)
  To: Rabin Vincent
  Cc: Alexandre Courbot, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wed, Jul 22, 2015 at 3:05 PM, Rabin Vincent <rabin@rab.in> wrote:

> BGPIO_F_UNREADABLE_REG_SET is incorrect, since the set register _is_
> readable.  What's really required is BGPIO_F_READ_OUTPUT_REG_SET:
> reading the set register reads the set output value.
>
> Signed-off-by: Rabin Vincent <rabin@rab.in>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 2/3] gpio: generic: support input-only chips
  2015-07-22 13:05 ` [PATCH 2/3] gpio: generic: support input-only chips Rabin Vincent
@ 2015-07-27 13:01   ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2015-07-27 13:01 UTC (permalink / raw)
  To: Rabin Vincent
  Cc: Alexandre Courbot, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wed, Jul 22, 2015 at 3:05 PM, Rabin Vincent <rabin@rab.in> wrote:

> Allow chips to indicates that they are input-only and thus cannot set
> the output value.  This will be used by the gpio-etraxfs driver.
>
> Signed-off-by: Rabin Vincent <rabin@rab.in>

Looks useful, patch applied!

Yours,
Linus Walleij

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

* Re: [PATCH 3/3] gpio: etraxfs: add support for ARTPEC-3
  2015-07-22 13:05 ` [PATCH 3/3] gpio: etraxfs: add support for ARTPEC-3 Rabin Vincent
@ 2015-07-27 13:03   ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2015-07-27 13:03 UTC (permalink / raw)
  To: Rabin Vincent
  Cc: Alexandre Courbot, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org

On Wed, Jul 22, 2015 at 3:05 PM, Rabin Vincent <rabin@rab.in> wrote:

> Add support for the GIO block in the ARTPEC-3 SoC.  The basic
> functionality is essentialy the same as the version in the ETRAX FS,
> except for a different set of ports, including a read-only port.
>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Rabin Vincent <rabin@rab.in>

Uncontroversial DT bindings, so patch applied.

Yours,
Linus Walleij

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

end of thread, other threads:[~2015-07-27 13:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-22 13:05 [PATCH 1/3] gpio: etraxfs: fix set register flag Rabin Vincent
2015-07-22 13:05 ` [PATCH 2/3] gpio: generic: support input-only chips Rabin Vincent
2015-07-27 13:01   ` Linus Walleij
2015-07-22 13:05 ` [PATCH 3/3] gpio: etraxfs: add support for ARTPEC-3 Rabin Vincent
2015-07-27 13:03   ` Linus Walleij
2015-07-27 12:59 ` [PATCH 1/3] gpio: etraxfs: fix set register flag Linus Walleij

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).