Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions drivers/adc/adc_ad7124.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,14 @@
#define AD7124_ADC_CTRL_REG_MODE_MSK GENMASK(5, 2)

/* IO Control 1 register bits */
#define AD7124_IO_CONTROL_1_REG_PDSW_EN BIT(15)
#define AD7124_IOUT1_CURRENT_MSK GENMASK(13, 11)
#define AD7124_IOUT0_CURRENT_MSK GENMASK(10, 8)
#define AD7124_IOUT1_CHANNEL_MSK GENMASK(7, 4)
#define AD7124_IOUT0_CHANNEL_MSK GENMASK(3, 0)
#define AD7124_IOUT_MSK \
(AD7124_IOUT1_CURRENT_MSK | AD7124_IOUT0_CURRENT_MSK | AD7124_IOUT1_CHANNEL_MSK | \
AD7124_IOUT0_CHANNEL_MSK)
(AD7124_IO_CONTROL_1_REG_PDSW_EN, AD7124_IOUT1_CURRENT_MSK | AD7124_IOUT0_CURRENT_MSK | \

Check warning on line 128 in drivers/adc/adc_ad7124.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

drivers/adc/adc_ad7124.c:128 please, no space before tabs

Check warning on line 128 in drivers/adc/adc_ad7124.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

drivers/adc/adc_ad7124.c:128 line length of 116 exceeds 100 columns

Check warning on line 128 in drivers/adc/adc_ad7124.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

drivers/adc/adc_ad7124.c:128 please, no space before tabs

Check warning on line 128 in drivers/adc/adc_ad7124.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

drivers/adc/adc_ad7124.c:128 line length of 116 exceeds 100 columns
AD7124_IOUT1_CHANNEL_MSK | AD7124_IOUT0_CHANNEL_MSK)

/* Current source configuration bits */
#define AD7124_CURRENT_SOURCE_IOUT_MSK BIT(3)
Expand Down Expand Up @@ -264,6 +265,7 @@
enum ad7124_device_type active_device;
uint8_t resolution;
bool ref_en;
bool pdsw_en;
};

struct adc_ad7124_data {
Expand Down Expand Up @@ -710,6 +712,7 @@
int configuration_setup = 0;
int configuration_mask = 0;
int ref_internal = 0;
int pd_switch = 0;

if (cfg->props.bipolar) {
configuration_setup |= AD7124_CFG_REG_BIPOLAR;
Expand Down Expand Up @@ -737,6 +740,10 @@
ref_internal = AD7124_ADC_CTRL_REG_REF_EN;
}

if (config->pdsw_en) {
pd_switch = AD7124_IO_CONTROL_1_REG_PDSW_EN;
}

if (cfg->props.refsel == INTERNAL_REF) {
ret = adc_ad7124_reg_write_msk(dev, AD7124_ADC_CONTROL, AD7124_ADC_CONTROL_REG_LEN,
ref_internal, AD7124_ADC_CTRL_REG_REF_EN);
Expand All @@ -745,6 +752,12 @@
}
}

ret = adc_ad7124_reg_write_msk(dev, AD7124_IO_CONTROL_1, AD7124_IO_CONTROL_1_REG_LEN,
pd_switch, AD7124_IO_CONTROL_1_REG_PDSW_EN);
if (ret) {
return ret;
}

return 0;
}

Expand Down Expand Up @@ -1447,6 +1460,7 @@
.power_mode = DT_INST_PROP(inst, power_mode), \
.active_device = DT_INST_PROP(inst, active_device), \
.ref_en = DT_INST_PROP(inst, reference_enable), \
.pdsw_en = DT_INST_PROP(inst, pd_switch_enable), \

Check warning on line 1463 in drivers/adc/adc_ad7124.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

drivers/adc/adc_ad7124.c:1463 line length of 132 exceeds 100 columns

Check warning on line 1463 in drivers/adc/adc_ad7124.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

drivers/adc/adc_ad7124.c:1463 line length of 132 exceeds 100 columns
}; \
static struct adc_ad7124_data adc_ad7124_data##inst = { \
ADC_CONTEXT_INIT_LOCK(adc_ad7124_data##inst, ctx), \
Expand Down
11 changes: 11 additions & 0 deletions dts/bindings/adc/adi,ad7124-adc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ properties:
- true: Enable internal reference
- false: Disable internal reference

pd-switch-enable:
type: boolean
default: false
description: |
Enable internal low side power switch for AD7124
- true: The switch is in the open position
- false: The switched is in the closed position
The default configuration places the switch in the
closed position for control setup upon power-up
or after reset.

filter-type-mask:
type: int
default: 0
Expand Down
Loading