drivers/power/supply/max77705_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/max77705_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/max77705_charger.c- Extension
.c- Size
- 18570 bytes
- Lines
- 700
- 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/i2c.hlinux/interrupt.hlinux/mfd/max77693-common.hlinux/mfd/max77705-private.hlinux/power/max77705_charger.hlinux/module.hlinux/platform_device.hlinux/power_supply.hlinux/regmap.h
Detected Declarations
function max77705_aicl_irqfunction max77705_chgin_irqfunction max77705_charger_enablefunction max77705_charger_disablefunction max77705_get_onlinefunction max77705_set_integerfunction max77705_check_batteryfunction max77705_get_charge_typefunction max77705_get_statusfunction max77705_get_vbus_statefunction max77705_get_battery_healthfunction max77705_get_healthfunction max77705_get_input_currentfunction max77705_get_charge_currentfunction max77705_set_float_voltagefunction max77705_get_float_voltagefunction max77705_chg_get_propertyfunction max77705_set_propertyfunction max77705_property_is_writeablefunction max77705_chgin_isr_workfunction max77705_charger_initializefunction max77705_charger_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Based on max77650-charger.c
*
* Copyright (C) 2025 Dzmitry Sankouski <dsankouski@gmail.org>
*
* Battery charger driver for MAXIM 77705 charger/power-supply.
*/
#include <linux/devm-helpers.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mfd/max77693-common.h>
#include <linux/mfd/max77705-private.h>
#include <linux/power/max77705_charger.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/regmap.h>
static const char *max77705_charger_model = "max77705";
static const char *max77705_charger_manufacturer = "Maxim Integrated";
static const struct regmap_config max77705_chg_regmap_config = {
.reg_base = MAX77705_CHG_REG_BASE,
.reg_bits = 8,
.val_bits = 8,
.max_register = MAX77705_CHG_REG_SAFEOUT_CTRL,
};
static enum power_supply_property max77705_charger_props[] = {
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_CHARGE_TYPE,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
};
static irqreturn_t max77705_aicl_irq(int irq, void *irq_drv_data)
{
struct max77705_charger_data *chg = irq_drv_data;
unsigned int regval, irq_status;
int err;
err = regmap_read(chg->regmap, MAX77705_CHG_REG_INT_OK, &irq_status);
if (err < 0)
return IRQ_HANDLED;
// irq is fiered at the end of current decrease sequence too
// early check AICL_I bit to guard against that excess irq call
while (!(irq_status & BIT(MAX77705_AICL_I))) {
err = regmap_field_read(chg->rfield[MAX77705_CHG_CHGIN_LIM], ®val);
if (err < 0)
return IRQ_HANDLED;
regval--;
err = regmap_field_write(chg->rfield[MAX77705_CHG_CHGIN_LIM], regval);
if (err < 0)
return IRQ_HANDLED;
msleep(AICL_WORK_DELAY_MS);
err = regmap_read(chg->regmap, MAX77705_CHG_REG_INT_OK, &irq_status);
if (err < 0)
return IRQ_HANDLED;
}
return IRQ_HANDLED;
}
static irqreturn_t max77705_chgin_irq(int irq, void *irq_drv_data)
{
struct max77705_charger_data *chg = irq_drv_data;
queue_work(chg->wqueue, &chg->chgin_work);
return IRQ_HANDLED;
}
static const struct regmap_irq max77705_charger_irqs[] = {
REGMAP_IRQ_REG_LINE(MAX77705_BYP_I, BITS_PER_BYTE),
REGMAP_IRQ_REG_LINE(MAX77705_INP_LIMIT_I, BITS_PER_BYTE),
REGMAP_IRQ_REG_LINE(MAX77705_BATP_I, BITS_PER_BYTE),
REGMAP_IRQ_REG_LINE(MAX77705_BAT_I, BITS_PER_BYTE),
REGMAP_IRQ_REG_LINE(MAX77705_CHG_I, BITS_PER_BYTE),
Annotation
- Immediate include surface: `linux/devm-helpers.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/mfd/max77693-common.h`, `linux/mfd/max77705-private.h`, `linux/power/max77705_charger.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `function max77705_aicl_irq`, `function max77705_chgin_irq`, `function max77705_charger_enable`, `function max77705_charger_disable`, `function max77705_get_online`, `function max77705_set_integer`, `function max77705_check_battery`, `function max77705_get_charge_type`, `function max77705_get_status`, `function max77705_get_vbus_state`.
- 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.