linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <sean.wang@mediatek.com>
To: <linus.walleij@linaro.org>, <linux-mediatek@lists.infradead.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Sean Wang <sean.wang@mediatek.com>,
	Zhiyong Tao <zhiyong.tao@mediatek.com>
Subject: [PATCH v2 19/22] pinctrl: mediatek: extend advanced pull support in pinctrl-mtk-common-v2.c
Date: Sat, 8 Sep 2018 19:07:35 +0800	[thread overview]
Message-ID: <818dc8145d9b1e193c0c203767d33b11fa69ead4.1536404280.git.sean.wang@mediatek.com> (raw)
In-Reply-To: <cover.1536404280.git.sean.wang@mediatek.com>

From: Sean Wang <sean.wang@mediatek.com>

Extend the advanced pull based on the legacy bias plus additional r0 and r1
to tweak the resistor level.

Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 37 ++++++++++++++++++++----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 7cdd46f..7d5f570 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -476,6 +476,19 @@ int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
 
 	err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PUPD, arg);
 
+	/* If PUPD register is not supported for that pin, let's fallback to
+	 * general bias control.
+	 */
+	if (err == -ENOTSUPP) {
+		if (hw->soc->bias_set) {
+			err = hw->soc->bias_set(hw, desc, pullup);
+			if (err)
+				return err;
+		} else {
+			return -ENOTSUPP;
+		}
+	}
+
 	return err;
 }
 
@@ -487,12 +500,26 @@ int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,
 	int err;
 
 	err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PUPD, &t);
-	if (err)
-		return err;
 
-	/* t == 0 supposes PULLUP for the customized PULL setup */
-	if (pullup ^ !t)
-		return -EINVAL;
+	/* If PUPD register is not supported for that pin, let's fallback to
+	 * general bias control.
+	 */
+	if (err == -ENOTSUPP) {
+		if (hw->soc->bias_get) {
+			err = hw->soc->bias_get(hw, desc, pullup, val);
+			if (err)
+				return err;
+		} else {
+			return -ENOTSUPP;
+		}
+	} else {
+		/* t == 0 supposes PULLUP for the customized PULL setup */
+		if (err)
+			return err;
+
+		if (pullup ^ !t)
+			return -EINVAL;
+	}
 
 	err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_R0, &t);
 	if (err)
-- 
2.7.4


  parent reply	other threads:[~2018-09-08 11:08 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-08 11:07 [PATCH v2 00/22] Unify MediaTek pinctrl in preparation for MT8183 and MT6765 sean.wang
2018-09-08 11:07 ` [PATCH v2 03/22] pinctrl: mediatek: extend struct mtk_pin_field_calc to pinctrl-mtk-common-v2.c sean.wang
2018-09-18 19:43   ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 12/22] pinctrl: mediatek: add MT7623 pinctrl driver based on generic pinctrl binding sean.wang
2018-09-18 19:52   ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 13/22] pinctrl: mediatek: use pin descriptor all in pinctrl-mtk-common-v2.c sean.wang
2018-09-18 19:53   ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 14/22] pinctrl: mediatek: add multiple register bases support to pinctrl-mtk-common-v2.c sean.wang
2018-09-18 19:56   ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 15/22] pinctrl: mediatek: adjust error code and message when some register not supported is found sean.wang
2018-09-18 19:57   ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 16/22] pinctrl: mediatek: extend struct mtk_pin_desc which per-pin driver depends on sean.wang
2018-09-18 19:58   ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 17/22] pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings sean.wang
2018-09-18 19:59   ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 18/22] pinctrl: mediatek: add MT8183 pinctrl driver sean.wang
2018-09-18 20:01   ` Linus Walleij
2018-09-08 11:07 ` sean.wang [this message]
2018-09-18 20:02   ` [PATCH v2 19/22] pinctrl: mediatek: extend advanced pull support in pinctrl-mtk-common-v2.c Linus Walleij
2018-09-08 11:07 ` [PATCH v2 20/22] pintcrl: mediatek: add pull tweaks for I2C related pins on MT8183 sean.wang
2018-09-18 20:03   ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 21/22] pinctrl: mediatek: extend eint build to pinctrl-mtk-common-v2.c sean.wang
2018-09-08 11:07 ` [PATCH v2 22/22] pinctrl: mediatek: add eint support to MT8183 pinctrl driver sean.wang
     [not found] ` <75d8f8c745d60b49ee1ec60de7f776ef51f97f79.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:36   ` [PATCH v2 01/22] pinctrl: mediatek: add pinctrl-mtk-common-v2 for all MediaTek pinctrls Linus Walleij
     [not found] ` <5001a940525e9da7b0e1ac1afead629e1373fe33.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:42   ` [PATCH v2 02/22] pinctrl: mediatek: add pinctrl-moore that implements the generic pinctrl dt-bindings Linus Walleij
     [not found] ` <8afc61bff2a4146731e5696f440c0eeaaf0ea341.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:44   ` [PATCH v2 04/22] pinctrl: mediatek: extend struct mtk_pin_desc to pinctrl-mtk-common-v2.c Linus Walleij
     [not found] ` <17ff79fcf3df7c7208b6cda6f207e5e96c4d6c7e.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:45   ` [PATCH v2 05/22] pinctrl: mediatek: extend struct mtk_pin_soc " Linus Walleij
     [not found] ` <ffa1fc0c62bc9408524619c8b530759351fd366c.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:46   ` [PATCH v2 06/22] pinctrl: mediatek: add driving strength related support " Linus Walleij
     [not found] ` <5a7880e3885ba8a1c51ca28a0753228eeeeb9ec7.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:47   ` [PATCH v2 07/22] pinctrl: mediatek: add drv register " Linus Walleij
     [not found] ` <f5324a24d1a70c37a5e011f859ce90867e9ad3fb.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:48   ` [PATCH v2 08/22] pinctrl: mediatek: add pull related " Linus Walleij
     [not found] ` <aa213c9af6f9261f2ba91055785f0058d615bc4d.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:49   ` [PATCH v2 09/22] pinctrl: mediatek: add advanced " Linus Walleij
     [not found] ` <af007cdcec1d4e8512faf47182aa4b17b17c1093.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:50   ` [PATCH v2 10/22] pinctrl: mediatek: add ies register " Linus Walleij
     [not found] ` <f698dee4dcac1b5acfde7133773f7dc1e8c40583.1536404280.git.sean.wang@mediatek.com>
2018-09-18 19:51   ` [PATCH v2 11/22] pinctrl: mediatek: add pullen, pullsel " Linus Walleij
2018-09-18 22:07 ` [PATCH v2 00/22] Unify MediaTek pinctrl in preparation for MT8183 and MT6765 Linus Walleij
2018-09-19  2:54   ` Sean Wang
2018-09-19  4:37     ` Manivannan Sadhasivam
2018-09-21  4:22       ` Sean Wang
2018-09-25 10:48         ` Matthias Brugger
2018-09-25 13:07           ` Manivannan Sadhasivam
2018-09-25 13:09             ` Manivannan Sadhasivam

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=818dc8145d9b1e193c0c203767d33b11fa69ead4.1536404280.git.sean.wang@mediatek.com \
    --to=sean.wang@mediatek.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=zhiyong.tao@mediatek.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).