Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: sensor: Fix TMAG5273/TMAG3001 by adding a TMAG3001 compatible #79955

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

yiding
Copy link
Contributor

@yiding yiding commented Oct 16, 2024

TMAG5273 and TMAG3001 share much of the similar functionality.

The previous code attempted to detect whether TMAG5273 or TMAG3001 was connected based on DEVICE ID register. This doesn't work as the bits that denote the version on one part are undefined on the other part, and cannot be relied on to be zero.

This commit adds a TMAG3001 compatible which (for now) is just derived from the TMAG5273 compatible. This allows TMAG3001 to be specified directly in the DT. The driver code is updated to support both compatibles.

I thought about moving the common properties to a ti,tmagxxxx.yaml, however there's other parts (namely, tmag5170) which is SPI and have different properties, so I did not do this. We might still want to pull out some common properties, as TMAG5273 does have functionality that doesn't exist in TMAG3001, which currently can't be reflected in the device tree yaml.

Test plan

I tested this with TMAG5273, but do not have a TMAG3001. However, this code shouldn't change any of that functionality. I did try the tmag3001 compatible to see that it builds.

@yiding
Copy link
Contributor Author

yiding commented Oct 16, 2024

There's some whitespace changes in tmag5273.h file. Seems like clang-format changed tabs to spaces in alignment spaces for the defines. Not sure if that's expected or my clang-format is somehow misconfigured (it does use leading tabs for indentation).

@yiding yiding force-pushed the tmag3001-fix-compatible branch from 6dcfac1 to d2b91ef Compare October 17, 2024 00:02
@yiding yiding changed the title Fix TMAG5273/TMAG3001 by adding a TMAG3001 compatible drivers: sensor: Fix TMAG5273/TMAG3001 by adding a TMAG3001 compatible Oct 17, 2024
@yiding yiding force-pushed the tmag3001-fix-compatible branch from d2b91ef to 0740ae0 Compare October 17, 2024 00:09
@gumulka
Copy link
Contributor

gumulka commented Oct 17, 2024

There's some whitespace changes in tmag5273.h file. Seems like clang-format changed tabs to spaces in alignment spaces for the defines. Not sure if that's expected or my clang-format is somehow misconfigured (it does use leading tabs for indentation).

The file was previously not correctly formatted. But you should try to keep the old wrong formatting, so that the change is not that big and one can see what has changed in your commit. Maybe add a second pull request for the formatting.

But thanks for the pull request. It was on my plate for a long time and I never came around to actually doing it.

@yiding yiding force-pushed the tmag3001-fix-compatible branch from 0740ae0 to a3f0580 Compare October 17, 2024 20:30
@yiding
Copy link
Contributor Author

yiding commented Oct 17, 2024

Reverted formatting changes.

@yiding yiding force-pushed the tmag3001-fix-compatible branch from a3f0580 to 78ec440 Compare October 18, 2024 00:07
Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

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

Add the new compatible to tests/drivers/build_all/sensor/i2c.dtsi

@yiding yiding force-pushed the tmag3001-fix-compatible branch 3 times, most recently from 8940ac2 to 89f3efd Compare October 25, 2024 20:02
@yiding
Copy link
Contributor Author

yiding commented Oct 25, 2024

Added the sensor to the build test. Also, that test is quite the merge conflict factory with all sensors being added at the end... might be cool if it's not one giant hand-edited file, like if the example declaration can be in a dtsi for each sensor driver, and some script comes and collects them all.

MaureenHelm
MaureenHelm previously approved these changes Oct 28, 2024
@MaureenHelm
Copy link
Member

Added the sensor to the build test. Also, that test is quite the merge conflict factory with all sensors being added at the end... might be cool if it's not one giant hand-edited file, like if the example declaration can be in a dtsi for each sensor driver, and some script comes and collects them all.

PRs are welcome

@kartben
Copy link
Collaborator

kartben commented Nov 26, 2024

@yiding can you please rebase again? Thanks

@@ -1185,3 +1185,13 @@ test_i2c_lsm6dso32: lsm6dso32@a5 {
gyro-range = <LSM6DSO_DT_FS_2000DPS>;
gyro-odr = <LSM6DSO_DT_ODR_6667Hz>;
};

test_i2c_tmag3001: tmag3001@9d {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
test_i2c_tmag3001: tmag3001@9d {
test_i2c_tmag3001: tmag3001@a6 {

@yiding yiding force-pushed the tmag3001-fix-compatible branch from 2489ed4 to 1e5f6d4 Compare December 20, 2024 01:23
MaureenHelm
MaureenHelm previously approved these changes Dec 20, 2024
ubieda
ubieda previously approved these changes Dec 30, 2024
Fixes issue introduced in zephyrproject-rtos#76460

The previous code attempted to detect whether TMAG5273 or TMAG3001 was
connected based on DEVICE ID register. This doesn't work as the bits that
denote the version on one part are undefined on the other part, and cannot
be relied on to be zero.

This commit adds a TMAG3001 compatible which (for now) is just derived from
the TMAG5273 compatible. This allows TMAG3001 to be specified directly in
the DT. The driver code is updated to support both compatibles.

Signed-off-by: Yiding Jia <yiding.jia@gmail.com>
@yiding yiding dismissed stale reviews from ubieda and MaureenHelm via ffe9857 December 31, 2024 05:16
@yiding yiding force-pushed the tmag3001-fix-compatible branch from 1e5f6d4 to ffe9857 Compare December 31, 2024 05:16
@yiding
Copy link
Contributor Author

yiding commented Dec 31, 2024

Feels like we are stuck in an endless loop here of fix merge and wait for accept.

@kartben kartben merged commit 2bf61e5 into zephyrproject-rtos:main Jan 8, 2025
24 checks passed
@yiding yiding deleted the tmag3001-fix-compatible branch January 15, 2025 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Sensors Sensors platform: TI SimpleLink Texas Instruments SimpleLink MCU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants