6666 FIELD_PREP(AD7173_CH_SETUP_AINNEG_MASK, neg))
6767#define AD7173_AIN_TEMP_POS 17
6868#define AD7173_AIN_TEMP_NEG 18
69+ #define AD7173_AIN_POW_MON_POS 19
70+ #define AD7173_AIN_POW_MON_NEG 20
71+ #define AD7173_AIN_REF_POS 21
72+ #define AD7173_AIN_REF_NEG 22
73+
74+ #define AD7173_IS_REF_INPUT (x ) ((x) == AD7173_AIN_REF_POS || \
75+ (x) == AD7173_AIN_REF_NEG)
6976
7077#define AD7172_2_ID 0x00d0
7178#define AD7175_ID 0x0cd0
@@ -146,6 +153,8 @@ struct ad7173_device_info {
146153 unsigned int id ;
147154 char * name ;
148155 bool has_temp ;
156+ /* ((AVDD1 − AVSS)/5) */
157+ bool has_pow_supply_monitoring ;
149158 bool has_input_buf ;
150159 bool has_int_ref ;
151160 bool has_ref2 ;
@@ -216,6 +225,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
216225 .has_temp = true,
217226 .has_input_buf = true,
218227 .has_int_ref = true,
228+ .has_pow_supply_monitoring = true,
219229 .clock = 2 * HZ_PER_MHZ ,
220230 .sinc5_data_rates = ad7173_sinc5_data_rates ,
221231 .num_sinc5_data_rates = ARRAY_SIZE (ad7173_sinc5_data_rates ),
@@ -230,6 +240,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
230240 .has_temp = false,
231241 .has_input_buf = true,
232242 .has_ref2 = true,
243+ .has_pow_supply_monitoring = true,
233244 .clock = 2 * HZ_PER_MHZ ,
234245 .sinc5_data_rates = ad7173_sinc5_data_rates ,
235246 .num_sinc5_data_rates = ARRAY_SIZE (ad7173_sinc5_data_rates ),
@@ -259,6 +270,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
259270 .has_temp = true,
260271 .has_input_buf = true,
261272 .has_int_ref = true,
273+ .has_pow_supply_monitoring = true,
262274 .clock = 16 * HZ_PER_MHZ ,
263275 .sinc5_data_rates = ad7175_sinc5_data_rates ,
264276 .num_sinc5_data_rates = ARRAY_SIZE (ad7175_sinc5_data_rates ),
@@ -274,6 +286,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
274286 .has_input_buf = true,
275287 .has_int_ref = true,
276288 .has_ref2 = true,
289+ .has_pow_supply_monitoring = true,
277290 .clock = 16 * HZ_PER_MHZ ,
278291 .sinc5_data_rates = ad7175_sinc5_data_rates ,
279292 .num_sinc5_data_rates = ARRAY_SIZE (ad7175_sinc5_data_rates ),
@@ -302,6 +315,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
302315 .has_temp = true,
303316 .has_input_buf = true,
304317 .has_int_ref = true,
318+ .has_pow_supply_monitoring = true,
305319 .clock = 16 * HZ_PER_MHZ ,
306320 .odr_start_value = AD7177_ODR_START_VALUE ,
307321 .sinc5_data_rates = ad7175_sinc5_data_rates ,
@@ -910,9 +924,18 @@ static int ad7173_validate_voltage_ain_inputs(struct ad7173_state *st,
910924 unsigned int ain0 , unsigned int ain1 )
911925{
912926 struct device * dev = & st -> sd .spi -> dev ;
927+ bool special_input0 , special_input1 ;
928+
929+ /* (AVDD1-AVSS)/5 power supply monitoring */
930+ if (ain0 == AD7173_AIN_POW_MON_POS && ain1 == AD7173_AIN_POW_MON_NEG &&
931+ st -> info -> has_pow_supply_monitoring )
932+ return 0 ;
933+
934+ special_input0 = AD7173_IS_REF_INPUT (ain0 );
935+ special_input1 = AD7173_IS_REF_INPUT (ain1 );
913936
914- if (ain0 >= st -> info -> num_inputs ||
915- ain1 >= st -> info -> num_inputs )
937+ if (( ain0 >= st -> info -> num_inputs && ! special_input0 ) ||
938+ ( ain1 >= st -> info -> num_inputs && ! special_input1 ) )
916939 return dev_err_probe (dev , - EINVAL ,
917940 "Input pin number out of range for pair (%d %d).\n" ,
918941 ain0 , ain1 );
0 commit comments