drivers/iio/proximity/sx9310.c
Source file repositories/reference/linux-study-clean/drivers/iio/proximity/sx9310.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/proximity/sx9310.c- Extension
.c- Size
- 30633 bytes
- Lines
- 1040
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/delay.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/log2.hlinux/mod_devicetable.hlinux/module.hlinux/pm.hlinux/property.hlinux/regmap.hlinux/iio/iio.hsx_common.h
Detected Declarations
struct sx931x_infofunction sx9310_read_prox_datafunction sx9310_wait_for_samplefunction sx9310_read_gainfunction sx9310_read_samp_freqfunction sx9310_read_rawfunction sx9310_read_availfunction sx9310_get_thresh_regfunction sx9310_read_threshfunction sx9310_read_hysteresisfunction sx9310_read_far_debouncefunction sx9310_read_close_debouncefunction sx9310_read_event_valfunction sx9310_write_threshfunction sx9310_write_hysteresisfunction sx9310_write_far_debouncefunction sx9310_write_close_debouncefunction sx9310_write_event_valfunction sx9310_set_samp_freqfunction sx9310_write_gainfunction sx9310_write_rawfunction sx9310_init_compensationfunction sx9310_get_default_regfunction sx9310_check_whoamifunction sx9310_probefunction sx9310_suspendfunction sx9310_resumefunction scoped_guard
Annotated Snippet
struct sx931x_info {
const char *name;
unsigned int whoami;
};
static const struct iio_chan_spec sx9310_channels[] = {
SX9310_CHANNEL(0), /* CS0 */
SX9310_CHANNEL(1), /* CS1 */
SX9310_CHANNEL(2), /* CS2 */
SX9310_NAMED_CHANNEL(3, "comb"), /* COMB */
IIO_CHAN_SOFT_TIMESTAMP(4),
};
/*
* Each entry contains the integer part (val) and the fractional part, in micro
* seconds. It conforms to the IIO output IIO_VAL_INT_PLUS_MICRO.
*/
static const struct {
int val;
int val2;
} sx9310_samp_freq_table[] = {
{ 500, 0 }, /* 0000: Min (no idle time) */
{ 66, 666666 }, /* 0001: 15 ms */
{ 33, 333333 }, /* 0010: 30 ms (Typ.) */
{ 22, 222222 }, /* 0011: 45 ms */
{ 16, 666666 }, /* 0100: 60 ms */
{ 11, 111111 }, /* 0101: 90 ms */
{ 8, 333333 }, /* 0110: 120 ms */
{ 5, 0 }, /* 0111: 200 ms */
{ 2, 500000 }, /* 1000: 400 ms */
{ 1, 666666 }, /* 1001: 600 ms */
{ 1, 250000 }, /* 1010: 800 ms */
{ 1, 0 }, /* 1011: 1 s */
{ 0, 500000 }, /* 1100: 2 s */
{ 0, 333333 }, /* 1101: 3 s */
{ 0, 250000 }, /* 1110: 4 s */
{ 0, 200000 }, /* 1111: 5 s */
};
static const unsigned int sx9310_scan_period_table[] = {
2, 15, 30, 45, 60, 90, 120, 200,
400, 600, 800, 1000, 2000, 3000, 4000, 5000,
};
static const struct regmap_range sx9310_writable_reg_ranges[] = {
regmap_reg_range(SX9310_REG_IRQ_MSK, SX9310_REG_IRQ_FUNC),
regmap_reg_range(SX9310_REG_PROX_CTRL0, SX9310_REG_PROX_CTRL19),
regmap_reg_range(SX9310_REG_SAR_CTRL0, SX9310_REG_SAR_CTRL2),
regmap_reg_range(SX9310_REG_SENSOR_SEL, SX9310_REG_SENSOR_SEL),
regmap_reg_range(SX9310_REG_OFFSET_MSB, SX9310_REG_OFFSET_LSB),
regmap_reg_range(SX9310_REG_PAUSE, SX9310_REG_PAUSE),
regmap_reg_range(SX9310_REG_RESET, SX9310_REG_RESET),
};
static const struct regmap_access_table sx9310_writeable_regs = {
.yes_ranges = sx9310_writable_reg_ranges,
.n_yes_ranges = ARRAY_SIZE(sx9310_writable_reg_ranges),
};
static const struct regmap_range sx9310_readable_reg_ranges[] = {
regmap_reg_range(SX9310_REG_IRQ_SRC, SX9310_REG_IRQ_FUNC),
regmap_reg_range(SX9310_REG_PROX_CTRL0, SX9310_REG_PROX_CTRL19),
regmap_reg_range(SX9310_REG_SAR_CTRL0, SX9310_REG_SAR_CTRL2),
regmap_reg_range(SX9310_REG_SENSOR_SEL, SX9310_REG_SAR_LSB),
regmap_reg_range(SX9310_REG_I2C_ADDR, SX9310_REG_WHOAMI),
regmap_reg_range(SX9310_REG_RESET, SX9310_REG_RESET),
};
static const struct regmap_access_table sx9310_readable_regs = {
.yes_ranges = sx9310_readable_reg_ranges,
.n_yes_ranges = ARRAY_SIZE(sx9310_readable_reg_ranges),
};
static const struct regmap_range sx9310_volatile_reg_ranges[] = {
regmap_reg_range(SX9310_REG_IRQ_SRC, SX9310_REG_STAT1),
regmap_reg_range(SX9310_REG_USE_MSB, SX9310_REG_DIFF_LSB),
regmap_reg_range(SX9310_REG_SAR_MSB, SX9310_REG_SAR_LSB),
regmap_reg_range(SX9310_REG_RESET, SX9310_REG_RESET),
};
static const struct regmap_access_table sx9310_volatile_regs = {
.yes_ranges = sx9310_volatile_reg_ranges,
.n_yes_ranges = ARRAY_SIZE(sx9310_volatile_reg_ranges),
};
static const struct regmap_config sx9310_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = SX9310_REG_RESET,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/log2.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct sx931x_info`, `function sx9310_read_prox_data`, `function sx9310_wait_for_sample`, `function sx9310_read_gain`, `function sx9310_read_samp_freq`, `function sx9310_read_raw`, `function sx9310_read_avail`, `function sx9310_get_thresh_reg`, `function sx9310_read_thresh`, `function sx9310_read_hysteresis`.
- 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.