drivers/iio/adc/max77541-adc.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/max77541-adc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/max77541-adc.c- Extension
.c- Size
- 4707 bytes
- Lines
- 195
- 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/iio/iio.hlinux/mod_devicetable.hlinux/platform_device.hlinux/regmap.hlinux/units.hlinux/mfd/max77541.h
Detected Declarations
enum max77541_adc_rangeenum max77541_adc_channelfunction max77541_adc_offsetfunction max77541_adc_scalefunction max77541_adc_rawfunction max77541_adc_read_rawfunction max77541_adc_probe
Annotated Snippet
switch (reg_val) {
case LOW_RANGE:
*val = 6;
*val2 = 250000;
break;
case MID_RANGE:
*val = 12;
*val2 = 500000;
break;
case HIGH_RANGE:
*val = 25;
return IIO_VAL_INT;
default:
return -EINVAL;
}
return IIO_VAL_INT_PLUS_MICRO;
case MAX77541_ADC_TEMP:
*val = 1725;
return IIO_VAL_INT;
default:
return -EINVAL;
}
}
static int max77541_adc_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val)
{
struct regmap **regmap = iio_priv(indio_dev);
int ret;
ret = regmap_read(*regmap, chan->address, val);
if (ret)
return ret;
return IIO_VAL_INT;
}
#define MAX77541_ADC_CHANNEL_V(_channel, _name, _type, _reg) \
{ \
.type = _type, \
.indexed = 1, \
.channel = _channel, \
.address = _reg, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
BIT(IIO_CHAN_INFO_SCALE), \
.datasheet_name = _name, \
}
#define MAX77541_ADC_CHANNEL_TEMP(_channel, _name, _type, _reg) \
{ \
.type = _type, \
.indexed = 1, \
.channel = _channel, \
.address = _reg, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
BIT(IIO_CHAN_INFO_SCALE) |\
BIT(IIO_CHAN_INFO_OFFSET),\
.datasheet_name = _name, \
}
static const struct iio_chan_spec max77541_adc_channels[] = {
MAX77541_ADC_CHANNEL_V(MAX77541_ADC_VSYS_V, "vsys_v", IIO_VOLTAGE,
MAX77541_REG_ADC_DATA_CH1),
MAX77541_ADC_CHANNEL_V(MAX77541_ADC_VOUT1_V, "vout1_v", IIO_VOLTAGE,
MAX77541_REG_ADC_DATA_CH2),
MAX77541_ADC_CHANNEL_V(MAX77541_ADC_VOUT2_V, "vout2_v", IIO_VOLTAGE,
MAX77541_REG_ADC_DATA_CH3),
MAX77541_ADC_CHANNEL_TEMP(MAX77541_ADC_TEMP, "temp", IIO_TEMP,
MAX77541_REG_ADC_DATA_CH6),
};
static int max77541_adc_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{
switch (mask) {
case IIO_CHAN_INFO_OFFSET:
return max77541_adc_offset(indio_dev, chan, val, val2);
case IIO_CHAN_INFO_SCALE:
return max77541_adc_scale(indio_dev, chan, val, val2);
case IIO_CHAN_INFO_RAW:
return max77541_adc_raw(indio_dev, chan, val);
default:
return -EINVAL;
}
}
static const struct iio_info max77541_adc_info = {
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/iio/iio.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/units.h`, `linux/mfd/max77541.h`.
- Detected declarations: `enum max77541_adc_range`, `enum max77541_adc_channel`, `function max77541_adc_offset`, `function max77541_adc_scale`, `function max77541_adc_raw`, `function max77541_adc_read_raw`, `function max77541_adc_probe`.
- 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.