drivers/gpio/gpio-arizona.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-arizona.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-arizona.c- Extension
.c- Size
- 5269 bytes
- Lines
- 212
- 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/gpio/driver.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hlinux/mfd/arizona/core.hlinux/mfd/arizona/pdata.hlinux/mfd/arizona/registers.h
Detected Declarations
struct arizona_gpiofunction arizona_gpio_direction_infunction arizona_gpio_getfunction arizona_gpio_direction_outfunction arizona_gpio_setfunction arizona_gpio_probe
Annotated Snippet
struct arizona_gpio {
struct arizona *arizona;
struct gpio_chip gpio_chip;
};
static int arizona_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
{
struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
struct arizona *arizona = arizona_gpio->arizona;
bool persistent = gpiochip_line_is_persistent(chip, offset);
bool change;
int ret;
ret = regmap_update_bits_check(arizona->regmap,
ARIZONA_GPIO1_CTRL + offset,
ARIZONA_GPN_DIR, ARIZONA_GPN_DIR,
&change);
if (ret < 0)
return ret;
if (change && persistent) {
pm_runtime_put_autosuspend(chip->parent);
}
return 0;
}
static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset)
{
struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
struct arizona *arizona = arizona_gpio->arizona;
unsigned int reg, val;
int ret;
reg = ARIZONA_GPIO1_CTRL + offset;
ret = regmap_read(arizona->regmap, reg, &val);
if (ret < 0)
return ret;
/* Resume to read actual registers for input pins */
if (val & ARIZONA_GPN_DIR) {
ret = pm_runtime_get_sync(chip->parent);
if (ret < 0) {
dev_err(chip->parent, "Failed to resume: %d\n", ret);
pm_runtime_put_autosuspend(chip->parent);
return ret;
}
/* Register is cached, drop it to ensure a physical read */
ret = regcache_drop_region(arizona->regmap, reg, reg);
if (ret < 0) {
dev_err(chip->parent, "Failed to drop cache: %d\n",
ret);
pm_runtime_put_autosuspend(chip->parent);
return ret;
}
ret = regmap_read(arizona->regmap, reg, &val);
if (ret < 0) {
pm_runtime_put_autosuspend(chip->parent);
return ret;
}
pm_runtime_put_autosuspend(chip->parent);
}
if (val & ARIZONA_GPN_LVL)
return 1;
else
return 0;
}
static int arizona_gpio_direction_out(struct gpio_chip *chip,
unsigned offset, int value)
{
struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
struct arizona *arizona = arizona_gpio->arizona;
bool persistent = gpiochip_line_is_persistent(chip, offset);
unsigned int val;
int ret;
ret = regmap_read(arizona->regmap, ARIZONA_GPIO1_CTRL + offset, &val);
if (ret < 0)
return ret;
if ((val & ARIZONA_GPN_DIR) && persistent) {
ret = pm_runtime_get_sync(chip->parent);
if (ret < 0) {
dev_err(chip->parent, "Failed to resume: %d\n", ret);
pm_runtime_put(chip->parent);
Annotation
- Immediate include surface: `linux/gpio/driver.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/slab.h`, `linux/mfd/arizona/core.h`, `linux/mfd/arizona/pdata.h`.
- Detected declarations: `struct arizona_gpio`, `function arizona_gpio_direction_in`, `function arizona_gpio_get`, `function arizona_gpio_direction_out`, `function arizona_gpio_set`, `function arizona_gpio_probe`.
- 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.