drivers/i2c/muxes/i2c-mux-pca954x.c

Source file repositories/reference/linux-study-clean/drivers/i2c/muxes/i2c-mux-pca954x.c

File Facts

System
Linux kernel
Corpus path
drivers/i2c/muxes/i2c-mux-pca954x.c
Extension
.c
Size
18903 bytes
Lines
718
Domain
Driver Families
Bucket
drivers/i2c
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 chip_desc {
	u8 nchans;
	u8 enable;	/* used for muxes only */
	u8 has_irq;
	enum muxtype {
		pca954x_ismux = 0,
		pca954x_isswi
	} muxtype;
	struct i2c_device_identity id;
};

struct pca954x {
	const struct chip_desc *chip;

	u8 last_chan;		/* last register value */
	/* MUX_IDLE_AS_IS, MUX_IDLE_DISCONNECT or >= 0 for channel */
	s32 idle_state;

	struct i2c_client *client;

	struct irq_domain *irq;
	unsigned int irq_mask;
	raw_spinlock_t lock;
	struct regulator *supply;

	struct gpio_desc *reset_gpio;
	struct reset_control *reset_cont;
};

/* Provide specs for the MAX735x, PCA954x and PCA984x types we know about */
static const struct chip_desc chips[] = {
	[max_7356] = {
		.nchans = 8,
		.muxtype = pca954x_isswi,
		.id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
	},
	[max_7357] = {
		.nchans = 8,
		.muxtype = pca954x_isswi,
		.id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
		/*
		 * No interrupt controller support. The interrupt
		 * provides information about stuck channels.
		 */
	},
	[max_7358] = {
		.nchans = 8,
		.muxtype = pca954x_isswi,
		.id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
		/*
		 * No interrupt controller support. The interrupt
		 * provides information about stuck channels.
		 */
	},
	[max_7367] = {
		.nchans = 4,
		.muxtype = pca954x_isswi,
		.has_irq = 1,
		.id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
	},
	[max_7368] = {
		.nchans = 4,
		.muxtype = pca954x_isswi,
		.id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
	},
	[max_7369] = {
		.nchans = 4,
		.enable = 0x4,
		.muxtype = pca954x_ismux,
		.has_irq = 1,
		.id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
	},
	[pca_9540] = {
		.nchans = 2,
		.enable = 0x4,
		.muxtype = pca954x_ismux,
		.id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
	},
	[pca_9542] = {
		.nchans = 2,
		.enable = 0x4,
		.has_irq = 1,
		.muxtype = pca954x_ismux,
		.id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
	},
	[pca_9543] = {
		.nchans = 2,
		.has_irq = 1,
		.muxtype = pca954x_isswi,
		.id = { .manufacturer_id = I2C_DEVICE_ID_NONE },

Annotation

Implementation Notes