Skip to content

Commit 1673d72

Browse files
dangowrtLinus Walleij
authored andcommitted
pinctrl: mediatek: add support for MTK_PULL_PD_TYPE
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 <[email protected]> Signed-off-by: Frank Wunderlich <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 1c67992 commit 1673d72

File tree

2 files changed

+63
-11
lines changed

2 files changed

+63
-11
lines changed

drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ EXPORT_SYMBOL_GPL(mtk_pinconf_bias_get_rev1);
573573
*/
574574
static int mtk_pinconf_bias_set_pu_pd(struct mtk_pinctrl *hw,
575575
const struct mtk_pin_desc *desc,
576-
u32 pullup, u32 arg)
576+
u32 pullup, u32 arg, bool pd_only)
577577
{
578578
int err, pu, pd;
579579

@@ -587,18 +587,34 @@ static int mtk_pinconf_bias_set_pu_pd(struct mtk_pinctrl *hw,
587587
pu = 0;
588588
pd = 1;
589589
} else {
590-
err = -EINVAL;
591-
goto out;
590+
return -EINVAL;
592591
}
593592

594-
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PU, pu);
595-
if (err)
596-
goto out;
593+
if (!pd_only) {
594+
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PU, pu);
595+
if (err)
596+
return err;
597+
}
597598

598-
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PD, pd);
599+
return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PD, pd);
600+
}
601+
602+
static int mtk_pinconf_bias_set_pd(struct mtk_pinctrl *hw,
603+
const struct mtk_pin_desc *desc,
604+
u32 pullup, u32 arg)
605+
{
606+
int err, pd;
607+
608+
if (arg != MTK_DISABLE && arg != MTK_ENABLE)
609+
return -EINVAL;
610+
611+
if (arg == MTK_DISABLE || pullup)
612+
pd = 0;
613+
else if (!pullup)
614+
pd = 1;
615+
616+
return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PD, pd);
599617

600-
out:
601-
return err;
602618
}
603619

604620
static int mtk_pinconf_bias_set_pullsel_pullen(struct mtk_pinctrl *hw,
@@ -737,7 +753,7 @@ static int mtk_pinconf_bias_set_pu_pd_rsel(struct mtk_pinctrl *hw,
737753
return err;
738754
}
739755

740-
return mtk_pinconf_bias_set_pu_pd(hw, desc, pullup, enable);
756+
return mtk_pinconf_bias_set_pu_pd(hw, desc, pullup, enable, false);
741757
}
742758

743759
int mtk_pinconf_bias_set_combo(struct mtk_pinctrl *hw,
@@ -758,8 +774,14 @@ int mtk_pinconf_bias_set_combo(struct mtk_pinctrl *hw,
758774
return 0;
759775
}
760776

777+
if (try_all_type & MTK_PULL_PD_TYPE) {
778+
err = mtk_pinconf_bias_set_pu_pd(hw, desc, pullup, arg, true);
779+
if (!err)
780+
return err;
781+
}
782+
761783
if (try_all_type & MTK_PULL_PU_PD_TYPE) {
762-
err = mtk_pinconf_bias_set_pu_pd(hw, desc, pullup, arg);
784+
err = mtk_pinconf_bias_set_pu_pd(hw, desc, pullup, arg, false);
763785
if (!err)
764786
return 0;
765787
}
@@ -878,6 +900,29 @@ static int mtk_pinconf_bias_get_pu_pd(struct mtk_pinctrl *hw,
878900
return err;
879901
}
880902

903+
static int mtk_pinconf_bias_get_pd(struct mtk_pinctrl *hw,
904+
const struct mtk_pin_desc *desc,
905+
u32 *pullup, u32 *enable)
906+
{
907+
int err, pd;
908+
909+
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PD, &pd);
910+
if (err)
911+
goto out;
912+
913+
if (pd == 0) {
914+
*pullup = 0;
915+
*enable = MTK_DISABLE;
916+
} else if (pd == 1) {
917+
*pullup = 0;
918+
*enable = MTK_ENABLE;
919+
} else
920+
err = -EINVAL;
921+
922+
out:
923+
return err;
924+
}
925+
881926
static int mtk_pinconf_bias_get_pullsel_pullen(struct mtk_pinctrl *hw,
882927
const struct mtk_pin_desc *desc,
883928
u32 *pullup, u32 *enable)
@@ -947,6 +992,12 @@ int mtk_pinconf_bias_get_combo(struct mtk_pinctrl *hw,
947992
return 0;
948993
}
949994

995+
if (try_all_type & MTK_PULL_PD_TYPE) {
996+
err = mtk_pinconf_bias_get_pd(hw, desc, pullup, enable);
997+
if (!err)
998+
return err;
999+
}
1000+
9501001
if (try_all_type & MTK_PULL_PU_PD_TYPE) {
9511002
err = mtk_pinconf_bias_get_pu_pd(hw, desc, pullup, enable);
9521003
if (!err)

drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* turned on/off itself. But it can't be selected pull up/down
2525
*/
2626
#define MTK_PULL_RSEL_TYPE BIT(3)
27+
#define MTK_PULL_PD_TYPE BIT(4)
2728
/* MTK_PULL_PU_PD_RSEL_TYPE is a type which is controlled by
2829
* MTK_PULL_PU_PD_TYPE and MTK_PULL_RSEL_TYPE.
2930
*/

0 commit comments

Comments
 (0)