riscv/mpfs: add i2c reset handler
Add reset functionality into the mpfs i2c driver. Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
This commit is contained in:
parent
04c805207a
commit
502210e98c
@ -95,10 +95,12 @@ config MPFS_UART4
|
||||
|
||||
config MPFS_I2C0
|
||||
bool "I2C 0"
|
||||
select ARCH_HAVE_I2CRESET
|
||||
default n
|
||||
|
||||
config MPFS_I2C1
|
||||
bool "I2C 1"
|
||||
select ARCH_HAVE_I2CRESET
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
@ -96,9 +96,16 @@ static int mpfs_i2c_transfer(struct i2c_master_s *dev,
|
||||
struct i2c_msg_s *msgs,
|
||||
int count);
|
||||
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
static int mpfs_i2c_reset(struct i2c_master_s *dev);
|
||||
#endif
|
||||
|
||||
static const struct i2c_ops_s mpfs_i2c_ops =
|
||||
{
|
||||
.transfer = mpfs_i2c_transfer
|
||||
.transfer = mpfs_i2c_transfer,
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
.reset = mpfs_i2c_reset,
|
||||
#endif
|
||||
};
|
||||
|
||||
struct mpfs_i2c_priv_s
|
||||
@ -692,6 +699,41 @@ static int mpfs_i2c_transfer(struct i2c_master_s *dev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mpfs_i2c_reset
|
||||
*
|
||||
* Description:
|
||||
* Performs an I2C bus reset. This may be used to recover from a buggy
|
||||
* situation.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - Device-specific state data
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; this should not fail.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifdef CONFIG_I2C_RESET
|
||||
static int mpfs_i2c_reset(struct i2c_master_s *dev)
|
||||
{
|
||||
struct mpfs_i2c_priv_s *priv = (struct mpfs_i2c_priv_s *)dev;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
up_disable_irq(priv->plic_irq);
|
||||
mpfs_i2c_init(priv);
|
||||
|
||||
priv->tx_size = 0;
|
||||
priv->tx_idx = 0;
|
||||
priv->rx_size = 0;
|
||||
priv->rx_idx = 0;
|
||||
|
||||
/* up_enable_irq() will be called at mpfs_i2c_sendstart() */
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user