224
224
225
225
#define MLXBF_I2C_MASTER_ENABLE \
226
226
(MLXBF_I2C_MASTER_LOCK_BIT | MLXBF_I2C_MASTER_BUSY_BIT | \
227
- MLXBF_I2C_MASTER_START_BIT | MLXBF_I2C_MASTER_STOP_BIT )
227
+ MLXBF_I2C_MASTER_START_BIT)
228
228
229
229
#define MLXBF_I2C_MASTER_ENABLE_WRITE \
230
230
(MLXBF_I2C_MASTER_ENABLE | MLXBF_I2C_MASTER_CTL_WRITE_BIT)
@@ -338,6 +338,7 @@ enum {
338
338
MLXBF_I2C_F_SMBUS_BLOCK = BIT (5 ),
339
339
MLXBF_I2C_F_SMBUS_PEC = BIT (6 ),
340
340
MLXBF_I2C_F_SMBUS_PROCESS_CALL = BIT (7 ),
341
+ MLXBF_I2C_F_WRITE_WITHOUT_STOP = BIT (8 ),
341
342
};
342
343
343
344
/* Mellanox BlueField chip type. */
@@ -638,16 +639,19 @@ static void mlxbf_i2c_smbus_read_data(struct mlxbf_i2c_priv *priv,
638
639
}
639
640
640
641
static int mlxbf_i2c_smbus_enable (struct mlxbf_i2c_priv * priv , u8 slave ,
641
- u8 len , u8 block_en , u8 pec_en , bool read )
642
+ u8 len , u8 block_en , u8 pec_en , bool read ,
643
+ bool stop )
642
644
{
643
- u32 command ;
645
+ u32 command = 0 ;
644
646
645
647
/* Set Master GW control word. */
648
+ if (stop )
649
+ command |= MLXBF_I2C_MASTER_STOP_BIT ;
646
650
if (read ) {
647
- command = MLXBF_I2C_MASTER_ENABLE_READ ;
651
+ command | = MLXBF_I2C_MASTER_ENABLE_READ ;
648
652
command |= rol32 (len , MLXBF_I2C_MASTER_READ_SHIFT );
649
653
} else {
650
- command = MLXBF_I2C_MASTER_ENABLE_WRITE ;
654
+ command | = MLXBF_I2C_MASTER_ENABLE_WRITE ;
651
655
command |= rol32 (len , MLXBF_I2C_MASTER_WRITE_SHIFT );
652
656
}
653
657
command |= rol32 (slave , MLXBF_I2C_MASTER_SLV_ADDR_SHIFT );
@@ -682,8 +686,10 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
682
686
u8 op_idx , data_idx , data_len , write_len , read_len ;
683
687
struct mlxbf_i2c_smbus_operation * operation ;
684
688
u8 read_en , write_en , block_en , pec_en ;
685
- u8 slave , flags , addr ;
689
+ bool stop_after_write = true;
690
+ u8 slave , addr ;
686
691
u8 * read_buf ;
692
+ u32 flags ;
687
693
u32 bits ;
688
694
int ret ;
689
695
@@ -755,7 +761,16 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
755
761
memcpy (data_desc + data_idx ,
756
762
operation -> buffer , operation -> length );
757
763
data_idx += operation -> length ;
764
+
765
+ /*
766
+ * The stop condition can be skipped when writing on the bus
767
+ * to implement a repeated start condition on the next read
768
+ * as required for several SMBus and I2C operations.
769
+ */
770
+ if (flags & MLXBF_I2C_F_WRITE_WITHOUT_STOP )
771
+ stop_after_write = false;
758
772
}
773
+
759
774
/*
760
775
* We assume that read operations are performed only once per
761
776
* SMBus transaction. *TBD* protect this statement so it won't
@@ -781,7 +796,7 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
781
796
782
797
if (write_en ) {
783
798
ret = mlxbf_i2c_smbus_enable (priv , slave , write_len , block_en ,
784
- pec_en , 0 );
799
+ pec_en , 0 , stop_after_write );
785
800
if (ret )
786
801
goto out_unlock ;
787
802
}
@@ -791,7 +806,7 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
791
806
mlxbf_i2c_smbus_write_data (priv , (const u8 * )& addr , 1 ,
792
807
MLXBF_I2C_MASTER_DATA_DESC_ADDR , true);
793
808
ret = mlxbf_i2c_smbus_enable (priv , slave , read_len , block_en ,
794
- pec_en , 1 );
809
+ pec_en , 1 , true );
795
810
if (!ret ) {
796
811
/* Get Master GW data descriptor. */
797
812
mlxbf_i2c_smbus_read_data (priv , data_desc , read_len + 1 ,
@@ -897,6 +912,9 @@ mlxbf_i2c_smbus_i2c_block_func(struct mlxbf_i2c_smbus_request *request,
897
912
request -> operation [0 ].flags |= pec_check ? MLXBF_I2C_F_SMBUS_PEC : 0 ;
898
913
request -> operation [0 ].buffer = command ;
899
914
915
+ if (read )
916
+ request -> operation [0 ].flags |= MLXBF_I2C_F_WRITE_WITHOUT_STOP ;
917
+
900
918
/*
901
919
* As specified in the standard, the max number of bytes to read/write
902
920
* per block operation is 32 bytes. In Golan code, the controller can
0 commit comments