From patchwork Sat Feb 7 06:13:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonyoung Shim X-Patchwork-Id: 5981 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n176Dert016424 for ; Sat, 7 Feb 2009 06:13:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750869AbZBGGNh (ORCPT ); Sat, 7 Feb 2009 01:13:37 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752064AbZBGGNh (ORCPT ); Sat, 7 Feb 2009 01:13:37 -0500 Received: from rv-out-0506.google.com ([209.85.198.234]:57826 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750869AbZBGGNg (ORCPT ); Sat, 7 Feb 2009 01:13:36 -0500 Received: by rv-out-0506.google.com with SMTP id k40so1109735rvb.1 for ; Fri, 06 Feb 2009 22:13:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=sYTfn0FPLjSHuGW8ql0g5k9hw5VmOvy8NUPfh2MwJV8=; b=VAzlbZDvzAfA58AvWqxHZP/0/flzF/pH3KEXaIpj2GCuMbcgkQ3Ykn1NYXYUFIBDNF WBgaHtOa6WClyuMdCzY9lSbxEdafPx1r7UzMeljGAACA4+m7TtivpT6gdXTgGdcxziD4 p6GRtHAeCJaOsksgkFZIU45SVIebY1mkEFauc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=SCLRA6vVY2KS9NbXMgsdsorHloc/92Ln+VulBncPjW+eKGEWfMAdhXOEZuVOrfbCyu 366xO5rJDxFBb/0Ic2XlSF1dg6jvoMFXMqjksso6WWWvmrJ1Ymli1w3LGdGPULJLVaV8 dFpsAoFfWFIVgjgk5oHNHWNeCruesrwUA70IQ= MIME-Version: 1.0 Received: by 10.140.173.10 with SMTP id v10mr1968417rve.199.1233987216023; Fri, 06 Feb 2009 22:13:36 -0800 (PST) Date: Sat, 7 Feb 2009 15:13:35 +0900 Message-ID: <4e1455be0902062213o769a4d15ha0c892508839dbad@mail.gmail.com> Subject: [PATCH] twl4030-gpio: Fix getting the value of the TWL4030 GPIO output pin From: Joonyoung Shim To: Tony Lindgren , David Brownell Cc: linux-arm-kernel@lists.arm.linux.org.uk, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org If TWL4030 GPIO pin is output, must read the value from REG_GPIODATAOUTx register in twl4030_get_gpio_datainout(). Signed-off-by: Joonyoung Shim --- -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/twl4030-gpio.c b/drivers/gpio/twl4030-gpio.c index afad147..890518a 100644 --- a/drivers/gpio/twl4030-gpio.c +++ b/drivers/gpio/twl4030-gpio.c @@ -183,7 +183,7 @@ static int twl4030_set_gpio_dataout(int gpio, int enable) return gpio_twl4030_write(base, d_msk); } -static int twl4030_get_gpio_datain(int gpio) +static int twl4030_get_gpio_datainout(int gpio) { u8 d_bnk = gpio >> 3; u8 d_off = gpio & 0x7; @@ -194,7 +194,17 @@ static int twl4030_get_gpio_datain(int gpio) || !(gpio_usage_count & BIT(gpio)))) return -EPERM; - base = REG_GPIODATAIN1 + d_bnk; + base = REG_GPIODATADIR1 + d_bnk; + ret = gpio_twl4030_read(base); + if (ret > 0) + ret = (ret >> d_off) & 0x1; + else + return ret; + + if (ret) + base = REG_GPIODATAOUT1 + d_bnk; + else + base = REG_GPIODATAIN1 + d_bnk; ret = gpio_twl4030_read(base); if (ret > 0) ret = (ret >> d_off) & 0x1;