From a783a062f84c3a8da3c435a8c7737b9c0692529a Mon Sep 17 00:00:00 2001 From: Armando Visconti Date: Mon, 31 May 2021 16:42:40 +0200 Subject: [PATCH] drivers/sensor: lis2dw12: Move power Kconfig property into dts Move lis2dw12 power-mode option from Kconfigs to Device Tree. Signed-off-by: Armando Visconti --- drivers/sensor/lis2dw12/Kconfig | 12 ------------ drivers/sensor/lis2dw12/lis2dw12.c | 5 +++-- dts/bindings/sensor/st,lis2dw12-common.yaml | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/sensor/lis2dw12/Kconfig b/drivers/sensor/lis2dw12/Kconfig index 0fa3f402346..6db6c8bcabd 100644 --- a/drivers/sensor/lis2dw12/Kconfig +++ b/drivers/sensor/lis2dw12/Kconfig @@ -115,16 +115,4 @@ config LIS2DW12_ODR_1600 endchoice -config LIS2DW12_POWER_MODE - int "Sensor Power Modes" - range 0 4 - default 0 - help - Specify the sensor power mode - 0: Low Power M1 - 1: Low Power M2 - 2: Low Power M3 - 3: Low Power M4 - 4: High Performance - endif # LIS2DW12 diff --git a/drivers/sensor/lis2dw12/lis2dw12.c b/drivers/sensor/lis2dw12/lis2dw12.c index 7ec16cc3f3b..f2868659360 100644 --- a/drivers/sensor/lis2dw12/lis2dw12.c +++ b/drivers/sensor/lis2dw12/lis2dw12.c @@ -288,7 +288,8 @@ static int lis2dw12_init(const struct device *dev) } /* set power mode */ - if (lis2dw12_set_power_mode(lis2dw12, CONFIG_LIS2DW12_POWER_MODE)) { + LOG_DBG("power-mode is %d", cfg->pm); + if (lis2dw12_set_power_mode(lis2dw12, cfg->pm)) { return -EIO; } @@ -318,7 +319,7 @@ static int lis2dw12_init(const struct device *dev) const struct lis2dw12_device_config lis2dw12_cfg = { .bus_name = DT_INST_BUS_LABEL(0), - .pm = CONFIG_LIS2DW12_POWER_MODE, + .pm = DT_INST_PROP(0, power_mode), #ifdef CONFIG_LIS2DW12_TRIGGER .gpio_int = GPIO_DT_SPEC_INST_GET_OR(0, irq_gpios, {0}), .int_pin = DT_INST_PROP(0, int_pin), diff --git a/dts/bindings/sensor/st,lis2dw12-common.yaml b/dts/bindings/sensor/st,lis2dw12-common.yaml index 5f73a51b38a..90a00a102bf 100644 --- a/dts/bindings/sensor/st,lis2dw12-common.yaml +++ b/dts/bindings/sensor/st,lis2dw12-common.yaml @@ -30,6 +30,26 @@ properties: mandatory and if not present it defaults to 1 which is the configuration at power-up. + power-mode: + type: int + required: false + default: 0 + description: | + Specify the sensor power mode. Default is power-up configuration. + + 0 # Low Power M1 + 1 # Low Power M2 + 2 # Low Power M3 + 3 # Low Power M4 + 4 # High Performance + + enum: + - 0 + - 1 + - 2 + - 3 + - 4 + # tap and tap-tap configuration section # All default values are selected to match the power-up values. # tap and tap-tap events can be generated on INT1 only.