mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: linux-kernel@vger.kernel.org
Cc: linus.walleij@linaro.org, Yang QU <yang.qu@stericsson.com>,
	Lee Jones <lee.jones@linaro.org>
Subject: [PATCH 17/21] gpio: ab8500: Add the action range for the internal pull up function on GPIO
Date: Fri, 14 Dec 2012 16:19:35 +0000	[thread overview]
Message-ID: <1355501979-1157-18-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1355501979-1157-1-git-send-email-lee.jones@linaro.org>

From: Yang QU <yang.qu@stericsson.com>

Only 4 GPIOs named GPIOx_VBAT have both internal pull up and pull
down capability on ab8540. Limit the action range for this function.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Yang QU <yang.qu@stericsson.com>
Reviewed-by: Per FORLIN <per.forlin@stericsson.com>
---
 drivers/gpio/gpio-ab8500.c             |   54 +++++++++++++++++---------------
 include/linux/mfd/abx500/ab8500-gpio.h |    6 ++--
 2 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/drivers/gpio/gpio-ab8500.c b/drivers/gpio/gpio-ab8500.c
index ff8df1f..b4f631a 100644
--- a/drivers/gpio/gpio-ab8500.c
+++ b/drivers/gpio/gpio-ab8500.c
@@ -23,10 +23,12 @@
 
 
 /*
- * The AB9540 GPIO support is an extended version of the
- * AB8500 GPIO support. The AB9540 supports an additional
- * (7th) register so that more GPIO may be configured and
- * used.
+ * The AB9540 and AB8540 GPIO support are extended versions
+ * of the AB8500 GPIO support.
+ * The AB9540 supports an additional (7th) register so that
+ * more GPIO may be configured and used.
+ * The AB8540 supports 4 new gpios (GPIOx_VBAT) that have
+ * internal pull-up and pull-down capabilities.
  */
 
 /*
@@ -636,46 +638,46 @@ int ab8500_config_pulldown(struct device *dev,
 }
 EXPORT_SYMBOL(ab8500_config_pulldown);
 
-/*
- * ab8540_config_pull_updown() only available for following GPIOs:
- * GPIO51(GPIO1_VBAT)
- * GPIO52(GPIO2_VBAT)
- * GPIO53(GPIO3_VBAT)
- * GPIO54(GPIO4_VBAT)
- */
 int ab8540_config_pull_updown(struct device *dev,
-				int gpio, enum ab8540_gpio_pull_updown reg)
+				int gpio, enum ab8540_gpio_pull_updown val)
 {
-	u8 offset =  gpio - AB8500_PIN_GPIO(51);
-	u8 pos = 2 * offset;
+	u8 pos;
 	int ret;
 
+	if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	pos = (gpio - AB8500_PIN_GPIO(51)) << 1;
+
 	ret = abx500_mask_and_set_register_interruptible(dev,
 			AB8500_MISC, AB8540_GPIO_PULL_UPDOWN_REG,
-			AB8540_GPIO_PULL_UPDOWN_MASK << pos, reg << pos);
+			AB8540_GPIO_PULL_UPDOWN_MASK << pos, val << pos);
+
+out:
 	if (ret < 0)
 		dev_err(dev, "%s failed (%d)\n", __func__, ret);
 	return ret;
 }
 EXPORT_SYMBOL(ab8540_config_pull_updown);
 
-/*
- * ab8540_gpio_config_vinsel() only available for following GPIOs:
- * GPIO51(GPIO1_VBAT)
- * GPIO52(GPIO2_VBAT)
- * GPIO53(GPIO3_VBAT)
- * GPIO54(GPIO4_VBAT)
- */
 int ab8540_gpio_config_vinsel(struct device *dev,
-				int gpio, enum ab8540_gpio_vinsel reg)
+				int gpio, enum ab8540_gpio_vinsel val)
 {
-	u8 offset =  gpio - AB8500_PIN_GPIO(51);
-	u8 pos = 2 * offset;
+	u8 pos;
 	int ret;
 
+	if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	ret = abx500_mask_and_set_register_interruptible(dev,
 			AB8500_MISC, AB8540_GPIO_VINSEL_REG,
-			AB8540_GPIO_VINSEL_MASK << pos, reg << pos);
+			AB8540_GPIO_VINSEL_MASK << pos, val << pos);
+
+out:
 	if (ret < 0)
 		dev_err(dev, "%s failed (%d)\n", __func__, ret);
 	return ret;
