drivers/power/supply/da9030_battery.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/da9030_battery.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/da9030_battery.c- Extension
.c- Size
- 15850 bytes
- Lines
- 582
- 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/kernel.hlinux/slab.hlinux/init.hlinux/types.hlinux/device.hlinux/workqueue.hlinux/module.hlinux/platform_device.hlinux/power_supply.hlinux/string_choices.hlinux/mfd/da903x.hlinux/debugfs.hlinux/seq_file.hlinux/notifier.h
Detected Declarations
struct da9030_adc_resstruct da9030_battery_thresholdsstruct da9030_chargerfunction da9030_reg_to_mVfunction da9030_millivolt_to_regfunction da9030_reg_to_mAfunction bat_debug_showfunction da9030_bat_remove_debugfsfunction da9030_bat_remove_debugfsfunction da9030_charger_update_statefunction da9030_set_chargefunction da9030_charger_check_statefunction da9030_charging_monitorfunction da9030_battery_check_statusfunction da9030_battery_check_healthfunction da9030_battery_get_propertyfunction da9030_battery_vbat_eventfunction da9030_battery_eventfunction da9030_battery_convert_thresholdsfunction da9030_battery_setup_psyfunction da9030_battery_charger_initfunction da9030_battery_probefunction da9030_battery_remove
Annotated Snippet
struct da9030_adc_res {
uint8_t vbat_res;
uint8_t vbatmin_res;
uint8_t vbatmintxon;
uint8_t ichmax_res;
uint8_t ichmin_res;
uint8_t ichaverage_res;
uint8_t vchmax_res;
uint8_t vchmin_res;
uint8_t tbat_res;
uint8_t adc_in4_res;
uint8_t adc_in5_res;
};
struct da9030_battery_thresholds {
int tbat_low;
int tbat_high;
int tbat_restart;
int vbat_low;
int vbat_crit;
int vbat_charge_start;
int vbat_charge_stop;
int vbat_charge_restart;
int vcharge_min;
int vcharge_max;
};
struct da9030_charger {
struct power_supply *psy;
struct power_supply_desc psy_desc;
struct device *master;
struct da9030_adc_res adc;
struct delayed_work work;
unsigned int interval;
struct power_supply_info *battery_info;
struct da9030_battery_thresholds thresholds;
unsigned int charge_milliamp;
unsigned int charge_millivolt;
/* charger status */
bool chdet;
uint8_t fault;
int mA;
int mV;
bool is_on;
struct notifier_block nb;
/* platform callbacks for battery low and critical events */
void (*battery_low)(void);
void (*battery_critical)(void);
struct dentry *debug_file;
};
static inline int da9030_reg_to_mV(int reg)
{
return ((reg * 2650) >> 8) + 2650;
}
static inline int da9030_millivolt_to_reg(int mV)
{
return ((mV - 2650) << 8) / 2650;
}
static inline int da9030_reg_to_mA(int reg)
{
return ((reg * 24000) >> 8) / 15;
}
#ifdef CONFIG_DEBUG_FS
static int bat_debug_show(struct seq_file *s, void *data)
{
struct da9030_charger *charger = s->private;
seq_printf(s, "charger is %s\n", str_on_off(charger->is_on));
if (charger->chdet) {
seq_printf(s, "iset = %dmA, vset = %dmV\n",
charger->mA, charger->mV);
}
seq_printf(s, "vbat_res = %d (%dmV)\n",
charger->adc.vbat_res,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/init.h`, `linux/types.h`, `linux/device.h`, `linux/workqueue.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `struct da9030_adc_res`, `struct da9030_battery_thresholds`, `struct da9030_charger`, `function da9030_reg_to_mV`, `function da9030_millivolt_to_reg`, `function da9030_reg_to_mA`, `function bat_debug_show`, `function da9030_bat_remove_debugfs`, `function da9030_bat_remove_debugfs`, `function da9030_charger_update_state`.
- 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.