drivers/pinctrl/pinctrl-axp209.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pinctrl-axp209.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pinctrl-axp209.c- Extension
.c- Size
- 14326 bytes
- Lines
- 536
- Domain
- Driver Families
- Bucket
- drivers/pinctrl
- 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/bitops.hlinux/device.hlinux/gpio/driver.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/mfd/axp20x.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/slab.hlinux/pinctrl/consumer.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.h
Detected Declarations
struct axp20x_pctrl_descstruct axp20x_pinctrl_functionstruct axp20x_pctlfunction axp20x_gpio_get_regfunction axp20x_gpio_getfunction axp20x_gpio_get_directionfunction axp20x_gpio_outputfunction axp20x_gpio_setfunction axp20x_pmx_setfunction axp20x_pmx_func_cntfunction axp20x_pmx_func_groupsfunction axp20x_pmx_set_muxfunction axp20x_pmx_gpio_set_directionfunction axp20x_groups_cntfunction axp20x_group_pinsfunction axp20x_funcs_groups_from_maskfunction for_each_set_bitfunction axp20x_build_funcs_groupsfunction axp20x_pctl_probe
Annotated Snippet
struct axp20x_pctrl_desc {
const struct pinctrl_pin_desc *pins;
unsigned int npins;
/* Stores the pins supporting LDO function. Bit offset is pin number. */
u8 ldo_mask;
/* Stores the pins supporting ADC function. Bit offset is pin number. */
u8 adc_mask;
u8 gpio_status_offset;
u8 adc_mux;
};
struct axp20x_pinctrl_function {
const char *name;
unsigned int muxval;
const char **groups;
unsigned int ngroups;
};
struct axp20x_pctl {
struct gpio_chip chip;
struct regmap *regmap;
struct pinctrl_dev *pctl_dev;
struct device *dev;
const struct axp20x_pctrl_desc *desc;
struct axp20x_pinctrl_function funcs[AXP20X_FUNCS_NB];
};
static const struct pinctrl_pin_desc axp209_pins[] = {
PINCTRL_PIN(0, "GPIO0"),
PINCTRL_PIN(1, "GPIO1"),
PINCTRL_PIN(2, "GPIO2"),
PINCTRL_PIN(3, "GPIO3"),
};
static const struct pinctrl_pin_desc axp22x_pins[] = {
PINCTRL_PIN(0, "GPIO0"),
PINCTRL_PIN(1, "GPIO1"),
};
static const struct axp20x_pctrl_desc axp20x_data = {
.pins = axp209_pins,
.npins = ARRAY_SIZE(axp209_pins),
.ldo_mask = BIT(0) | BIT(1),
.adc_mask = BIT(0) | BIT(1),
.gpio_status_offset = 4,
.adc_mux = AXP20X_MUX_ADC,
};
static const struct axp20x_pctrl_desc axp22x_data = {
.pins = axp22x_pins,
.npins = ARRAY_SIZE(axp22x_pins),
.ldo_mask = BIT(0) | BIT(1),
.gpio_status_offset = 0,
};
static const struct axp20x_pctrl_desc axp813_data = {
.pins = axp22x_pins,
.npins = ARRAY_SIZE(axp22x_pins),
.ldo_mask = BIT(0) | BIT(1),
.adc_mask = BIT(0),
.gpio_status_offset = 0,
.adc_mux = AXP813_MUX_ADC,
};
static int axp20x_gpio_get_reg(unsigned int offset)
{
switch (offset) {
case 0:
return AXP20X_GPIO0_CTRL;
case 1:
return AXP20X_GPIO1_CTRL;
case 2:
return AXP20X_GPIO2_CTRL;
}
return -EINVAL;
}
static int axp20x_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct axp20x_pctl *pctl = gpiochip_get_data(chip);
unsigned int val;
int ret;
/* AXP209 has GPIO3 status sharing the settings register */
if (offset == 3) {
ret = regmap_read(pctl->regmap, AXP20X_GPIO3_CTRL, &val);
if (ret)
return ret;
return !!(val & BIT(0));
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/device.h`, `linux/gpio/driver.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mfd/axp20x.h`, `linux/module.h`.
- Detected declarations: `struct axp20x_pctrl_desc`, `struct axp20x_pinctrl_function`, `struct axp20x_pctl`, `function axp20x_gpio_get_reg`, `function axp20x_gpio_get`, `function axp20x_gpio_get_direction`, `function axp20x_gpio_output`, `function axp20x_gpio_set`, `function axp20x_pmx_set`, `function axp20x_pmx_func_cnt`.
- Atlas domain: Driver Families / drivers/pinctrl.
- 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.