dt-bindings: sensor: ina237: add configuration properties

Add properties to replace the configuration register values.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
This commit is contained in:
Eric Holmberg 2023-07-23 16:39:23 +12:00 committed by Maureen Helm
commit c7135a2ac5
5 changed files with 89 additions and 14 deletions

View file

@ -365,7 +365,12 @@ static const struct sensor_driver_api ina237_driver_api = {
static const struct ina237_config ina237_config_##inst = { \
.bus = I2C_DT_SPEC_INST_GET(inst), \
.config = DT_INST_PROP(inst, config), \
.adc_config = DT_INST_PROP(inst, adc_config), \
.adc_config = DT_INST_PROP(inst, adc_config) | \
(DT_INST_ENUM_IDX(inst, adc_mode) << 12) | \
(DT_INST_ENUM_IDX(inst, vbus_conversion_time_us) << 9) | \
(DT_INST_ENUM_IDX(inst, vshunt_conversion_time_us) << 6) | \
(DT_INST_ENUM_IDX(inst, temp_conversion_time_us) << 3) | \
DT_INST_ENUM_IDX(inst, avg_count), \
.current_lsb = DT_INST_PROP(inst, current_lsb_microamps), \
.cal = INA237_CAL_SCALING * DT_INST_PROP(inst, current_lsb_microamps) * \
DT_INST_PROP(inst, rshunt_micro_ohms) / 10000000000ULL, \

View file

@ -16,6 +16,16 @@ compatible: "ti,ina230"
include: ti,ina23x-common.yaml
properties:
config:
type: int
required: true
description: |
Value of the configuration register
e.g shunt voltage and bus voltage ADC conversion
times and averaging, operating mode for INA230 or
delay for initial ADC conversion, shunt full scale range
for INA237.
mask:
type: int
default: 0

View file

@ -15,13 +15,85 @@ compatible: "ti,ina237"
include: ti,ina23x-common.yaml
properties:
config:
type: int
deprecated: true
default: 0x0000
description: |
Value of the configuration register
e.g shunt voltage and bus voltage ADC conversion
times and averaging, operating mode for INA230 or
delay for initial ADC conversion, shunt full scale range
for INA237.
Deprecated, please use new properties instead.
adc-config:
type: int
required: true
deprecated: true
default: 0x0000
description: |
Value of the ADC configuration register (ADC conversion times,
averaging, operating mode and etc).
Deprecated, please use new properties instead.
alert-config:
type: int
description: Diag alert register, default matches the power-on reset value
adc-mode:
type: string
description: |
ADC channel conversion configuration.
Default is the power-on reset value.
default: "Temperature, bus, and shunt voltage continuous"
enum:
- "Shutdown single shot"
- "Bus Voltage single shot"
- "Shunt Voltage single shot"
- "Bus and Shunt Voltage single shot"
- "Temperature Single shot"
- "Temperature and bus voltage single shot"
- "Temperature and shunt voltage single shot"
- "Temperature, bus, and shunt voltage single shot"
- "Shutdown continuous"
- "Bus voltage continuous"
- "Shunt voltage continuous"
- "Bus and shunt voltage continuous"
- "Temperature continuous"
- "Temperature and bus voltage continuous"
- "Temperature and shunt voltage continuous"
- "Temperature, bus, and shunt voltage continuous"
vbus-conversion-time-us:
type: int
description: |
Vbus conversion time in microseconds.
Default is the power-on reset value.
default: 1052
enum: [50, 84, 150, 280, 540, 1052, 2074, 4120]
vshunt-conversion-time-us:
type: int
description: |
Vshunt conversion time in microseconds.
Default is the power-on reset value.
default: 1052
enum: [50, 84, 150, 280, 540, 1052, 2074, 4120]
temp-conversion-time-us:
type: int
description: |
Temperature conversion time in microseconds.
Default is the power-on reset value.
default: 1052
enum: [50, 84, 150, 280, 540, 1052, 2074, 4120]
avg-count:
type: int
description: |
Number of samples to average (applies to all inputs).
Default is the power-on reset value.
default: 1
enum: [1, 4, 16, 64, 128, 256, 512, 1024]

View file

@ -7,16 +7,6 @@
include: [sensor-device.yaml, i2c-device.yaml]
properties:
config:
type: int
required: true
description: |
Value of the configuration register
e.g shunt voltage and bus voltage ADC conversion
times and averaging, operating mode for INA230 or
delay for initial ADC conversion, shunt full scale range
for INA237.
current-lsb-microamps:
type: int
required: true

View file

@ -588,9 +588,7 @@ test_i2c_ina231: ina231@59 {
test_i2c_ina237: ina237@5a {
compatible = "ti,ina237";
reg = <0x5a>;
config = <0>;
current-lsb-microamps = <1000>;
adc-config = <0>;
rshunt-micro-ohms = <1000>;
alert-config = <0>;
alert-gpios = <&test_gpio 0 0>;