drivers/iio/adc/rohm-bd79124.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/rohm-bd79124.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/rohm-bd79124.c- Extension
.c- Size
- 30604 bytes
- Lines
- 1126
- 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/array_size.hlinux/bitfield.hlinux/bitmap.hlinux/bits.hlinux/device.hlinux/delay.hlinux/devm-helpers.hlinux/err.hlinux/gpio/driver.hlinux/i2c.hlinux/interrupt.hlinux/irqreturn.hlinux/module.hlinux/mod_devicetable.hlinux/regmap.hlinux/types.hasm/byteorder.hlinux/iio/events.hlinux/iio/iio.hlinux/iio/adc-helpers.h
Detected Declarations
struct bd79124_datastruct bd79124_rawfunction bd79124gpo_direction_getfunction bd79124gpo_setfunction bd79124gpo_set_multiplefunction bd79124_init_valid_maskfunction bd79124_read_reg_to_intfunction bd79124_write_int_to_regfunction bd79124_read_event_valuefunction bd79124_start_measurementfunction bd79124_stop_measurementfunction bd79124_read_event_configfunction bd79124_disable_eventfunction bd79124_enable_eventfunction bd79124_write_event_configfunction bd79124_write_event_valuefunction bd79124_single_chan_seqfunction bd79124_single_chan_seq_endfunction bd79124_read_rawfunction bd79124_re_enable_lofunction bd79124_re_enable_hifunction bd79124_alm_enable_workerfunction __bd79124_event_ratelimitfunction bd79124_event_ratelimit_hifunction bd79124_event_ratelimit_lofunction bd79124_event_handlerfunction bd79124_irq_handlerfunction bd79124_chan_initfunction bd79124_get_gpio_pinsfunction bd79124_hw_initfunction bd79124_probe
Annotated Snippet
struct bd79124_data {
s64 timestamp;
struct regmap *map;
struct device *dev;
int vmax;
/*
* Keep measurement status so read_raw() knows if the measurement needs
* to be started.
*/
int alarm_monitored[BD79124_MAX_NUM_CHANNELS];
/*
* The BD79124 does not allow disabling/enabling limit separately for
* one direction only. Hence, we do the disabling by changing the limit
* to maximum/minimum measurable value. This means we need to cache
* the limit in order to maintain it over the time limit is disabled.
*/
u16 alarm_r_limit[BD79124_MAX_NUM_CHANNELS];
u16 alarm_f_limit[BD79124_MAX_NUM_CHANNELS];
/* Bitmask of disabled events (for rate limiting) for each channel. */
int alarm_suppressed[BD79124_MAX_NUM_CHANNELS];
/*
* The BD79124 is configured to run the measurements in the background.
* This is done for the event monitoring as well as for the read_raw().
* Protect the measurement starting/stopping using a mutex.
*/
struct mutex mutex;
struct delayed_work alm_enable_work;
struct gpio_chip gc;
u8 gpio_valid_mask;
};
static const struct regmap_range bd79124_ro_ranges[] = {
regmap_reg_range(BD79124_REG_EVENT_FLAG, BD79124_REG_EVENT_FLAG),
regmap_reg_range(BD79124_REG_RECENT_CH0_LSB, BD79124_REG_RECENT_CH7_MSB),
};
static const struct regmap_access_table bd79124_ro_regs = {
.no_ranges = &bd79124_ro_ranges[0],
.n_no_ranges = ARRAY_SIZE(bd79124_ro_ranges),
};
static const struct regmap_range bd79124_volatile_ranges[] = {
regmap_reg_range(BD79124_REG_RECENT_CH0_LSB, BD79124_REG_RECENT_CH7_MSB),
regmap_reg_range(BD79124_REG_EVENT_FLAG, BD79124_REG_EVENT_FLAG),
regmap_reg_range(BD79124_REG_EVENT_FLAG_HI, BD79124_REG_EVENT_FLAG_HI),
regmap_reg_range(BD79124_REG_EVENT_FLAG_LO, BD79124_REG_EVENT_FLAG_LO),
regmap_reg_range(BD79124_REG_SYSTEM_STATUS, BD79124_REG_SYSTEM_STATUS),
};
static const struct regmap_access_table bd79124_volatile_regs = {
.yes_ranges = &bd79124_volatile_ranges[0],
.n_yes_ranges = ARRAY_SIZE(bd79124_volatile_ranges),
};
static const struct regmap_range bd79124_precious_ranges[] = {
regmap_reg_range(BD79124_REG_EVENT_FLAG_HI, BD79124_REG_EVENT_FLAG_HI),
regmap_reg_range(BD79124_REG_EVENT_FLAG_LO, BD79124_REG_EVENT_FLAG_LO),
};
static const struct regmap_access_table bd79124_precious_regs = {
.yes_ranges = &bd79124_precious_ranges[0],
.n_yes_ranges = ARRAY_SIZE(bd79124_precious_ranges),
};
static const struct regmap_config bd79124_regmap = {
.reg_bits = 16,
.val_bits = 8,
.read_flag_mask = BD79124_I2C_MULTI_READ,
.write_flag_mask = BD79124_I2C_MULTI_WRITE,
.max_register = BD79124_REG_MAX,
.cache_type = REGCACHE_MAPLE,
.volatile_table = &bd79124_volatile_regs,
.wr_table = &bd79124_ro_regs,
.precious_table = &bd79124_precious_regs,
};
static int bd79124gpo_direction_get(struct gpio_chip *gc, unsigned int offset)
{
return GPIO_LINE_DIRECTION_OUT;
}
static int bd79124gpo_set(struct gpio_chip *gc, unsigned int offset, int value)
{
struct bd79124_data *data = gpiochip_get_data(gc);
return regmap_assign_bits(data->map, BD79124_REG_GPO_VAL, BIT(offset),
value);
}
static int bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask,
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitfield.h`, `linux/bitmap.h`, `linux/bits.h`, `linux/device.h`, `linux/delay.h`, `linux/devm-helpers.h`, `linux/err.h`.
- Detected declarations: `struct bd79124_data`, `struct bd79124_raw`, `function bd79124gpo_direction_get`, `function bd79124gpo_set`, `function bd79124gpo_set_multiple`, `function bd79124_init_valid_mask`, `function bd79124_read_reg_to_int`, `function bd79124_write_int_to_reg`, `function bd79124_read_event_value`, `function bd79124_start_measurement`.
- 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.