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

New adis support #2411

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

New adis support #2411

wants to merge 7 commits into from

Conversation

rbolboac
Copy link
Contributor

  • add support for ADIS16501 in adis16475 driver
  • add support for ADIS1657X family in adis16475 driver
  • add FIFO support for ADIS1657X family

Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Alright, initial review done. I guess most important thing for now is to split some changes in preparatory patches so it#s easier to review things.

drivers/iio/imu/Kconfig Outdated Show resolved Hide resolved
drivers/iio/imu/Kconfig Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Show resolved Hide resolved
drivers/iio/imu/adis_buffer.c Outdated Show resolved Hide resolved
include/linux/iio/imu/adis.h Outdated Show resolved Hide resolved
@rbolboac rbolboac force-pushed the dev/adis1657x branch 2 times, most recently from a19a6ba to ab05734 Compare February 23, 2024 12:38
Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Looks better. I think we need to re-think that burst_request handling...

drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
@rbolboac rbolboac force-pushed the dev/adis1657x branch 3 times, most recently from 2ff961f to 6bb0677 Compare March 14, 2024 15:21
@rbolboac
Copy link
Contributor Author

  • implemented transfer for adis1657x family for burst request and fifo read without popping the fifo
  • using adis lock in the trigger handler with fifo does not allow other registers reads while reading from fifo
  • for adis1657x only the trigger handler with fifo is available
  • adis16475_burst32_check is called after fifo has been read

drivers/iio/imu/adis16475.c Show resolved Hide resolved
drivers/iio/imu/adis16475.c Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Show resolved Hide resolved
drivers/iio/imu/adis16475.c Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Some more comments. Almost there, but the kzalloc() on every sample is a no-go IMO

struct adis *adis = &st->adis;

adis->burst_req_msb = burst_req;
adis_update_scan_mode(indio_dev, indio_dev->active_scan_mask);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, If I'm not missing nothing the only thing we wanna change is the burst_req command right? So, doing kfree() plus kzalloc() on every sample is definitely too much... I would just change the byte in adis->xfer[0] and then restore it after burst_req is done. Note that we're already directly messing with the transfer size in adis16475_burst32_check() anyways. I admit is not that pretty but better than the allocation overhead. At some point (if we get another driver needing stuff like this) we may think in moving this to a better API in the lib. But for now, I would just do it in here...

With the above, I guess you can drop the patch for adis->burst_req_msb

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so changing the byte in adis->xfer[0] is a little tricky because tx_buff is const void *, so I had to use the same lines of code as in adis_update_scan_mode_burst, I hope this is alright. do you have another suggestion?

drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
drivers/iio/imu/adis16475.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Just some minor comments.

AFAICT, this is fine to go upstream.. It took some iterations but I think we have a better end result :)

struct iio_dev *indio_dev = pf->indio_dev;
struct adis16475 *st = iio_priv(indio_dev);
struct adis *adis = &st->adis;
u8 *tx = adis->buffer + adis->data->burst_max_len;
Copy link
Collaborator

@nunojsa nunojsa Apr 5, 2024

Choose a reason for hiding this comment

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

Yeps, exactly what I had in mind. But, are we guaranteed to always have adis->data->burst_max_len? We handle it a bit different in update_scan_mode_burst().

Also, see below...


tx[0] = ADIS_READ_REG(burst_req);
tx[1] = 0;
adis->xfer[0].tx_buf = tx;
Copy link
Collaborator

@nunojsa nunojsa Apr 5, 2024

Choose a reason for hiding this comment

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

I do not think we need the above two lines. Just tx[0] = ADIS_READ_REG(burst_req); should be enough. The pointer is the same. We're just changing the first byte under the wood :)

I admit this is not pretty as it should be the lib to handle this internal data. When upstreaming, feel free to purpose something like adis_update_burst_request()... The only thing I don't like with having it in the lib is that we just have one user for it. Up to you anyways.

Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

This LGTM... Not approving just because this should be upstreamed first and I don't want to give the idea that this can be merged now.

@rbolboac
Copy link
Contributor Author

This LGTM... Not approving just because this should be upstreamed first and I don't want to give the idea that this can be merged now.

Sure, currently I am waiting for some feedback from the MEMS team to make sure nothing has changed in the meanwhile.

Update ADIS16475 existing documentation with documentation
for ADIS16501 device.

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Add support for ADIS16501 device in already existing ADIS16475
driver.

Datasheet: TBD
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Re-define ADIS16475_DATA such that it takes _burst_max_len and
_burst_max_speed_hz as parameters.

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Add new API called devm_adis_setup_buffer_and_trigger_with_attrs() which
also takes buffer attributes as a parameter.
Rewrite devm_adis_setup_buffer_and_trigger() implementation such that it
calls devm_adis_setup_buffer_and_trigger_with_attrs() with buffer
attributes parameter NULL.

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Create push single sample API reposnsible for pushing a single
sample into the buffer.
This is a preparation patch for FIFO support where more than
one sample has to be pushed in the trigger handler.

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Update ADIS16475 existing documentation with documentation
for ADIS1657X family devices.

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Add support for ADIS1657X family devices in already exiting
ADIS16475 driver.

Datasheet: TBD
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
@rbolboac
Copy link
Contributor Author

  • main rebase

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.

None yet

2 participants