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.

Dependency Surface

Detected Declarations

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

Implementation Notes