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.

Dependency Surface

Detected Declarations

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

Implementation Notes