From patchwork Fri Dec 14 16:19:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13606 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 64CEA23FB4 for ; Fri, 14 Dec 2012 16:20:20 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id ED40AA195DC for ; Fri, 14 Dec 2012 16:20:19 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so6158276ieb.11 for ; Fri, 14 Dec 2012 08:20:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=0Nx8fkObGg+x9x+Is2Mks7zhcosAafDnQiFmAicXR14=; b=UybOFjhvSJBKTNJqHeYJjMGE89Qu907tPy+7R4REwdObJOIObcrot39CbvL668+0RU V3eS3H/9dJLFGJWeCiQlmHO5kW6rTpkiddsoVNdTo8X41xmLo2yxT+6sAJwbKv/1p19r tNHykjyQehZvNJzukOarFU2btDIpyMcezIX70LdcVxXHv0sHCorbCeKHbR+L6nzve2Ot TQWWk+ms/b5R53jnnQeDTdbP5XItGxLY9dHOdEvedKKSoLHkOxt4AXFzf4HMvmCcp0X3 Kybh10d85JkMo6lzc4WiTXc+xyAhQcFl285glfBihR/p84OCPQ4/J+AUSCSKMaekzCD5 dG2w== Received: by 10.50.173.34 with SMTP id bh2mr2004628igc.70.1355502019399; Fri, 14 Dec 2012 08:20:19 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp81616igt; Fri, 14 Dec 2012 08:20:18 -0800 (PST) Received: by 10.194.86.40 with SMTP id m8mr4509339wjz.24.1355502018288; Fri, 14 Dec 2012 08:20:18 -0800 (PST) Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by mx.google.com with ESMTPS id l1si3719855wjr.64.2012.12.14.08.20.17 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 08:20:18 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.46 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.46 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wg0-f46.google.com with SMTP id dr13so1446610wgb.1 for ; Fri, 14 Dec 2012 08:20:17 -0800 (PST) Received: by 10.194.236.166 with SMTP id uv6mr4469877wjc.34.1355502017830; Fri, 14 Dec 2012 08:20:17 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id u6sm8325248wif.2.2012.12.14.08.20.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 08:20:16 -0800 (PST) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: linus.walleij@linaro.org, Yang QU , Lee Jones Subject: [PATCH 20/21] gpio: ab8500: Fix ab8540 setting direction output error Date: Fri, 14 Dec 2012 16:19:38 +0000 Message-Id: <1355501979-1157-21-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1355501979-1157-1-git-send-email-lee.jones@linaro.org> References: <1355501979-1157-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkNUB+XquBu3K6QKmEmP/rjp5heTSyWJrWEMIF/JmwYrYtXMFr7KcbEIEMYXhvzCu0pi+1m From: Yang QU Set GpioPullUpDownSel register for direction output function as GPIO51 to GPIO54 not share the same register with other GPIOs on AB8540. Signed-off-by: Lee Jones Signed-off-by: Yang QU Reviewed-by: Patrick DELAUNAY Reviewed-by: Xiao Mei ZHANG Reviewed-by: Philippe LANGLAIS Reviewed-by: Maxime COQUELIN Reviewed-by: Jonas ABERG Reviewed-by: Mattias WALLIN --- drivers/gpio/gpio-ab8500.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpio-ab8500.c b/drivers/gpio/gpio-ab8500.c index edc3037..ed5832e 100644 --- a/drivers/gpio/gpio-ab8500.c +++ b/drivers/gpio/gpio-ab8500.c @@ -86,6 +86,8 @@ #define AB8500_NUM_VIR_GPIO_IRQ 16 #define AB8540_GPIO_PULL_UPDOWN_MASK 0x03 #define AB8540_GPIO_VINSEL_MASK 0x03 +#define AB8540_GPIOX_VBAT_START 51 +#define AB8540_GPIOX_VBAT_END 54 enum ab8500_gpio_action { NONE, @@ -222,6 +224,7 @@ static void ab8500_gpio_set(struct gpio_chip *chip, unsigned offset, int val) static int ab8500_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { + struct ab8500_gpio *ab8500_gpio = to_ab8500_gpio(chip); int ret; /* set direction as output */ ret = ab8500_gpio_set_bits(chip, AB8500_GPIO_DIR1_REG, offset, 1); @@ -231,6 +234,18 @@ static int ab8500_gpio_direction_output(struct gpio_chip *chip, unsigned offset, ret = ab8500_gpio_set_bits(chip, AB8500_GPIO_PUD1_REG, offset, 1); if (ret < 0) return ret; + /* + * Disable both pull down and pull up for GPIO51 to GPIO54 (GPIO1_VBAT + * to GPIO4_VBAT). + */ + if (is_ab8540(ab8500_gpio->parent)) { + if (offset >= (AB8540_GPIOX_VBAT_START - 1) + && offset <= (AB8540_GPIOX_VBAT_END - 1)) + ret = ab8540_config_pull_updown(ab8500_gpio->dev, + AB8500_PIN_GPIO(offset + 1), AB8540_GPIO_PULL_NONE); + if (ret < 0) + return ret; + } /* set the output as 1 or 0 */ return ab8500_gpio_set_bits(chip, AB8500_GPIO_OUT1_REG, offset, val); @@ -278,10 +293,10 @@ static unsigned int irq_to_rising(unsigned int irq) int offset = irq - ab8500_gpio->irq_base; int new_irq; if (is_ab8540(ab8500_gpio->parent)) { - new_irq = offset * 2 + AB8540_INT_GPIO43R + new_irq = offset * 2 + AB8540_INT_GPIO43R + ab8500_gpio->parent->irq_base; } else - new_irq = offset + AB8500_INT_GPIO6R + new_irq = offset + AB8500_INT_GPIO6R + ab8500_gpio->parent->irq_base; return new_irq; } @@ -292,10 +307,10 @@ static unsigned int irq_to_falling(unsigned int irq) int offset = irq - ab8500_gpio->irq_base; int new_irq; if (is_ab8540(ab8500_gpio->parent)) { - new_irq = offset * 2 + AB8540_INT_GPIO43F + new_irq = offset * 2 + AB8540_INT_GPIO43F + ab8500_gpio->parent->irq_base; } else - new_irq = offset + AB8500_INT_GPIO6F + new_irq = offset + AB8500_INT_GPIO6F + ab8500_gpio->parent->irq_base; return new_irq; @@ -670,12 +685,13 @@ int ab8540_config_pull_updown(struct device *dev, u8 pos; int ret; - if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) { + if ((gpio < AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_START)) + || (gpio > AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_END))) { ret = -EINVAL; goto out; } - pos = (gpio - AB8500_PIN_GPIO(51)) << 1; + pos = (gpio - AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_START)) << 1; ret = abx500_mask_and_set_register_interruptible(dev, AB8500_MISC, AB8540_GPIO_PULL_UPDOWN_REG, @@ -694,12 +710,13 @@ int ab8540_gpio_config_vinsel(struct device *dev, u8 pos; int ret; - if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) { + if ((gpio < AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_START)) + || (gpio > AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_END))) { ret = -EINVAL; goto out; } - pos = (gpio - AB8500_PIN_GPIO(51)) << 1; + pos = (gpio - AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_START)) << 1; ret = abx500_mask_and_set_register_interruptible(dev, AB8500_MISC, AB8540_GPIO_VINSEL_REG,