i2c: mt76xx: add I2C_FUNC_NOSTART and I2C_M_REV_DIR_ADDR
PATCH v2 1/1 i2c: mt76xx: add I2C_FUNC_NOSTART and I2C_M_REV_DIR_ADDR
This patch adds I2C_FUNC_NOSTART and I2C_M_REV_DIR_ADDR support for MediaTek MT7621/7628/7688. This is useful for some I2C slave chips, such as 'drivers/input/joystick/as5011.c'.
Signed-off-by Jianhui Zhao <[email protected]>
Reviewed-by Stefan Roese <[email protected]>
---
Changes v1 -> v2:
- Fix code style
--- drivers/i2c/busses/i2c-mt7621.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-mt7621.c +8 -1
@@ -150,6 +150,9 @@ static int mtk_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,for (i =0 ; i < num; i++) { pmsg = &msgs[i]; +if (pmsg->flags &I2C_M_NOSTART ) + goto nostart; +/* wait hardware idle */ ret =mtk_i2c_wait_idle (i2c);if (ret)
@@ -174,6 +177,8 @@ static int mtk_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, }else {/* 7 bits address */ addr =i2c_8bit_addr_from_msg (pmsg); +if (pmsg->flags &I2C_M_REV_DIR_ADDR ) + addr ^=1 ;iowrite32 (addr, i2c->base +REG_SM0D0_REG ); ret =mtk_i2c_master_cmd (i2c,SM0CTL1_WRITE ,1 );if (ret)
@@ -187,6 +192,7 @@ static int mtk_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, goto err_ack; } +nostart:/* transfer data */ for (len = pmsg->len, j =0 ; len >0 ; len -=8 , j +=8 ) { page_len = (len >=8 ) ?8 : len;
@@ -242,7 +248,8 @@ static int mtk_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,static u32 mtk_i2c_func (struct i2c_adapter *a) { -return I2C_FUNC_I2C |I2C_FUNC_SMBUS_EMUL |I2C_FUNC_PROTOCOL_MANGLING ; +return I2C_FUNC_I2C |I2C_FUNC_SMBUS_EMUL |I2C_FUNC_10BIT_ADDR | +I2C_FUNC_PROTOCOL_MANGLING |I2C_FUNC_NOSTART ; }static const struct i2c_algorithm mtk_i2c_algo = {
Signature · 7 lines
2.25.1 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek