drivers/power/supply/max17040_battery.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/max17040_battery.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/max17040_battery.c- Extension
.c- Size
- 15879 bytes
- Lines
- 642
- 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/module.hlinux/init.hlinux/platform_device.hlinux/mutex.hlinux/err.hlinux/i2c.hlinux/delay.hlinux/interrupt.hlinux/power_supply.hlinux/of.hlinux/regmap.hlinux/slab.hlinux/iio/consumer.h
Detected Declarations
struct chip_datastruct max17040_chipenum chip_idfunction max17040_resetfunction max17040_set_low_soc_alertfunction max17040_set_soc_alertfunction max17040_set_rcompfunction max17040_raw_vcell_to_uvoltsfunction max17040_get_vcellfunction max17040_get_socfunction max17040_get_versionfunction max17040_get_onlinefunction max17040_get_of_datafunction max17040_check_changesfunction max17040_queue_workfunction max17040_stop_workfunction max17040_workfunction max17040_handle_soc_alertfunction max17040_thread_handlerfunction max17040_enable_alert_irqfunction max17040_prop_writeablefunction max17040_set_propertyfunction max17040_get_propertyfunction max17040_probefunction max17040_suspendfunction max17040_resume
Annotated Snippet
struct chip_data {
u16 reset_val;
u16 vcell_shift;
u16 vcell_mul;
u16 vcell_div;
u8 has_low_soc_alert;
u8 rcomp_bytes;
u8 has_soc_alert;
};
static struct chip_data max17040_family[] = {
[ID_MAX17040] = {
.reset_val = 0x0054,
.vcell_shift = 4,
.vcell_mul = 1250,
.vcell_div = 1,
.has_low_soc_alert = 0,
.rcomp_bytes = 2,
.has_soc_alert = 0,
},
[ID_MAX17041] = {
.reset_val = 0x0054,
.vcell_shift = 4,
.vcell_mul = 2500,
.vcell_div = 1,
.has_low_soc_alert = 0,
.rcomp_bytes = 2,
.has_soc_alert = 0,
},
[ID_MAX17043] = {
.reset_val = 0x0054,
.vcell_shift = 4,
.vcell_mul = 1250,
.vcell_div = 1,
.has_low_soc_alert = 1,
.rcomp_bytes = 1,
.has_soc_alert = 0,
},
[ID_MAX17044] = {
.reset_val = 0x0054,
.vcell_shift = 4,
.vcell_mul = 2500,
.vcell_div = 1,
.has_low_soc_alert = 1,
.rcomp_bytes = 1,
.has_soc_alert = 0,
},
[ID_MAX17048] = {
.reset_val = 0x5400,
.vcell_shift = 0,
.vcell_mul = 625,
.vcell_div = 8,
.has_low_soc_alert = 1,
.rcomp_bytes = 1,
.has_soc_alert = 1,
},
[ID_MAX17049] = {
.reset_val = 0x5400,
.vcell_shift = 0,
.vcell_mul = 625,
.vcell_div = 4,
.has_low_soc_alert = 1,
.rcomp_bytes = 1,
.has_soc_alert = 1,
},
[ID_MAX17058] = {
.reset_val = 0x5400,
.vcell_shift = 0,
.vcell_mul = 625,
.vcell_div = 8,
.has_low_soc_alert = 1,
.rcomp_bytes = 1,
.has_soc_alert = 0,
},
[ID_MAX17059] = {
.reset_val = 0x5400,
.vcell_shift = 0,
.vcell_mul = 625,
.vcell_div = 4,
.has_low_soc_alert = 1,
.rcomp_bytes = 1,
.has_soc_alert = 0,
},
};
struct max17040_chip {
struct i2c_client *client;
struct regmap *regmap;
struct delayed_work work;
struct power_supply *battery;
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/platform_device.h`, `linux/mutex.h`, `linux/err.h`, `linux/i2c.h`, `linux/delay.h`, `linux/interrupt.h`.
- Detected declarations: `struct chip_data`, `struct max17040_chip`, `enum chip_id`, `function max17040_reset`, `function max17040_set_low_soc_alert`, `function max17040_set_soc_alert`, `function max17040_set_rcomp`, `function max17040_raw_vcell_to_uvolts`, `function max17040_get_vcell`, `function max17040_get_soc`.
- 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.