drivers/power/supply/axp288_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/axp288_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/axp288_charger.c- Extension
.c- Size
- 27782 bytes
- Lines
- 975
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/acpi.hlinux/bitops.hlinux/module.hlinux/devm-helpers.hlinux/device.hlinux/regmap.hlinux/workqueue.hlinux/delay.hlinux/platform_device.hlinux/usb/otg.hlinux/notifier.hlinux/power_supply.hlinux/property.hlinux/mfd/axp20x.hlinux/extcon.hlinux/dmi.hasm/iosf_mbi.h
Detected Declarations
struct axp288_chrg_infofunction axp288_charger_set_ccfunction axp288_charger_set_cvfunction axp288_charger_get_vbus_inlmtfunction axp288_charger_set_vbus_inlmtfunction axp288_charger_vbus_path_selectfunction axp288_charger_enable_chargerfunction axp288_get_charger_healthfunction axp288_charger_usb_set_propertyfunction axp288_charger_reg_readbfunction axp288_charger_usb_update_propertyfunction axp288_charger_usb_get_propertyfunction axp288_charger_property_is_writeablefunction axp288_charger_irq_thread_handlerfunction axp288_charger_extcon_evt_workerfunction axp288_charger_handle_cable_evtfunction axp288_charger_otg_evt_workerfunction axp288_charger_handle_otg_evtfunction charger_init_hw_regsfunction axp288_charger_probe
Annotated Snippet
struct axp288_chrg_info {
struct platform_device *pdev;
struct regmap *regmap;
struct regmap_irq_chip_data *regmap_irqc;
int irq[CHRG_INTR_END];
struct power_supply *psy_usb;
struct mutex lock;
/* OTG/Host mode */
struct {
struct work_struct work;
struct extcon_dev *cable;
struct notifier_block id_nb;
bool id_short;
} otg;
/* SDP/CDP/DCP USB charging cable notifications */
struct {
struct extcon_dev *edev;
struct notifier_block nb;
struct work_struct work;
} cable;
int cc;
int cv;
int max_cc;
int max_cv;
unsigned long last_updated;
unsigned int input_status;
unsigned int op_mode;
unsigned int backend_control;
bool valid;
};
static inline int axp288_charger_set_cc(struct axp288_chrg_info *info, int cc)
{
u8 reg_val;
int ret;
if (cc < CHRG_CCCV_CC_OFFSET)
cc = CHRG_CCCV_CC_OFFSET;
else if (cc > info->max_cc)
cc = info->max_cc;
reg_val = (cc - CHRG_CCCV_CC_OFFSET) / CHRG_CCCV_CC_LSB_RES;
cc = (reg_val * CHRG_CCCV_CC_LSB_RES) + CHRG_CCCV_CC_OFFSET;
reg_val = reg_val << CHRG_CCCV_CC_BIT_POS;
ret = regmap_update_bits(info->regmap,
AXP20X_CHRG_CTRL1,
CHRG_CCCV_CC_MASK, reg_val);
if (ret >= 0)
info->cc = cc;
return ret;
}
static inline int axp288_charger_set_cv(struct axp288_chrg_info *info, int cv)
{
u8 reg_val;
int ret;
if (cv >= CV_4350MV) {
reg_val = CHRG_CCCV_CV_4350MV;
cv = CV_4350MV;
} else if (cv >= CV_4200MV) {
reg_val = CHRG_CCCV_CV_4200MV;
cv = CV_4200MV;
} else if (cv >= CV_4150MV) {
reg_val = CHRG_CCCV_CV_4150MV;
cv = CV_4150MV;
} else {
reg_val = CHRG_CCCV_CV_4100MV;
cv = CV_4100MV;
}
reg_val = reg_val << CHRG_CCCV_CV_BIT_POS;
ret = regmap_update_bits(info->regmap,
AXP20X_CHRG_CTRL1,
CHRG_CCCV_CV_MASK, reg_val);
if (ret >= 0)
info->cv = cv;
return ret;
}
static int axp288_charger_get_vbus_inlmt(struct axp288_chrg_info *info)
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bitops.h`, `linux/module.h`, `linux/devm-helpers.h`, `linux/device.h`, `linux/regmap.h`, `linux/workqueue.h`, `linux/delay.h`.
- Detected declarations: `struct axp288_chrg_info`, `function axp288_charger_set_cc`, `function axp288_charger_set_cv`, `function axp288_charger_get_vbus_inlmt`, `function axp288_charger_set_vbus_inlmt`, `function axp288_charger_vbus_path_select`, `function axp288_charger_enable_charger`, `function axp288_get_charger_health`, `function axp288_charger_usb_set_property`, `function axp288_charger_reg_readb`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.