drivers/iio/adc/ade9000.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ade9000.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ade9000.c- Extension
.c- Size
- 52182 bytes
- Lines
- 1795
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/clk.hlinux/clk-provider.hlinux/completion.hlinux/delay.hlinux/gpio/consumer.hlinux/iio/iio.hlinux/iio/buffer.hlinux/iio/kfifo_buf.hlinux/iio/events.hlinux/interrupt.hlinux/minmax.hlinux/module.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/unaligned.h
Detected Declarations
struct ade9000_statestruct ade9000_irq1_eventenum ade9000_wfb_cfgfunction ade9000_filter_type_getfunction ade9000_filter_type_setfunction BITfunction ade9000_spi_write_regfunction ade9000_spi_read_regfunction ade9000_is_volatile_regfunction ade9000_configure_scanfunction ade9000_iio_push_streamingfunction ade9000_iio_push_bufferfunction ade9000_irq0_threadfunction ade9000_irq1_threadfunction ade9000_dready_threadfunction ade9000_read_rawfunction ade9000_write_rawfunction ade9000_reg_accessfunction ade9000_read_event_configfunction ade9000_write_event_configfunction ade9000_write_event_valuefunction ade9000_read_event_valuefunction ade9000_waveform_buffer_configfunction ade9000_waveform_buffer_interrupt_setupfunction ade9000_buffer_preenablefunction ade9000_buffer_postdisablefunction ade9000_resetfunction ade9000_setupfunction ade9000_setup_clkoutfunction ade9000_request_irqfunction ade9000_probe
Annotated Snippet
struct ade9000_state {
struct completion reset_completion;
struct mutex lock; /* Protects SPI transactions */
u8 wf_src;
u32 wfb_trg;
u8 wfb_nr_activ_chan;
u32 wfb_nr_samples;
struct spi_device *spi;
struct clk *clkin;
struct spi_transfer xfer[2];
struct spi_message spi_msg;
struct regmap *regmap;
union{
u8 byte[ADE9000_WFB_FULL_BUFF_SIZE];
__be32 word[ADE9000_WFB_FULL_BUFF_NR_SAMPLES];
} rx_buff __aligned(IIO_DMA_MINALIGN);
u8 tx_buff[2] __aligned(IIO_DMA_MINALIGN);
unsigned int bulk_read_buf[2];
};
struct ade9000_irq1_event {
u32 bit_mask;
enum iio_chan_type chan_type;
u32 channel;
enum iio_event_type event_type;
enum iio_event_direction event_dir;
};
static const struct ade9000_irq1_event ade9000_irq1_events[] = {
{ ADE9000_ST1_ZXVA_BIT, IIO_VOLTAGE, ADE9000_PHASE_A_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER },
{ ADE9000_ST1_ZXIA_BIT, IIO_CURRENT, ADE9000_PHASE_A_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER },
{ ADE9000_ST1_ZXVB_BIT, IIO_VOLTAGE, ADE9000_PHASE_B_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER },
{ ADE9000_ST1_ZXIB_BIT, IIO_CURRENT, ADE9000_PHASE_B_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER },
{ ADE9000_ST1_ZXVC_BIT, IIO_VOLTAGE, ADE9000_PHASE_C_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER },
{ ADE9000_ST1_ZXIC_BIT, IIO_CURRENT, ADE9000_PHASE_C_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER },
{ ADE9000_ST1_SWELLA_BIT, IIO_ALTVOLTAGE, ADE9000_PHASE_A_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING },
{ ADE9000_ST1_SWELLB_BIT, IIO_ALTVOLTAGE, ADE9000_PHASE_B_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING },
{ ADE9000_ST1_SWELLC_BIT, IIO_ALTVOLTAGE, ADE9000_PHASE_C_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING },
{ ADE9000_ST1_DIPA_BIT, IIO_ALTVOLTAGE, ADE9000_PHASE_A_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING },
{ ADE9000_ST1_DIPB_BIT, IIO_ALTVOLTAGE, ADE9000_PHASE_B_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING },
{ ADE9000_ST1_DIPC_BIT, IIO_ALTVOLTAGE, ADE9000_PHASE_C_NR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING },
};
/* Voltage events (zero crossing on instantaneous voltage) */
static const struct iio_event_spec ade9000_voltage_events[] = {
{
/* Zero crossing detection - datasheet: ZXV interrupts */
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_EITHER,
.mask_separate = BIT(IIO_EV_INFO_ENABLE),
},
};
/* Current events (zero crossing on instantaneous current) */
static const struct iio_event_spec ade9000_current_events[] = {
{
/* Zero crossing detection - datasheet: ZXI interrupts */
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_EITHER,
.mask_separate = BIT(IIO_EV_INFO_ENABLE),
},
};
/* RMS voltage events (swell/sag detection on RMS values) */
static const struct iio_event_spec ade9000_rms_voltage_events[] = {
{
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_RISING, /* RMS swell detection */
.mask_separate = BIT(IIO_EV_INFO_ENABLE) | BIT(IIO_EV_INFO_VALUE),
},
{
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_FALLING, /* RMS sag/dip detection */
.mask_separate = BIT(IIO_EV_INFO_ENABLE) | BIT(IIO_EV_INFO_VALUE),
},
};
static const char * const ade9000_filter_type_items[] = {
"sinc4", "sinc4+lp",
};
static const int ade9000_filter_type_values[] = {
0, 2,
};
static int ade9000_filter_type_get(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
{
struct ade9000_state *st = iio_priv(indio_dev);
u32 val;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/completion.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/iio/iio.h`, `linux/iio/buffer.h`.
- Detected declarations: `struct ade9000_state`, `struct ade9000_irq1_event`, `enum ade9000_wfb_cfg`, `function ade9000_filter_type_get`, `function ade9000_filter_type_set`, `function BIT`, `function ade9000_spi_write_reg`, `function ade9000_spi_read_reg`, `function ade9000_is_volatile_reg`, `function ade9000_configure_scan`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.