drivers/pinctrl/pinctrl-da9062.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pinctrl-da9062.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pinctrl-da9062.c- Extension
.c- Size
- 8100 bytes
- Lines
- 301
- 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/bits.hlinux/module.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/gpio/consumer.hlinux/gpio/driver.hlinux/mfd/da9062/core.hlinux/mfd/da9062/registers.h
Detected Declarations
struct da9062_pctlfunction da9062_pctl_get_pin_modefunction da9062_pctl_set_pin_modefunction da9062_gpio_getfunction da9062_gpio_setfunction da9062_gpio_get_directionfunction da9062_gpio_direction_inputfunction da9062_gpio_direction_outputfunction da9062_gpio_set_configfunction da9062_gpio_to_irqfunction da9062_pctl_probe
Annotated Snippet
struct da9062_pctl {
struct da9062 *da9062;
struct gpio_chip gc;
unsigned int pin_config[DA9062_GPIO_NUM];
};
static int da9062_pctl_get_pin_mode(struct da9062_pctl *pctl,
unsigned int offset)
{
struct regmap *regmap = pctl->da9062->regmap;
int ret, val;
ret = regmap_read(regmap, DA9062AA_GPIO_0_1 + (offset >> 1), &val);
if (ret < 0)
return ret;
val >>= DA9062_PIN_SHIFT(offset);
val &= DA9062AA_GPIO0_PIN_MASK;
return val;
}
static int da9062_pctl_set_pin_mode(struct da9062_pctl *pctl,
unsigned int offset, unsigned int mode_req)
{
struct regmap *regmap = pctl->da9062->regmap;
unsigned int mode = mode_req;
unsigned int mask;
int ret;
mode &= DA9062AA_GPIO0_PIN_MASK;
mode <<= DA9062_PIN_SHIFT(offset);
mask = DA9062AA_GPIO0_PIN_MASK << DA9062_PIN_SHIFT(offset);
ret = regmap_update_bits(regmap, DA9062AA_GPIO_0_1 + (offset >> 1),
mask, mode);
if (!ret)
pctl->pin_config[offset] = mode_req;
return ret;
}
static int da9062_gpio_get(struct gpio_chip *gc, unsigned int offset)
{
struct da9062_pctl *pctl = gpiochip_get_data(gc);
struct regmap *regmap = pctl->da9062->regmap;
int gpio_mode, val;
int ret;
gpio_mode = da9062_pctl_get_pin_mode(pctl, offset);
if (gpio_mode < 0)
return gpio_mode;
switch (gpio_mode) {
case DA9062_PIN_ALTERNATE:
return -ENOTSUPP;
case DA9062_PIN_GPI:
ret = regmap_read(regmap, DA9062AA_STATUS_B, &val);
if (ret < 0)
return ret;
break;
case DA9062_PIN_GPO_OD:
case DA9062_PIN_GPO_PP:
ret = regmap_read(regmap, DA9062AA_GPIO_MODE0_4, &val);
if (ret < 0)
return ret;
}
return !!(val & BIT(offset));
}
static int da9062_gpio_set(struct gpio_chip *gc, unsigned int offset,
int value)
{
struct da9062_pctl *pctl = gpiochip_get_data(gc);
struct regmap *regmap = pctl->da9062->regmap;
return regmap_update_bits(regmap, DA9062AA_GPIO_MODE0_4, BIT(offset),
value << offset);
}
static int da9062_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
{
struct da9062_pctl *pctl = gpiochip_get_data(gc);
int gpio_mode;
gpio_mode = da9062_pctl_get_pin_mode(pctl, offset);
if (gpio_mode < 0)
return gpio_mode;
Annotation
- Immediate include surface: `linux/bits.h`, `linux/module.h`, `linux/platform_device.h`, `linux/property.h`, `linux/regmap.h`, `linux/gpio/consumer.h`, `linux/gpio/driver.h`, `linux/mfd/da9062/core.h`.
- Detected declarations: `struct da9062_pctl`, `function da9062_pctl_get_pin_mode`, `function da9062_pctl_set_pin_mode`, `function da9062_gpio_get`, `function da9062_gpio_set`, `function da9062_gpio_get_direction`, `function da9062_gpio_direction_input`, `function da9062_gpio_direction_output`, `function da9062_gpio_set_config`, `function da9062_gpio_to_irq`.
- 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.