linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan O'Donovan <dan@emutex.com>
To: mika.westerberg@linux.intel.com, linus.walleij@linaro.org
Cc: heikki.krogerus@linux.intel.com, linux-gpio@vger.kernel.org,
	Dan O'Donovan <dan@emutex.com>
Subject: [PATCH 2/5] pinctrl: cherryview: add option to set open-drain pin config
Date: Thu,  2 Jun 2016 22:55:40 +0100	[thread overview]
Message-ID: <1464904543-4094-3-git-send-email-dan@emutex.com> (raw)
In-Reply-To: <1464904543-4094-1-git-send-email-dan@emutex.com>

On some CHV platforms, we need an option to configure the
open-drain setting for these pins.  This adds support for the
PIN_CONFIG_DRIVE_PUSH_PULL and PIN_CONFIG_DRIVE_OPEN_DRAIN to
disable/enable open-drain mode for a specific pin.

Signed-off-by: Dan O'Donovan <dan@emutex.com>
---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 33 ++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index c79f4cc..7e5545f 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -1101,6 +1101,27 @@ static int chv_config_set_pull(struct chv_pinctrl *pctrl, unsigned int pin,
 	return 0;
 }
 
+static int chv_config_set_oden(struct chv_pinctrl *pctrl, unsigned int pin,
+			       bool enable)
+{
+	void __iomem *reg = chv_padreg(pctrl, pin, CHV_PADCTRL1);
+	unsigned long flags;
+	u32 ctrl1;
+
+	raw_spin_lock_irqsave(&pctrl->lock, flags);
+	ctrl1 = readl(reg);
+
+	if (enable)
+		ctrl1 |= CHV_PADCTRL1_ODEN;
+	else
+		ctrl1 &= ~CHV_PADCTRL1_ODEN;
+
+	chv_writel(ctrl1, reg);
+	raw_spin_unlock_irqrestore(&pctrl->lock, flags);
+
+	return 0;
+}
+
 static int chv_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
 			  unsigned long *configs, unsigned int nconfigs)
 {
@@ -1125,6 +1146,18 @@ static int chv_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
 				return ret;
 			break;
 
+		case PIN_CONFIG_DRIVE_PUSH_PULL:
+			ret = chv_config_set_oden(pctrl, pin, false);
+			if (ret)
+				return ret;
+			break;
+
+		case PIN_CONFIG_DRIVE_OPEN_DRAIN:
+			ret = chv_config_set_oden(pctrl, pin, true);
+			if (ret)
+				return ret;
+			break;
+
 		default:
 			return -ENOTSUPP;
 		}
-- 
2.1.4


  parent reply	other threads:[~2016-06-02 21:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02 21:55 [PATCH 0/5] pinctrl: cherryview: fixes and enhancements Dan O'Donovan
2016-06-02 21:55 ` [PATCH 1/5] pinctrl: cherryview: convert bare unsigned to unsigned int Dan O'Donovan
2016-06-06 10:28   ` Mika Westerberg
2016-06-09 16:04     ` Dan O'Donovan
2016-06-02 21:55 ` Dan O'Donovan [this message]
2016-06-06 10:32   ` [PATCH 2/5] pinctrl: cherryview: add option to set open-drain pin config Mika Westerberg
2016-06-02 21:55 ` [PATCH 3/5] pinctrl: cherryview: add handlers for pin_config_group_get/set Dan O'Donovan
2016-06-02 21:55 ` [PATCH 4/5] pinctrl: cherryview: prevent concurrent access to GPIO controllers Dan O'Donovan
2016-06-06 10:31   ` Mika Westerberg
2016-06-09 16:11     ` Dan O'Donovan
2016-06-02 21:55 ` [PATCH 5/5] pinctrl: cherryview: restore padctrl1 reg when gpio is disabled Dan O'Donovan
2016-06-06 10:40   ` Mika Westerberg
2016-06-09 16:41     ` Dan O'Donovan
2016-06-10  6:00       ` Mika Westerberg
2016-06-10  8:43         ` Dan O'Donovan
2016-06-08  8:32 ` [PATCH 0/5] pinctrl: cherryview: fixes and enhancements Linus Walleij
2016-06-10 12:23 ` [PATCH v2 0/3] " Dan O'Donovan
2016-06-10 12:23   ` [PATCH v2 1/3] pinctrl: cherryview: prevent concurrent access to GPIO controllers Dan O'Donovan
2016-06-13 12:23     ` Linus Walleij
2016-06-13 12:30       ` Dan O'Donovan
2016-06-10 12:23   ` [PATCH v2 2/3] pinctrl: cherryview: add option to set open-drain pin config Dan O'Donovan
2016-06-13 12:25     ` Linus Walleij
2016-06-10 12:23   ` [PATCH v2 3/3] pinctrl: cherryview: add handlers for pin_config_group_get/set Dan O'Donovan
2016-06-13 12:26     ` Linus Walleij
2016-06-13  9:21   ` [PATCH v2 0/3] pinctrl: cherryview: fixes and enhancements Mika Westerberg

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=1464904543-4094-3-git-send-email-dan@emutex.com \
    --to=dan@emutex.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.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;
as well as URLs for NNTP newsgroup(s).