arch: cxd56xx: Improve i2c reset function

During I2C communication between non-Spresense devices is performed,
the I2C bus may freeze after initialization of the Spresense I2C.
As a workaround, add clock gating process and disable GPIO input
to the I2C reset function.

Signed-off-by: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com>
This commit is contained in:
SPRESENSE 2025-02-19 17:03:53 +09:00 committed by Alin Jerpelea
parent c782131c5f
commit d521b926aa

View file

@ -723,6 +723,10 @@ static int cxd56_i2c_reset(struct i2c_master_s *dev)
nxmutex_lock(&priv->lock);
/* Disable clock gating (clock enable) */
cxd56_i2c_clock_gate_disable(priv->port);
/* Use GPIO configuration to un-wedge the bus */
cxd56_i2c_pincontrol(priv->port, false);
@ -794,6 +798,11 @@ static int cxd56_i2c_reset(struct i2c_master_s *dev)
up_udelay(10);
}
/* Disable input of SCL and SDA pins */
cxd56_gpio_config(scl_gpio, false);
cxd56_gpio_config(sda_gpio, false);
/* Generate a start followed by a stop to reset slave
* state machines.
*/
@ -820,6 +829,10 @@ out:
cxd56_i2c_pincontrol(priv->port, true);
/* Enable clock gating (clock disable) */
cxd56_i2c_clock_gate_enable(priv->port);
/* Release the port for re-use by other clients */
nxmutex_unlock(&priv->lock);