drivers/power/supply/max8925_power.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/max8925_power.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/max8925_power.c- Extension
.c- Size
- 14899 bytes
- Lines
- 577
- 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/module.hlinux/err.hlinux/slab.hlinux/of.hlinux/i2c.hlinux/interrupt.hlinux/platform_device.hlinux/power_supply.hlinux/mfd/max8925.h
Detected Declarations
struct max8925_power_infofunction __set_chargerfunction max8925_charger_handlerfunction start_measurefunction max8925_ac_get_propfunction max8925_usb_get_propfunction max8925_bat_get_propfunction max8925_init_chargerfunction max8925_deinit_chargerfunction max8925_power_dt_initfunction max8925_power_dt_initfunction max8925_power_probefunction max8925_power_remove
Annotated Snippet
struct max8925_power_info {
struct max8925_chip *chip;
struct i2c_client *gpm;
struct i2c_client *adc;
struct power_supply *ac;
struct power_supply *usb;
struct power_supply *battery;
int irq_base;
unsigned ac_online:1;
unsigned usb_online:1;
unsigned bat_online:1;
unsigned chg_mode:2;
unsigned batt_detect:1; /* detecting MB by ID pin */
unsigned topoff_threshold:2;
unsigned fast_charge:3;
unsigned no_temp_support:1;
unsigned no_insert_detect:1;
int (*set_charger) (int);
};
static int __set_charger(struct max8925_power_info *info, int enable)
{
struct max8925_chip *chip = info->chip;
if (enable) {
/* enable charger in platform */
if (info->set_charger)
info->set_charger(1);
/* enable charger */
max8925_set_bits(info->gpm, MAX8925_CHG_CNTL1, 1 << 7, 0);
} else {
/* disable charge */
max8925_set_bits(info->gpm, MAX8925_CHG_CNTL1, 1 << 7, 1 << 7);
if (info->set_charger)
info->set_charger(0);
}
dev_dbg(chip->dev, "%s\n", (enable) ? "Enable charger"
: "Disable charger");
return 0;
}
static irqreturn_t max8925_charger_handler(int irq, void *data)
{
struct max8925_power_info *info = (struct max8925_power_info *)data;
struct max8925_chip *chip = info->chip;
switch (irq - chip->irq_base) {
case MAX8925_IRQ_VCHG_DC_R:
info->ac_online = 1;
__set_charger(info, 1);
dev_dbg(chip->dev, "Adapter inserted\n");
break;
case MAX8925_IRQ_VCHG_DC_F:
info->ac_online = 0;
__set_charger(info, 0);
dev_dbg(chip->dev, "Adapter removed\n");
break;
case MAX8925_IRQ_VCHG_THM_OK_F:
/* Battery is not ready yet */
dev_dbg(chip->dev, "Battery temperature is out of range\n");
fallthrough;
case MAX8925_IRQ_VCHG_DC_OVP:
dev_dbg(chip->dev, "Error detection\n");
__set_charger(info, 0);
break;
case MAX8925_IRQ_VCHG_THM_OK_R:
/* Battery is ready now */
dev_dbg(chip->dev, "Battery temperature is in range\n");
break;
case MAX8925_IRQ_VCHG_SYSLOW_R:
/* VSYS is low */
dev_info(chip->dev, "Sys power is too low\n");
break;
case MAX8925_IRQ_VCHG_SYSLOW_F:
dev_dbg(chip->dev, "Sys power is above low threshold\n");
break;
case MAX8925_IRQ_VCHG_DONE:
__set_charger(info, 0);
dev_dbg(chip->dev, "Charging is done\n");
break;
case MAX8925_IRQ_VCHG_TOPOFF:
dev_dbg(chip->dev, "Charging in top-off mode\n");
break;
case MAX8925_IRQ_VCHG_TMR_FAULT:
__set_charger(info, 0);
dev_dbg(chip->dev, "Safe timer is expired\n");
break;
case MAX8925_IRQ_VCHG_RST:
__set_charger(info, 0);
Annotation
- Immediate include surface: `linux/module.h`, `linux/err.h`, `linux/slab.h`, `linux/of.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/power_supply.h`.
- Detected declarations: `struct max8925_power_info`, `function __set_charger`, `function max8925_charger_handler`, `function start_measure`, `function max8925_ac_get_prop`, `function max8925_usb_get_prop`, `function max8925_bat_get_prop`, `function max8925_init_charger`, `function max8925_deinit_charger`, `function max8925_power_dt_init`.
- 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.