drivers/power/supply/max1720x_battery.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/max1720x_battery.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/max1720x_battery.c- Extension
.c- Size
- 21003 bytes
- Lines
- 635
- 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/bitfield.hlinux/i2c.hlinux/module.hlinux/nvmem-provider.hlinux/power_supply.hlinux/regmap.hlinux/unaligned.h
Detected Declarations
struct max1720x_device_infofunction max172xx_time_to_psfunction max172xx_percent_to_psfunction max172xx_voltage_to_psfunction max172xx_capacity_to_psfunction max172xx_temperature_to_psfunction max172xx_current_to_voltagefunction max172xx_battery_healthfunction max1720x_battery_get_propertyfunction max1720x_read_tempfunction temp_ain1_showfunction temp_ain2_showfunction temp_int_showfunction max1720x_nvmem_reg_readfunction max1720x_unregister_ancillaryfunction max1720x_probe_nvmemfunction max1720x_probe
Annotated Snippet
struct max1720x_device_info {
struct regmap *regmap;
struct regmap *regmap_nv;
struct i2c_client *ancillary;
int rsense;
};
/*
* Model Gauge M5 Algorithm output register
* Volatile data (must not be cached)
*/
static const struct regmap_range max1720x_volatile_allow[] = {
regmap_reg_range(MAX172XX_STATUS, MAX172XX_CYCLES),
regmap_reg_range(MAX172XX_AVG_VCELL, MAX172XX_TTF),
regmap_reg_range(MAX172XX_QR_TABLE10, MAX172XX_ATAVCAP),
};
static const struct regmap_range max1720x_readable_allow[] = {
regmap_reg_range(MAX172XX_STATUS, MAX172XX_ATAVCAP),
};
static const struct regmap_range max1720x_readable_deny[] = {
/* unused registers */
regmap_reg_range(0x24, 0x26),
regmap_reg_range(0x30, 0x31),
regmap_reg_range(0x33, 0x34),
regmap_reg_range(0x37, 0x37),
regmap_reg_range(0x3B, 0x3C),
regmap_reg_range(0x40, 0x41),
regmap_reg_range(0x43, 0x44),
regmap_reg_range(0x47, 0x49),
regmap_reg_range(0x4B, 0x4C),
regmap_reg_range(0x4E, 0xAF),
regmap_reg_range(0xB1, 0xB3),
regmap_reg_range(0xB5, 0xB7),
regmap_reg_range(0xBF, 0xD0),
regmap_reg_range(0xDB, 0xDB),
regmap_reg_range(0xE0, 0xFF),
};
static const struct regmap_access_table max1720x_readable_regs = {
.yes_ranges = max1720x_readable_allow,
.n_yes_ranges = ARRAY_SIZE(max1720x_readable_allow),
.no_ranges = max1720x_readable_deny,
.n_no_ranges = ARRAY_SIZE(max1720x_readable_deny),
};
static const struct regmap_access_table max1720x_volatile_regs = {
.yes_ranges = max1720x_volatile_allow,
.n_yes_ranges = ARRAY_SIZE(max1720x_volatile_allow),
.no_ranges = max1720x_readable_deny,
.n_no_ranges = ARRAY_SIZE(max1720x_readable_deny),
};
static const struct regmap_config max1720x_regmap_cfg = {
.reg_bits = 8,
.val_bits = 16,
.max_register = MAX172XX_ATAVCAP,
.val_format_endian = REGMAP_ENDIAN_LITTLE,
.rd_table = &max1720x_readable_regs,
.volatile_table = &max1720x_volatile_regs,
.cache_type = REGCACHE_MAPLE,
};
static const struct regmap_range max1720x_nvmem_allow[] = {
regmap_reg_range(MAX172XX_TEMP1, MAX172XX_INT_TEMP),
regmap_reg_range(MAX172XX_TEMP2, MAX172XX_TEMP2),
regmap_reg_range(MAX1720X_NXTABLE0, MAX1720X_NDEVICE_NAME4),
};
static const struct regmap_range max1720x_nvmem_deny[] = {
regmap_reg_range(0x00, 0x33),
regmap_reg_range(0x36, 0x3A),
regmap_reg_range(0x3C, 0x7F),
regmap_reg_range(0xE0, 0xFF),
};
static const struct regmap_access_table max1720x_nvmem_regs = {
.yes_ranges = max1720x_nvmem_allow,
.n_yes_ranges = ARRAY_SIZE(max1720x_nvmem_allow),
.no_ranges = max1720x_nvmem_deny,
.n_no_ranges = ARRAY_SIZE(max1720x_nvmem_deny),
};
static const struct regmap_config max1720x_nvmem_regmap_cfg = {
.reg_bits = 8,
.val_bits = 16,
.max_register = MAX1720X_NDEVICE_NAME4,
.val_format_endian = REGMAP_ENDIAN_LITTLE,
.rd_table = &max1720x_nvmem_regs,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/i2c.h`, `linux/module.h`, `linux/nvmem-provider.h`, `linux/power_supply.h`, `linux/regmap.h`, `linux/unaligned.h`.
- Detected declarations: `struct max1720x_device_info`, `function max172xx_time_to_ps`, `function max172xx_percent_to_ps`, `function max172xx_voltage_to_ps`, `function max172xx_capacity_to_ps`, `function max172xx_temperature_to_ps`, `function max172xx_current_to_voltage`, `function max172xx_battery_health`, `function max1720x_battery_get_property`, `function max1720x_read_temp`.
- 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.