developer | 038a8f3 | 2023-08-03 16:16:20 +0800 | [diff] [blame] | 1 | --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c |
| 2 | +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c |
| 3 | @@ -541,6 +541,30 @@ out: |
| 4 | return err; |
| 5 | } |
| 6 | |
| 7 | +static int mtk_pinconf_bias_set_pd(struct mtk_pinctrl *hw, |
| 8 | + const struct mtk_pin_desc *desc, |
| 9 | + u32 pullup, u32 arg) |
| 10 | +{ |
| 11 | + int err, pd; |
| 12 | + |
| 13 | + if (arg == MTK_DISABLE) |
| 14 | + pd = 0; |
| 15 | + else if ((arg == MTK_ENABLE) && pullup) |
| 16 | + pd = 0; |
| 17 | + else if ((arg == MTK_ENABLE) && !pullup) |
| 18 | + pd = 1; |
| 19 | + else { |
| 20 | + err = -EINVAL; |
| 21 | + goto out; |
| 22 | + } |
| 23 | + |
| 24 | + err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_PD, pd); |
| 25 | + |
| 26 | +out: |
| 27 | + return err; |
| 28 | + |
| 29 | +} |
| 30 | + |
| 31 | static int mtk_pinconf_bias_set_pullsel_pullen(struct mtk_pinctrl *hw, |
| 32 | const struct mtk_pin_desc *desc, |
| 33 | u32 pullup, u32 arg) |
| 34 | @@ -695,6 +719,12 @@ int mtk_pinconf_bias_set_combo(struct mt |
| 35 | return err; |
| 36 | } |
| 37 | |
| 38 | + if (try_all_type & MTK_PULL_PD_TYPE) { |
| 39 | + err = mtk_pinconf_bias_set_pd(hw, desc, pullup, arg); |
| 40 | + if (!err) |
| 41 | + return err; |
| 42 | + } |
| 43 | + |
| 44 | if (try_all_type & MTK_PULL_PU_PD_TYPE) { |
| 45 | err = mtk_pinconf_bias_set_pu_pd(hw, desc, pullup, arg); |
| 46 | if (!err) |
| 47 | @@ -815,6 +845,29 @@ out: |
| 48 | return err; |
| 49 | } |
| 50 | |
| 51 | +static int mtk_pinconf_bias_get_pd(struct mtk_pinctrl *hw, |
| 52 | + const struct mtk_pin_desc *desc, |
| 53 | + u32 *pullup, u32 *enable) |
| 54 | +{ |
| 55 | + int err, pd; |
| 56 | + |
| 57 | + err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_PD, &pd); |
| 58 | + if (err) |
| 59 | + goto out; |
| 60 | + |
| 61 | + if (pd == 0) { |
| 62 | + *pullup = 0; |
| 63 | + *enable = MTK_DISABLE; |
| 64 | + } else if (pd == 1) { |
| 65 | + *pullup = 0; |
| 66 | + *enable = MTK_ENABLE; |
| 67 | + } else |
| 68 | + err = -EINVAL; |
| 69 | + |
| 70 | +out: |
| 71 | + return err; |
| 72 | +} |
| 73 | + |
| 74 | static int mtk_pinconf_bias_get_pullsel_pullen(struct mtk_pinctrl *hw, |
| 75 | const struct mtk_pin_desc *desc, |
| 76 | u32 *pullup, u32 *enable) |
| 77 | @@ -883,6 +936,12 @@ int mtk_pinconf_bias_get_combo(struct mt |
| 78 | if (!err) |
| 79 | return err; |
| 80 | } |
| 81 | + |
| 82 | + if (try_all_type & MTK_PULL_PD_TYPE) { |
| 83 | + err = mtk_pinconf_bias_get_pd(hw, desc, pullup, enable); |
| 84 | + if (!err) |
| 85 | + return err; |
| 86 | + } |
| 87 | |
| 88 | if (try_all_type & MTK_PULL_PU_PD_TYPE) { |
| 89 | err = mtk_pinconf_bias_get_pu_pd(hw, desc, pullup, enable); |
| 90 | --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h |
| 91 | +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h |
| 92 | @@ -24,6 +24,7 @@ |
| 93 | * turned on/off itself. But it can't be selected pull up/down |
| 94 | */ |
| 95 | #define MTK_PULL_RSEL_TYPE BIT(3) |
| 96 | +#define MTK_PULL_PD_TYPE BIT(4) |
| 97 | /* MTK_PULL_PU_PD_RSEL_TYPE is a type which is controlled by |
| 98 | * MTK_PULL_PU_PD_TYPE and MTK_PULL_RSEL_TYPE. |
| 99 | */ |