can: tcan4x5x: fix reset gpio usage during probe
authorBrett Werling <brett.werling@garmin.com>
Fri, 11 Jul 2025 14:17:28 +0000 (09:17 -0500)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 15 Jul 2025 09:59:43 +0000 (11:59 +0200)
commit0f97a7588db7a545ea07ee0d512789bfad4931d8
tree8abe35ccbbfd35529aced01b1d10b8694b687a51
parentf0f2b992d8185a0366be951685e08643aae17d6d
can: tcan4x5x: fix reset gpio usage during probe

Fixes reset GPIO usage during probe by ensuring we retrieve the GPIO and
take the device out of reset (if it defaults to being in reset) before
we attempt to communicate with the device. This is achieved by moving
the call to tcan4x5x_get_gpios() before tcan4x5x_find_version() and
avoiding any device communication while getting the GPIOs. Once we
determine the version, we can then take the knowledge of which GPIOs we
obtained and use it to decide whether we need to disable the wake or
state pin functions within the device.

This change is necessary in a situation where the reset GPIO is pulled
high externally before the CPU takes control of it, meaning we need to
explicitly bring the device out of reset before we can start
communicating with it at all.

This also has the effect of fixing an issue where a reset of the device
would occur after having called tcan4x5x_disable_wake(), making the
original behavior not actually disable the wake. This patch should now
disable wake or state pin functions well after the reset occurs.

Signed-off-by: Brett Werling <brett.werling@garmin.com>
Link: https://patch.msgid.link/20250711141728.1826073-1-brett.werling@garmin.com
Cc: Markus Schneider-Pargmann <msp@baylibre.com>
Fixes: 142c6dc6d9d7 ("can: tcan4x5x: Add support for tcan4552/4553")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/m_can/tcan4x5x-core.c