diff --git a/include/linux/mfd/abx500/ab8500-gpio.h b/include/linux/mfd/abx500/ab8500-gpio.h
index 20df07d..86ccb33 100644
--- a/include/linux/mfd/abx500/ab8500-gpio.h
+++ b/include/linux/mfd/abx500/ab8500-gpio.h
@@ -39,11 +39,13 @@ enum ab8540_gpio_vinsel {
 int ab8500_config_pulldown(struct device *dev,
 				int gpio, bool enable);
 
+/* Selects pull up/pull down for GPIOx_VBAT, x=1 to 4 */
 int ab8540_config_pull_updown(struct device *dev,
-				int gpio, enum ab8540_gpio_pull_updown reg);
+				int gpio, enum ab8540_gpio_pull_updown val);
 
+/* Selects voltage for GPIOx_VBAT, x=1 to 4 */
 int ab8540_gpio_config_vinsel(struct device *dev,
-				int gpio, enum ab8540_gpio_vinsel reg);
+				int gpio, enum ab8540_gpio_vinsel val);
 
 int ab8500_gpio_config_select(struct device *dev,
 				int gpio, bool gpio_select);
-- 
1.7.9.5


  parent reply	other threads:[~2012-12-14 16:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-14 16:19 [PATCH 00/21] gpio: ab8500: Bring AB8500 back to life Lee Jones
2012-12-14 16:19 ` [PATCH 01/21] gpio: ab8500: Activate and port AB8500 GPIO driver to new framework Lee Jones
2012-12-14 16:19 ` [PATCH 02/21] gpio: ab8500: Make pins configurable Lee Jones
2012-12-14 16:19 ` [PATCH 03/21] gpio: ab8500: Fix alternate function register address Lee Jones
2012-12-14 16:19 ` [PATCH 04/21] gpio: ab8500: Read register corrected in get_value api Lee Jones
2012-12-14 16:19 ` [PATCH 05/21] gpio: ab8500: Allow direction and pullups configuration Lee Jones
2012-12-14 16:19 ` [PATCH 06/21] gpio: ab8500: Add api to enable pulldown Lee Jones
2012-12-14 16:19 ` [PATCH 07/21] gpio: ab8500: Write argument value instead of hardwired 1 Lee Jones
2012-12-14 16:19 ` [PATCH 08/21] gpio: ab8500: Fix gpio offset bounds for irq mapping Lee Jones
2012-12-14 16:19 ` [PATCH 09/21] gpio: ab8500: Fix bad include name after renaming Lee Jones
2012-12-14 16:19 ` [PATCH 10/21] gpio: ab8500: Add support for the AB9540 Lee Jones
2012-12-14 16:19 ` [PATCH 11/21] gpio: ab8500: Add support for AB8505 Chip Lee Jones
2012-12-14 16:19 ` [PATCH 12/21] gpio: ab8500: Allow gpios to wake the system from suspend Lee Jones
2012-12-14 16:19 ` [PATCH 13/21] gpio: ab8500: Use most recent run-time platform checker Lee Jones
2012-12-14 16:19 ` [PATCH 14/21] gpio: ab8500: Remove ENUMs from linux/mfd/abx500/ab8500-gpio.h Lee Jones
2012-12-14 16:19 ` [PATCH 15/21] gpio: ab8500: Add support for the ab8540 Lee Jones
2012-12-14 16:19 ` [PATCH 16/21] gpio: ab8500: Add internal pull up on GPIO of ab8540 Lee Jones
2012-12-14 16:19 ` Lee Jones [this message]
2012-12-14 16:19 ` [PATCH 18/21] gpio: ab8500: Fix parameter uninitialized warning for ab8540 Lee Jones
2012-12-14 16:19 ` [PATCH 19/21] gpio: ab8500: Update gpio ab8540 interrupt mapping Lee Jones
2012-12-14 16:19 ` [PATCH 20/21] gpio: ab8500: Fix ab8540 setting direction output error Lee Jones
2012-12-14 16:19 ` [PATCH 21/21] gpio: ab8500: Add explicit dependencies Lee Jones
2012-12-19 14:18 ` [PATCH 00/21] gpio: ab8500: Bring AB8500 back to life Linus Walleij
2012-12-19 22:49   ` Grant Likely
2012-12-20  7:51     ` Lee Jones
2013-01-04 14:17   ` Linus Walleij
2013-01-04 14:46     ` Lee Jones
2012-12-19 22:26 ` Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355501979-1157-18-git-send-email-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yang.qu@stericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®