drivers/power/supply/max77650-charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/max77650-charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/max77650-charger.c- Extension
.c- Size
- 10011 bytes
- Lines
- 375
- 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/i2c.hlinux/interrupt.hlinux/mfd/max77650.hlinux/module.hlinux/platform_device.hlinux/power_supply.hlinux/regmap.h
Detected Declarations
struct max77650_charger_datafunction max77650_charger_set_vchgin_minfunction max77650_charger_set_ichgin_limfunction max77650_charger_enablefunction max77650_charger_disablefunction max77650_charger_check_statusfunction max77650_charger_get_propertyfunction max77650_charger_probefunction max77650_charger_remove
Annotated Snippet
struct max77650_charger_data {
struct regmap *map;
struct device *dev;
};
static enum power_supply_property max77650_charger_properties[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_CHARGE_TYPE
};
static const unsigned int max77650_charger_vchgin_min_table[] = {
4000000, 4100000, 4200000, 4300000, 4400000, 4500000, 4600000, 4700000
};
static const unsigned int max77650_charger_ichgin_lim_table[] = {
95000, 190000, 285000, 380000, 475000
};
static int max77650_charger_set_vchgin_min(struct max77650_charger_data *chg,
unsigned int val)
{
int i, rv;
for (i = 0; i < ARRAY_SIZE(max77650_charger_vchgin_min_table); i++) {
if (val == max77650_charger_vchgin_min_table[i]) {
rv = regmap_update_bits(chg->map,
MAX77650_REG_CNFG_CHG_B,
MAX77650_CHARGER_VCHGIN_MIN_MASK,
MAX77650_CHARGER_VCHGIN_MIN_SHIFT(i));
if (rv)
return rv;
return 0;
}
}
return -EINVAL;
}
static int max77650_charger_set_ichgin_lim(struct max77650_charger_data *chg,
unsigned int val)
{
int i, rv;
for (i = 0; i < ARRAY_SIZE(max77650_charger_ichgin_lim_table); i++) {
if (val == max77650_charger_ichgin_lim_table[i]) {
rv = regmap_update_bits(chg->map,
MAX77650_REG_CNFG_CHG_B,
MAX77650_CHARGER_ICHGIN_LIM_MASK,
MAX77650_CHARGER_ICHGIN_LIM_SHIFT(i));
if (rv)
return rv;
return 0;
}
}
return -EINVAL;
}
static int max77650_charger_enable(struct max77650_charger_data *chg)
{
int rv;
rv = regmap_update_bits(chg->map,
MAX77650_REG_CNFG_CHG_B,
MAX77650_CHARGER_CHG_EN_MASK,
MAX77650_CHARGER_ENABLED);
if (rv)
dev_err(chg->dev, "unable to enable the charger: %d\n", rv);
return rv;
}
static void max77650_charger_disable(struct max77650_charger_data *chg)
{
int rv;
rv = regmap_update_bits(chg->map,
MAX77650_REG_CNFG_CHG_B,
MAX77650_CHARGER_CHG_EN_MASK,
MAX77650_CHARGER_DISABLED);
if (rv)
dev_err(chg->dev, "unable to disable the charger: %d\n", rv);
}
static irqreturn_t max77650_charger_check_status(int irq, void *data)
{
struct max77650_charger_data *chg = data;
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/interrupt.h`, `linux/mfd/max77650.h`, `linux/module.h`, `linux/platform_device.h`, `linux/power_supply.h`, `linux/regmap.h`.
- Detected declarations: `struct max77650_charger_data`, `function max77650_charger_set_vchgin_min`, `function max77650_charger_set_ichgin_lim`, `function max77650_charger_enable`, `function max77650_charger_disable`, `function max77650_charger_check_status`, `function max77650_charger_get_property`, `function max77650_charger_probe`, `function max77650_charger_remove`.
- 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.