public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: max732x: fix input configuration for open-drain pins
@ 2010-03-16  9:19 Marc Zyngier
  2010-04-15 13:10 ` Eric Miao
  2010-04-20 23:51 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Marc Zyngier @ 2010-03-16  9:19 UTC (permalink / raw)
  To: Eric Miao; +Cc: LKML

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

Eric,

The attached patch tries to fix a bug I noticed while hacking on the
max732x driver for interrupt support.
According to the datasheets, open-drain pins have to be configured as
output-high (which in that case is actually high impedance) to be used as
input.

Note that this patch has only been compile tested, as I still have to
solder the actual chip to one of my boards...

Thanks,

        M.
-- 
Who you jivin' with that Cosmik Debris?

[-- Attachment #2: 0002-gpio-max732x-fix-input-configuration-for-open-drain-.patch --]
[-- Type: text/plain, Size: 1338 bytes --]

From 059eb9b61b276a681d634781abaa1159dfb547bc Mon Sep 17 00:00:00 2001
From: Marc Zyngier <maz@misterjones.org>
Date: Mon, 15 Mar 2010 22:14:51 +0000
Subject: [PATCH] gpio: max732x: fix input configuration for open-drain pins

max732x datasheets indicate that open-drain pins must be
configured as output-high to be used as input...

Signed-off-by: Marc Zyngier <maz@misterjones.org>
---
 drivers/gpio/max732x.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/max732x.c b/drivers/gpio/max732x.c
index f786824..3618feb 100644
--- a/drivers/gpio/max732x.c
+++ b/drivers/gpio/max732x.c
@@ -179,15 +179,25 @@ static int max732x_gpio_direction_input(struct gpio_chip *gc, unsigned off)
 {
 	struct max732x_chip *chip;
 	unsigned int mask = 1u << off;
+	unsigned int is_input;
 
 	chip = container_of(gc, struct max732x_chip, gpio_chip);
 
-	if ((mask & chip->dir_input) == 0) {
+	is_input = mask & chip->dir_input;
+
+	if (!is_input) {
 		dev_dbg(&chip->client->dev, "%s port %d is output only\n",
 			chip->client->name, off);
 		return -EACCES;
 	}
 
+	/*
+	 * Open-drain pins must be set to high impedance (which is
+	 * equivalent to output-high) to be turned into an input.
+	 */
+	if ((is_input & chip->dir_output))
+		max732x_gpio_set_value(gc, off, 1);
+
 	return 0;
 }
 
-- 
1.7.0.2


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

end of thread, other threads:[~2010-04-23 13:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-16  9:19 [PATCH] gpio: max732x: fix input configuration for open-drain pins Marc Zyngier
2010-04-15 13:10 ` Eric Miao
2010-04-20 23:51 ` Andrew Morton
2010-04-23 13:37   ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox