drivers/gpio/gpio-ltc4283.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-ltc4283.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-ltc4283.c- Extension
.c- Size
- 5561 bytes
- Lines
- 219
- Domain
- Driver Families
- Bucket
- drivers/gpio
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/auxiliary_bus.hlinux/bitfield.hlinux/bitmap.hlinux/bits.hlinux/device.hlinux/gpio/driver.hlinux/mod_devicetable.hlinux/module.hlinux/regmap.h
Detected Declarations
struct ltc4283_gpiofunction ltc4283_pgio_get_directionfunction ltc4283_gpio_get_directionfunction ltc4283_gpio_direction_setfunction __ltc4283_gpio_set_valuefunction ltc4283_gpio_direction_inputfunction ltc4283_gpio_direction_outputfunction ltc4283_gpio_get_valuefunction ltc4283_gpio_set_valuefunction ltc4283_init_valid_maskfunction ltc4283_gpio_probe
Annotated Snippet
struct ltc4283_gpio {
struct gpio_chip gpio_chip;
struct regmap *regmap;
};
static int ltc4283_pgio_get_direction(const struct ltc4283_gpio *st, unsigned int off)
{
unsigned int val;
int ret;
ret = regmap_read(st->regmap, LTC4283_PGIO_CONFIG, &val);
if (ret)
return ret;
val = field_get(LTC4283_PGIO_CFG_MASK(off), val);
if (val == LTC4283_PGIO_DIR_IN)
return GPIO_LINE_DIRECTION_IN;
return GPIO_LINE_DIRECTION_OUT;
}
static int ltc4283_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
{
struct ltc4283_gpio *st = gpiochip_get_data(gc);
unsigned int val;
int ret;
if (off >= LTC4283_PGIOX_START_NR)
return ltc4283_pgio_get_direction(st, off);
ret = regmap_read(st->regmap, LTC4283_ADIO_CONFIG, &val);
if (ret)
return ret;
if (val & LTC4283_ADIOX_CONFIG_MASK(off))
return GPIO_LINE_DIRECTION_IN;
return GPIO_LINE_DIRECTION_OUT;
}
static int ltc4283_gpio_direction_set(const struct ltc4283_gpio *st,
unsigned int off, bool input)
{
if (off >= LTC4283_PGIOX_START_NR) {
unsigned int val = LTC4283_PGIO_DIR_OUT;
if (input)
val = LTC4283_PGIO_DIR_IN;
val = field_prep(LTC4283_PGIO_CFG_MASK(off), val);
return regmap_update_bits(st->regmap, LTC4283_PGIO_CONFIG,
LTC4283_PGIO_CFG_MASK(off), val);
}
return regmap_update_bits(st->regmap, LTC4283_ADIO_CONFIG,
LTC4283_ADIOX_CONFIG_MASK(off),
field_prep(LTC4283_ADIOX_CONFIG_MASK(off), input));
}
static int __ltc4283_gpio_set_value(const struct ltc4283_gpio *st,
unsigned int off, int val)
{
u32 reg = off < LTC4283_PGIOX_START_NR ? LTC4283_ADIO_CONFIG : LTC4283_PGIO_CONFIG_2;
return regmap_update_bits(st->regmap, reg, BIT(off),
field_prep(BIT(off), !!val));
}
static int ltc4283_gpio_direction_input(struct gpio_chip *gc, unsigned int off)
{
struct ltc4283_gpio *st = gpiochip_get_data(gc);
return ltc4283_gpio_direction_set(st, off, true);
}
static int ltc4283_gpio_direction_output(struct gpio_chip *gc, unsigned int off, int val)
{
struct ltc4283_gpio *st = gpiochip_get_data(gc);
int ret;
ret = ltc4283_gpio_direction_set(st, off, false);
if (ret)
return ret;
return __ltc4283_gpio_set_value(st, off, val);
}
static int ltc4283_gpio_get_value(struct gpio_chip *gc, unsigned int off)
{
struct ltc4283_gpio *st = gpiochip_get_data(gc);
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/bitfield.h`, `linux/bitmap.h`, `linux/bits.h`, `linux/device.h`, `linux/gpio/driver.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct ltc4283_gpio`, `function ltc4283_pgio_get_direction`, `function ltc4283_gpio_get_direction`, `function ltc4283_gpio_direction_set`, `function __ltc4283_gpio_set_value`, `function ltc4283_gpio_direction_input`, `function ltc4283_gpio_direction_output`, `function ltc4283_gpio_get_value`, `function ltc4283_gpio_set_value`, `function ltc4283_init_valid_mask`.
- Atlas domain: Driver Families / drivers/gpio.
- 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.