@@ -315,14 +315,12 @@ static const struct iio_chan_spec meson_sar_adc_and_temp_iio_channels[] = {
315
315
struct meson_sar_adc_param {
316
316
bool has_bl30_integration ;
317
317
unsigned long clock_rate ;
318
- u32 bandgap_reg ;
319
318
unsigned int resolution ;
320
319
const struct regmap_config * regmap_config ;
321
320
u8 temperature_trimming_bits ;
322
321
unsigned int temperature_multiplier ;
323
322
unsigned int temperature_divider ;
324
323
u8 disable_ring_counter ;
325
- bool has_reg11 ;
326
324
bool has_vref_select ;
327
325
u8 vref_select ;
328
326
u8 cmv_select ;
@@ -976,7 +974,7 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
976
974
MESON_SAR_ADC_REG3_CTRL_CONT_RING_COUNTER_EN ,
977
975
regval );
978
976
979
- if (priv -> param -> has_reg11 ) {
977
+ if (priv -> param -> regmap_config -> max_register >= MESON_SAR_ADC_REG11 ) {
980
978
regval = FIELD_PREP (MESON_SAR_ADC_REG11_EOC , priv -> param -> adc_eoc );
981
979
regmap_update_bits (priv -> regmap , MESON_SAR_ADC_REG11 ,
982
980
MESON_SAR_ADC_REG11_EOC , regval );
@@ -1013,16 +1011,15 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
1013
1011
static void meson_sar_adc_set_bandgap (struct iio_dev * indio_dev , bool on_off )
1014
1012
{
1015
1013
struct meson_sar_adc_priv * priv = iio_priv (indio_dev );
1016
- const struct meson_sar_adc_param * param = priv -> param ;
1017
- u32 enable_mask ;
1018
1014
1019
- if (param -> bandgap_reg == MESON_SAR_ADC_REG11 )
1020
- enable_mask = MESON_SAR_ADC_REG11_BANDGAP_EN ;
1015
+ if (priv -> param -> regmap_config -> max_register >= MESON_SAR_ADC_REG11 )
1016
+ regmap_update_bits (priv -> regmap , MESON_SAR_ADC_REG11 ,
1017
+ MESON_SAR_ADC_REG11_BANDGAP_EN ,
1018
+ on_off ? MESON_SAR_ADC_REG11_BANDGAP_EN : 0 );
1021
1019
else
1022
- enable_mask = MESON_SAR_ADC_DELTA_10_TS_VBG_EN ;
1023
-
1024
- regmap_update_bits (priv -> regmap , param -> bandgap_reg , enable_mask ,
1025
- on_off ? enable_mask : 0 );
1020
+ regmap_update_bits (priv -> regmap , MESON_SAR_ADC_DELTA_10 ,
1021
+ MESON_SAR_ADC_DELTA_10_TS_VBG_EN ,
1022
+ on_off ? MESON_SAR_ADC_DELTA_10_TS_VBG_EN : 0 );
1026
1023
}
1027
1024
1028
1025
static int meson_sar_adc_hw_enable (struct iio_dev * indio_dev )
@@ -1186,7 +1183,6 @@ static const struct iio_info meson_sar_adc_iio_info = {
1186
1183
static const struct meson_sar_adc_param meson_sar_adc_meson8_param = {
1187
1184
.has_bl30_integration = false,
1188
1185
.clock_rate = 1150000 ,
1189
- .bandgap_reg = MESON_SAR_ADC_DELTA_10 ,
1190
1186
.regmap_config = & meson_sar_adc_regmap_config_meson8 ,
1191
1187
.resolution = 10 ,
1192
1188
.temperature_trimming_bits = 4 ,
@@ -1197,7 +1193,6 @@ static const struct meson_sar_adc_param meson_sar_adc_meson8_param = {
1197
1193
static const struct meson_sar_adc_param meson_sar_adc_meson8b_param = {
1198
1194
.has_bl30_integration = false,
1199
1195
.clock_rate = 1150000 ,
1200
- .bandgap_reg = MESON_SAR_ADC_DELTA_10 ,
1201
1196
.regmap_config = & meson_sar_adc_regmap_config_meson8 ,
1202
1197
.resolution = 10 ,
1203
1198
.temperature_trimming_bits = 5 ,
@@ -1208,34 +1203,28 @@ static const struct meson_sar_adc_param meson_sar_adc_meson8b_param = {
1208
1203
static const struct meson_sar_adc_param meson_sar_adc_gxbb_param = {
1209
1204
.has_bl30_integration = true,
1210
1205
.clock_rate = 1200000 ,
1211
- .bandgap_reg = MESON_SAR_ADC_REG11 ,
1212
1206
.regmap_config = & meson_sar_adc_regmap_config_gxbb ,
1213
1207
.resolution = 10 ,
1214
- .has_reg11 = true,
1215
1208
.vref_voltage = 1 ,
1216
1209
.cmv_select = 1 ,
1217
1210
};
1218
1211
1219
1212
static const struct meson_sar_adc_param meson_sar_adc_gxl_param = {
1220
1213
.has_bl30_integration = true,
1221
1214
.clock_rate = 1200000 ,
1222
- .bandgap_reg = MESON_SAR_ADC_REG11 ,
1223
1215
.regmap_config = & meson_sar_adc_regmap_config_gxbb ,
1224
1216
.resolution = 12 ,
1225
1217
.disable_ring_counter = 1 ,
1226
- .has_reg11 = true,
1227
1218
.vref_voltage = 1 ,
1228
1219
.cmv_select = 1 ,
1229
1220
};
1230
1221
1231
1222
static const struct meson_sar_adc_param meson_sar_adc_axg_param = {
1232
1223
.has_bl30_integration = true,
1233
1224
.clock_rate = 1200000 ,
1234
- .bandgap_reg = MESON_SAR_ADC_REG11 ,
1235
1225
.regmap_config = & meson_sar_adc_regmap_config_gxbb ,
1236
1226
.resolution = 12 ,
1237
1227
.disable_ring_counter = 1 ,
1238
- .has_reg11 = true,
1239
1228
.vref_voltage = 1 ,
1240
1229
.has_vref_select = true,
1241
1230
.vref_select = VREF_VDDA ,
@@ -1245,11 +1234,9 @@ static const struct meson_sar_adc_param meson_sar_adc_axg_param = {
1245
1234
static const struct meson_sar_adc_param meson_sar_adc_g12a_param = {
1246
1235
.has_bl30_integration = false,
1247
1236
.clock_rate = 1200000 ,
1248
- .bandgap_reg = MESON_SAR_ADC_REG11 ,
1249
1237
.regmap_config = & meson_sar_adc_regmap_config_gxbb ,
1250
1238
.resolution = 12 ,
1251
1239
.disable_ring_counter = 1 ,
1252
- .has_reg11 = true,
1253
1240
.adc_eoc = 1 ,
1254
1241
.has_vref_select = true,
1255
1242
.vref_select = VREF_VDDA ,
0 commit comments