Repository navigation
Conversation
d76eef2 to
103bf88
Compare
|
v2:
|
b02255c to
f962583
Compare
Document the spi-device-addr property which selects the hardware device address via the A0 and A1 pins. Up to four AD5706R devices can share a single SPI chip select by strapping these pins to different values (0–3). Also constrain spi-max-frequency to the 25 MHz maximum specified in the datasheet. Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
f962583 to
f5a01e9
Compare
|
v3 changes and a short summary overall: New Features:
Changed in v3 via feedback:
Reorganized:
|
f5a01e9 to
edcad1c
Compare
|
v4 changes: ad5706r:
ABI:
|
Add support for the six power supplies (iovdd, avdd, pvdd0–3) using devm_regulator_bulk_get_enable(). Support an optional external voltage reference via vref-supply, falling back to the internal bandgap reference when absent. Add optional hardware reset via reset-gpios with the required t_RESET_PW (20 ns) and t_RESET_DELAY (200 us) timing. Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
The AD5706R supports up to four devices on a shared SPI bus, addressed by two hardware address pins (A1:A0). Read the device address from the spi-device-addr DT property and embed it in every SPI command word using FIELD_PREP(AD5706R_ADDR_PIN_MASK). Also switch to DECREMENT mode for two-byte register accesses (reg++ before transmit) so the device clocks out MSB then LSB as required by the datasheet. Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
edcad1c to
602c68a
Compare
e4c1de6 to
0553027
Compare
Configure the device on probe: enable async load mode so DAC outputs update immediately on INPUT A write (no LDAC pulse needed), and put all channels in normal (non-shutdown) operating mode. Expose per-channel output enable through IIO_CHAN_INFO_ENABLE. When an enable-gpios is provided, the OUT_EN register is written to give the GPIO control over the channel outputs; otherwise the enable attribute is not writable. Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
Add support for the LDAC PWM input, which triggers DAC updates at a configurable rate. The PWM consumer is initialised at 1 MHz with zero duty cycle and exposed via IIO_CHAN_INFO_SAMP_FREQ on both physical and toggle channels. Add toggle mode: writing 1 to the toggle channel's enable attribute switches the channel into TOGGLE function mode, alternating between INPUT A and INPUT B on each LDAC pulse. The toggle channels use a 100-offset on the channel index (channel = phys + 100) to produce unique sysfs paths without conflicting with physical channel indices. Add read_label() to report human-readable names (phy0–phy3, toggle0–toggle3) for both channel types. Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
0553027 to
fdf2497
Compare
LLM reviewThis series adds the AD5706R TOGGLE/DITHER channel hierarchy, the LDAC PWM, output enable, regulator and reset handling, the SPI binding properties and the driver documentation. Changes are requested: the LDAC mode is inverted so sysfs writes do not reach the outputs, Session: 43821377129
|
fdf2497 to
41a097e
Compare
Add support for dither mode, which superimposes a sine wave on the DAC output to reduce the effect of ADC quantisation at the system level. Dither channels are of type IIO_ALTCURRENT with channel indices 0–3, matching the physical channel they modulate. The dither frequency is controlled via IIO_CHAN_INFO_FREQUENCY (the N divider written to DITHER_PERIOD: N * frequency = sampling_frequency). The dither amplitude is set via IIO_CHAN_INFO_RAW (DITHER_SCALE register). IIO_CHAN_INFO_SAMP_FREQ is shared with the physical/toggle channels and reflects the LDAC PWM rate. Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
Add documentation for the AD5706R IIO DAC driver describing the channel hierarchy and operating modes. Signed-off-by: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
41a097e to
57e61dd
Compare
|
v5:
|
| } | ||
|
|
||
| /* Enable async load mode: DAC output updates immediately on INPUT A write, no LDAC pulse needed */ | ||
| ret = regmap_write(st->regmap, AD5706R_REG_LDAC_SYNC_ASYNC, GENMASK(3, 0)); |
There was a problem hiding this comment.
llm review is correct. The intended behavior is achieved by writing zeros here.
|
|
||
| /* Enable OUT_EN pin control only when the pin is driven by enable-gpios */ | ||
| if (st->out_en_gpio) { | ||
| ret = regmap_write(st->regmap, AD5706R_REG_OUT_EN, GENMASK(3, 0)); |
There was a problem hiding this comment.
same here. HW_SHUTDOWN_EN=0 is normal operation.
| ret = regmap_read(st->regmap, reg, ®_val); | ||
| if (ret) | ||
| return ret; | ||
| *val = !!(reg_val & AD5706R_CH_EN_BIT(chan->channel)); |
There was a problem hiding this comment.
You have set out_en_gpio to LOW in the probe, so the only way to achieve normal operation is:
- OUT_OP_MODE_CH = 1
- HW_SHUTDOWN_EN_CH = 0
and it powers down with: - OUT_OP_MODE_CH = 1
- HW_SHUTDOWN_EN = 1
but if out_en_gpio is not provided, datasheet says to use OUT_EN = IOVDD, but the logic should not rely on that, so in normal operation:
- OUT_OP_MODE_CH = 1
- HW_SHUTDOWN_EN_CH = 0
and it powers down with: - OUT_OP_MODE_CH = 0
- HW_SHUTDOWN_EN_CH = x
Note that judging the power state by looking at HW_SHUTDOWN_EN vs OUT_OP_MODE_CH ... there is an inversion when using HW_SHUTDOWN_EN.
OUT_SWITCH_EN would control a different power mode not covered at this point.
| n = DIV_ROUND_CLOSEST_ULL(NANO, ldac_pwm_state.period * val); | ||
|
|
||
| /* The dither period is encoded as 2^n, where n = 2..6 (4..64) */ | ||
| if (n < 4 || n > 64 || !is_power_of_2(n)) |
There was a problem hiding this comment.
Instead of returning -EINVAL, I suggest to clamp() the value and use roundup_pow_of_two() or roundown_pow_of_two(), like n = roundup_pow_of_two(clamp(n, 4, 64))... or take ilog2() right after the clamp(), as ilog2() always rounds down. Another approach is find_closest() if using a pre-defined array as reference (4, 8, 16, 32, 64).
| break; | ||
| case AD5706R_CHAN_IDX_TOGGLE_0 ... AD5706R_CHAN_IDX_TOGGLE_3: | ||
| case AD5706R_CHAN_IDX_DITHER_0 ... AD5706R_CHAN_IDX_DITHER_3: | ||
| reg = AD5706R_REG_FUNC_DAC_INPUT_B_CH(ad5706r_phys_ch(chan)); |
There was a problem hiding this comment.
llm review indicates that range to check for val is different for INPUT_B in dither mode.
| if (val < 0 || val > AD5706R_DITHER_PHASE_MAX) | ||
| return -EINVAL; | ||
| reg = AD5706R_REG_FUNC_DITHER_PHASE_CH(ad5706r_phys_ch(chan)); | ||
| return regmap_write(st->regmap, reg, val); |
There was a problem hiding this comment.
phase should be in radians, not raw value.
PR Description
This is part 2 of series of patches to fully support ad5706r
refer to part 1 here: #3325
Adding device attributes to AD5706R, a quad 16-bit current output digital-to-analog converter with integrated precision reference.
Datasheet of AD5706R.
Features Implemented:
This PR is related to #3096
The upstream asked this to be split.
Part 1 - basic driver
Part 2 - device attributes (this)
Part 3 - Channel attributes
Part 4 - debugfs attributes
PR Type
PR Checklist