-
Notifications
You must be signed in to change notification settings - Fork 904
Add Support for ADMT4000 #2944
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
base: main
Are you sure you want to change the base?
Add Support for ADMT4000 #2944
Conversation
5372162 to
68a67ca
Compare
The ADMT4000 is a magnetic turn count sensor that records the rotations of a magnetic system even when powered down. Signed-off-by: adiceline <[email protected]>
Add ABI documentation for ADMT4000 sysfs attributes: - phase and magnitude correction for harmonics - filter enable control Signed-off-by: adiceline <[email protected]>
6858ddb to
4c9a4b7
Compare
de29f9d to
b699a29
Compare
Add ADI ADMT4000 magnetic turn count sensor driver support Signed-off-by: adiceline <[email protected]>
imply ADMT4000_POS Signed-off-by: adiceline <[email protected]>
b699a29 to
75cdd19
Compare
| # When adding new entries keep the list in alphabetical order | ||
|
|
||
| obj-$(CONFIG_ADMT4000_POS) += admt4000.o | ||
| obj-$(CONFIG_ADMT4000_ADG714) += adg714.o |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove this.
| #include <linux/of.h> | ||
| #include <linux/of_device.h> | ||
|
|
||
| /*ADMT4000 Registers*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /*ADMT4000 Registers*/ | |
| /* ADMT4000 Registers */ |
Apply to other comments as well.
| KernelVersion: 6.6.0 | ||
| Contact: [email protected] | ||
| Description: | ||
| Enable or disable the device's angle measurement filter. No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add empty line at EOF.
| switch (private) { | ||
| case ADMT4000_ANGLE_FILT_EN: | ||
| ret = kstrtobool(buf, &is_en); | ||
| ret = admt4000_set_angle_filt(st, (bool)is_en); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ret = admt4000_set_angle_filt(st, (bool)is_en); | |
| ret = admt4000_set_angle_filt(st, is_en); |
is_en is already bool, no?
| if (ret) | ||
| return ret; | ||
|
|
||
| *is_filtered = (bool)FIELD_GET(ADMT4000_ANGL_FILT_MASK, temp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| *is_filtered = (bool)FIELD_GET(ADMT4000_ANGL_FILT_MASK, temp); | |
| *is_filtered = !!FIELD_GET(ADMT4000_ANGL_FILT_MASK, temp); |
| int turns; | ||
| u16 angle[2]; | ||
|
|
||
| mutex_lock(&st->lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need locking for scale and offset.
|
|
||
| mutex_lock(&st->lock); | ||
| switch (mask) { | ||
| case IIO_CHAN_INFO_RAW: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use iio_device_claim_direct_mode and iio_device_release_direct_mode for locking and unlocking. Same with IIO_CHAN_INFO_PROCESSED.
| // SPDX-License-Identifier: GPL-2.0 | ||
| /* | ||
| * | ||
| * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * | |
| * Analog Devices ADMT4000 SPI True Power-On Multiturn Sensor driver |
| #include <linux/iio/triggered_buffer.h> | ||
| #include <linux/iio/trigger_consumer.h> | ||
|
|
||
| //adg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need this?
| if (value) | ||
| code[(eff_pos >> 3)] |= BIT(eff_pos & 0x7); | ||
|
|
||
| *ecc |= (value << i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix alignment.
| int turns; | ||
| u16 angle[2]; | ||
|
|
||
| mutex_lock(&st->lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| mutex_lock(&st->lock); | |
| guard(mutex)(&st->lock); |
Then you don't need to call mutex_unlock(&st->lock); later. Apply to other mutex_lock(&st->lock);
| *val2 = 1632; | ||
| if (st->ext_vdd == ADMT4000_3P3V) | ||
| *val2 = 1632; | ||
| else if (st->ext_vdd == ADMT4000_5V) | ||
| *val2 = 1627; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| *val2 = 1632; | |
| if (st->ext_vdd == ADMT4000_3P3V) | |
| *val2 = 1632; | |
| else if (st->ext_vdd == ADMT4000_5V) | |
| *val2 = 1627; | |
| if (st->ext_vdd == ADMT4000_5V) | |
| *val2 = 1627; | |
| else | |
| *val2 = 1632; |
PR Description
PR Type
PR Checklist