@@ -185,6 +185,9 @@ static int si2157_find_and_load_firmware(struct dvb_frontend *fe)
185
185
return - EINVAL ;
186
186
}
187
187
188
+ /* Update the part id based on device's report */
189
+ dev -> part_id = part_id ;
190
+
188
191
dev_info (& client -> dev ,
189
192
"found a 'Silicon Labs Si21%d-%c%c%c ROM 0x%02x'\n" ,
190
193
part_id , cmd .args [1 ], cmd .args [3 ], cmd .args [4 ], rom_id );
@@ -235,10 +238,12 @@ static int si2157_init(struct dvb_frontend *fe)
235
238
dev -> if_frequency = 0 ; /* we no longer know current tuner state */
236
239
237
240
/* power up */
238
- if (dev -> chiptype == SI2157_CHIPTYPE_SI2146 ) {
241
+ if (dev -> part_id == SI2146 ) {
242
+ /* clock_mode = XTAL, clock_freq = 24MHz */
239
243
memcpy (cmd .args , "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01" , 9 );
240
244
cmd .wlen = 9 ;
241
- } else if (dev -> chiptype == SI2157_CHIPTYPE_SI2141 ) {
245
+ } else if (dev -> part_id == SI2141 ) {
246
+ /* clock_mode: XTAL, xout enabled */
242
247
memcpy (cmd .args , "\xc0\x00\x0d\x0e\x00\x01\x01\x01\x01\x03" , 10 );
243
248
cmd .wlen = 10 ;
244
249
} else {
@@ -247,11 +252,11 @@ static int si2157_init(struct dvb_frontend *fe)
247
252
}
248
253
cmd .rlen = 1 ;
249
254
ret = si2157_cmd_execute (client , & cmd );
250
- if (ret && (dev -> chiptype != SI2157_CHIPTYPE_SI2141 || ret != - EAGAIN ))
255
+ if (ret && (dev -> part_id != SI2141 || ret != - EAGAIN ))
251
256
goto err ;
252
257
253
- /* Si2141 needs a second command before it answers the revision query */
254
- if (dev -> chiptype == SI2157_CHIPTYPE_SI2141 ) {
258
+ /* Si2141 needs a wake up command */
259
+ if (dev -> part_id == SI2141 ) {
255
260
memcpy (cmd .args , "\xc0\x08\x01\x02\x00\x00\x01" , 7 );
256
261
cmd .wlen = 7 ;
257
262
ret = si2157_cmd_execute (client , & cmd );
@@ -493,7 +498,8 @@ static int si2157_set_params(struct dvb_frontend *fe)
493
498
if (ret )
494
499
goto err ;
495
500
496
- if (dev -> chiptype == SI2157_CHIPTYPE_SI2146 )
501
+ /* On SI2146, set DTV AGC source to DLIF_AGC_3DB */
502
+ if (dev -> part_id == SI2146 )
497
503
memcpy (cmd .args , "\x14\x00\x02\x07\x00\x01" , 6 );
498
504
else
499
505
memcpy (cmd .args , "\x14\x00\x02\x07\x00\x00" , 6 );
@@ -560,9 +566,9 @@ static int si2157_set_analog_params(struct dvb_frontend *fe,
560
566
u8 color = 0 ; /* 0=NTSC/PAL, 0x10=SECAM */
561
567
u8 invert_analog = 1 ; /* analog tuner spectrum; 0=normal, 1=inverted */
562
568
563
- if (dev -> chiptype != SI2157_CHIPTYPE_SI2157 ) {
564
- dev_info (& client -> dev , "Analog tuning not supported for chiptype=%u \n" ,
565
- dev -> chiptype );
569
+ if (dev -> part_id != SI2157 ) {
570
+ dev_info (& client -> dev , "Analog tuning not supported yet for Si21%d \n" ,
571
+ dev -> part_id );
566
572
ret = - EINVAL ;
567
573
goto err ;
568
574
}
@@ -874,7 +880,7 @@ static int si2157_probe(struct i2c_client *client,
874
880
dev -> inversion = cfg -> inversion ;
875
881
dev -> dont_load_firmware = cfg -> dont_load_firmware ;
876
882
dev -> if_port = cfg -> if_port ;
877
- dev -> chiptype = (u8 )id -> driver_data ;
883
+ dev -> part_id = (u8 )id -> driver_data ;
878
884
dev -> if_frequency = 5000000 ; /* default value of property 0x0706 */
879
885
mutex_init (& dev -> i2c_mutex );
880
886
INIT_DELAYED_WORK (& dev -> stat_work , si2157_stat_work );
@@ -917,10 +923,8 @@ static int si2157_probe(struct i2c_client *client,
917
923
}
918
924
#endif
919
925
920
- dev_info (& client -> dev , "Silicon Labs %s successfully attached\n" ,
921
- dev -> chiptype == SI2157_CHIPTYPE_SI2141 ? "Si2141" :
922
- dev -> chiptype == SI2157_CHIPTYPE_SI2146 ?
923
- "Si2146" : "Si2147/2148/2157/2158" );
926
+ dev_info (& client -> dev , "Silicon Labs Si21%d successfully attached\n" ,
927
+ dev -> part_id );
924
928
925
929
return 0 ;
926
930
@@ -953,11 +957,16 @@ static int si2157_remove(struct i2c_client *client)
953
957
return 0 ;
954
958
}
955
959
960
+ /*
961
+ * The part_id used here will only be used on buggy devices that don't
962
+ * accept firmware uploads. Non-buggy devices should just use "si2157" for
963
+ * all SiLabs TER tuners, as the driver should auto-detect it.
964
+ */
956
965
static const struct i2c_device_id si2157_id_table [] = {
957
- {"si2157" , SI2157_CHIPTYPE_SI2157 },
958
- {"si2146" , SI2157_CHIPTYPE_SI2146 },
959
- {"si2141" , SI2157_CHIPTYPE_SI2141 },
960
- {"si2177" , SI2157_CHIPTYPE_SI2177 },
966
+ {"si2157" , SI2157 },
967
+ {"si2146" , SI2146 },
968
+ {"si2141" , SI2141 },
969
+ {"si2177" , SI2177 },
961
970
{}
962
971
};
963
972
MODULE_DEVICE_TABLE (i2c , si2157_id_table );
0 commit comments