drivers/i2c/muxes/i2c-mux-ltc4306.c
Source file repositories/reference/linux-study-clean/drivers/i2c/muxes/i2c-mux-ltc4306.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/muxes/i2c-mux-ltc4306.c- Extension
.c- Size
- 7772 bytes
- Lines
- 318
- 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.
- 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/gpio/consumer.hlinux/gpio/driver.hlinux/i2c-mux.hlinux/i2c.hlinux/module.hlinux/of.hlinux/property.hlinux/regmap.hlinux/slab.h
Detected Declarations
struct chip_descstruct ltc4306enum ltc_typefunction ltc4306_is_volatile_regfunction ltc4306_gpio_getfunction ltc4306_gpio_setfunction ltc4306_gpio_get_directionfunction ltc4306_gpio_direction_inputfunction ltc4306_gpio_direction_outputfunction ltc4306_gpio_set_configfunction ltc4306_gpio_initfunction ltc4306_select_muxfunction ltc4306_deselect_muxfunction ltc4306_probefunction ltc4306_remove
Annotated Snippet
struct chip_desc {
u8 nchans;
u8 num_gpios;
};
struct ltc4306 {
struct regmap *regmap;
struct gpio_chip gpiochip;
const struct chip_desc *chip;
};
static const struct chip_desc chips[] = {
[ltc_4305] = {
.nchans = LTC4305_MAX_NCHANS,
},
[ltc_4306] = {
.nchans = LTC4306_MAX_NCHANS,
.num_gpios = 2,
},
};
static bool ltc4306_is_volatile_reg(struct device *dev, unsigned int reg)
{
return reg == LTC_REG_CONFIG;
}
static const struct regmap_config ltc4306_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = LTC_REG_SWITCH,
.volatile_reg = ltc4306_is_volatile_reg,
.cache_type = REGCACHE_FLAT,
};
static int ltc4306_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct ltc4306 *data = gpiochip_get_data(chip);
unsigned int val;
int ret;
ret = regmap_read(data->regmap, LTC_REG_CONFIG, &val);
if (ret < 0)
return ret;
return !!(val & BIT(1 - offset));
}
static int ltc4306_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
struct ltc4306 *data = gpiochip_get_data(chip);
return regmap_update_bits(data->regmap, LTC_REG_CONFIG,
BIT(5 - offset), value ? BIT(5 - offset) : 0);
}
static int ltc4306_gpio_get_direction(struct gpio_chip *chip,
unsigned int offset)
{
struct ltc4306 *data = gpiochip_get_data(chip);
unsigned int val;
int ret;
ret = regmap_read(data->regmap, LTC_REG_MODE, &val);
if (ret < 0)
return ret;
return !!(val & BIT(7 - offset));
}
static int ltc4306_gpio_direction_input(struct gpio_chip *chip,
unsigned int offset)
{
struct ltc4306 *data = gpiochip_get_data(chip);
return regmap_update_bits(data->regmap, LTC_REG_MODE,
BIT(7 - offset), BIT(7 - offset));
}
static int ltc4306_gpio_direction_output(struct gpio_chip *chip,
unsigned int offset, int value)
{
struct ltc4306 *data = gpiochip_get_data(chip);
ltc4306_gpio_set(chip, offset, value);
return regmap_update_bits(data->regmap, LTC_REG_MODE,
BIT(7 - offset), 0);
}
static int ltc4306_gpio_set_config(struct gpio_chip *chip,
Annotation
- Immediate include surface: `linux/gpio/consumer.h`, `linux/gpio/driver.h`, `linux/i2c-mux.h`, `linux/i2c.h`, `linux/module.h`, `linux/of.h`, `linux/property.h`, `linux/regmap.h`.
- Detected declarations: `struct chip_desc`, `struct ltc4306`, `enum ltc_type`, `function ltc4306_is_volatile_reg`, `function ltc4306_gpio_get`, `function ltc4306_gpio_set`, `function ltc4306_gpio_get_direction`, `function ltc4306_gpio_direction_input`, `function ltc4306_gpio_direction_output`, `function ltc4306_gpio_set_config`.
- Atlas domain: Driver Families / drivers/i2c.
- 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.