drivers/iio/pressure/icp10100.c
Source file repositories/reference/linux-study-clean/drivers/iio/pressure/icp10100.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/pressure/icp10100.c- Extension
.c- Size
- 15981 bytes
- Lines
- 655
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/module.hlinux/mod_devicetable.hlinux/i2c.hlinux/pm_runtime.hlinux/crc8.hlinux/mutex.hlinux/delay.hlinux/log2.hlinux/math64.hlinux/regulator/consumer.hlinux/iio/iio.h
Detected Declarations
struct icp10100_statestruct icp10100_commandenum icp10100_modefunction icp10100_i2c_xferfunction icp10100_send_cmdfunction icp10100_read_cal_otpfunction icp10100_init_chipfunction icp10100_get_measuresfunction icp10100_get_pressurefunction icp10100_read_raw_measuresfunction icp10100_read_rawfunction icp10100_read_availfunction icp10100_write_rawfunction icp10100_write_raw_get_fmtfunction icp10100_enable_regulatorfunction icp10100_disable_regulator_actionfunction icp10100_pm_disablefunction icp10100_probefunction icp10100_suspendfunction icp10100_resume
Annotated Snippet
struct icp10100_state {
struct mutex lock;
struct i2c_client *client;
struct regulator *vdd;
enum icp10100_mode mode;
int16_t cal[4];
};
struct icp10100_command {
__be16 cmd;
unsigned long wait_us;
unsigned long wait_max_us;
size_t response_word_nb;
};
static const struct icp10100_command icp10100_cmd_soft_reset = {
.cmd = cpu_to_be16(0x805D),
.wait_us = 170,
.wait_max_us = 200,
.response_word_nb = 0,
};
static const struct icp10100_command icp10100_cmd_read_id = {
.cmd = cpu_to_be16(0xEFC8),
.wait_us = 0,
.response_word_nb = 1,
};
static const struct icp10100_command icp10100_cmd_read_otp = {
.cmd = cpu_to_be16(0xC7F7),
.wait_us = 0,
.response_word_nb = 1,
};
static const struct icp10100_command icp10100_cmd_measure[] = {
[ICP10100_MODE_LP] = {
.cmd = cpu_to_be16(0x401A),
.wait_us = 1800,
.wait_max_us = 2000,
.response_word_nb = 3,
},
[ICP10100_MODE_N] = {
.cmd = cpu_to_be16(0x48A3),
.wait_us = 6300,
.wait_max_us = 6500,
.response_word_nb = 3,
},
[ICP10100_MODE_LN] = {
.cmd = cpu_to_be16(0x5059),
.wait_us = 23800,
.wait_max_us = 24000,
.response_word_nb = 3,
},
[ICP10100_MODE_ULN] = {
.cmd = cpu_to_be16(0x58E0),
.wait_us = 94500,
.wait_max_us = 94700,
.response_word_nb = 3,
},
};
static const uint8_t icp10100_switch_mode_otp[] =
{0xC5, 0x95, 0x00, 0x66, 0x9c};
DECLARE_CRC8_TABLE(icp10100_crc8_table);
static inline int icp10100_i2c_xfer(struct i2c_adapter *adap,
struct i2c_msg *msgs, int num)
{
int ret;
ret = i2c_transfer(adap, msgs, num);
if (ret < 0)
return ret;
if (ret != num)
return -EIO;
return 0;
}
static int icp10100_send_cmd(struct icp10100_state *st,
const struct icp10100_command *cmd,
__be16 *buf, size_t buf_len)
{
size_t size = cmd->response_word_nb * ICP10100_RESPONSE_WORD_LENGTH;
uint8_t data[16];
uint8_t *ptr;
uint8_t *buf_ptr = (uint8_t *)buf;
struct i2c_msg msgs[2] = {
Annotation
- Immediate include surface: `linux/device.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/i2c.h`, `linux/pm_runtime.h`, `linux/crc8.h`, `linux/mutex.h`, `linux/delay.h`.
- Detected declarations: `struct icp10100_state`, `struct icp10100_command`, `enum icp10100_mode`, `function icp10100_i2c_xfer`, `function icp10100_send_cmd`, `function icp10100_read_cal_otp`, `function icp10100_init_chip`, `function icp10100_get_measures`, `function icp10100_get_pressure`, `function icp10100_read_raw_measures`.
- 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.
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.