1 |
From 53ba1958362978e1e58c40989528c8086501ee4d Mon Sep 17 00:00:00 2001 |
2 |
From: Douglas Anderson <dianders@chromium.org> |
3 |
Date: Thu, 30 Aug 2018 08:23:39 -0700 |
4 |
Subject: [PATCH 066/145] pinctrl: spmi-mpp: Fix pmic_mpp_config_get() to be |
5 |
compliant |
6 |
|
7 |
[ Upstream commit 0d5b476f8f57fcb06c45fe27681ac47254f63fd2 ] |
8 |
|
9 |
If you look at "pinconf-groups" in debugfs for ssbi-mpp you'll notice |
10 |
it looks like nonsense. |
11 |
|
12 |
The problem is fairly well described in commit 1cf86bc21257 ("pinctrl: |
13 |
qcom: spmi-gpio: Fix pmic_gpio_config_get() to be compliant") and |
14 |
commit 05e0c828955c ("pinctrl: msm: Fix msm_config_group_get() to be |
15 |
compliant"), but it was pointed out that ssbi-mpp has the same |
16 |
problem. Let's fix it there too. |
17 |
|
18 |
NOTE: in case it's helpful to someone reading this, the way to tell |
19 |
whether to do the -EINVAL or not is to look at the PCONFDUMP for a |
20 |
given attribute. If the last element (has_arg) is false then you need |
21 |
to do the -EINVAL trick. |
22 |
|
23 |
ALSO NOTE: it seems unlikely that the values returned when we try to |
24 |
get PIN_CONFIG_BIAS_PULL_UP will actually be printed since "has_arg" |
25 |
is false for that one, but I guess it's still fine to return different |
26 |
values so I kept doing that. It seems like another driver (ssbi-gpio) |
27 |
uses a custom attribute (PM8XXX_QCOM_PULL_UP_STRENGTH) for something |
28 |
similar so maybe a future change should do that here too. |
29 |
|
30 |
Fixes: cfb24f6ebd38 ("pinctrl: Qualcomm SPMI PMIC MPP pin controller driver") |
31 |
Signed-off-by: Douglas Anderson <dianders@chromium.org> |
32 |
Reviewed-by: Stephen Boyd <sboyd@kernel.org> |
33 |
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> |
34 |
Signed-off-by: Linus Walleij <linus.walleij@linaro.org> |
35 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
36 |
--- |
37 |
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 19 ++++++++++++------- |
38 |
1 file changed, 12 insertions(+), 7 deletions(-) |
39 |
|
40 |
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c |
41 |
index 7577f133d326..ac251c62bc66 100644 |
42 |
--- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c |
43 |
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c |
44 |
@@ -345,13 +345,12 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev, |
45 |
|
46 |
switch (param) { |
47 |
case PIN_CONFIG_BIAS_DISABLE: |
48 |
- arg = pad->pullup == PMIC_MPP_PULL_UP_OPEN; |
49 |
+ if (pad->pullup != PMIC_MPP_PULL_UP_OPEN) |
50 |
+ return -EINVAL; |
51 |
+ arg = 1; |
52 |
break; |
53 |
case PIN_CONFIG_BIAS_PULL_UP: |
54 |
switch (pad->pullup) { |
55 |
- case PMIC_MPP_PULL_UP_OPEN: |
56 |
- arg = 0; |
57 |
- break; |
58 |
case PMIC_MPP_PULL_UP_0P6KOHM: |
59 |
arg = 600; |
60 |
break; |
61 |
@@ -366,13 +365,17 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev, |
62 |
} |
63 |
break; |
64 |
case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: |
65 |
- arg = !pad->is_enabled; |
66 |
+ if (pad->is_enabled) |
67 |
+ return -EINVAL; |
68 |
+ arg = 1; |
69 |
break; |
70 |
case PIN_CONFIG_POWER_SOURCE: |
71 |
arg = pad->power_source; |
72 |
break; |
73 |
case PIN_CONFIG_INPUT_ENABLE: |
74 |
- arg = pad->input_enabled; |
75 |
+ if (!pad->input_enabled) |
76 |
+ return -EINVAL; |
77 |
+ arg = 1; |
78 |
break; |
79 |
case PIN_CONFIG_OUTPUT: |
80 |
arg = pad->out_value; |
81 |
@@ -384,7 +387,9 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev, |
82 |
arg = pad->amux_input; |
83 |
break; |
84 |
case PMIC_MPP_CONF_PAIRED: |
85 |
- arg = pad->paired; |
86 |
+ if (!pad->paired) |
87 |
+ return -EINVAL; |
88 |
+ arg = 1; |
89 |
break; |
90 |
case PIN_CONFIG_DRIVE_STRENGTH: |
91 |
arg = pad->drive_strength; |
92 |
-- |
93 |
2.19.1 |
94 |
|