drivers/power/supply/act8945a_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/act8945a_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/act8945a_charger.c- Extension
.c- Size
- 15956 bytes
- Lines
- 661
- 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/interrupt.hlinux/module.hlinux/of.hlinux/of_irq.hlinux/platform_device.hlinux/power_supply.hlinux/regmap.hlinux/gpio/consumer.h
Detected Declarations
struct act8945a_chargerfunction act8945a_get_charger_statefunction act8945a_get_charge_typefunction act8945a_get_battery_healthfunction act8945a_get_capacity_levelfunction Risetfunction act8945a_charger_get_propertyfunction act8945a_enable_interruptfunction act8945a_set_supply_typefunction act8945a_workfunction act8945a_status_changedfunction act8945a_charger_configfunction act8945a_charger_probefunction act8945a_charger_remove
Annotated Snippet
struct act8945a_charger {
struct power_supply *psy;
struct power_supply_desc desc;
struct regmap *regmap;
struct work_struct work;
bool init_done;
struct gpio_desc *lbo_gpio;
struct gpio_desc *chglev_gpio;
};
static int act8945a_get_charger_state(struct regmap *regmap, int *val)
{
int ret;
unsigned int status, state;
ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status);
if (ret < 0)
return ret;
ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state);
if (ret < 0)
return ret;
state &= APCH_STATE_CSTATE;
state >>= APCH_STATE_CSTATE_SHIFT;
switch (state) {
case APCH_STATE_CSTATE_PRE:
case APCH_STATE_CSTATE_FAST:
*val = POWER_SUPPLY_STATUS_CHARGING;
break;
case APCH_STATE_CSTATE_EOC:
if (status & APCH_STATUS_CHGDAT)
*val = POWER_SUPPLY_STATUS_FULL;
else
*val = POWER_SUPPLY_STATUS_CHARGING;
break;
case APCH_STATE_CSTATE_DISABLED:
default:
if (!(status & APCH_STATUS_INDAT))
*val = POWER_SUPPLY_STATUS_DISCHARGING;
else
*val = POWER_SUPPLY_STATUS_NOT_CHARGING;
break;
}
return 0;
}
static int act8945a_get_charge_type(struct regmap *regmap, int *val)
{
int ret;
unsigned int status, state;
ret = regmap_read(regmap, ACT8945A_APCH_STATUS, &status);
if (ret < 0)
return ret;
ret = regmap_read(regmap, ACT8945A_APCH_STATE, &state);
if (ret < 0)
return ret;
state &= APCH_STATE_CSTATE;
state >>= APCH_STATE_CSTATE_SHIFT;
switch (state) {
case APCH_STATE_CSTATE_PRE:
*val = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
break;
case APCH_STATE_CSTATE_FAST:
*val = POWER_SUPPLY_CHARGE_TYPE_FAST;
break;
case APCH_STATE_CSTATE_EOC:
*val = POWER_SUPPLY_CHARGE_TYPE_NONE;
break;
case APCH_STATE_CSTATE_DISABLED:
default:
if (!(status & APCH_STATUS_INDAT))
*val = POWER_SUPPLY_CHARGE_TYPE_NONE;
else
*val = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
break;
}
return 0;
}
static int act8945a_get_battery_health(struct regmap *regmap, int *val)
{
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/module.h`, `linux/of.h`, `linux/of_irq.h`, `linux/platform_device.h`, `linux/power_supply.h`, `linux/regmap.h`, `linux/gpio/consumer.h`.
- Detected declarations: `struct act8945a_charger`, `function act8945a_get_charger_state`, `function act8945a_get_charge_type`, `function act8945a_get_battery_health`, `function act8945a_get_capacity_level`, `function Riset`, `function act8945a_charger_get_property`, `function act8945a_enable_interrupt`, `function act8945a_set_supply_type`, `function act8945a_work`.
- 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.