55
55
#define I2C_DMA_INT_FLAG_NONE 0x0000
56
56
#define I2C_DMA_CLR_FLAG 0x0000
57
57
#define I2C_DMA_HARD_RST 0x0002
58
- #define I2C_DMA_4G_MODE 0x0001
59
58
60
59
#define MAX_SAMPLE_CNT_DIV 8
61
60
#define MAX_STEP_CNT_DIV 64
@@ -204,11 +203,11 @@ struct mtk_i2c_compatible {
204
203
unsigned char dcm : 1 ;
205
204
unsigned char auto_restart : 1 ;
206
205
unsigned char aux_len_reg : 1 ;
207
- unsigned char support_33bits : 1 ;
208
206
unsigned char timing_adjust : 1 ;
209
207
unsigned char dma_sync : 1 ;
210
208
unsigned char ltiming_adjust : 1 ;
211
209
unsigned char apdma_sync : 1 ;
210
+ unsigned char max_dma_support ;
212
211
};
213
212
214
213
struct mtk_i2c_ac_timing {
@@ -311,11 +310,11 @@ static const struct mtk_i2c_compatible mt2712_compat = {
311
310
.dcm = 1 ,
312
311
.auto_restart = 1 ,
313
312
.aux_len_reg = 1 ,
314
- .support_33bits = 1 ,
315
313
.timing_adjust = 1 ,
316
314
.dma_sync = 0 ,
317
315
.ltiming_adjust = 0 ,
318
316
.apdma_sync = 0 ,
317
+ .max_dma_support = 33 ,
319
318
};
320
319
321
320
static const struct mtk_i2c_compatible mt6577_compat = {
@@ -325,11 +324,11 @@ static const struct mtk_i2c_compatible mt6577_compat = {
325
324
.dcm = 1 ,
326
325
.auto_restart = 0 ,
327
326
.aux_len_reg = 0 ,
328
- .support_33bits = 0 ,
329
327
.timing_adjust = 0 ,
330
328
.dma_sync = 0 ,
331
329
.ltiming_adjust = 0 ,
332
330
.apdma_sync = 0 ,
331
+ .max_dma_support = 32 ,
333
332
};
334
333
335
334
static const struct mtk_i2c_compatible mt6589_compat = {
@@ -339,11 +338,11 @@ static const struct mtk_i2c_compatible mt6589_compat = {
339
338
.dcm = 0 ,
340
339
.auto_restart = 0 ,
341
340
.aux_len_reg = 0 ,
342
- .support_33bits = 0 ,
343
341
.timing_adjust = 0 ,
344
342
.dma_sync = 0 ,
345
343
.ltiming_adjust = 0 ,
346
344
.apdma_sync = 0 ,
345
+ .max_dma_support = 32 ,
347
346
};
348
347
349
348
static const struct mtk_i2c_compatible mt7622_compat = {
@@ -353,11 +352,11 @@ static const struct mtk_i2c_compatible mt7622_compat = {
353
352
.dcm = 1 ,
354
353
.auto_restart = 1 ,
355
354
.aux_len_reg = 1 ,
356
- .support_33bits = 0 ,
357
355
.timing_adjust = 0 ,
358
356
.dma_sync = 0 ,
359
357
.ltiming_adjust = 0 ,
360
358
.apdma_sync = 0 ,
359
+ .max_dma_support = 32 ,
361
360
};
362
361
363
362
static const struct mtk_i2c_compatible mt8173_compat = {
@@ -366,11 +365,11 @@ static const struct mtk_i2c_compatible mt8173_compat = {
366
365
.dcm = 1 ,
367
366
.auto_restart = 1 ,
368
367
.aux_len_reg = 1 ,
369
- .support_33bits = 1 ,
370
368
.timing_adjust = 0 ,
371
369
.dma_sync = 0 ,
372
370
.ltiming_adjust = 0 ,
373
371
.apdma_sync = 0 ,
372
+ .max_dma_support = 33 ,
374
373
};
375
374
376
375
static const struct mtk_i2c_compatible mt8183_compat = {
@@ -380,11 +379,11 @@ static const struct mtk_i2c_compatible mt8183_compat = {
380
379
.dcm = 0 ,
381
380
.auto_restart = 1 ,
382
381
.aux_len_reg = 1 ,
383
- .support_33bits = 1 ,
384
382
.timing_adjust = 1 ,
385
383
.dma_sync = 1 ,
386
384
.ltiming_adjust = 1 ,
387
385
.apdma_sync = 0 ,
386
+ .max_dma_support = 33 ,
388
387
};
389
388
390
389
static const struct of_device_id mtk_i2c_of_match [] = {
@@ -796,11 +795,6 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk)
796
795
return 0 ;
797
796
}
798
797
799
- static inline u32 mtk_i2c_set_4g_mode (dma_addr_t addr )
800
- {
801
- return (addr & BIT_ULL (32 )) ? I2C_DMA_4G_MODE : I2C_DMA_CLR_FLAG ;
802
- }
803
-
804
798
static int mtk_i2c_do_transfer (struct mtk_i2c * i2c , struct i2c_msg * msgs ,
805
799
int num , int left_num )
806
800
{
@@ -885,8 +879,8 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs,
885
879
return - ENOMEM ;
886
880
}
887
881
888
- if (i2c -> dev_comp -> support_33bits ) {
889
- reg_4g_mode = mtk_i2c_set_4g_mode (rpaddr );
882
+ if (i2c -> dev_comp -> max_dma_support > 32 ) {
883
+ reg_4g_mode = upper_32_bits (rpaddr );
890
884
writel (reg_4g_mode , i2c -> pdmabase + OFFSET_RX_4G_MODE );
891
885
}
892
886
@@ -908,8 +902,8 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs,
908
902
return - ENOMEM ;
909
903
}
910
904
911
- if (i2c -> dev_comp -> support_33bits ) {
912
- reg_4g_mode = mtk_i2c_set_4g_mode (wpaddr );
905
+ if (i2c -> dev_comp -> max_dma_support > 32 ) {
906
+ reg_4g_mode = upper_32_bits (wpaddr );
913
907
writel (reg_4g_mode , i2c -> pdmabase + OFFSET_TX_4G_MODE );
914
908
}
915
909
@@ -954,11 +948,11 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs,
954
948
return - ENOMEM ;
955
949
}
956
950
957
- if (i2c -> dev_comp -> support_33bits ) {
958
- reg_4g_mode = mtk_i2c_set_4g_mode (wpaddr );
951
+ if (i2c -> dev_comp -> max_dma_support > 32 ) {
952
+ reg_4g_mode = upper_32_bits (wpaddr );
959
953
writel (reg_4g_mode , i2c -> pdmabase + OFFSET_TX_4G_MODE );
960
954
961
- reg_4g_mode = mtk_i2c_set_4g_mode (rpaddr );
955
+ reg_4g_mode = upper_32_bits (rpaddr );
962
956
writel (reg_4g_mode , i2c -> pdmabase + OFFSET_RX_4G_MODE );
963
957
}
964
958
@@ -1232,8 +1226,9 @@ static int mtk_i2c_probe(struct platform_device *pdev)
1232
1226
return - EINVAL ;
1233
1227
}
1234
1228
1235
- if (i2c -> dev_comp -> support_33bits ) {
1236
- ret = dma_set_mask (& pdev -> dev , DMA_BIT_MASK (33 ));
1229
+ if (i2c -> dev_comp -> max_dma_support > 32 ) {
1230
+ ret = dma_set_mask (& pdev -> dev ,
1231
+ DMA_BIT_MASK (i2c -> dev_comp -> max_dma_support ));
1237
1232
if (ret ) {
1238
1233
dev_err (& pdev -> dev , "dma_set_mask return error.\n" );
1239
1234
return ret ;
0 commit comments