drivers/power/supply/bq2515x_charger.c

Source file repositories/reference/linux-study-clean/drivers/power/supply/bq2515x_charger.c

File Facts

System
Linux kernel
Corpus path
drivers/power/supply/bq2515x_charger.c
Extension
.c
Size
29669 bytes
Lines
1167
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 bq2515x_init_data {
	int ilim;
	int ichg;
	int vbatreg;
	int iprechg;
};

/**
 * struct bq2515x_info -
 * @regmap_config: register map config
 * @ilim: input current limit
 */
struct bq2515x_info {
	const struct regmap_config *regmap_config;
	int ilim;
};

/**
 * struct bq2515x_device -
 * @mains: mains properties
 * @battery: battery properties
 * @regmap: register map structure
 * @dev: device structure
 *
 * @reset_gpio: manual reset (MR) pin
 * @powerdown_gpio: low power mode pin
 * @ac_detect_gpio: power good (PG) pin
 * @ce_gpio: charge enable (CE) pin
 *
 * @info: device info
 * @model_name: string value describing device model
 * @mains_online: boolean value indicating power supply online
 *
 * @init_data: charger initialization data structure
 */
struct bq2515x_device {
	struct power_supply *mains;
	struct power_supply *battery;
	struct regmap *regmap;
	struct device *dev;

	struct gpio_desc *reset_gpio;
	struct gpio_desc *powerdown_gpio;
	struct gpio_desc *ac_detect_gpio;
	struct gpio_desc *ce_gpio;

	const struct bq2515x_info *info;
	char model_name[I2C_NAME_SIZE];
	bool mains_online;

	struct bq2515x_init_data init_data;
};

static const struct reg_default bq25150_reg_defaults[] = {
	{BQ2515X_FLAG0, 0x0},
	{BQ2515X_FLAG1, 0x0},
	{BQ2515X_FLAG2, 0x0},
	{BQ2515X_FLAG3, 0x0},
	{BQ2515X_MASK0, 0x0},
	{BQ2515X_MASK1, 0x0},
	{BQ2515X_MASK2, 0x71},
	{BQ2515X_MASK3, 0x0},
	{BQ2515X_VBAT_CTRL, 0x3C},
	{BQ2515X_ICHG_CTRL, 0x8},
	{BQ2515X_PCHRGCTRL, 0x2},
	{BQ2515X_TERMCTRL, 0x14},
	{BQ2515X_BUVLO, 0x0},
	{BQ2515X_CHARGERCTRL0, 0x82},
	{BQ2515X_CHARGERCTRL1, 0x42},
	{BQ2515X_ILIMCTRL, 0x1},
	{BQ2515X_LDOCTRL, 0xB0},
	{BQ2515X_MRCTRL, 0x2A},
	{BQ2515X_ICCTRL0, 0x10},
	{BQ2515X_ICCTRL1, 0x0},
	{BQ2515X_ICCTRL2, 0x0},
	{BQ2515X_ADCCTRL0, 0x2},
	{BQ2515X_ADCCTRL1, 0x40},
	{BQ2515X_ADC_COMP1_M, 0x23},
	{BQ2515X_ADC_COMP1_L, 0x20},
	{BQ2515X_ADC_COMP2_M, 0x38},
	{BQ2515X_ADC_COMP2_L, 0x90},
	{BQ2515X_ADC_COMP3_M, 0x0},
	{BQ2515X_ADC_COMP3_L, 0x0},
	{BQ2515X_ADC_READ_EN, 0x0},
	{BQ2515X_TS_FASTCHGCTRL, 0x34},
	{BQ2515X_TS_COLD, 0x7C},
	{BQ2515X_TS_COOL, 0x6D},
	{BQ2515X_TS_WARM, 0x38},
	{BQ2515X_TS_HOT, 0x27},
	{BQ2515X_DEVICE_ID, 0x20},

Annotation

Implementation Notes