mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <patrice.chotard.st@gmail.com>
To: <linux-kernel@vger.kernel.org>, Linus Walleij <linus.walleij@linaro.org>
Cc: Olivier Clergeaud <olivier.clergeaud@st.com>,
	Lee Jones <lee.jones@linaro.org>,
	Fabio Baltieri <fabio.baltieri@linaro.org>,
	Patrice Chotard <patrice.chotard@st.com>
Subject: [PATCH 2/3] pinctrl: abx500: allow to set pull up
Date: Fri, 24 May 2013 14:06:30 +0200	[thread overview]
Message-ID: <1369397191-16643-3-git-send-email-patrice.chotard.st@gmail.com> (raw)
In-Reply-To: <1369397191-16643-1-git-send-email-patrice.chotard.st@gmail.com>

From: Patrice Chotard <patrice.chotard@st.com>

On ABx500 chip family, all pins support only pull down except for
AB8540 which supports pull up/down on some pins.
Rework abx500_pin_config_set to be able to set pull up on
pins which support this feature.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---
 drivers/pinctrl/pinctrl-abx500.c |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c
index 7d2e8d7..7f2202a 100644
--- a/drivers/pinctrl/pinctrl-abx500.c
+++ b/drivers/pinctrl/pinctrl-abx500.c
@@ -725,7 +725,7 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev,
 	struct pullud *pullud = pct->soc->pullud;
 	struct gpio_chip *chip = &pct->chip;
 	unsigned offset;
-	int ret;
+	int ret = 0;
 	enum pin_config_param param = pinconf_to_config_param(config);
 	enum pin_config_param argument = pinconf_to_config_argument(config);
 
@@ -763,6 +763,28 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev,
 				offset, argument ? 0 : 1);
 		break;
 
+	case PIN_CONFIG_BIAS_PULL_UP:
+		/*
+		 * if argument = 1 set the pull up
+		 * else clear the pull up
+		 */
+		ret = abx500_gpio_direction_input(chip, offset);
+		/*
+		 * Some chips only support pull down, while some actually
+		 * support both pull up and pull down. Such chips have
+		 * a "pullud" range specified for the pins that support
+		 * both features. If the pin is not within that range, do
+		 * nothing
+		 */
+		if (pullud &&
+		    pin >= pullud->first_pin &&
+		    pin <= pullud->last_pin) {
+			ret = abx500_config_pull_updown(pct,
+				pin,
+				argument ? ABX500_GPIO_PULL_UP : ABX500_GPIO_PULL_NONE);
+		}
+		break;
+
 	case PIN_CONFIG_OUTPUT:
 		ret = abx500_gpio_direction_output(chip, offset, argument);
 
-- 
1.7.10


  parent reply	other threads:[~2013-05-24 12:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-24 12:06 [PATCH 0/3] pinctrl: abx500: Fix pull up/down feature patrice.chotard.st
2013-05-24 12:06 ` [PATCH 1/3] pinctrl: abx500: fix abx500_config_pull_updown patrice.chotard.st
2013-05-24 12:06 ` patrice.chotard.st [this message]
2013-05-24 12:06 ` [PATCH 3/3] pinctrl: abx500: fix abx500_gpio_dbg_show_one() to show pull up/down patrice.chotard.st
2013-05-28  7:06 ` [PATCH 0/3] pinctrl: abx500: Fix pull up/down feature Linus Walleij

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=1369397191-16643-3-git-send-email-patrice.chotard.st@gmail.com \
    --to=patrice.chotard.st@gmail.com \
    --cc=fabio.baltieri@linaro.org \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olivier.clergeaud@st.com \
    --cc=patrice.chotard@st.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®