drivers/sensor: lsm6dso: Add power mode properties to DTS
Add power mode properties for bot accelerometer and gyrometer to Device Tree. Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
parent
18e8cadaf9
commit
34fed86b2b
3 changed files with 56 additions and 0 deletions
|
@ -744,6 +744,21 @@ static int lsm6dso_init_chip(const struct device *dev)
|
||||||
|
|
||||||
k_busy_wait(100);
|
k_busy_wait(100);
|
||||||
|
|
||||||
|
/* set accel power mode */
|
||||||
|
LOG_DBG("accel pm is %d", cfg->accel_pm);
|
||||||
|
switch (cfg->accel_pm) {
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
lsm6dso_xl_power_mode_set(ctx, LSM6DSO_HIGH_PERFORMANCE_MD);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
lsm6dso_xl_power_mode_set(ctx, LSM6DSO_LOW_NORMAL_POWER_MD);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
lsm6dso_xl_power_mode_set(ctx, LSM6DSO_ULTRA_LOW_POWER_MD);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
fs = cfg->accel_range;
|
fs = cfg->accel_range;
|
||||||
LOG_DBG("accel range is %d", fs);
|
LOG_DBG("accel range is %d", fs);
|
||||||
if (lsm6dso_accel_set_fs_raw(dev, fs) < 0) {
|
if (lsm6dso_accel_set_fs_raw(dev, fs) < 0) {
|
||||||
|
@ -760,6 +775,18 @@ static int lsm6dso_init_chip(const struct device *dev)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set gyro power mode */
|
||||||
|
LOG_DBG("gyro pm is %d", cfg->gyro_pm);
|
||||||
|
switch (cfg->gyro_pm) {
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
lsm6dso_gy_power_mode_set(ctx, LSM6DSO_GY_HIGH_PERFORMANCE);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
lsm6dso_gy_power_mode_set(ctx, LSM6DSO_GY_NORMAL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
fs = cfg->gyro_range;
|
fs = cfg->gyro_range;
|
||||||
LOG_DBG("gyro range is %d", fs);
|
LOG_DBG("gyro range is %d", fs);
|
||||||
if (lsm6dso_gyro_set_fs_raw(dev, fs) < 0) {
|
if (lsm6dso_gyro_set_fs_raw(dev, fs) < 0) {
|
||||||
|
@ -877,8 +904,10 @@ static int lsm6dso_init(const struct device *dev)
|
||||||
LSM6DSO_SPI_OP, \
|
LSM6DSO_SPI_OP, \
|
||||||
0), \
|
0), \
|
||||||
}, \
|
}, \
|
||||||
|
.accel_pm = DT_INST_PROP(inst, accel_pm), \
|
||||||
.accel_odr = DT_INST_PROP(inst, accel_odr), \
|
.accel_odr = DT_INST_PROP(inst, accel_odr), \
|
||||||
.accel_range = DT_INST_PROP(inst, accel_range), \
|
.accel_range = DT_INST_PROP(inst, accel_range), \
|
||||||
|
.gyro_pm = DT_INST_PROP(inst, gyro_pm), \
|
||||||
.gyro_odr = DT_INST_PROP(inst, gyro_odr), \
|
.gyro_odr = DT_INST_PROP(inst, gyro_odr), \
|
||||||
.gyro_range = DT_INST_PROP(inst, gyro_range), \
|
.gyro_range = DT_INST_PROP(inst, gyro_range), \
|
||||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
||||||
|
@ -902,8 +931,10 @@ static int lsm6dso_init(const struct device *dev)
|
||||||
.stmemsc_cfg = { \
|
.stmemsc_cfg = { \
|
||||||
.i2c = I2C_DT_SPEC_INST_GET(inst), \
|
.i2c = I2C_DT_SPEC_INST_GET(inst), \
|
||||||
}, \
|
}, \
|
||||||
|
.accel_pm = DT_INST_PROP(inst, accel_pm), \
|
||||||
.accel_odr = DT_INST_PROP(inst, accel_odr), \
|
.accel_odr = DT_INST_PROP(inst, accel_odr), \
|
||||||
.accel_range = DT_INST_PROP(inst, accel_range), \
|
.accel_range = DT_INST_PROP(inst, accel_range), \
|
||||||
|
.gyro_pm = DT_INST_PROP(inst, gyro_pm), \
|
||||||
.gyro_odr = DT_INST_PROP(inst, gyro_odr), \
|
.gyro_odr = DT_INST_PROP(inst, gyro_odr), \
|
||||||
.gyro_range = DT_INST_PROP(inst, gyro_range), \
|
.gyro_range = DT_INST_PROP(inst, gyro_range), \
|
||||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
||||||
|
|
|
@ -50,8 +50,10 @@ struct lsm6dso_config {
|
||||||
const struct spi_dt_spec spi;
|
const struct spi_dt_spec spi;
|
||||||
#endif
|
#endif
|
||||||
} stmemsc_cfg;
|
} stmemsc_cfg;
|
||||||
|
uint8_t accel_pm;
|
||||||
uint8_t accel_odr;
|
uint8_t accel_odr;
|
||||||
uint8_t accel_range;
|
uint8_t accel_range;
|
||||||
|
uint8_t gyro_pm;
|
||||||
uint8_t gyro_odr;
|
uint8_t gyro_odr;
|
||||||
uint8_t gyro_range;
|
uint8_t gyro_range;
|
||||||
#ifdef CONFIG_LSM6DSO_TRIGGER
|
#ifdef CONFIG_LSM6DSO_TRIGGER
|
||||||
|
|
|
@ -27,6 +27,18 @@ properties:
|
||||||
mandatory and if not present it defaults to 1 which is the
|
mandatory and if not present it defaults to 1 which is the
|
||||||
configuration at power-up.
|
configuration at power-up.
|
||||||
|
|
||||||
|
accel-pm:
|
||||||
|
type: int
|
||||||
|
required: false
|
||||||
|
default: 0
|
||||||
|
description: |
|
||||||
|
Specify the accelerometer power mode.
|
||||||
|
Default is power-up configuration.
|
||||||
|
enum:
|
||||||
|
- 0 # High Performance mode (default)
|
||||||
|
- 1 # Low/Normal Power mode
|
||||||
|
- 2 # Ultra Low Power mode
|
||||||
|
|
||||||
accel-range:
|
accel-range:
|
||||||
type: int
|
type: int
|
||||||
required: false
|
required: false
|
||||||
|
@ -59,6 +71,17 @@ properties:
|
||||||
- 9 # 3333Hz
|
- 9 # 3333Hz
|
||||||
- 10 # 6667Hz
|
- 10 # 6667Hz
|
||||||
|
|
||||||
|
gyro-pm:
|
||||||
|
type: int
|
||||||
|
required: false
|
||||||
|
default: 0
|
||||||
|
description: |
|
||||||
|
Specify the gyrometer power mode.
|
||||||
|
Default is power-up configuration.
|
||||||
|
enum:
|
||||||
|
- 0 # High Performance mode (default)
|
||||||
|
- 1 # Low/Normal Power mode
|
||||||
|
|
||||||
gyro-range:
|
gyro-range:
|
||||||
type: int
|
type: int
|
||||||
required: false
|
required: false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue