Skip to content

add ad3530r driver #2680

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

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

add ad3530r driver #2680

wants to merge 5 commits into from

Conversation

kseerp
Copy link
Contributor

@kseerp kseerp commented Dec 17, 2024

PR Description

AD3530R/AD3530 8-Channel, 16-Bit Voltage Output DAC
AD3531R/AD3531 4-Channel, 16-Bit Voltage Output DAC (unreleased)

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)

@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...

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

@kseerp
Copy link
Contributor Author

kseerp commented Jan 31, 2025

v3

  • added ABI file

bindings:

  • added iovcc-supply property
  • made vcc-supply and iovcc-supply as required property
  • added datasheet link

ad3530r:

  • dropped unused macros, headers and registers
  • used devm_regulator_get_enable_read_voltage()
  • used IIO_DMA_MINALIGN macro for alignment
  • used macros for hardcoded values
  • modified state for reset-gpio

@kseerp kseerp force-pushed the dev/ad353xr branch 2 times, most recently from 1a76933 to 46485a3 Compare March 12, 2025 06:50
@kseerp
Copy link
Contributor Author

kseerp commented Mar 12, 2025

v4

  • added support for the AD3531R (unreleased)
  • introduced chip_info struct to handle number of channels and some different register addresses, such as input_ch_reg and sw_ldac_trig_reg
  • include new DAC powerdown mode (7.7kohm_to_gnd and 32kohm_to_gnd) in IIO ABI

will appreciate any reviews and feedback

@kseerp
Copy link
Contributor Author

kseerp commented Mar 14, 2025

v5

  • utilize regmap API (bulk_read/writes for multibyte registers)

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 notes from me... I would say to take my inputs, change what you agree with and send this upstream.

I would also recommend to improve your commit message on the bindings patch. Give a small description of the HW. Like it is now you'll most likely get some comments from maintainers because the message only state the obvious.

required:
- compatible
- reg
- spi-max-frequency
Copy link
Collaborator

Choose a reason for hiding this comment

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

odd to make this mandatory...

const: 1

'#size-cells':
const: 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

drop the above... you don't have any child node

@@ -6,6 +6,16 @@

menu "Digital to analog converters"

config AD3530R
tristate "Analog Devices AD3530R DAC driver"
depends on SPI_MASTER
Copy link
Collaborator

Choose a reason for hiding this comment

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

you also need to select REGMAP_SPI

{
struct ad3530r_state *st = iio_priv(indio_dev);

guard(mutex)(&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.

need to include cleanup.h

ret = regmap_update_bits(st->regmap, AD3530R_OUTPUT_OPERATING_MODE_0,
GENMASK(chan->channel * 2 + 1, chan->channel * 2),
(powerdown ? st->chan[chan->channel].powerdown_mode : 0) <<
(chan->channel * 2));
Copy link
Collaborator

Choose a reason for hiding this comment

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

not pretty... I would simplify this with some helper variables or even consider an helper function

((chan->channel - 4) * 2);
if (ret)
return ret;

Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

struct ad3530r_state *st = iio_priv(indio_dev);

return regmap_write(st->regmap, AD3530R_MUX_OUT_SELECT, val);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

up to you but I thought debugfd was going to be the path forward


return regmap_update_bits(st->regmap, st->chip_info->sw_ldac_trig_reg,
AD3530R_SW_LDAC_TRIG_MASK,
FIELD_PREP(AD3530R_SW_LDAC_TRIG_MASK, 1));
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing a lock

for (i = 0; i < chip_info->num_channels; i++) {
st->channels[i] = ad3530r_channel_template;
st->channels[i].channel = i;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder about the template usage... I'm not seeing anything being changed dynamically so it seems to be you could have a static channel definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh I have in mind another device in ad353xr series that will be released soon. It has specific feature that can be included as extended info and can be changed dynamically through that implementation above

kseerp added 5 commits April 2, 2025 11:25
Define muxout_select and muxout_select_available sysfs interface for the
AD3530R and AD3531R DAC.

Signed-off-by: Kim Seer Paller <[email protected]>
Add a new powerdown mode for DACs with 7.7kohm and 32kohm resistor
to GND.

Signed-off-by: Kim Seer Paller <[email protected]>
Document the AD3530R/AD3530, an 8-Channel, 16-bit Voltage Output DAC,
and the AD3531R/AD3531 is a 4-Channel, 16-Bit Voltage Output DAC.
These devices include software-programmable gain controls that provide
full-scale output spans of 2.5V or 5V for reference voltages of 2.5V.
They operate from a single supply voltage range of 2.7V to 5.5V and are
guaranteed to be monotonic by design. Additionally, these devices
features a 2.5V, 5ppm/°C internal reference, which is disabled by default.

Signed-off-by: Kim Seer Paller <[email protected]>
The AD3530R/AD3530 is an 8-Channel, 16-Bit Voltage Output DAC, while the
AD3531R/AD3531 is a 4-Channel, 16-Bit Voltage Output DAC. These devices
include software-programmable gain controls that provide full-scale
output spans of 2.5V or 5V for reference voltages of 2.5V. They operate
from a single supply voltage range of 2.7V to 5.5V and are guaranteed to
be monotonic by design. Additionally, these devices features a 2.5V,
5ppm/°C internal reference, which is disabled by default.

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

Signed-off-by: Kim Seer Paller <[email protected]>
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