Skip to content

Commit

Permalink
drivers: si7006: add support for vin supply
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
yishai1999 committed Jan 19, 2025
1 parent c9e4d83 commit 55de925
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions boards/silabs/radio_boards/xg23_rb4210a/xg23_rb4210a.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -125,6 +133,7 @@
si7021: si7021@40 {
compatible = "silabs,si7006";
reg = <0x40>;
vin-supply = <&sensor_disp_enable>;
status = "okay";
};
};
Expand Down
1 change: 1 addition & 0 deletions drivers/sensor/silabs/si7006/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion drivers/sensor/silabs/si7006/si7006.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include <zephyr/device.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/regulator.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/__assert.h>
#include <zephyr/drivers/i2c.h>
#include <stdio.h>
#include <stdlib.h>
#include <zephyr/sys/util.h>
Expand All @@ -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;
};
Expand Down Expand Up @@ -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;
Expand All @@ -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, \
}; \
\
Expand Down
1 change: 1 addition & 0 deletions tests/drivers/build_all/eeprom/boards/xg23_rb4210a.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_REGULATOR_FIXED_INIT_PRIORITY=55

0 comments on commit 55de925

Please sign in to comment.