iio: imu: inv_icm42600: add support of accel low power
Subsystems (2)
v4 cover iio: imu: inv_icm42600: add support of accel low power
From: Jean-Baptiste Maneyrol <[email protected]>
Add accel low power support, enabling use of lower ODR below 12.5Hz.
Add new sysfs API for controlling the power mode and enforce power mode used when using an ODR that supports only 1 mode (ODR < 12.5Hz or ODR > 500Hz).
Changelog
V2:
- fix patch missing Signed-off tag
V3:
- make all ODRs available and switch power mode automatically for ODR supporting only 1 mode.
V4:
- prevent power mode setting when the ODR is not supported
- return the actual power mode when sensor is on, otherwise the requested one.
- add sysfs ABI documentation
Jean-Baptiste Maneyrol (1):
iio: imu: inv_icm42600: add support of accel low-power mode
drivers/iio/imu/inv_icm42600/inv_icm42600.h | 4 + .../iio/imu/inv_icm42600/inv_icm42600_accel.c | 124 +++++++++++++++++- .../iio/imu/inv_icm42600/inv_icm42600_core.c | 27 ++++ 3 files changed, 151 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
PATCH v4 1/2 iio: document inv_icm42600 driver private sysfs attributes
From: Jean-Baptiste Maneyrol <[email protected]>
Add ABI documentation for inv_icm42600 private sysfs attributes.
--- .../ABI/testing/sysfs-bus-iio-inv_icm42600 | 18 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 19 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-inv_icm42600
Documentation/ABI/testing/sysfs-bus-iio-inv_icm42600 new file +18 -0
@@ -0,0 +1,18 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_accel_power_mode +KernelVersion: 6.11 +Contact: [email protected] +Description: + Accelerometer power mode. Setting this attribute will set the + requested power mode to use if the ODR support it. If ODR + support only 1 mode, power mode will be enforced. + Reading this attribute will return the current accelerometer + power mode if the sensor is on, or the requested value if the + sensor is off. The value between real and requested value can + be different for ODR supporting only 1 mode. + +What: /sys/bus/iio/devices/iio:deviceX/in_accel_power_mode_available +KernelVersion: 6.11 +Contact: [email protected] +Description: + List of available accelerometer power modes that can be set in + in_accel_power_mode attribute.
MAINTAINERS +1 -0
@@ -11336,6 +11336,7 @@ M: Jean-Baptiste Maneyrol <[email protected]> L: [email protected] S: Maintained W: https://invensense.tdk.com/ +F: Documentation/ABI/testing/sysfs-bus-iio-inv_icm42600 F: Documentation/devicetree/bindings/iio/imu/invensense,icm42600.yaml F: drivers/iio/imu/inv_icm42600/
Signature · 1 line
2.34.1
PATCH v4 2/2 iio: imu: inv_icm42600: add support of accel low-power mode
In reply to [email protected]From: Jean-Baptiste Maneyrol <[email protected]>
Add ODRs accessible only in low-power mode. Switch automatically to low-power or low-noise depending on the ODR set.
Add channel attributes "power_mode" and "power_mode_available" for setting the power mode to use (low-noise or low-power) for ODRs supporting both mode. Reading "power_mode" when the sensor is on will return the actual mode and not the requested one. It will be different when using ODRs not supported by the requested mode.
Use low-power mode by default.
--- drivers/iio/imu/inv_icm42600/inv_icm42600.h | 4 + .../iio/imu/inv_icm42600/inv_icm42600_accel.c | 124 +++++++++++++++++- .../iio/imu/inv_icm42600/inv_icm42600_core.c | 27 ++++ 3 files changed, 151 insertions(+), 4 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600.h +4 -0
@@ -177,11 +177,15 @@ struct inv_icm42600_state {* struct inv_icm42600_sensor_state - sensor state variables * @scales: table of scales. * @scales_len: length (nb of items) of the scales table. +* @power_mode: sensor requested power mode (for common frequencies) +* @filter: sensor filter. * @ts: timestamp module states. */ struct inv_icm42600_sensor_state {const int *scales;size_t scales_len; +enum inv_icm42600_sensor_mode power_mode; +enum inv_icm42600_filter filter;struct inv_sensors_timestamp ts; };
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +120 -4
177 lines not on this page · raw message
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c +27 -0
@@ -248,6 +248,23 @@ int inv_icm42600_set_accel_conf(struct inv_icm42600_state *st,if (conf->filter <0 ) conf->filter = oldconf->filter; +/* force power mode against ODR when sensor is on */ +switch (conf->mode) { +case INV_ICM42600_SENSOR_MODE_LOW_POWER : +case INV_ICM42600_SENSOR_MODE_LOW_NOISE : +if (conf->odr <=INV_ICM42600_ODR_1KHZ_LN ) { + conf->mode =INV_ICM42600_SENSOR_MODE_LOW_NOISE ; + conf->filter =INV_ICM42600_FILTER_BW_ODR_DIV_2 ; + }else if (conf->odr >=INV_ICM42600_ODR_6_25HZ_LP && + conf->odr <=INV_ICM42600_ODR_1_5625HZ_LP ) { + conf->mode =INV_ICM42600_SENSOR_MODE_LOW_POWER ; + conf->filter =INV_ICM42600_FILTER_AVG_16X ; + } +break ; +default : +break ; + } +/* set ACCEL_CONFIG0 register (accel fullscale & odr) */ if (conf->fs != oldconf->fs || conf->odr != oldconf->odr) { val = INV_ICM42600_ACCEL_CONFIG0_FS(conf->fs) |
@@ -441,6 +458,16 @@ static int inv_icm42600_setup(struct inv_icm42600_state *st,if (ret)return ret; +/* +* Use RC clock for accel low-power to fix glitches when switching +* gyro on/off while accel low-power is on. +*/ + ret =regmap_update_bits (st->map,INV_ICM42600_REG_INTF_CONFIG1 , +INV_ICM42600_INTF_CONFIG1_ACCEL_LP_CLK_RC , +INV_ICM42600_INTF_CONFIG1_ACCEL_LP_CLK_RC ); +if (ret) +return ret; +return inv_icm42600_set_conf (st, hw->conf); }
Signature · 1 line
2.34.1
Jonathan Cameron
maintainerQuoted 6 lines · On Wed, 5 Jun 2024 19:59:47 +0000 [email protected] wrote:
From: Jean-Baptiste Maneyrol <[email protected]>
Add accel low power support, enabling use of lower ODR below 12.5Hz.
Add new sysfs API for controlling the power mode and enforce power mode used when using an ODR that supports only 1 mode (ODR < 12.5Hz or ODR > 500Hz).
Applied to the togreg branch of iio.git and pushed out as testing for 0-day to poke at it.
Thanks,
Jonathan
Quoted 23 lines
Changelog
V2:
- fix patch missing Signed-off tagV3:
- make all ODRs available and switch power mode automatically for ODR supporting only 1 mode.V4:
- prevent power mode setting when the ODR is not supported
- return the actual power mode when sensor is on, otherwise the requested one.
- add sysfs ABI documentationJean-Baptiste Maneyrol (1):
iio: imu:inv_icm42600: add support of accel low-power modedrivers/iio/imu/inv_icm42600/inv_icm42600.h | 4 + .../iio/imu/inv_icm42600/inv_icm42600_accel.c | 124 +++++++++++++++++- .../iio/imu/inv_icm42600/inv_icm42600_core.c | 27 ++++ 3 files changed, 151 insertions(+), 4 deletions(-)
Jean-Baptiste Maneyrol
maintainerHi Jonathan,
I'm sorry I am not able to find this patch in togreg branch currently.
Am I not looking at the correct place or there is a problem somewhere?
Thanks,
JB
________________________________________
From: Jonathan Cameron <[email protected]>
Sent: Sunday, June 9, 2024 12:09
To: INV Git Commit <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Jean-Baptiste Maneyrol <[email protected]> Subject: Re: [PATCH v4 0/2] iio: imu: inv_icm42600: add support of accel low power
This Message Is From an External Sender
This message came from outside your organization.
Quoted 6 lines · On Wed, 5 Jun 2024 19:59:47 +0000 [email protected] wrote:
From: Jean-Baptiste Maneyrol <[email protected]>
Add accel low power support, enabling use of lower ODR below 12.5Hz.
Add new sysfs API for controlling the power mode and enforce power mode used when using an ODR that supports only 1 mode (ODR < 12.5Hz or ODR > 500Hz).
Applied to the togreg branch of iio.git and pushed out as testing for 0-day to poke at it.
Thanks,
Jonathan
Quoted 23 lines
Changelog
V2:
- fix patch missing Signed-off tagV3:
- make all ODRs available and switch power mode automatically for ODR supporting only 1 mode.V4:
- prevent power mode setting when the ODR is not supported
- return the actual power mode when sensor is on, otherwise the requested one.
- add sysfs ABI documentationJean-Baptiste Maneyrol (1):
iio: imu:inv_icm42600: add support of accel low-power modedrivers/iio/imu/inv_icm42600/inv_icm42600.h | 4 + .../iio/imu/inv_icm42600/inv_icm42600_accel.c | 124 +++++++++++++++++- .../iio/imu/inv_icm42600/inv_icm42600_core.c | 27 ++++ 3 files changed, 151 insertions(+), 4 deletions(-)
Jonathan Cameron
maintainerQuoted 5 lines · On Wed, 12 Jun 2024 12:28:50 +0000 Jean-Baptiste Maneyrol…
Hi Jonathan,
I'm sorry I am not able to find this patch in togreg branch currently.
Am I not looking at the correct place or there is a problem somewhere?
As so often happens I was being dozy at end of a reviewing session and failed to push out.
Done now.
Quoted 54 lines
Thanks,
JB________________________________________
From: Jonathan Cameron <[email protected]>
Sent: Sunday, June 9, 2024 12:09
To: INV Git Commit <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Jean-Baptiste Maneyrol <[email protected]> Subject: Re: [PATCH v4 0/2] iio: imu:inv_icm42600: add support of accel low power
This Message Is From an External Sender
This message came from outside your organization.Quoted 6 lines · On Wed, 5 Jun 2024 19:59:47 +0000 [email protected] wrote:
From: Jean-Baptiste Maneyrol <[email protected]>
Add accel low power support, enabling use of lower ODR below 12.5Hz.
Add new sysfs API for controlling the power mode and enforce power mode used when using an ODR that supports only 1 mode (ODR < 12.5Hz or ODR > 500Hz).
Applied to the togreg branch of iio.git and pushed out as testing for 0-day to poke at it.
Thanks,
Jonathan
Quoted 23 lines
Changelog
V2:
- fix patch missing Signed-off tagV3:
- make all ODRs available and switch power mode automatically for ODR supporting only 1 mode.V4:
- prevent power mode setting when the ODR is not supported
- return the actual power mode when sensor is on, otherwise the requested one.
- add sysfs ABI documentationJean-Baptiste Maneyrol (1):
iio: imu:inv_icm42600: add support of accel low-power modedrivers/iio/imu/inv_icm42600/inv_icm42600.h | 4 + .../iio/imu/inv_icm42600/inv_icm42600_accel.c | 124 +++++++++++++++++- .../iio/imu/inv_icm42600/inv_icm42600_core.c | 27 ++++ 3 files changed, 151 insertions(+), 4 deletions(-)