drivers/iio/dac/ad3552r-hs.c
Source file repositories/reference/linux-study-clean/drivers/iio/dac/ad3552r-hs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/dac/ad3552r-hs.c- Extension
.c- Size
- 22778 bytes
- Lines
- 888
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/debugfs.hlinux/delay.hlinux/gpio/consumer.hlinux/iio/backend.hlinux/iio/buffer.hlinux/mod_devicetable.hlinux/platform_device.hlinux/property.hlinux/units.had3552r.had3552r-hs.h
Detected Declarations
struct ad3552r_hs_stateenum ad3552r_sourcesfunction ad3552r_hs_reg_readfunction ad3552r_hs_set_data_sourcefunction ad3552r_hs_update_reg_bitsfunction ad3552r_hs_read_rawfunction ad3552r_hs_write_rawfunction ad3552r_hs_set_bus_io_mode_hsfunction ad3552r_hs_set_target_io_mode_hsfunction ad3552r_hs_buffer_postenablefunction ad3552r_hs_buffer_predisablefunction ad3552r_hs_set_output_rangefunction ad3552r_hs_resetfunction ad3552r_hs_scratch_pad_testfunction ad3552r_hs_setup_custom_gainfunction ad3552r_hs_reg_accessfunction ad3552r_hs_show_data_sourcefunction ad3552r_hs_write_data_sourcefunction ad3552r_hs_show_data_source_availfunction ad3552r_hs_setupfunction device_for_each_child_node_scopedfunction ad3552r_hs_debugfs_initfunction ad3552r_hs_probe
Annotated Snippet
static const struct file_operations ad3552r_hs_data_source_fops = {
.owner = THIS_MODULE,
.write = ad3552r_hs_write_data_source,
.read = ad3552r_hs_show_data_source,
};
static const struct file_operations ad3552r_hs_data_source_avail_fops = {
.owner = THIS_MODULE,
.read = ad3552r_hs_show_data_source_avail,
};
static int ad3552r_hs_setup(struct ad3552r_hs_state *st)
{
u16 id;
u16 gain = 0, offset = 0;
u32 ch, val, range;
int ret;
ret = ad3552r_hs_reset(st);
if (ret)
return ret;
/* HDL starts with DDR enabled, disabling it. */
ret = iio_backend_ddr_disable(st->back);
if (ret)
return ret;
ret = st->data->bus_reg_write(st->back,
AD3552R_REG_ADDR_INTERFACE_CONFIG_B,
AD3552R_MASK_SINGLE_INST |
AD3552R_MASK_SHORT_INSTRUCTION, 1);
if (ret)
return ret;
ret = ad3552r_hs_scratch_pad_test(st);
if (ret)
return ret;
/*
* Caching config_d, needed to restore it after streaming,
* and also, to detect possible DDR read, that's not allowed.
*/
ret = st->data->bus_reg_read(st->back,
AD3552R_REG_ADDR_INTERFACE_CONFIG_D,
&st->config_d, 1);
if (ret)
return ret;
ret = ad3552r_hs_reg_read(st, AD3552R_REG_ADDR_PRODUCT_ID_L, &val, 1);
if (ret)
return ret;
id = val;
ret = ad3552r_hs_reg_read(st, AD3552R_REG_ADDR_PRODUCT_ID_H, &val, 1);
if (ret)
return ret;
id |= val << 8;
if (id != st->model_data->chip_id)
dev_warn(st->dev,
"chip ID mismatch, detected 0x%x but expected 0x%x\n",
id, st->model_data->chip_id);
dev_dbg(st->dev, "chip id %s detected", st->model_data->model_name);
/* Clear reset error flag, see ad3552r manual, rev B table 38. */
ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_ERR_STATUS,
AD3552R_MASK_RESET_STATUS, 1);
if (ret)
return ret;
ret = st->data->bus_reg_write(st->back,
AD3552R_REG_ADDR_SH_REFERENCE_CONFIG,
0, 1);
if (ret)
return ret;
ret = ad3552r_hs_set_data_source(st, IIO_BACKEND_EXTERNAL);
if (ret)
return ret;
ret = ad3552r_get_ref_voltage(st->dev, &val);
if (ret < 0)
return ret;
val = ret;
ret = ad3552r_hs_update_reg_bits(st,
AD3552R_REG_ADDR_SH_REFERENCE_CONFIG,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/debugfs.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/iio/backend.h`, `linux/iio/buffer.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`.
- Detected declarations: `struct ad3552r_hs_state`, `enum ad3552r_sources`, `function ad3552r_hs_reg_read`, `function ad3552r_hs_set_data_source`, `function ad3552r_hs_update_reg_bits`, `function ad3552r_hs_read_raw`, `function ad3552r_hs_write_raw`, `function ad3552r_hs_set_bus_io_mode_hs`, `function ad3552r_hs_set_target_io_mode_hs`, `function ad3552r_hs_buffer_postenable`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: pattern implementation candidate.
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.