drivers/power/supply/ab8500_fg.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/ab8500_fg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/ab8500_fg.c- Extension
.c- Size
- 85864 bytes
- Lines
- 3255
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/init.hlinux/module.hlinux/component.hlinux/device.hlinux/interrupt.hlinux/platform_device.hlinux/power_supply.hlinux/kobject.hlinux/slab.hlinux/delay.hlinux/time.hlinux/time64.hlinux/of.hlinux/completion.hlinux/mfd/core.hlinux/mfd/abx500.hlinux/mfd/abx500/ab8500.hlinux/iio/consumer.hlinux/kernel.hlinux/fixp-arith.hab8500-bm.h
Detected Declarations
struct ab8500_fg_interruptsstruct ab8500_fg_avg_capstruct ab8500_fg_cap_scalingstruct ab8500_fg_battery_capacitystruct ab8500_fg_flagsstruct ab8500_fgstruct ab8500_fg_sysfs_entryenum ab8500_fg_discharge_stateenum ab8500_fg_charge_stateenum ab8500_fg_calibration_statefunction ab8500_fg_getfunction ab8500_volt_to_regvalfunction ab8500_fg_is_low_currfunction ab8500_fg_add_cap_samplefunction ab8500_fg_clear_cap_samplesfunction ab8500_fg_fill_cap_samplefunction ab8500_fg_coulomb_counterfunction ab8500_fg_inst_curr_startfunction ab8500_fg_inst_curr_startedfunction ab8500_fg_inst_curr_donefunction ab8500_fg_inst_curr_finalizefunction ab8500_fg_inst_curr_blockingfunction ab8500_fg_acc_cur_workfunction ab8500_fg_bat_voltagefunction ab8500_fg_volt_to_capacityfunction ab8500_fg_uncomp_volt_to_capacityfunction ab8500_fg_battery_resistancefunction ab8500_load_comp_fg_bat_voltagefunction ab8500_fg_load_comp_volt_to_capacityfunction ab8500_fg_convert_mah_to_permillefunction ab8500_fg_convert_permille_to_mahfunction ab8500_fg_convert_mah_to_uwhfunction ab8500_fg_calc_cap_chargingfunction ab8500_fg_calc_cap_discharge_voltagefunction ab8500_fg_calc_cap_discharge_fgfunction ab8500_fg_capacity_levelfunction ab8500_fg_calculate_scaled_capacityfunction ab8500_fg_update_cap_scalersfunction ab8500_fg_check_capacity_limitsfunction ab8500_fg_charge_state_tofunction ab8500_fg_discharge_state_tofunction ab8500_fg_algorithm_chargingfunction force_capacityfunction check_sysfs_capacityfunction ab8500_fg_algorithm_dischargingfunction ab8500_fg_algorithm_calibratefunction ab8500_fg_algorithmfunction ab8500_fg_periodic_work
Annotated Snippet
struct ab8500_fg_interrupts {
char *name;
irqreturn_t (*isr)(int irq, void *data);
};
enum ab8500_fg_discharge_state {
AB8500_FG_DISCHARGE_INIT,
AB8500_FG_DISCHARGE_INITMEASURING,
AB8500_FG_DISCHARGE_INIT_RECOVERY,
AB8500_FG_DISCHARGE_RECOVERY,
AB8500_FG_DISCHARGE_READOUT_INIT,
AB8500_FG_DISCHARGE_READOUT,
AB8500_FG_DISCHARGE_WAKEUP,
};
static char *discharge_state[] = {
"DISCHARGE_INIT",
"DISCHARGE_INITMEASURING",
"DISCHARGE_INIT_RECOVERY",
"DISCHARGE_RECOVERY",
"DISCHARGE_READOUT_INIT",
"DISCHARGE_READOUT",
"DISCHARGE_WAKEUP",
};
enum ab8500_fg_charge_state {
AB8500_FG_CHARGE_INIT,
AB8500_FG_CHARGE_READOUT,
};
static char *charge_state[] = {
"CHARGE_INIT",
"CHARGE_READOUT",
};
enum ab8500_fg_calibration_state {
AB8500_FG_CALIB_INIT,
AB8500_FG_CALIB_WAIT,
AB8500_FG_CALIB_END,
};
struct ab8500_fg_avg_cap {
int avg;
int samples[NBR_AVG_SAMPLES];
time64_t time_stamps[NBR_AVG_SAMPLES];
int pos;
int nbr_samples;
int sum;
};
struct ab8500_fg_cap_scaling {
bool enable;
int cap_to_scale[2];
int disable_cap_level;
int scaled_cap;
};
struct ab8500_fg_battery_capacity {
int max_mah_design;
int max_mah;
int mah;
int permille;
int level;
int prev_mah;
int prev_percent;
int prev_level;
int user_mah;
struct ab8500_fg_cap_scaling cap_scale;
};
struct ab8500_fg_flags {
bool fg_enabled;
bool conv_done;
bool charging;
bool fully_charged;
bool force_full;
bool low_bat_delay;
bool low_bat;
bool bat_ovv;
bool batt_unknown;
bool calibrate;
bool user_cap;
bool batt_id_received;
};
/**
* struct ab8500_fg - ab8500 FG device information
* @dev: Pointer to the structure device
* @node: a list of AB8500 FGs, hence prepared for reentrance
* @irq holds the CCEOC interrupt number
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/component.h`, `linux/device.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/power_supply.h`, `linux/kobject.h`.
- Detected declarations: `struct ab8500_fg_interrupts`, `struct ab8500_fg_avg_cap`, `struct ab8500_fg_cap_scaling`, `struct ab8500_fg_battery_capacity`, `struct ab8500_fg_flags`, `struct ab8500_fg`, `struct ab8500_fg_sysfs_entry`, `enum ab8500_fg_discharge_state`, `enum ab8500_fg_charge_state`, `enum ab8500_fg_calibration_state`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.