drivers/power/supply/pf1550-charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/pf1550-charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/pf1550-charger.c- Extension
.c- Size
- 16114 bytes
- Lines
- 642
- 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/devm-helpers.hlinux/interrupt.hlinux/mfd/pf1550.hlinux/module.hlinux/platform_device.hlinux/power_supply.h
Detected Declarations
struct pf1550_chargerfunction pf1550_get_charger_statefunction pf1550_get_charge_typefunction pf1550_get_battery_healthfunction pf1550_get_presentfunction pf1550_get_onlinefunction pf1550_chg_bat_workfunction pf1550_chg_chg_workfunction pf1550_chg_vbus_workfunction pf1550_charger_irq_handlerfunction pf1550_charger_get_propertyfunction pf1550_set_constant_voltfunction pf1550_set_min_system_voltfunction pf1550_set_thermal_regulation_tempfunction pf1550_reg_initfunction pf1550_dt_parse_dev_infofunction pf1550_charger_probe
Annotated Snippet
struct pf1550_charger {
struct device *dev;
const struct pf1550_ddata *pf1550;
struct power_supply *charger;
struct power_supply *battery;
struct delayed_work vbus_sense_work;
struct delayed_work chg_sense_work;
struct delayed_work bat_sense_work;
int virqs[PF1550_CHARGER_IRQ_NR];
u32 constant_volt;
u32 min_system_volt;
u32 thermal_regulation_temp;
};
static int pf1550_get_charger_state(struct regmap *regmap, int *val)
{
unsigned int data;
int ret;
ret = regmap_read(regmap, PF1550_CHARG_REG_CHG_SNS, &data);
if (ret < 0)
return ret;
data &= PF1550_CHG_SNS_MASK;
switch (data) {
case PF1550_CHG_PRECHARGE:
case PF1550_CHG_CONSTANT_CURRENT:
case PF1550_CHG_CONSTANT_VOL:
case PF1550_CHG_EOC:
*val = POWER_SUPPLY_STATUS_CHARGING;
break;
case PF1550_CHG_DONE:
*val = POWER_SUPPLY_STATUS_FULL;
break;
case PF1550_CHG_TIMER_FAULT:
case PF1550_CHG_SUSPEND:
*val = POWER_SUPPLY_STATUS_NOT_CHARGING;
break;
case PF1550_CHG_OFF_INV:
case PF1550_CHG_OFF_TEMP:
case PF1550_CHG_LINEAR_ONLY:
*val = POWER_SUPPLY_STATUS_DISCHARGING;
break;
default:
*val = POWER_SUPPLY_STATUS_UNKNOWN;
}
return 0;
}
static int pf1550_get_charge_type(struct regmap *regmap, int *val)
{
unsigned int data;
int ret;
ret = regmap_read(regmap, PF1550_CHARG_REG_CHG_SNS, &data);
if (ret < 0)
return ret;
data &= PF1550_CHG_SNS_MASK;
switch (data) {
case PF1550_CHG_SNS_MASK:
*val = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
break;
case PF1550_CHG_CONSTANT_CURRENT:
case PF1550_CHG_CONSTANT_VOL:
case PF1550_CHG_EOC:
*val = POWER_SUPPLY_CHARGE_TYPE_FAST;
break;
case PF1550_CHG_DONE:
case PF1550_CHG_TIMER_FAULT:
case PF1550_CHG_SUSPEND:
case PF1550_CHG_OFF_INV:
case PF1550_CHG_BAT_OVER:
case PF1550_CHG_OFF_TEMP:
case PF1550_CHG_LINEAR_ONLY:
*val = POWER_SUPPLY_CHARGE_TYPE_NONE;
break;
default:
*val = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
}
return 0;
}
/*
* Supported health statuses:
Annotation
- Immediate include surface: `linux/devm-helpers.h`, `linux/interrupt.h`, `linux/mfd/pf1550.h`, `linux/module.h`, `linux/platform_device.h`, `linux/power_supply.h`.
- Detected declarations: `struct pf1550_charger`, `function pf1550_get_charger_state`, `function pf1550_get_charge_type`, `function pf1550_get_battery_health`, `function pf1550_get_present`, `function pf1550_get_online`, `function pf1550_chg_bat_work`, `function pf1550_chg_chg_work`, `function pf1550_chg_vbus_work`, `function pf1550_charger_irq_handler`.
- 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.