iio: imu: bno555: Fix reset pin operation
PATCH 1/1 iio: imu: bno555: Fix reset pin operation
The reset input is low-active and this is how the dt bindinds example configures it. However, the driver code treats it as high-active because the gpio functions set the logical state not the physical state.
--- drivers/iio/imu/bno055/bno055.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/imu/bno055/bno055.c +4 -4
@@ -355,9 +355,9 @@ static int bno055_system_reset(struct bno055_priv *priv)int ret;if (priv->reset_gpio) { -gpiod_set_value_cansleep (priv->reset_gpio,0 ); -usleep_range (5000 ,10000 );gpiod_set_value_cansleep (priv->reset_gpio,1 ); +usleep_range (5000 ,10000 ); +gpiod_set_value_cansleep (priv->reset_gpio,0 ); }else if (priv->sw_reset) { ret =regmap_write (priv->regmap,BNO055_SYS_TRIGGER_REG ,BNO055_SYS_TRIGGER_RST_SYS );
@@ -1603,7 +1603,7 @@ int bno055_probe(struct device *dev, struct regmap *regmap, priv->xfer_burst_break_thr = xfer_burst_break_thr; priv->sw_reset = sw_reset; - priv->reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_LOW ); + priv->reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (priv->reset_gpio))return dev_err_probe (dev,PTR_ERR (priv->reset_gpio),"Failed to get reset GPIO\n" );
@@ -1613,7 +1613,7 @@ int bno055_probe(struct device *dev, struct regmap *regmap,if (priv->reset_gpio) {usleep_range (5000 ,10000 ); -gpiod_set_value_cansleep (priv->reset_gpio,1 ); +gpiod_set_value_cansleep (priv->reset_gpio,0 );usleep_range (650000 ,750000 ); }else if (!sw_reset) {dev_warn (dev,"No usable reset method; IMU may be unreliable\n" );
Signature · 1 line
2.56.1
Quoted 4 lines · Jochen Henneberg
The reset input is low-active and this is how the dt bindinds example configures it. However, the driver code treats it as high-active because the gpio functions set the logical state not the physical state.
Please, just convert this to use reset-gpio driver and reset APIs. It will be better and might allow shared signals in the future (if ever required).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 4 lines · Jochen Henneberg
The reset input is low-active and this is how the dt bindinds example configures it. However, the driver code treats it as high-active because the gpio functions set the logical state not the physical state.
The change itself looks right to me: with GPIO_ACTIVE_LOW as in the binding, probe currently ends up holding the chip in reset. A few comments on the patch:
- Subject: s/bno555/bno055/. Also s/bindinds/bindings/ above.
- This needs a Fixes: tag, I think:
- Any DT that worked around the old behaviour by describing the line as GPIO_ACTIVE_HIGH will stop working after this. There is no such user in-tree (the only in-tree bno055 node, omap3-gta04a5.dts, has no reset-gpios), but please say that in the commit message so it is clear the behaviour change was considered.