Skip to content

Commit c7ac447

Browse files
macromorganjic23
authored andcommitted
iio: adc: axp20x_adc: Add adc_en1 and adc_en2 to axp_data
Add the register for adc_en1 and adc_en2 to the axp_data struct. This allows us to specify a different register to enable the adc channels for different devices such as the AXP717. Acked-by: Jonathan Cameron <[email protected]> Signed-off-by: Chris Morgan <[email protected]> Acked-by: Krzysztof Kozlowski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent d1360cc commit c7ac447

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

drivers/iio/adc/axp20x_adc.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,9 @@ struct axp_data {
889889
const struct iio_info *iio_info;
890890
int num_channels;
891891
struct iio_chan_spec const *channels;
892+
unsigned long adc_en1;
892893
unsigned long adc_en1_mask;
894+
unsigned long adc_en2;
893895
unsigned long adc_en2_mask;
894896
int (*adc_rate)(struct axp20x_adc_iio *info,
895897
int rate);
@@ -910,7 +912,9 @@ static const struct axp_data axp20x_data = {
910912
.iio_info = &axp20x_adc_iio_info,
911913
.num_channels = ARRAY_SIZE(axp20x_adc_channels),
912914
.channels = axp20x_adc_channels,
915+
.adc_en1 = AXP20X_ADC_EN1,
913916
.adc_en1_mask = AXP20X_ADC_EN1_MASK,
917+
.adc_en2 = AXP20X_ADC_EN2,
914918
.adc_en2_mask = AXP20X_ADC_EN2_MASK,
915919
.adc_rate = axp20x_adc_rate,
916920
.maps = axp20x_maps,
@@ -920,6 +924,7 @@ static const struct axp_data axp22x_data = {
920924
.iio_info = &axp22x_adc_iio_info,
921925
.num_channels = ARRAY_SIZE(axp22x_adc_channels),
922926
.channels = axp22x_adc_channels,
927+
.adc_en1 = AXP20X_ADC_EN1,
923928
.adc_en1_mask = AXP22X_ADC_EN1_MASK,
924929
.adc_rate = axp22x_adc_rate,
925930
.maps = axp22x_maps,
@@ -929,6 +934,7 @@ static const struct axp_data axp813_data = {
929934
.iio_info = &axp813_adc_iio_info,
930935
.num_channels = ARRAY_SIZE(axp813_adc_channels),
931936
.channels = axp813_adc_channels,
937+
.adc_en1 = AXP20X_ADC_EN1,
932938
.adc_en1_mask = AXP22X_ADC_EN1_MASK,
933939
.adc_rate = axp813_adc_rate,
934940
.maps = axp22x_maps,
@@ -988,14 +994,16 @@ static int axp20x_probe(struct platform_device *pdev)
988994
indio_dev->channels = info->data->channels;
989995

990996
/* Enable the ADCs on IP */
991-
regmap_write(info->regmap, AXP20X_ADC_EN1, info->data->adc_en1_mask);
997+
regmap_write(info->regmap, info->data->adc_en1,
998+
info->data->adc_en1_mask);
992999

9931000
if (info->data->adc_en2_mask)
994-
regmap_set_bits(info->regmap, AXP20X_ADC_EN2,
1001+
regmap_set_bits(info->regmap, info->data->adc_en2,
9951002
info->data->adc_en2_mask);
9961003

9971004
/* Configure ADCs rate */
998-
info->data->adc_rate(info, 100);
1005+
if (info->data->adc_rate)
1006+
info->data->adc_rate(info, 100);
9991007

10001008
ret = iio_map_array_register(indio_dev, info->data->maps);
10011009
if (ret < 0) {
@@ -1015,10 +1023,10 @@ static int axp20x_probe(struct platform_device *pdev)
10151023
iio_map_array_unregister(indio_dev);
10161024

10171025
fail_map:
1018-
regmap_write(info->regmap, AXP20X_ADC_EN1, 0);
1026+
regmap_write(info->regmap, info->data->adc_en1, 0);
10191027

10201028
if (info->data->adc_en2_mask)
1021-
regmap_write(info->regmap, AXP20X_ADC_EN2, 0);
1029+
regmap_write(info->regmap, info->data->adc_en2, 0);
10221030

10231031
return ret;
10241032
}
@@ -1031,10 +1039,10 @@ static void axp20x_remove(struct platform_device *pdev)
10311039
iio_device_unregister(indio_dev);
10321040
iio_map_array_unregister(indio_dev);
10331041

1034-
regmap_write(info->regmap, AXP20X_ADC_EN1, 0);
1042+
regmap_write(info->regmap, info->data->adc_en1, 0);
10351043

10361044
if (info->data->adc_en2_mask)
1037-
regmap_write(info->regmap, AXP20X_ADC_EN2, 0);
1045+
regmap_write(info->regmap, info->data->adc_en2, 0);
10381046
}
10391047

10401048
static struct platform_driver axp20x_adc_driver = {

0 commit comments

Comments
 (0)