drivers/iio/dac/ad5758.c
Source file repositories/reference/linux-study-clean/drivers/iio/dac/ad5758.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/dac/ad5758.c- Extension
.c- Size
- 22723 bytes
- Lines
- 905
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bsearch.hlinux/delay.hlinux/kernel.hlinux/module.hlinux/mod_devicetable.hlinux/property.hlinux/spi/spi.hlinux/gpio/consumer.hlinux/iio/iio.hlinux/iio/sysfs.h
Detected Declarations
struct ad5758_rangestruct ad5758_stateenum ad5758_output_rangeenum ad5758_dc_dc_modefunction ad5758_spi_reg_readfunction ad5758_spi_reg_writefunction ad5758_spi_write_maskfunction cmpfuncfunction ad5758_find_closest_matchfunction ad5758_wait_for_task_completefunction ad5758_calib_mem_refreshfunction ad5758_soft_resetfunction ad5758_set_dc_dc_conv_modefunction ad5758_set_dc_dc_ilimfunction ad5758_slew_rate_setfunction ad5758_slew_rate_configfunction ad5758_set_out_rangefunction ad5758_internal_buffers_enfunction ad5758_resetfunction ad5758_reg_accessfunction ad5758_read_rawfunction ad5758_write_rawfunction ad5758_read_powerdownfunction ad5758_write_powerdownfunction ad5758_is_valid_modefunction ad5758_crc_disablefunction ad5758_find_out_rangefunction ad5758_parse_dtfunction ad5758_initfunction ad5758_probe
Annotated Snippet
struct ad5758_range {
int reg;
int min;
int max;
};
/**
* struct ad5758_state - driver instance specific data
* @spi: spi_device
* @lock: mutex lock
* @gpio_reset: gpio descriptor for the reset line
* @out_range: struct which stores the output range
* @dc_dc_mode: variable which stores the mode of operation
* @dc_dc_ilim: variable which stores the dc-to-dc converter current limit
* @slew_time: variable which stores the target slew time
* @pwr_down: variable which contains whether a channel is powered down or not
* @d32: spi transfer buffers
*/
struct ad5758_state {
struct spi_device *spi;
struct mutex lock;
struct gpio_desc *gpio_reset;
struct ad5758_range out_range;
unsigned int dc_dc_mode;
unsigned int dc_dc_ilim;
unsigned int slew_time;
bool pwr_down;
__be32 d32[3];
};
/*
* Output ranges corresponding to bits [3:0] from DAC_CONFIG register
* 0000: 0 V to 5 V voltage range
* 0001: 0 V to 10 V voltage range
* 0010: ±5 V voltage range
* 0011: ±10 V voltage range
* 1000: 0 mA to 20 mA current range
* 1001: 0 mA to 24 mA current range
* 1010: 4 mA to 20 mA current range
* 1011: ±20 mA current range
* 1100: ±24 mA current range
* 1101: -1 mA to +22 mA current range
*/
enum ad5758_output_range {
AD5758_RANGE_0V_5V,
AD5758_RANGE_0V_10V,
AD5758_RANGE_PLUSMINUS_5V,
AD5758_RANGE_PLUSMINUS_10V,
AD5758_RANGE_0mA_20mA = 8,
AD5758_RANGE_0mA_24mA,
AD5758_RANGE_4mA_24mA,
AD5758_RANGE_PLUSMINUS_20mA,
AD5758_RANGE_PLUSMINUS_24mA,
AD5758_RANGE_MINUS_1mA_PLUS_22mA,
};
enum ad5758_dc_dc_mode {
AD5758_DCDC_MODE_POWER_OFF,
AD5758_DCDC_MODE_DPC_CURRENT,
AD5758_DCDC_MODE_DPC_VOLTAGE,
AD5758_DCDC_MODE_PPC_CURRENT,
};
static const struct ad5758_range ad5758_voltage_range[] = {
{ AD5758_RANGE_0V_5V, 0, 5000000 },
{ AD5758_RANGE_0V_10V, 0, 10000000 },
{ AD5758_RANGE_PLUSMINUS_5V, -5000000, 5000000 },
{ AD5758_RANGE_PLUSMINUS_10V, -10000000, 10000000 }
};
static const struct ad5758_range ad5758_current_range[] = {
{ AD5758_RANGE_0mA_20mA, 0, 20000},
{ AD5758_RANGE_0mA_24mA, 0, 24000 },
{ AD5758_RANGE_4mA_24mA, 4, 24000 },
{ AD5758_RANGE_PLUSMINUS_20mA, -20000, 20000 },
{ AD5758_RANGE_PLUSMINUS_24mA, -24000, 24000 },
{ AD5758_RANGE_MINUS_1mA_PLUS_22mA, -1000, 22000 },
};
static const int ad5758_sr_clk[16] = {
240000, 200000, 150000, 128000, 64000, 32000, 16000, 8000, 4000, 2000,
1000, 512, 256, 128, 64, 16
};
static const int ad5758_sr_step[8] = {
4, 12, 64, 120, 256, 500, 1820, 2048
};
static const int ad5758_dc_dc_ilim[6] = {
150000, 200000, 250000, 300000, 350000, 400000
Annotation
- Immediate include surface: `linux/bsearch.h`, `linux/delay.h`, `linux/kernel.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/property.h`, `linux/spi/spi.h`, `linux/gpio/consumer.h`.
- Detected declarations: `struct ad5758_range`, `struct ad5758_state`, `enum ad5758_output_range`, `enum ad5758_dc_dc_mode`, `function ad5758_spi_reg_read`, `function ad5758_spi_reg_write`, `function ad5758_spi_write_mask`, `function cmpfunc`, `function ad5758_find_closest_match`, `function ad5758_wait_for_task_complete`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.