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

add ad3530r driver #2680

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

add ad3530r driver #2680

wants to merge 3 commits into from

Conversation

kseerp
Copy link
Contributor

@kseerp kseerp commented Dec 17, 2024

PR Description

Part is unreleased, allowed by requestor to create PR for public release and initial review.

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)

Add documentation for ad3530r.

Signed-off-by: Kim Seer Paller <[email protected]>
The AD3530R/AD3530 are low power, 8-channel, 16-bit, buffered voltage
output, DACs that include a 2.5V internal reference (disabled by
default), and a gain bit field, resulting in a full-scale output span
of 2.5V (gain = 1) or 5V (gain = 2) for a reference voltage of 2.5V.

Signed-off-by: Kim Seer Paller <[email protected]>
Add entry for the AD3530R driver.

Signed-off-by: Kim Seer Paller <[email protected]>
@kseerp
Copy link
Contributor Author

kseerp commented Dec 20, 2024

v2

  • address relevant CI complaints

@kseerp kseerp marked this pull request as ready for review December 20, 2024 15:46
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.

First round...

#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/mutex.h>
#include <linux/of.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why of.h?

return dev_err_probe(dev, ret, "Failed to get ref\n");

st->vref_mv = st->range_multiplier ? 2 * ret / 1000 : ret / 1000;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems devm_regulator_get_enable_read_voltage() was backported to our tree. That will simplify the above block a lot.

st = iio_priv(indio_dev);
st->spi = spi;

mutex_init(&st->lock);
Copy link
Collaborator

Choose a reason for hiding this comment

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

devm_mutex_init() when upstreaming

struct gpio_desc *reset_gpio;
int i, ret;

reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess you actually want GPIOD_OUT_HIGH

"Failed to get reset GPIO\n");

if (reset_gpio) {
/* Perfomr hardware reset */
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo

return ret;

return len;
case 4 ... 7:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some macros would be nice

st->chan[chan->channel].powerdown = powerdown;

switch (chan->channel) {
case 0 ... 3:
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

u8 ldac;
bool range_multiplier;

__be32 tx_buf __aligned(ARCH_DMA_MINALIGN);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be IIO_DMA_MINALIGN

char *buf)
{
struct ad3530r_state *st = iio_priv(indio_dev);

Copy link
Collaborator

Choose a reason for hiding this comment

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

for correctness, you should also guard() your access in here

return ret;

guard(mutex)(&st->lock);
st->chan[chan->channel].powerdown = powerdown;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should only be set after a successful cal to ad3530r_reg_update_bits()

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