Skip to content

Commit

Permalink
arch: cxd56xx: Improve i2c reset function
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
SPRESENSE committed Feb 21, 2025
1 parent 32bc951 commit a9d0fb9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions arch/arm/src/cxd56xx/cxd56_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
*/
Expand All @@ -820,6 +829,10 @@ static int cxd56_i2c_reset(struct i2c_master_s *dev)

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);
Expand Down

0 comments on commit a9d0fb9

Please sign in to comment.