drivers/power/supply/max77976_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/max77976_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/max77976_charger.c- Extension
.c- Size
- 13810 bytes
- Lines
- 511
- 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.
- 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/module.hlinux/power_supply.hlinux/regmap.h
Detected Declarations
struct max77976enum max77976_charging_stateenum max77976_battery_stateenum max77976_modeenum max77976_field_idxfunction max77976_get_statusfunction max77976_get_charge_typefunction max77976_get_healthfunction max77976_get_onlinefunction max77976_get_integerfunction max77976_set_integerfunction max77976_get_propertyfunction max77976_set_propertyfunction max77976_property_is_writeablefunction max77976_detectfunction max77976_configurefunction max77976_probe
Annotated Snippet
struct max77976 {
struct i2c_client *client;
struct regmap *regmap;
struct regmap_field *rfield[MAX77976_N_REGMAP_FIELDS];
};
/* --------------------------------------------------------------------------
* power_supply properties
*/
static int max77976_get_status(struct max77976 *chg, int *val)
{
unsigned int regval;
int err;
err = regmap_field_read(chg->rfield[CHG_DTLS], ®val);
if (err < 0)
return err;
switch (regval) {
case MAX77976_CHARGING_PREQUALIFICATION:
case MAX77976_CHARGING_FAST_CONST_CURRENT:
case MAX77976_CHARGING_FAST_CONST_VOLTAGE:
case MAX77976_CHARGING_TOP_OFF:
*val = POWER_SUPPLY_STATUS_CHARGING;
break;
case MAX77976_CHARGING_DONE:
*val = POWER_SUPPLY_STATUS_FULL;
break;
case MAX77976_CHARGING_TIMER_FAULT:
case MAX77976_CHARGING_SUSPENDED_QBATT_OFF:
case MAX77976_CHARGING_SUSPENDED_JEITA:
case MAX77976_CHARGING_SUSPENDED_THM_REMOVAL:
case MAX77976_CHARGING_SUSPENDED_PIN:
*val = POWER_SUPPLY_STATUS_NOT_CHARGING;
break;
case MAX77976_CHARGING_OFF:
case MAX77976_CHARGING_THERMAL_SHUTDOWN:
case MAX77976_CHARGING_WATCHDOG_EXPIRED:
*val = POWER_SUPPLY_STATUS_DISCHARGING;
break;
default:
*val = POWER_SUPPLY_STATUS_UNKNOWN;
}
return 0;
}
static int max77976_get_charge_type(struct max77976 *chg, int *val)
{
unsigned int regval;
int err;
err = regmap_field_read(chg->rfield[CHG_DTLS], ®val);
if (err < 0)
return err;
switch (regval) {
case MAX77976_CHARGING_PREQUALIFICATION:
*val = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
break;
case MAX77976_CHARGING_FAST_CONST_CURRENT:
case MAX77976_CHARGING_FAST_CONST_VOLTAGE:
*val = POWER_SUPPLY_CHARGE_TYPE_FAST;
break;
case MAX77976_CHARGING_TOP_OFF:
*val = POWER_SUPPLY_CHARGE_TYPE_STANDARD;
break;
case MAX77976_CHARGING_DONE:
case MAX77976_CHARGING_TIMER_FAULT:
case MAX77976_CHARGING_SUSPENDED_QBATT_OFF:
case MAX77976_CHARGING_OFF:
case MAX77976_CHARGING_THERMAL_SHUTDOWN:
case MAX77976_CHARGING_WATCHDOG_EXPIRED:
case MAX77976_CHARGING_SUSPENDED_JEITA:
case MAX77976_CHARGING_SUSPENDED_THM_REMOVAL:
case MAX77976_CHARGING_SUSPENDED_PIN:
*val = POWER_SUPPLY_CHARGE_TYPE_NONE;
break;
default:
*val = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
}
return 0;
}
static int max77976_get_health(struct max77976 *chg, int *val)
{
unsigned int regval;
int err;
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/module.h`, `linux/power_supply.h`, `linux/regmap.h`.
- Detected declarations: `struct max77976`, `enum max77976_charging_state`, `enum max77976_battery_state`, `enum max77976_mode`, `enum max77976_field_idx`, `function max77976_get_status`, `function max77976_get_charge_type`, `function max77976_get_health`, `function max77976_get_online`, `function max77976_get_integer`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
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.