-
Notifications
You must be signed in to change notification settings - Fork 853
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
base: main
Are you sure you want to change the base?
add ad3530r driver #2680
Conversation
c22be05
to
69aa554
Compare
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]>
v2
|
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.
First round...
#include <linux/module.h> | ||
#include <linux/mod_devicetable.h> | ||
#include <linux/mutex.h> | ||
#include <linux/of.h> |
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.
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; | ||
} |
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.
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); |
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.
devm_mutex_init() when upstreaming
struct gpio_desc *reset_gpio; | ||
int i, ret; | ||
|
||
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); |
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 guess you actually want GPIOD_OUT_HIGH
"Failed to get reset GPIO\n"); | ||
|
||
if (reset_gpio) { | ||
/* Perfomr hardware reset */ |
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.
typo
return ret; | ||
|
||
return len; | ||
case 4 ... 7: |
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.
Some macros would be nice
st->chan[chan->channel].powerdown = powerdown; | ||
|
||
switch (chan->channel) { | ||
case 0 ... 3: |
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.
ditto
u8 ldac; | ||
bool range_multiplier; | ||
|
||
__be32 tx_buf __aligned(ARCH_DMA_MINALIGN); |
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.
this should be IIO_DMA_MINALIGN
char *buf) | ||
{ | ||
struct ad3530r_state *st = iio_priv(indio_dev); | ||
|
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.
for correctness, you should also guard() your access in here
return ret; | ||
|
||
guard(mutex)(&st->lock); | ||
st->chan[chan->channel].powerdown = powerdown; |
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.
This should only be set after a successful cal to ad3530r_reg_update_bits()
PR Description
Part is unreleased, allowed by requestor to create PR for public release and initial review.
PR Type
PR Checklist