@@ -204,6 +204,7 @@ struct rk3x_i2c {
204204
205205 /* Settings */
206206 struct i2c_timings t ;
207+ int bus_nr ;
207208
208209 /* Synchronization & notification */
209210 spinlock_t lock ;
@@ -969,7 +970,7 @@ static int rk3x_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
969970 *
970971 * returns: Number of I2C msgs processed or negative in case of error
971972 */
972- static int rk3x_i2c_setup (struct rk3x_i2c * i2c , struct i2c_msg * msgs , int num )
973+ static int rk3x_i2c_setup (struct rk3x_i2c * i2c , struct i2c_msg * msgs , int num , bool nostart )
973974{
974975 u32 addr = (msgs [0 ].addr & 0x7f ) << 1 ;
975976 int ret = 0 ;
@@ -982,13 +983,14 @@ static int rk3x_i2c_setup(struct rk3x_i2c *i2c, struct i2c_msg *msgs, int num)
982983 */
983984
984985 if (num >= 2 && msgs [0 ].len < 4 &&
985- !(msgs [0 ].flags & I2C_M_RD ) && (msgs [1 ].flags & I2C_M_RD )) {
986+ !(msgs [0 ].flags & I2C_M_RD ) && (msgs [1 ].flags & I2C_M_RD ) && ! nostart ) {
986987 u32 reg_addr = 0 ;
987988 int i ;
988989
989990 dev_dbg (i2c -> dev , "Combined write/read from addr 0x%x\n" ,
990991 addr >> 1 );
991992
993+ dev_err (i2c -> dev , "flags from: %d, %d, addr: 0x%x\n" , msgs [0 ].flags , msgs [1 ].flags , msgs [0 ].addr );
992994 /* Fill MRXRADDR with the register address(es) */
993995 for (i = 0 ; i < msgs [0 ].len ; ++ i ) {
994996 reg_addr |= msgs [0 ].buf [i ] << (i * 8 );
@@ -1049,6 +1051,7 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
10491051 u32 val ;
10501052 int ret = 0 ;
10511053 int i ;
1054+ bool nostart ;
10521055
10531056 spin_lock_irqsave (& i2c -> lock , flags );
10541057
@@ -1062,14 +1065,19 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
10621065 * rk3x_i2c_setup()).
10631066 */
10641067 for (i = 0 ; i < num ; i += ret ) {
1065- ret = rk3x_i2c_setup (i2c , msgs + i , num - i );
1068+ if ((i2c -> bus_nr == 1 ) || (i2c -> bus_nr == 4 ))
1069+ nostart = true;
1070+ else
1071+ nostart = false;
1072+
1073+ ret = rk3x_i2c_setup (i2c , msgs + i , num - i , nostart );
10661074
10671075 if (ret < 0 ) {
10681076 dev_err (i2c -> dev , "rk3x_i2c_setup() failed\n" );
10691077 break ;
10701078 }
10711079
1072- if (i + ret >= num )
1080+ if (( i + ret >= num ) || nostart )
10731081 i2c -> is_last_msg = true;
10741082
10751083 spin_unlock_irqrestore (& i2c -> lock , flags );
@@ -1213,6 +1221,7 @@ static int rk3x_i2c_probe(struct platform_device *pdev)
12131221
12141222 /* Try to set the I2C adapter number from dt */
12151223 bus_nr = of_alias_get_id (np , "i2c" );
1224+ i2c -> bus_nr = bus_nr ;
12161225
12171226 /*
12181227 * Switch to new interface if the SoC also offers the old one.
0 commit comments