drivers/iio/adc/pac1934.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/pac1934.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/pac1934.c- Extension
.c- Size
- 48810 bytes
- Lines
- 1633
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/bitfield.hlinux/delay.hlinux/device.hlinux/i2c.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/unaligned.h
Detected Declarations
struct pac1934_featuresstruct reg_datastruct pac1934_chip_infoenum pac1934_idsenum pac1934_sampsenum pac1934_ch_idxfunction BITfunction pac1934_i2c_readfunction pac1934_get_samp_rate_idxfunction pac1934_shunt_value_showfunction pac1934_shunt_value_storefunction pac1934_read_availfunction pac1934_send_refreshfunction pac1934_reg_snapshotfunction pac1934_retrieve_datafunction pac1934_read_rawfunction pac1934_write_rawfunction scoped_guardfunction scoped_guardfunction pac1934_read_labelfunction pac1934_work_periodic_rfshfunction pac1934_read_revisionfunction pac1934_chip_identifyfunction pac1934_acpi_parse_channel_configfunction pac1934_fw_parse_channel_configfunction device_for_each_child_node_scopedfunction pac1934_cancel_delayed_workfunction pac1934_chip_configurefunction pac1934_prep_iio_channelsfunction railfunction pac1934_prep_custom_attributesfunction pac1934_probe
Annotated Snippet
struct pac1934_features {
u8 phys_channels;
const char *name;
};
static const unsigned int samp_rate_map_tbl[] = {
[PAC1934_SAMP_1024SPS] = 1024,
[PAC1934_SAMP_256SPS] = 256,
[PAC1934_SAMP_64SPS] = 64,
[PAC1934_SAMP_8SPS] = 8,
};
static const struct pac1934_features pac1934_chip_config[] = {
[PAC1931] = {
.phys_channels = 1,
.name = "pac1931",
},
[PAC1932] = {
.phys_channels = 2,
.name = "pac1932",
},
[PAC1933] = {
.phys_channels = 3,
.name = "pac1933",
},
[PAC1934] = {
.phys_channels = 4,
.name = "pac1934",
},
};
/**
* struct reg_data - data from the registers
* @meas_regs: snapshot of raw measurements registers
* @ctrl_regs: snapshot of control registers
* @energy_sec_acc: snapshot of energy values
* @vpower_acc: accumulated vpower values
* @vpower: snapshot of vpower registers
* @vbus: snapshot of vbus registers
* @vbus_avg: averages of vbus registers
* @vsense: snapshot of vsense registers
* @vsense_avg: averages of vsense registers
* @num_enabled_channels: count of how many chip channels are currently enabled
*/
struct reg_data {
u8 meas_regs[PAC1934_MEAS_REG_LEN];
u8 ctrl_regs[PAC1934_CTRL_REG_LEN];
s64 energy_sec_acc[PAC1934_MAX_NUM_CHANNELS];
s64 vpower_acc[PAC1934_MAX_NUM_CHANNELS];
s32 vpower[PAC1934_MAX_NUM_CHANNELS];
s32 vbus[PAC1934_MAX_NUM_CHANNELS];
s32 vbus_avg[PAC1934_MAX_NUM_CHANNELS];
s32 vsense[PAC1934_MAX_NUM_CHANNELS];
s32 vsense_avg[PAC1934_MAX_NUM_CHANNELS];
u8 num_enabled_channels;
};
/**
* struct pac1934_chip_info - information about the chip
* @client: the i2c-client attached to the device
* @lock: synchronize access to driver's state members
* @work_chip_rfsh: work queue used for refresh commands
* @phys_channels: phys channels count
* @active_channels: array of values, true means that channel is active
* @enable_energy: array of values, true means that channel energy is measured
* @bi_dir: array of bools, true means that channel is bidirectional
* @chip_variant: chip variant
* @chip_revision: chip revision
* @shunts: shunts
* @chip_reg_data: chip reg data
* @sample_rate_value: sampling frequency
* @labels: table with channels labels
* @iio_info: iio_info
* @tstamp: chip's uptime
*/
struct pac1934_chip_info {
struct i2c_client *client;
struct mutex lock; /* synchronize access to driver's state members */
struct delayed_work work_chip_rfsh;
u8 phys_channels;
bool active_channels[PAC1934_MAX_NUM_CHANNELS];
bool enable_energy[PAC1934_MAX_NUM_CHANNELS];
bool bi_dir[PAC1934_MAX_NUM_CHANNELS];
u8 chip_variant;
u8 chip_revision;
u32 shunts[PAC1934_MAX_NUM_CHANNELS];
struct reg_data chip_reg_data;
s32 sample_rate_value;
char *labels[PAC1934_MAX_NUM_CHANNELS];
struct iio_info iio_info;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bitfield.h`, `linux/delay.h`, `linux/device.h`, `linux/i2c.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/unaligned.h`.
- Detected declarations: `struct pac1934_features`, `struct reg_data`, `struct pac1934_chip_info`, `enum pac1934_ids`, `enum pac1934_samps`, `enum pac1934_ch_idx`, `function BIT`, `function pac1934_i2c_read`, `function pac1934_get_samp_rate_idx`, `function pac1934_shunt_value_show`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source 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.