drivers/power/supply/max77693_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/max77693_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/max77693_charger.c- Extension
.c- Size
- 19705 bytes
- Lines
- 809
- 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/module.hlinux/platform_device.hlinux/power_supply.hlinux/regmap.hlinux/mfd/max77693.hlinux/mfd/max77693-common.hlinux/mfd/max77693-private.h
Detected Declarations
struct max77693_chargerfunction max77693_get_charger_statefunction max77693_get_charge_typefunction max77693_get_battery_healthfunction max77693_get_presentfunction max77693_get_onlinefunction max77693_get_input_current_limitfunction max77693_get_fast_charge_currentfunction max77693_charger_get_propertyfunction device_attr_storefunction fast_charge_timer_showfunction max77693_set_fast_charge_timerfunction fast_charge_timer_storefunction top_off_threshold_current_showfunction max77693_set_top_off_threshold_currentfunction top_off_threshold_current_storefunction top_off_timer_showfunction max77693_set_top_off_timerfunction top_off_timer_storefunction max77693_set_constant_voltfunction max77693_set_min_system_voltfunction max77693_set_thermal_regulation_tempfunction max77693_set_batttery_overcurrentfunction max77693_set_charge_input_threshold_voltfunction max77693_reg_initfunction max77693_dt_initfunction max77693_dt_initfunction max77693_charger_probefunction max77693_charger_remove
Annotated Snippet
struct max77693_charger {
struct device *dev;
struct max77693_dev *max77693;
struct power_supply *charger;
u32 constant_volt;
u32 min_system_volt;
u32 thermal_regulation_temp;
u32 batttery_overcurrent;
u32 charge_input_threshold_volt;
};
static int max77693_get_charger_state(struct regmap *regmap, int *val)
{
int ret;
unsigned int data;
ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_DETAILS_01, &data);
if (ret < 0)
return ret;
data &= CHG_DETAILS_01_CHG_MASK;
data >>= CHG_DETAILS_01_CHG_SHIFT;
switch (data) {
case MAX77693_CHARGING_PREQUALIFICATION:
case MAX77693_CHARGING_FAST_CONST_CURRENT:
case MAX77693_CHARGING_FAST_CONST_VOLTAGE:
case MAX77693_CHARGING_TOP_OFF:
/* In high temp the charging current is reduced, but still charging */
case MAX77693_CHARGING_HIGH_TEMP:
*val = POWER_SUPPLY_STATUS_CHARGING;
break;
case MAX77693_CHARGING_DONE:
*val = POWER_SUPPLY_STATUS_FULL;
break;
case MAX77693_CHARGING_TIMER_EXPIRED:
case MAX77693_CHARGING_THERMISTOR_SUSPEND:
*val = POWER_SUPPLY_STATUS_NOT_CHARGING;
break;
case MAX77693_CHARGING_OFF:
case MAX77693_CHARGING_OVER_TEMP:
case MAX77693_CHARGING_WATCHDOG_EXPIRED:
*val = POWER_SUPPLY_STATUS_DISCHARGING;
break;
case MAX77693_CHARGING_RESERVED:
default:
*val = POWER_SUPPLY_STATUS_UNKNOWN;
}
return 0;
}
static int max77693_get_charge_type(struct regmap *regmap, int *val)
{
int ret;
unsigned int data;
ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_DETAILS_01, &data);
if (ret < 0)
return ret;
data &= CHG_DETAILS_01_CHG_MASK;
data >>= CHG_DETAILS_01_CHG_SHIFT;
switch (data) {
case MAX77693_CHARGING_PREQUALIFICATION:
/*
* Top-off: trickle or fast? In top-off the current varies between
* 100 and 250 mA. It is higher than prequalification current.
*/
case MAX77693_CHARGING_TOP_OFF:
*val = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
break;
case MAX77693_CHARGING_FAST_CONST_CURRENT:
case MAX77693_CHARGING_FAST_CONST_VOLTAGE:
/* In high temp the charging current is reduced, but still charging */
case MAX77693_CHARGING_HIGH_TEMP:
*val = POWER_SUPPLY_CHARGE_TYPE_FAST;
break;
case MAX77693_CHARGING_DONE:
case MAX77693_CHARGING_TIMER_EXPIRED:
case MAX77693_CHARGING_THERMISTOR_SUSPEND:
case MAX77693_CHARGING_OFF:
case MAX77693_CHARGING_OVER_TEMP:
case MAX77693_CHARGING_WATCHDOG_EXPIRED:
*val = POWER_SUPPLY_CHARGE_TYPE_NONE;
break;
case MAX77693_CHARGING_RESERVED:
default:
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/power_supply.h`, `linux/regmap.h`, `linux/mfd/max77693.h`, `linux/mfd/max77693-common.h`, `linux/mfd/max77693-private.h`.
- Detected declarations: `struct max77693_charger`, `function max77693_get_charger_state`, `function max77693_get_charge_type`, `function max77693_get_battery_health`, `function max77693_get_present`, `function max77693_get_online`, `function max77693_get_input_current_limit`, `function max77693_get_fast_charge_current`, `function max77693_charger_get_property`, `function device_attr_store`.
- 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.