Skip to content

Commit 512f9fc

Browse files
machschmittnunojsa
authored andcommitted
iio: adc: ad4630: Add output mode for ADAQ4216 and ADAQ4220
The IIO channels are defined according to the output mode and for each output mode the precision bits is set statically in the output mode struct. Due to static assignment of channel precision bits in output mode structs, new output mode structs need to be declared for devices that have different amount of precision bits. Maybe we can have less code duplication if the precision bits for each ADC can be retrieved (maybe from devicetree?, static table?) then used for output mode declaration. For now, add output mode structs for ADAQ4216 and ADAQ4220 which are equal to ADAQ4224 except for they have different precision and don't have 24-bit + 8-bit common mode. Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
1 parent e2d82b9 commit 512f9fc

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

drivers/iio/adc/ad4630.c

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,48 @@ static const struct ad4630_out_mode ad4630_24_modes[] = {
893893
}
894894
};
895895

896+
static const struct ad4630_out_mode adaq4216_modes[] = {
897+
[AD4630_16_DIFF] = {
898+
.channels = {
899+
AD4630_CHAN(0, BIT(IIO_CHAN_INFO_SCALE), 64, 16, 0, NULL),
900+
},
901+
.data_width = 16,
902+
},
903+
[AD4630_16_DIFF_8_COM] = {
904+
.channels = {
905+
AD4630_CHAN(0, BIT(IIO_CHAN_INFO_SCALE), 64, 16, 8, NULL),
906+
},
907+
.data_width = 24,
908+
},
909+
[AD4630_30_AVERAGED_DIFF] = {
910+
.channels = {
911+
AD4630_CHAN(0, BIT(IIO_CHAN_INFO_SCALE), 64, 30, 2, ad4630_ext_info),
912+
},
913+
.data_width = 32,
914+
}
915+
};
916+
917+
static const struct ad4630_out_mode adaq4220_modes[] = {
918+
[AD4630_16_DIFF] = {
919+
.channels = {
920+
AD4630_CHAN(0, BIT(IIO_CHAN_INFO_SCALE), 64, 20, 0, NULL),
921+
},
922+
.data_width = 20,
923+
},
924+
[AD4630_16_DIFF_8_COM] = {
925+
.channels = {
926+
AD4630_CHAN(0, BIT(IIO_CHAN_INFO_SCALE), 64, 16, 8, NULL),
927+
},
928+
.data_width = 24,
929+
},
930+
[AD4630_30_AVERAGED_DIFF] = {
931+
.channels = {
932+
AD4630_CHAN(0, BIT(IIO_CHAN_INFO_SCALE), 64, 30, 2, ad4630_ext_info),
933+
},
934+
.data_width = 32,
935+
}
936+
};
937+
896938
static const struct ad4630_out_mode adaq4224_modes[] = {
897939
[AD4630_24_DIFF] = {
898940
.channels = {
@@ -1000,7 +1042,7 @@ static const struct ad4630_chip_info ad4630_chip_info[] = {
10001042
},
10011043
[ID_ADAQ4216] = {
10021044
.available_masks = ad4030_channel_masks,
1003-
.modes = adaq4224_modes,
1045+
.modes = adaq4216_modes,
10041046
.out_modes_mask = GENMASK(3, 0),
10051047
.name = "adaq4216",
10061048
.grade = 0x1E,
@@ -1012,7 +1054,7 @@ static const struct ad4630_chip_info ad4630_chip_info[] = {
10121054
},
10131055
[ID_ADAQ4220] = {
10141056
.available_masks = ad4030_channel_masks,
1015-
.modes = adaq4224_modes,
1057+
.modes = adaq4220_modes,
10161058
.out_modes_mask = GENMASK(3, 0),
10171059
.name = "adaq4220",
10181060
.grade = 0x1D,

0 commit comments

Comments
 (0)