drivers/iio/light/veml6030.c
Source file repositories/reference/linux-study-clean/drivers/iio/light/veml6030.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/light/veml6030.c- Extension
.c- Size
- 32916 bytes
- Lines
- 1243
- 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/module.hlinux/i2c.hlinux/err.hlinux/regmap.hlinux/interrupt.hlinux/pm_runtime.hlinux/units.hlinux/regulator/consumer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/events.hlinux/iio/iio-gts-helper.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.h
Detected Declarations
struct veml6030_rfstruct veml603x_chipstruct veml6030_dataenum veml6030_scanenum veml6030_chanfunction in_illuminance_period_available_showfunction veml6030_als_pwr_onfunction veml6030_als_shut_downfunction veml6030_als_shut_down_actionfunction veml6030_get_itfunction veml6030_set_itfunction veml6030_read_persistencefunction veml6030_write_persistencefunction veml6030_set_scalefunction veml6030_read_threshfunction veml6030_write_threshfunction veml6030_get_total_gainfunction veml6030_get_scalefunction veml6030_process_alsfunction lightfunction veml6030_read_availfunction veml6030_write_rawfunction veml6030_write_raw_get_fmtfunction veml6030_read_event_valfunction veml6030_write_event_valfunction veml6030_read_interrupt_configfunction veml6030_write_interrupt_configfunction veml6030_event_handlerfunction veml6030_trigger_handlerfunction iio_for_each_active_channelfunction veml6030_set_infofunction veml7700_set_infofunction veml6030_regfield_initfunction veml6030_hw_initfunction veml6035_hw_initfunction veml6030_probefunction veml6030_runtime_suspendfunction veml6030_runtime_resume
Annotated Snippet
struct veml6030_rf {
struct regmap_field *it;
struct regmap_field *gain;
};
struct veml603x_chip {
const char *name;
const struct iio_chan_spec *channels;
const int num_channels;
const struct reg_field gain_rf;
const struct reg_field it_rf;
const int max_scale;
int (*hw_init)(struct iio_dev *indio_dev, struct device *dev);
int (*set_info)(struct iio_dev *indio_dev);
};
/*
* The resolution depends on both gain and integration time. The
* cur_resolution stores one of the resolution mentioned in the
* table during startup and gets updated whenever integration time
* or gain is changed.
*
* Table 'resolution and maximum detection range' in the appnotes
* is visualized as a 2D array. The cur_gain stores index of gain
* in this table (0-3 for VEML6030, 0-5 for VEML6035) while the
* cur_integration_time holds index of integration time (0-5).
*/
struct veml6030_data {
struct i2c_client *client;
struct regmap *regmap;
struct veml6030_rf rf;
const struct veml603x_chip *chip;
struct iio_gts gts;
};
#define VEML6030_SEL_IT_25MS 0x0C
#define VEML6030_SEL_IT_50MS 0x08
#define VEML6030_SEL_IT_100MS 0x00
#define VEML6030_SEL_IT_200MS 0x01
#define VEML6030_SEL_IT_400MS 0x02
#define VEML6030_SEL_IT_800MS 0x03
static const struct iio_itime_sel_mul veml6030_it_sel[] = {
GAIN_SCALE_ITIME_US(25000, VEML6030_SEL_IT_25MS, 1),
GAIN_SCALE_ITIME_US(50000, VEML6030_SEL_IT_50MS, 2),
GAIN_SCALE_ITIME_US(100000, VEML6030_SEL_IT_100MS, 4),
GAIN_SCALE_ITIME_US(200000, VEML6030_SEL_IT_200MS, 8),
GAIN_SCALE_ITIME_US(400000, VEML6030_SEL_IT_400MS, 16),
GAIN_SCALE_ITIME_US(800000, VEML6030_SEL_IT_800MS, 32),
};
/* Gains are multiplied by 8 to work with integers. The values in the
* iio-gts tables don't need corrections because the maximum value of
* the scale refers to GAIN = x1, and the rest of the values are
* obtained from the resulting linear function.
*/
#define VEML6030_SEL_MILLI_GAIN_X125 2
#define VEML6030_SEL_MILLI_GAIN_X250 3
#define VEML6030_SEL_MILLI_GAIN_X1000 0
#define VEML6030_SEL_MILLI_GAIN_X2000 1
static const struct iio_gain_sel_pair veml6030_gain_sel[] = {
GAIN_SCALE_GAIN(1, VEML6030_SEL_MILLI_GAIN_X125),
GAIN_SCALE_GAIN(2, VEML6030_SEL_MILLI_GAIN_X250),
GAIN_SCALE_GAIN(8, VEML6030_SEL_MILLI_GAIN_X1000),
GAIN_SCALE_GAIN(16, VEML6030_SEL_MILLI_GAIN_X2000),
};
#define VEML6035_SEL_MILLI_GAIN_X125 4
#define VEML6035_SEL_MILLI_GAIN_X250 5
#define VEML6035_SEL_MILLI_GAIN_X500 7
#define VEML6035_SEL_MILLI_GAIN_X1000 0
#define VEML6035_SEL_MILLI_GAIN_X2000 1
#define VEML6035_SEL_MILLI_GAIN_X4000 3
static const struct iio_gain_sel_pair veml6035_gain_sel[] = {
GAIN_SCALE_GAIN(1, VEML6035_SEL_MILLI_GAIN_X125),
GAIN_SCALE_GAIN(2, VEML6035_SEL_MILLI_GAIN_X250),
GAIN_SCALE_GAIN(4, VEML6035_SEL_MILLI_GAIN_X500),
GAIN_SCALE_GAIN(8, VEML6035_SEL_MILLI_GAIN_X1000),
GAIN_SCALE_GAIN(16, VEML6035_SEL_MILLI_GAIN_X2000),
GAIN_SCALE_GAIN(32, VEML6035_SEL_MILLI_GAIN_X4000),
};
/*
* Persistence = 1/2/4/8 x integration time
* Minimum time for which light readings must stay above configured
* threshold to assert the interrupt.
*/
static const char * const period_values[] = {
"0.1 0.2 0.4 0.8",
"0.2 0.4 0.8 1.6",
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/module.h`, `linux/i2c.h`, `linux/err.h`, `linux/regmap.h`, `linux/interrupt.h`, `linux/pm_runtime.h`, `linux/units.h`.
- Detected declarations: `struct veml6030_rf`, `struct veml603x_chip`, `struct veml6030_data`, `enum veml6030_scan`, `enum veml6030_chan`, `function in_illuminance_period_available_show`, `function veml6030_als_pwr_on`, `function veml6030_als_shut_down`, `function veml6030_als_shut_down_action`, `function veml6030_get_it`.
- 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.