drivers: sensor: sensirion: shtcx: remove chip property

Removes the dts "chip" property, the compatible should be used instead.

Any existing dts should be converted from something like:

test_i2c_shtc3: shtc3@70 {
	compatible = "sensirion,shtcx";
	reg = <0x70>;
	chip = "shtc3";
	measure-mode = "normal";
	clock-stretching;
};

to something like:

test_i2c_shtc3: shtc3@70 {
	compatible = "sensirion,shtc3", "sensirion,shtcx";
	reg = <0x70>;
	measure-mode = "normal";
	clock-stretching;
};

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
This commit is contained in:
Thomas Stranger 2024-04-28 14:11:39 +02:00 committed by Johan Hedberg
commit 34cac05775
3 changed files with 31 additions and 16 deletions

View file

@ -237,10 +237,13 @@ static int shtcx_init(const struct device *dev)
return 0; return 0;
} }
#define SHTCX_CHIP(inst) \
(DT_INST_NODE_HAS_COMPAT(inst, sensirion_shtc1) ? CHIP_SHTC1 : CHIP_SHTC3)
#define SHTCX_CONFIG(inst) \ #define SHTCX_CONFIG(inst) \
{ \ { \
.i2c = I2C_DT_SPEC_INST_GET(inst), \ .i2c = I2C_DT_SPEC_INST_GET(inst), \
.chip = DT_INST_ENUM_IDX(inst, chip), \ .chip = SHTCX_CHIP(inst), \
.measure_mode = DT_INST_ENUM_IDX(inst, measure_mode), \ .measure_mode = DT_INST_ENUM_IDX(inst, measure_mode), \
.clock_stretching = DT_INST_PROP(inst, clock_stretching) \ .clock_stretching = DT_INST_PROP(inst, clock_stretching) \
} }

View file

@ -1,24 +1,30 @@
# Copyright (c) 2021, Thomas Stranger # Copyright (c) 2021, Thomas Stranger
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
description: Sensirion SHTCx humidity and temperature sensor description: |
Sensirion SHTCx humidity and temperature sensor
Additionally use "sensirion,shtc1" or "sensirion,shtc3" compatibles
such that a generic driver can consider chip specific behaviour.
Example device tree node describing a Sensirion SHTC3 Sensor on the i2c0 bus:
&i2c0 {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
shtc3@70 {
compatible = "sensirion,shtc3", "sensirion,shtcx";
reg = <0x70>;
measure-mode = "normal";
clock-stretching;
};
};
compatible: "sensirion,shtcx" compatible: "sensirion,shtcx"
include: [sensor-device.yaml, i2c-device.yaml] include: [sensor-device.yaml, i2c-device.yaml]
properties: properties:
chip:
type: string
required: true
description: |
Specifies which chip exactly is used. This is necessary to get exact
timing information and supported command set.
SHTC3 has an additional sleep mode that is entered between measurements.
enum:
- "shtc1"
- "shtc3"
measure-mode: measure-mode:
type: string type: string
required: true required: true

View file

@ -231,10 +231,9 @@ test_i2c_sht4xd: sht4x@20 {
repeatability = <2>; repeatability = <2>;
}; };
test_i2c_shtc3: SHTC3@21 { test_i2c_shtc3: shtc3@21 {
compatible = "sensirion,shtcx"; compatible = "sensirion,shtc3", "sensirion,shtcx";
reg = <0x21>; reg = <0x21>;
chip = "shtc3";
measure-mode = "normal"; measure-mode = "normal";
clock-stretching; clock-stretching;
}; };
@ -1049,3 +1048,10 @@ test_i2c_ina226: ina226@8d {
current-lsb-microamps = <5000>; current-lsb-microamps = <5000>;
rshunt-micro-ohms = <500>; rshunt-micro-ohms = <500>;
}; };
test_i2c_shtc1: shtc1@8e {
compatible = "sensirion,shtc1", "sensirion,shtcx";
reg = <0x8e>;
measure-mode = "low-power";
clock-stretching;
};