Skip to content

Commit

Permalink
pinctrl: mediatek: add support for MTK_PULL_PD_TYPE
Browse files Browse the repository at this point in the history
The MediaTek MT7988 SoC got some pins which only got configurable
pull-down but unlike previous designs there is no pull-up option.
Add new type MTK_PULL_PD_TYPE to support configuring such pins.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  • Loading branch information
dangowrt authored and K900 committed Jan 20, 2025
1 parent d141ca0 commit 5de43d6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
59 changes: 59 additions & 0 deletions drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,30 @@ static int mtk_pinconf_bias_set_pu_pd(struct mtk_pinctrl *hw,
return err;
}

static int mtk_pinconf_bias_set_pd(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc,
u32 pullup, u32 arg)
{
int err, pd;

if (arg == MTK_DISABLE)
pd = 0;
else if ((arg == MTK_ENABLE) && pullup)
pd = 0;
else if ((arg == MTK_ENABLE) && !pullup)
pd = 1;
else {
err = -EINVAL;
goto out;
}

err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PD, pd);

out:
return err;

}

static int mtk_pinconf_bias_set_pullsel_pullen(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc,
u32 pullup, u32 arg)
Expand Down Expand Up @@ -758,6 +782,12 @@ int mtk_pinconf_bias_set_combo(struct mtk_pinctrl *hw,
return 0;
}

if (try_all_type & MTK_PULL_PD_TYPE) {
err = mtk_pinconf_bias_set_pd(hw, desc, pullup, arg);
if (!err)
return err;
}

if (try_all_type & MTK_PULL_PU_PD_TYPE) {
err = mtk_pinconf_bias_set_pu_pd(hw, desc, pullup, arg);
if (!err)
Expand Down Expand Up @@ -878,6 +908,29 @@ static int mtk_pinconf_bias_get_pu_pd(struct mtk_pinctrl *hw,
return err;
}

static int mtk_pinconf_bias_get_pd(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc,
u32 *pullup, u32 *enable)
{
int err, pd;

err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PD, &pd);
if (err)
goto out;

if (pd == 0) {
*pullup = 0;
*enable = MTK_DISABLE;
} else if (pd == 1) {
*pullup = 0;
*enable = MTK_ENABLE;
} else
err = -EINVAL;

out:
return err;
}

static int mtk_pinconf_bias_get_pullsel_pullen(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc,
u32 *pullup, u32 *enable)
Expand Down Expand Up @@ -947,6 +1000,12 @@ int mtk_pinconf_bias_get_combo(struct mtk_pinctrl *hw,
return 0;
}

if (try_all_type & MTK_PULL_PD_TYPE) {
err = mtk_pinconf_bias_get_pd(hw, desc, pullup, enable);
if (!err)
return err;
}

if (try_all_type & MTK_PULL_PU_PD_TYPE) {
err = mtk_pinconf_bias_get_pu_pd(hw, desc, pullup, enable);
if (!err)
Expand Down
1 change: 1 addition & 0 deletions drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* turned on/off itself. But it can't be selected pull up/down
*/
#define MTK_PULL_RSEL_TYPE BIT(3)
#define MTK_PULL_PD_TYPE BIT(4)
/* MTK_PULL_PU_PD_RSEL_TYPE is a type which is controlled by
* MTK_PULL_PU_PD_TYPE and MTK_PULL_RSEL_TYPE.
*/
Expand Down

0 comments on commit 5de43d6

Please sign in to comment.