On 12/11/19 12:42 AM, Sean Nyekjaer wrote:
It's a good idea to reset a ip-block/spi device before using it,
this patch will reset the device.
And a generic reset function if needed elsewhere.
Signed-off-by: Sean Nyekjaer <sean@xxxxxxxxxx>
---
Changes since v2:
- added reset function
drivers/net/can/m_can/tcan4x5x.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c
index 1f04fec7723d..b5d2ea0999c1 100644
--- a/drivers/net/can/m_can/tcan4x5x.c
+++ b/drivers/net/can/m_can/tcan4x5x.c
@@ -166,6 +166,18 @@ static void tcan4x5x_check_wake(struct tcan4x5x_priv *priv)
}
}
+static void tcan4x5x_reset(struct tcan4x5x_priv *priv)
+{
+ if (priv->reset_gpio) {
+ gpiod_set_value(priv->reset_gpio, 1);
+
+ /* tpulse_width minimum 30us */
+ usleep_range(30, 100);
+ gpiod_set_value(priv->reset_gpio, 0);
+ usleep_range(700, 1000);
+ }
Do the software reset if GPIO is not valid then this will make sure the
device is reset in either case. Otherwise w/out the GPIO the device is
not reset as the commit message indicates. This is another reason for
this function
} else {
regmap_write(priv-regmap, TCAN4X5X_CONFIG, TCAN4X5X_SW_RESET);
}
Dan