drivers/iio/light/rpr0521.c
Source file repositories/reference/linux-study-clean/drivers/iio/light/rpr0521.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/light/rpr0521.c- Extension
.c- Size
- 27392 bytes
- Lines
- 1127
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/mod_devicetable.hlinux/cleanup.hlinux/init.hlinux/i2c.hlinux/regmap.hlinux/delay.hlinux/iio/iio.hlinux/iio/buffer.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hlinux/iio/sysfs.hlinux/pm_runtime.h
Detected Declarations
struct rpr0521_gainstruct rpr0521_reg_descstruct rpr0521_samp_freqstruct rpr0521_dataenum rpr0521_channelenum rpr0521_scan_index_orderfunction rpr0521_als_enablefunction rpr0521_pxs_enablefunction rpr0521_set_power_statefunction rpr0521_is_triggeredfunction rpr0521_drdy_irq_handlerfunction rpr0521_drdy_irq_threadfunction rpr0521_trigger_consumer_handlerfunction rpr0521_write_int_enablefunction rpr0521_write_int_disablefunction rpr0521_pxs_drdy_set_statefunction rpr0521_buffer_preenablefunction rpr0521_buffer_postdisablefunction rpr0521_get_gainfunction rpr0521_set_gainfunction rpr0521_read_samp_freqfunction rpr0521_write_samp_freq_commonfunction rpr0521_read_ps_offsetfunction rpr0521_write_ps_offsetfunction rpr0521_read_info_rawfunction rpr0521_read_rawfunction rpr0521_write_rawfunction rpr0521_initfunction rpr0521_powerofffunction rpr0521_is_volatile_regfunction rpr0521_probefunction rpr0521_set_power_statefunction rpr0521_removefunction rpr0521_runtime_suspendfunction rpr0521_runtime_resume
Annotated Snippet
struct rpr0521_gain {
int scale;
int uscale;
};
static const struct rpr0521_gain rpr0521_als_gain[4] = {
{1, 0}, /* x1 */
{0, 500000}, /* x2 */
{0, 15625}, /* x64 */
{0, 7812}, /* x128 */
};
static const struct rpr0521_gain rpr0521_pxs_gain[3] = {
{1, 0}, /* x1 */
{0, 500000}, /* x2 */
{0, 125000}, /* x4 */
};
enum rpr0521_channel {
RPR0521_CHAN_PXS,
RPR0521_CHAN_ALS_DATA0,
RPR0521_CHAN_ALS_DATA1,
};
struct rpr0521_reg_desc {
u8 address;
u8 device_mask;
};
static const struct rpr0521_reg_desc rpr0521_data_reg[] = {
[RPR0521_CHAN_PXS] = {
.address = RPR0521_REG_PXS_DATA,
.device_mask = RPR0521_MODE_PXS_MASK,
},
[RPR0521_CHAN_ALS_DATA0] = {
.address = RPR0521_REG_ALS_DATA0,
.device_mask = RPR0521_MODE_ALS_MASK,
},
[RPR0521_CHAN_ALS_DATA1] = {
.address = RPR0521_REG_ALS_DATA1,
.device_mask = RPR0521_MODE_ALS_MASK,
},
};
static const struct rpr0521_gain_info {
u8 reg;
u8 mask;
u8 shift;
const struct rpr0521_gain *gain;
int size;
} rpr0521_gain[] = {
[RPR0521_CHAN_PXS] = {
.reg = RPR0521_REG_PXS_CTRL,
.mask = RPR0521_PXS_GAIN_MASK,
.shift = RPR0521_PXS_GAIN_SHIFT,
.gain = rpr0521_pxs_gain,
.size = ARRAY_SIZE(rpr0521_pxs_gain),
},
[RPR0521_CHAN_ALS_DATA0] = {
.reg = RPR0521_REG_ALS_CTRL,
.mask = RPR0521_ALS_DATA0_GAIN_MASK,
.shift = RPR0521_ALS_DATA0_GAIN_SHIFT,
.gain = rpr0521_als_gain,
.size = ARRAY_SIZE(rpr0521_als_gain),
},
[RPR0521_CHAN_ALS_DATA1] = {
.reg = RPR0521_REG_ALS_CTRL,
.mask = RPR0521_ALS_DATA1_GAIN_MASK,
.shift = RPR0521_ALS_DATA1_GAIN_SHIFT,
.gain = rpr0521_als_gain,
.size = ARRAY_SIZE(rpr0521_als_gain),
},
};
struct rpr0521_samp_freq {
int als_hz;
int als_uhz;
int pxs_hz;
int pxs_uhz;
};
static const struct rpr0521_samp_freq rpr0521_samp_freq_i[13] = {
/* {ALS, PXS}, W==currently writable option */
{0, 0, 0, 0}, /* W0000, 0=standby */
{0, 0, 100, 0}, /* 0001 */
{0, 0, 25, 0}, /* 0010 */
{0, 0, 10, 0}, /* 0011 */
{0, 0, 2, 500000}, /* 0100 */
{10, 0, 20, 0}, /* 0101 */
{10, 0, 10, 0}, /* W0110 */
Annotation
- Immediate include surface: `linux/module.h`, `linux/mod_devicetable.h`, `linux/cleanup.h`, `linux/init.h`, `linux/i2c.h`, `linux/regmap.h`, `linux/delay.h`, `linux/iio/iio.h`.
- Detected declarations: `struct rpr0521_gain`, `struct rpr0521_reg_desc`, `struct rpr0521_samp_freq`, `struct rpr0521_data`, `enum rpr0521_channel`, `enum rpr0521_scan_index_order`, `function rpr0521_als_enable`, `function rpr0521_pxs_enable`, `function rpr0521_set_power_state`, `function rpr0521_is_triggered`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.