提交 a85fbd64 编写于 作者: D Douglas Anderson 提交者: Dmitry Torokhov

Input: elants_i2c - properly handle the reset GPIO when power is off

As can be seen in elants_i2c_power_off(), we want the reset GPIO
asserted when power is off. The reset GPIO is active low so we need
the reset line logic low when power is off to avoid leakage.

We have a problem, though, at probe time. At probe time we haven't
powered the regulators on yet but we have:

  devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW);

While that _looks_ right, it turns out that it's not. The
GPIOD_OUT_LOW doesn't mean to init the GPIO to low. It means init the
GPIO to "not asserted". Since this is an active low GPIO that inits it
to be high.

Let's fix this to properly init the GPIO. Now after both probe and
power off the state of the GPIO is consistent (it's "asserted" or
level low).

Once we fix this, we can see that at power on time we no longer to
assert the reset GPIO as the first thing. The reset GPIO is _always_
asserted before powering on. Let's fix powering on to account for
this.

Fixes: afe10358 ("Input: elants_i2c - wire up regulator support")
Signed-off-by: NDouglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20221117123805.1.I9959ac561dd6e1e8e1ce7085e4de6167b27c574f@changeidSigned-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
上级 c7f43645
...@@ -1329,14 +1329,12 @@ static int elants_i2c_power_on(struct elants_data *ts) ...@@ -1329,14 +1329,12 @@ static int elants_i2c_power_on(struct elants_data *ts)
if (IS_ERR_OR_NULL(ts->reset_gpio)) if (IS_ERR_OR_NULL(ts->reset_gpio))
return 0; return 0;
gpiod_set_value_cansleep(ts->reset_gpio, 1);
error = regulator_enable(ts->vcc33); error = regulator_enable(ts->vcc33);
if (error) { if (error) {
dev_err(&ts->client->dev, dev_err(&ts->client->dev,
"failed to enable vcc33 regulator: %d\n", "failed to enable vcc33 regulator: %d\n",
error); error);
goto release_reset_gpio; return error;
} }
error = regulator_enable(ts->vccio); error = regulator_enable(ts->vccio);
...@@ -1345,7 +1343,7 @@ static int elants_i2c_power_on(struct elants_data *ts) ...@@ -1345,7 +1343,7 @@ static int elants_i2c_power_on(struct elants_data *ts)
"failed to enable vccio regulator: %d\n", "failed to enable vccio regulator: %d\n",
error); error);
regulator_disable(ts->vcc33); regulator_disable(ts->vcc33);
goto release_reset_gpio; return error;
} }
/* /*
...@@ -1354,7 +1352,6 @@ static int elants_i2c_power_on(struct elants_data *ts) ...@@ -1354,7 +1352,6 @@ static int elants_i2c_power_on(struct elants_data *ts)
*/ */
udelay(ELAN_POWERON_DELAY_USEC); udelay(ELAN_POWERON_DELAY_USEC);
release_reset_gpio:
gpiod_set_value_cansleep(ts->reset_gpio, 0); gpiod_set_value_cansleep(ts->reset_gpio, 0);
if (error) if (error)
return error; return error;
...@@ -1462,7 +1459,7 @@ static int elants_i2c_probe(struct i2c_client *client) ...@@ -1462,7 +1459,7 @@ static int elants_i2c_probe(struct i2c_client *client)
return error; return error;
} }
ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW); ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(ts->reset_gpio)) { if (IS_ERR(ts->reset_gpio)) {
error = PTR_ERR(ts->reset_gpio); error = PTR_ERR(ts->reset_gpio);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册