From: <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
"Ryder.Lee" <ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH v2 09/22] pinctrl: mediatek: add advanced pull related support to pinctrl-mtk-common-v2.c
Date: Sat, 8 Sep 2018 19:07:25 +0800 [thread overview]
Message-ID: <aa213c9af6f9261f2ba91055785f0058d615bc4d.1536404280.git.sean.wang@mediatek.com> (raw)
In-Reply-To: <cover.1536404280.git.sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
There are some specific pins (i.e. MMC/SD) need specific registers to
turn on/off the 10K & 50k(75K) resistors when pull up/down.
Therefore, this patch adds the custom prarmeters so that the user could
control it through device tree.
Signed-off-by: Ryder.Lee <ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Signed-off-by: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
drivers/pinctrl/mediatek/pinctrl-moore.c | 33 ++++++++++++++
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 55 ++++++++++++++++++++++++
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 17 ++++++++
3 files changed, 105 insertions(+)
diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
index d69f024..4009329 100644
--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
@@ -15,16 +15,22 @@
/* Custom pinconf parameters */
#define MTK_PIN_CONFIG_TDSEL (PIN_CONFIG_END + 1)
#define MTK_PIN_CONFIG_RDSEL (PIN_CONFIG_END + 2)
+#define MTK_PIN_CONFIG_PU_ADV (PIN_CONFIG_END + 3)
+#define MTK_PIN_CONFIG_PD_ADV (PIN_CONFIG_END + 4)
static const struct pinconf_generic_params mtk_custom_bindings[] = {
{"mediatek,tdsel", MTK_PIN_CONFIG_TDSEL, 0},
{"mediatek,rdsel", MTK_PIN_CONFIG_RDSEL, 0},
+ {"mediatek,pull-up-adv", MTK_PIN_CONFIG_PU_ADV, 1},
+ {"mediatek,pull-down-adv", MTK_PIN_CONFIG_PD_ADV, 1},
};
#ifdef CONFIG_DEBUG_FS
static const struct pin_config_item mtk_conf_items[] = {
PCONFDUMP(MTK_PIN_CONFIG_TDSEL, "tdsel", NULL, true),
PCONFDUMP(MTK_PIN_CONFIG_RDSEL, "rdsel", NULL, true),
+ PCONFDUMP(MTK_PIN_CONFIG_PU_ADV, "pu-adv", NULL, true),
+ PCONFDUMP(MTK_PIN_CONFIG_PD_ADV, "pd-adv", NULL, true),
};
#endif
@@ -169,6 +175,19 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
ret = val;
break;
+ case MTK_PIN_CONFIG_PU_ADV:
+ case MTK_PIN_CONFIG_PD_ADV:
+ if (hw->soc->adv_pull_get) {
+ bool pullup;
+
+ pullup = param == MTK_PIN_CONFIG_PU_ADV;
+ err = hw->soc->adv_pull_get(hw, desc, pullup, &ret);
+ if (err)
+ return err;
+ } else {
+ return -ENOTSUPP;
+ }
+ break;
default:
return -ENOTSUPP;
}
@@ -282,6 +301,20 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
if (err)
goto err;
break;
+ case MTK_PIN_CONFIG_PU_ADV:
+ case MTK_PIN_CONFIG_PD_ADV:
+ if (hw->soc->adv_pull_set) {
+ bool pullup;
+
+ pullup = param == MTK_PIN_CONFIG_PU_ADV;
+ err = hw->soc->adv_pull_set(hw, desc, pullup,
+ arg);
+ if (err)
+ return err;
+ } else {
+ return -ENOTSUPP;
+ }
+ break;
default:
err = -ENOTSUPP;
}
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 67c95ef..e66bf49 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -358,3 +358,58 @@ int mtk_pinconf_drive_get_rev1(struct mtk_pinctrl *hw,
return 0;
}
+
+int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, bool pullup,
+ u32 arg)
+{
+ int err;
+
+ /* 10K off & 50K (75K) off, when (R0, R1) = (0, 0);
+ * 10K off & 50K (75K) on, when (R0, R1) = (0, 1);
+ * 10K on & 50K (75K) off, when (R0, R1) = (1, 0);
+ * 10K on & 50K (75K) on, when (R0, R1) = (1, 1)
+ */
+ err = mtk_hw_set_value(hw, desc->number, PINCTRL_PIN_REG_R0, arg & 1);
+ if (err)
+ return 0;
+
+ err = mtk_hw_set_value(hw, desc->number, PINCTRL_PIN_REG_R1,
+ !!(arg & 2));
+ if (err)
+ return 0;
+
+ arg = pullup ? 0 : 1;
+
+ err = mtk_hw_set_value(hw, desc->number, PINCTRL_PIN_REG_PUPD, arg);
+
+ return err;
+}
+
+int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, bool pullup,
+ u32 *val)
+{
+ u32 t, t2;
+ int err;
+
+ err = mtk_hw_get_value(hw, desc->number, PINCTRL_PIN_REG_PUPD, &t);
+ if (err)
+ return err;
+
+ /* t == 0 supposes PULLUP for the customized PULL setup */
+ if (pullup ^ !t)
+ return -EINVAL;
+
+ err = mtk_hw_get_value(hw, desc->number, PINCTRL_PIN_REG_R0, &t);
+ if (err)
+ return err;
+
+ err = mtk_hw_get_value(hw, desc->number, PINCTRL_PIN_REG_R1, &t2);
+ if (err)
+ return err;
+
+ *val = (t | t2 << 1) & 0x7;
+
+ return 0;
+}
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index 3a55ef7..ce364a1 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -51,6 +51,9 @@ enum {
PINCTRL_PIN_REG_TDSEL,
PINCTRL_PIN_REG_RDSEL,
PINCTRL_PIN_REG_DRV,
+ PINCTRL_PIN_REG_PUPD,
+ PINCTRL_PIN_REG_R0,
+ PINCTRL_PIN_REG_R1,
PINCTRL_PIN_REG_MAX,
};
@@ -163,6 +166,13 @@ struct mtk_pin_soc {
const struct mtk_pin_desc *desc, u32 arg);
int (*drive_get)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, int *val);
+
+ int (*adv_pull_set)(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, bool pullup,
+ u32 arg);
+ int (*adv_pull_get)(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, bool pullup,
+ u32 *val);
};
struct mtk_pinctrl {
@@ -199,4 +209,11 @@ int mtk_pinconf_drive_set_rev1(struct mtk_pinctrl *hw,
int mtk_pinconf_drive_get_rev1(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, int *val);
+int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, bool pullup,
+ u32 arg);
+int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, bool pullup,
+ u32 *val);
+
#endif /* __PINCTRL_MTK_COMMON_V2_H */
--
2.7.4
next prev parent reply other threads:[~2018-09-08 11:07 UTC|newest]
Thread overview: 50+ 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
[not found] ` <cover.1536404280.git.sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2018-09-08 11:07 ` [PATCH v2 01/22] pinctrl: mediatek: add pinctrl-mtk-common-v2 for all MediaTek pinctrls sean.wang-NuS5LvNUpcJWk0Htik3J/w
2018-09-18 19:36 ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 02/22] pinctrl: mediatek: add pinctrl-moore that implements the generic pinctrl dt-bindings sean.wang-NuS5LvNUpcJWk0Htik3J/w
2018-09-18 19:42 ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 04/22] pinctrl: mediatek: extend struct mtk_pin_desc to pinctrl-mtk-common-v2.c sean.wang-NuS5LvNUpcJWk0Htik3J/w
2018-09-18 19:44 ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 05/22] pinctrl: mediatek: extend struct mtk_pin_soc " sean.wang-NuS5LvNUpcJWk0Htik3J/w
2018-09-18 19:45 ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 06/22] pinctrl: mediatek: add driving strength related support " sean.wang-NuS5LvNUpcJWk0Htik3J/w
2018-09-18 19:46 ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 07/22] pinctrl: mediatek: add drv register " sean.wang-NuS5LvNUpcJWk0Htik3J/w
2018-09-18 19:47 ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 08/22] pinctrl: mediatek: add pull related " sean.wang-NuS5LvNUpcJWk0Htik3J/w
2018-09-18 19:48 ` Linus Walleij
2018-09-08 11:07 ` sean.wang-NuS5LvNUpcJWk0Htik3J/w [this message]
2018-09-18 19:49 ` [PATCH v2 09/22] pinctrl: mediatek: add advanced " Linus Walleij
2018-09-08 11:07 ` [PATCH v2 10/22] pinctrl: mediatek: add ies register " sean.wang-NuS5LvNUpcJWk0Htik3J/w
2018-09-18 19:50 ` Linus Walleij
2018-09-08 11:07 ` [PATCH v2 11/22] pinctrl: mediatek: add pullen, pullsel " sean.wang-NuS5LvNUpcJWk0Htik3J/w
2018-09-18 19:51 ` 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 ` [PATCH v2 19/22] pinctrl: mediatek: extend advanced pull support in pinctrl-mtk-common-v2.c sean.wang
2018-09-18 20:02 ` 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
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=aa213c9af6f9261f2ba91055785f0058d615bc4d.1536404280.git.sean.wang@mediatek.com \
--to=sean.wang-nus5lvnupcjwk0htik3j/w@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=ryder.lee-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
/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).