drivers/iio/proximity/hx9023s.c
Source file repositories/reference/linux-study-clean/drivers/iio/proximity/hx9023s.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/proximity/hx9023s.c- Extension
.c- Size
- 32809 bytes
- Lines
- 1228
- 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.
- 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/array_size.hlinux/bitfield.hlinux/bitops.hlinux/cleanup.hlinux/device.hlinux/errno.hlinux/firmware.hlinux/i2c.hlinux/interrupt.hlinux/irqreturn.hlinux/math64.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/pm.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/types.hlinux/units.hasm/byteorder.hlinux/unaligned.hlinux/iio/buffer.hlinux/iio/events.hlinux/iio/iio.hlinux/iio/trigger.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.hlinux/iio/types.h
Detected Declarations
struct hx9023s_binstruct hx9023s_ch_datastruct hx9023s_datafunction hx9023s_interrupt_enablefunction hx9023s_interrupt_disablefunction hx9023s_data_lockfunction hx9023s_ch_cfgfunction hx9023s_write_far_debouncefunction hx9023s_write_near_debouncefunction hx9023s_read_far_debouncefunction hx9023s_read_near_debouncefunction hx9023s_get_thres_nearfunction hx9023s_get_thres_farfunction hx9023s_set_thres_nearfunction hx9023s_set_thres_farfunction hx9023s_get_prox_statefunction hx9023s_data_selectfunction hx9023s_samplefunction hx9023s_ch_enfunction hx9023s_property_getfunction device_for_each_child_node_scopedfunction hx9023s_update_chan_enfunction hx9023s_get_proximityfunction hx9023s_get_samp_freqfunction hx9023s_read_rawfunction hx9023s_set_samp_freqfunction hx9023s_write_rawfunction hx9023s_irq_handlerfunction hx9023s_push_eventsfunction hx9023s_irq_thread_handlerfunction hx9023s_read_event_valfunction hx9023s_write_event_valfunction hx9023s_read_event_configfunction hx9023s_write_event_configfunction hx9023s_set_trigger_statefunction hx9023s_trigger_handlerfunction iio_for_each_active_channelfunction hx9023s_buffer_preenablefunction hx9023s_buffer_postdisablefunction hx9023s_id_checkfunction hx9023s_bin_loadfunction hx9023s_send_cfgfunction hx9023s_cfg_updatefunction hx9023s_probefunction hx9023s_suspendfunction hx9023s_resume
Annotated Snippet
struct hx9023s_bin {
u16 reg_count;
u16 fw_size;
u8 fw_ver;
u8 data[] __counted_by(fw_size);
};
struct hx9023s_ch_data {
s16 raw; /* Raw Data*/
s16 lp; /* Low Pass Filter Data*/
s16 bl; /* Base Line Data */
s16 diff; /* Difference of Low Pass Data and Base Line Data */
struct {
unsigned int near;
unsigned int far;
} thres;
u16 dac;
u8 channel_positive;
u8 channel_negative;
bool sel_bl;
bool sel_raw;
bool sel_diff;
bool sel_lp;
bool enable;
};
struct hx9023s_data {
struct iio_trigger *trig;
struct regmap *regmap;
unsigned long chan_prox_stat;
unsigned long chan_read;
unsigned long chan_event;
unsigned long ch_en_stat;
unsigned long chan_in_use;
unsigned int prox_state_reg;
bool trigger_enabled;
struct {
__le16 channels[HX9023S_CH_NUM];
aligned_s64 ts;
} buffer;
/*
* Serialize access to registers below:
* HX9023S_PROX_INT_LOW_CFG,
* HX9023S_PROX_INT_HIGH_CFG,
* HX9023S_INTERRUPT_CFG,
* HX9023S_CH_NUM_CFG
* Serialize access to channel configuration in
* hx9023s_push_events and hx9023s_trigger_handler.
*/
struct mutex mutex;
struct hx9023s_ch_data ch_data[HX9023S_CH_NUM];
};
static const struct reg_sequence hx9023s_reg_init_list[] = {
/* scan period */
REG_SEQ0(HX9023S_PRF_CFG, 0x17),
/* full scale of conversion phase of each channel */
REG_SEQ0(HX9023S_RANGE_7_0, 0x11),
REG_SEQ0(HX9023S_RANGE_9_8, 0x02),
REG_SEQ0(HX9023S_RANGE_18_16, 0x00),
/* ADC average number and OSR number of each channel */
REG_SEQ0(HX9023S_AVG0_NOSR0_CFG, 0x71),
REG_SEQ0(HX9023S_NOSR12_CFG, 0x44),
REG_SEQ0(HX9023S_NOSR34_CFG, 0x00),
REG_SEQ0(HX9023S_AVG12_CFG, 0x33),
REG_SEQ0(HX9023S_AVG34_CFG, 0x00),
/* sample & integration frequency of the ADC */
REG_SEQ0(HX9023S_SAMPLE_NUM_7_0, 0x65),
REG_SEQ0(HX9023S_INTEGRATION_NUM_7_0, 0x65),
/* coefficient of the first order low pass filter during each channel */
REG_SEQ0(HX9023S_LP_ALP_1_0_CFG, 0x22),
REG_SEQ0(HX9023S_LP_ALP_3_2_CFG, 0x22),
REG_SEQ0(HX9023S_LP_ALP_4_CFG, 0x02),
/* up coefficient of the first order low pass filter during each channel */
REG_SEQ0(HX9023S_UP_ALP_1_0_CFG, 0x88),
REG_SEQ0(HX9023S_UP_ALP_3_2_CFG, 0x88),
REG_SEQ0(HX9023S_DN_UP_ALP_0_4_CFG, 0x18),
/* down coefficient of the first order low pass filter during each channel */
REG_SEQ0(HX9023S_DN_ALP_2_1_CFG, 0x11),
REG_SEQ0(HX9023S_DN_ALP_4_3_CFG, 0x11),
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitfield.h`, `linux/bitops.h`, `linux/cleanup.h`, `linux/device.h`, `linux/errno.h`, `linux/firmware.h`, `linux/i2c.h`.
- Detected declarations: `struct hx9023s_bin`, `struct hx9023s_ch_data`, `struct hx9023s_data`, `function hx9023s_interrupt_enable`, `function hx9023s_interrupt_disable`, `function hx9023s_data_lock`, `function hx9023s_ch_cfg`, `function hx9023s_write_far_debounce`, `function hx9023s_write_near_debounce`, `function hx9023s_read_far_debounce`.
- 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.