Commit 686f7c9a authored by Nikita Yushchenko's avatar Nikita Yushchenko Committed by Stefan Bader

iio: hi8435: cleanup reset gpio

BugLink: http://bugs.launchpad.net/bugs/1765010

[ Upstream commit 61305664 ]

Reset GPIO is active low.

Currently driver uses gpiod_set_value(1) to clean reset, which depends
on device tree to contain GPIO_ACTIVE_HIGH - that does not match reality.

This fixes driver to use _raw version of gpiod_set_value() to enforce
active-low semantics despite of what's written in device tree. Allowing
device tree to override that only opens possibility for errors and does
not add any value.

Additionally, use _cansleep version to make things work with i2c-gpio
and other sleeping gpio drivers.
Signed-off-by: default avatarNikita Yushchenko <nikita.yoush@cogentembedded.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 8b522de1
...@@ -453,13 +453,15 @@ static int hi8435_probe(struct spi_device *spi) ...@@ -453,13 +453,15 @@ static int hi8435_probe(struct spi_device *spi)
priv->spi = spi; priv->spi = spi;
reset_gpio = devm_gpiod_get(&spi->dev, NULL, GPIOD_OUT_LOW); reset_gpio = devm_gpiod_get(&spi->dev, NULL, GPIOD_OUT_LOW);
if (IS_ERR(reset_gpio)) { if (!IS_ERR(reset_gpio)) {
/* chip s/w reset if h/w reset failed */ /* need >=100ns low pulse to reset chip */
gpiod_set_raw_value_cansleep(reset_gpio, 0);
udelay(1);
gpiod_set_raw_value_cansleep(reset_gpio, 1);
} else {
/* s/w reset chip if h/w reset is not available */
hi8435_writeb(priv, HI8435_CTRL_REG, HI8435_CTRL_SRST); hi8435_writeb(priv, HI8435_CTRL_REG, HI8435_CTRL_SRST);
hi8435_writeb(priv, HI8435_CTRL_REG, 0); hi8435_writeb(priv, HI8435_CTRL_REG, 0);
} else {
udelay(5);
gpiod_set_value(reset_gpio, 1);
} }
spi_set_drvdata(spi, idev); spi_set_drvdata(spi, idev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment