From 55de925c81757f33c6d5258d9f4737efca18a6cf Mon Sep 17 00:00:00 2001 From: Yishai Jaffe Date: Wed, 1 Jan 2025 18:21:58 +0200 Subject: [PATCH] drivers: si7006: add support for vin supply Added support for vin supply which seems to be needed for the radio boards in order to power on the sensor. Signed-off-by: Yishai Jaffe --- boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts | 9 +++++++++ drivers/sensor/silabs/si7006/Kconfig | 1 + drivers/sensor/silabs/si7006/si7006.c | 9 ++++++++- tests/drivers/build_all/eeprom/boards/xg23_rb4210a.conf | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/drivers/build_all/eeprom/boards/xg23_rb4210a.conf diff --git a/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts b/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts index 56f4a5760fdd04..1b848846c4fc7e 100644 --- a/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts +++ b/boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts @@ -58,6 +58,14 @@ }; }; + sensor_disp_enable: sensor_disp_enable { + compatible = "regulator-fixed"; + regulator-name = "sensor_disp_enable"; + enable-gpios = <&gpioc 9 GPIO_ACTIVE_HIGH>; + /* As stated by the Si7006 spec - Maximum powerup time is 80ms */ + startup-delay-us = <80000>; + status = "okay"; + }; }; &cpu0 { @@ -125,6 +133,7 @@ si7021: si7021@40 { compatible = "silabs,si7006"; reg = <0x40>; + vin-supply = <&sensor_disp_enable>; status = "okay"; }; }; diff --git a/drivers/sensor/silabs/si7006/Kconfig b/drivers/sensor/silabs/si7006/Kconfig index 37872744bdd561..33b2a95b9a078b 100644 --- a/drivers/sensor/silabs/si7006/Kconfig +++ b/drivers/sensor/silabs/si7006/Kconfig @@ -6,6 +6,7 @@ config SI7006 default y depends on DT_HAS_SILABS_SI7006_ENABLED || DT_HAS_SENSIRION_SHT21_ENABLED select I2C + select REGULATOR if $(dt_compat_any_has_prop,$(DT_COMPAT_SILABS_SI7006),vin-supply) help Enable I2C-based driver for several humidity and temperature sensors compatible with the Sensirion SHT21, such as the Silicon Labs diff --git a/drivers/sensor/silabs/si7006/si7006.c b/drivers/sensor/silabs/si7006/si7006.c index bbfe67df49af36..7a3c03d814ea73 100644 --- a/drivers/sensor/silabs/si7006/si7006.c +++ b/drivers/sensor/silabs/si7006/si7006.c @@ -7,11 +7,11 @@ #include #include +#include #include #include #include #include -#include #include #include #include @@ -27,6 +27,7 @@ struct si7006_data { struct si7006_config { struct i2c_dt_spec i2c; + const struct device *vin_supply; /** Use "read temp" vs "read old temp" command, the latter only with SiLabs sensors. */ uint8_t read_temp_cmd; }; @@ -192,6 +193,10 @@ static int si7006_init(const struct device *dev) return -ENODEV; } + if (IS_ENABLED(CONFIG_REGULATOR) && config->vin_supply) { + regulator_enable(config->vin_supply); + } + LOG_DBG("si7006 init ok"); return 0; @@ -202,6 +207,8 @@ static int si7006_init(const struct device *dev) \ static const struct si7006_config si7006_config_##name##_##inst = { \ .i2c = I2C_DT_SPEC_INST_GET(inst), \ + .vin_supply = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(DT_DRV_INST(inst), \ + vin_supply)), \ .read_temp_cmd = temp_cmd, \ }; \ \ diff --git a/tests/drivers/build_all/eeprom/boards/xg23_rb4210a.conf b/tests/drivers/build_all/eeprom/boards/xg23_rb4210a.conf new file mode 100644 index 00000000000000..49603736d45dc3 --- /dev/null +++ b/tests/drivers/build_all/eeprom/boards/xg23_rb4210a.conf @@ -0,0 +1 @@ +CONFIG_REGULATOR_FIXED_INIT_PRIORITY=55