Skip to content

Conversation

@adiceline
Copy link
Collaborator

@adiceline adiceline commented Sep 19, 2025

PR Description

  • This adds driver support and device tree binding for ADMT4000 True Power-On Multiturn Sensor
  • Datasheet: ADMT4000
  • Tested on RPI4 using the following demo board: EVAL-ADMT4000

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

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]>
@adiceline adiceline force-pushed the dev/admt4000 branch 3 times, most recently from 6858ddb to 4c9a4b7 Compare September 19, 2025 07:46
Add ADI ADMT4000 magnetic turn count sensor driver support

Signed-off-by: adiceline <[email protected]>
imply ADMT4000_POS

Signed-off-by: adiceline <[email protected]>
@adiceline adiceline marked this pull request as ready for review October 20, 2025 01:18
# When adding new entries keep the list in alphabetical order

obj-$(CONFIG_ADMT4000_POS) += admt4000.o
obj-$(CONFIG_ADMT4000_ADG714) += adg714.o
Copy link
Contributor

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*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/*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
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
*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);
Copy link
Contributor

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:
Copy link
Contributor

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
/*
*
*
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
*
* Analog Devices ADMT4000 SPI True Power-On Multiturn Sensor driver

#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>

//adg
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

@jemfgeronimo jemfgeronimo Oct 20, 2025

Choose a reason for hiding this comment

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

Suggested change
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);

Comment on lines +1150 to +1154
*val2 = 1632;
if (st->ext_vdd == ADMT4000_3P3V)
*val2 = 1632;
else if (st->ext_vdd == ADMT4000_5V)
*val2 = 1627;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
*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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants