From 56b435f2bfb211263e9ba297cb5cd3d0472820e4 Mon Sep 17 00:00:00 2001 From: Armando Visconti Date: Mon, 13 Dec 2021 18:05:14 +0100 Subject: [PATCH] drivers/sensor: lps22hh: Move odr Kconfig property into dts Move odr options from Kconfigs to Device Tree. Signed-off-by: Armando Visconti --- drivers/sensor/lps22hh/Kconfig | 20 -------------------- drivers/sensor/lps22hh/lps22hh.c | 8 ++++++-- drivers/sensor/lps22hh/lps22hh.h | 1 + dts/bindings/sensor/st,lps22hh-common.yaml | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/sensor/lps22hh/Kconfig b/drivers/sensor/lps22hh/Kconfig index 2771ec59db1..364b2cbdc37 100644 --- a/drivers/sensor/lps22hh/Kconfig +++ b/drivers/sensor/lps22hh/Kconfig @@ -52,24 +52,4 @@ config LPS22HH_THREAD_STACK_SIZE help Stack size of thread used by the driver to handle interrupts. -menu "Attributes" - -config LPS22HH_SAMPLING_RATE - int "Output data rate" - range 0 7 - default 0 - help - Sensor output data rate expressed in samples per second. - Data rates supported by the chip are: - 0: ODR selected at runtime - 1: 1Hz - 2: 10Hz - 3: 25Hz - 4: 50Hz - 5: 75Hz - 6: 100Hz - 7: 200Hz - -endmenu - endif # LPS22HH diff --git a/drivers/sensor/lps22hh/lps22hh.c b/drivers/sensor/lps22hh/lps22hh.c index 63945cbe81e..4d3bf172a83 100644 --- a/drivers/sensor/lps22hh/lps22hh.c +++ b/drivers/sensor/lps22hh/lps22hh.c @@ -171,9 +171,11 @@ static int lps22hh_init_chip(const struct device *dev) LOG_DBG("%s: chip id 0x%x", dev->name, chip_id); - ret = lps22hh_set_odr_raw(dev, CONFIG_LPS22HH_SAMPLING_RATE); + /* set sensor default odr */ + LOG_DBG("%s: odr: %d", dev->name, cfg->odr); + ret = lps22hh_set_odr_raw(dev, cfg->odr); if (ret < 0) { - LOG_ERR("%s: Failed to set sampling rate", dev->name); + LOG_ERR("%s: Failed to set odr %d", dev->name, cfg->odr); return ret; } @@ -237,6 +239,7 @@ static int lps22hh_init(const struct device *dev) LPS22HH_SPI_OPERATION, \ 0), \ }, \ + .odr = DT_INST_PROP(inst, odr), \ COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, drdy_gpios), \ (LPS22HH_CFG_IRQ(inst)), ()) \ } @@ -258,6 +261,7 @@ static int lps22hh_init(const struct device *dev) .stmemsc_cfg = { \ .i2c = I2C_DT_SPEC_INST_GET(inst), \ }, \ + .odr = DT_INST_PROP(inst, odr), \ COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, drdy_gpios), \ (LPS22HH_CFG_IRQ(inst)), ()) \ } diff --git a/drivers/sensor/lps22hh/lps22hh.h b/drivers/sensor/lps22hh/lps22hh.h index 8ab85c7c772..4701eb03d28 100644 --- a/drivers/sensor/lps22hh/lps22hh.h +++ b/drivers/sensor/lps22hh/lps22hh.h @@ -33,6 +33,7 @@ struct lps22hh_config { const struct spi_dt_spec spi; #endif } stmemsc_cfg; + uint8_t odr; #ifdef CONFIG_LPS22HH_TRIGGER struct gpio_dt_spec gpio_int; #endif diff --git a/dts/bindings/sensor/st,lps22hh-common.yaml b/dts/bindings/sensor/st,lps22hh-common.yaml index 50f01a808b5..9eee9c0f98b 100644 --- a/dts/bindings/sensor/st,lps22hh-common.yaml +++ b/dts/bindings/sensor/st,lps22hh-common.yaml @@ -11,3 +11,20 @@ properties: This pin defaults to active high when produced by the sensor. The property value should ensure the flags properly describe the signal that is presented to the driver. + + odr: + type: int + required: false + default: 0 + description: | + Specify the default output data rate expressed in samples per second (Hz). + Default is power-down mode + enum: + - 0 # Power-Down + - 1 # 1Hz + - 2 # 10Hz + - 3 # 25Hz + - 4 # 50Hz + - 5 # 75Hz + - 6 # 100Hz + - 7 # 200Hz