drivers/power/supply/axp20x_ac_power.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/axp20x_ac_power.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/axp20x_ac_power.c- Extension
.c- Size
- 11123 bytes
- Lines
- 424
- Domain
- Driver Families
- Bucket
- drivers/power
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/device.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/mfd/axp20x.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm.hlinux/power_supply.hlinux/regmap.hlinux/slab.hlinux/iio/consumer.h
Detected Declarations
struct axp20x_ac_powerstruct axp_datafunction axp20x_ac_power_irqfunction axp20x_ac_power_get_propertyfunction axp813_ac_power_set_propertyfunction axp813_ac_power_prop_writeablefunction axp20x_ac_power_suspendfunction axp20x_ac_power_resumefunction axp20x_ac_power_probe
Annotated Snippet
struct axp20x_ac_power {
struct regmap *regmap;
struct power_supply *supply;
struct iio_channel *acin_v;
struct iio_channel *acin_i;
bool has_acin_path_sel;
unsigned int num_irqs;
unsigned int irqs[] __counted_by(num_irqs);
};
static irqreturn_t axp20x_ac_power_irq(int irq, void *devid)
{
struct axp20x_ac_power *power = devid;
power_supply_changed(power->supply);
return IRQ_HANDLED;
}
static int axp20x_ac_power_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct axp20x_ac_power *power = power_supply_get_drvdata(psy);
int ret, reg;
switch (psp) {
case POWER_SUPPLY_PROP_HEALTH:
ret = regmap_read(power->regmap, AXP20X_PWR_INPUT_STATUS, ®);
if (ret)
return ret;
if (reg & AXP20X_PWR_STATUS_ACIN_PRESENT) {
val->intval = POWER_SUPPLY_HEALTH_GOOD;
return 0;
}
val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
return 0;
case POWER_SUPPLY_PROP_PRESENT:
ret = regmap_read(power->regmap, AXP20X_PWR_INPUT_STATUS, ®);
if (ret)
return ret;
val->intval = !!(reg & AXP20X_PWR_STATUS_ACIN_PRESENT);
return 0;
case POWER_SUPPLY_PROP_ONLINE:
ret = regmap_read(power->regmap, AXP20X_PWR_INPUT_STATUS, ®);
if (ret)
return ret;
val->intval = !!(reg & AXP20X_PWR_STATUS_ACIN_AVAIL);
/* ACIN_PATH_SEL disables ACIN even if ACIN_AVAIL is set. */
if (val->intval && power->has_acin_path_sel) {
ret = regmap_read(power->regmap, AXP813_ACIN_PATH_CTRL,
®);
if (ret)
return ret;
val->intval = !!(reg & AXP813_ACIN_PATH_SEL);
}
return 0;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
ret = iio_read_channel_processed(power->acin_v, &val->intval);
if (ret)
return ret;
/* IIO framework gives mV but Power Supply framework gives uV */
val->intval *= 1000;
return 0;
case POWER_SUPPLY_PROP_CURRENT_NOW:
ret = iio_read_channel_processed(power->acin_i, &val->intval);
if (ret)
return ret;
/* IIO framework gives mA but Power Supply framework gives uA */
val->intval *= 1000;
return 0;
case POWER_SUPPLY_PROP_VOLTAGE_MIN:
ret = regmap_read(power->regmap, AXP813_ACIN_PATH_CTRL, ®);
if (ret)
Annotation
- Immediate include surface: `linux/device.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mfd/axp20x.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct axp20x_ac_power`, `struct axp_data`, `function axp20x_ac_power_irq`, `function axp20x_ac_power_get_property`, `function axp813_ac_power_set_property`, `function axp813_ac_power_prop_writeable`, `function axp20x_ac_power_suspend`, `function axp20x_ac_power_resume`, `function axp20x_ac_power_probe`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.