Skip to content

Conversation

@mniestroj
Copy link
Member

LIS3DH contains CTRL_REG0 (1Eh) register to control internal pull-up on
SDO/SA0 line (enabled by default). Add a helper
LIS2DH_HAS_SDO_SA0_PULL_UP macro, which is defined only when "st,lis3dh"
was passed to compatible list in device-tree. Based on that macro
disable internal pull-up registers, which consume around 180uA at 3.6V
in accelerometer power-down mode.

Signed-off-by: Marcin Niestroj [email protected]

@mniestroj mniestroj requested a review from avisconti as a code owner October 4, 2019 17:03
@mniestroj mniestroj force-pushed the lis2dh-pull-up-disable branch 2 times, most recently from 5424175 to fa97deb Compare October 4, 2019 17:06
@zephyrbot zephyrbot added the area: Sensors Sensors label Oct 4, 2019
@avisconti avisconti requested a review from MaureenHelm October 7, 2019 08:38
@pabigot pabigot self-requested a review October 17, 2019 13:44
Copy link
Contributor

@pabigot pabigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the commit that unconditionally builds the helper function.

As for the pull-up control we should be avoiding Kconfig as devicetree is the "way forward". For my suggested approach see below in context.

It would be nice to move the existing irq-gpios and proposed disconnect-sdo-sda0-pull-up into a new st,lis2dh-common.yaml file that is included by both the SPI and I2C variants.

Create a common binding file that will be included by all bindings
handled by lis2dh.c driver. For now this includes optional irq-gpios
property.

Use introduced st,lis2dh-common.yaml in st,lsm303dlhc-accel.yaml in
order to support defining irq-gpios.

Also improve description of st,lis2dh-i2c.yaml to better match what can
be found in st,lis2dh-spi.yaml.

Signed-off-by: Marcin Niestroj <[email protected]>
There is little reason to compile lis2dh_reg_field_update() function
conditionally, based on enabled features. If it is not used, then linker
will drop it anyway.

Signed-off-by: Marcin Niestroj <[email protected]>
@mniestroj mniestroj force-pushed the lis2dh-pull-up-disable branch from fa97deb to 3095b94 Compare October 28, 2019 14:34
@mniestroj
Copy link
Member Author

Based on the review comments I have introduced new device-tree property to disconnect SDO/SA0 pull-up when specified to be fully controlable by user. Hence previous logic based on compatible string has been dropped. Also a commit dts: bindings: lis2dh: create a common st,lis2dh-common.yaml has been cherry-picked from #20004 .

Copy link
Contributor

@pabigot pabigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using IS_ENABLED(M) is standard for Kconfig and devicetree macros that have 0 or 1 as their value. It also evaluates to syntactically acceptable content when the macro definition is absent, as with frdm_k64f on test_build_sensors_i_z where there is no define for any LIS2DH devicetree entries. I think you should put it back which should fix the build problems.

Some chips supported by lis2dh driver (such as LIS2DH12 and LIS3DH)
contain CTRL_REG0 (1Eh) register to control internal pull-up on SDO/SA0
line (enabled by default). Add disconnect-sdo-sa0-pull-up boolean
device-tree property to allow disconnecting pull-up during driver
initialization. This allows to save around 180uA at 3.6V in
accelerometer power-down mode.

Signed-off-by: Marcin Niestroj <[email protected]>
@mniestroj mniestroj force-pushed the lis2dh-pull-up-disable branch from 3095b94 to 5fe4844 Compare October 28, 2019 15:55
Copy link
Contributor

@avisconti avisconti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@galak galak merged commit afa5183 into zephyrproject-rtos:master Nov 5, 2019
@mniestroj mniestroj deleted the lis2dh-pull-up-disable branch August 12, 2020 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants