drivers/power/supply/bq256xx_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/bq256xx_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/bq256xx_charger.c- Extension
.c- Size
- 53021 bytes
- Lines
- 1820
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/err.hlinux/i2c.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/power_supply.hlinux/regmap.hlinux/types.hlinux/usb/phy.hlinux/device.hlinux/moduleparam.hlinux/slab.hlinux/acpi.h
Detected Declarations
struct bq256xx_init_datastruct bq256xx_statestruct bq256xx_devicestruct bq256xx_chip_infoenum bq256xx_idfunction bq256xx_array_parsefunction bq256xx_usb_notifierfunction bq256xx_usb_workfunction bq256xx_get_statefunction bq256xx_set_charge_typefunction bq256xx_get_ichg_currfunction bq25618_619_get_ichg_currfunction bq256xx_set_ichg_currfunction bq25618_619_set_ichg_currfunction bq25618_619_get_chrg_voltfunction bq25611d_get_chrg_voltfunction bq2560x_get_chrg_voltfunction bq25601d_get_chrg_voltfunction bq25618_619_set_chrg_voltfunction bq25611d_set_chrg_voltfunction bq2560x_set_chrg_voltfunction bq25601d_set_chrg_voltfunction bq256xx_set_ts_ignorefunction bq256xx_get_prechrg_currfunction bq256xx_set_prechrg_currfunction bq25618_619_get_prechrg_currfunction bq25618_619_set_prechrg_currfunction bq256xx_get_term_currfunction bq256xx_set_term_currfunction bq25618_619_get_term_currfunction bq25618_619_set_term_currfunction bq256xx_get_input_volt_limfunction bq256xx_set_input_volt_limfunction bq256xx_get_input_curr_limfunction bq256xx_set_input_curr_limfunction bq256xx_charger_resetfunction bq256xx_set_charger_propertyfunction bq256xx_get_battery_propertyfunction bq256xx_get_charger_propertyfunction bq256xx_state_changedfunction bq256xx_irq_handler_threadfunction bq256xx_property_is_writeablefunction bq256xx_is_volatile_regfunction bq256xx_power_supply_initfunction bq256xx_hw_initfunction bq256xx_parse_dtfunction bq256xx_probe
Annotated Snippet
struct bq256xx_init_data {
u32 ichg;
u32 iindpm;
u32 vbatreg;
u32 iterm;
u32 iprechg;
u32 vindpm;
u32 ichg_max;
u32 vbatreg_max;
bool ts_ignore;
};
/**
* struct bq256xx_state -
* @vbus_stat: VBUS status according to BQ256XX_CHARGER_STATUS_0
* @chrg_stat: charging status according to BQ256XX_CHARGER_STATUS_0
* @online: PG status according to BQ256XX_CHARGER_STATUS_0
*
* @wdt_fault: watchdog fault according to BQ256XX_CHARGER_STATUS_1
* @bat_fault: battery fault according to BQ256XX_CHARGER_STATUS_1
* @chrg_fault: charging fault according to BQ256XX_CHARGER_STATUS_1
* @ntc_fault: TS fault according to BQ256XX_CHARGER_STATUS_1
*/
struct bq256xx_state {
u8 vbus_stat;
u8 chrg_stat;
bool online;
u8 wdt_fault;
u8 bat_fault;
u8 chrg_fault;
u8 ntc_fault;
};
enum bq256xx_id {
BQ25600,
BQ25600D,
BQ25601,
BQ25601D,
BQ25618,
BQ25619,
BQ25611D,
};
/**
* struct bq256xx_device -
* @client: i2c client structure
* @regmap: register map structure
* @dev: device structure
* @charger: power supply registered for the charger
* @battery: power supply registered for the battery
* @lock: mutex lock structure
*
* @usb2_phy: usb_phy identifier
* @usb3_phy: usb_phy identifier
* @usb_nb: notifier block
* @usb_work: usb work queue
* @usb_event: usb_event code
*
* @model_name: i2c name string
*
* @init_data: initialization data
* @chip_info: device variant information
* @state: device status and faults
* @watchdog_timer: watchdog timer value in milliseconds
*/
struct bq256xx_device {
struct i2c_client *client;
struct device *dev;
struct power_supply *charger;
struct power_supply *battery;
struct mutex lock;
struct regmap *regmap;
struct usb_phy *usb2_phy;
struct usb_phy *usb3_phy;
struct notifier_block usb_nb;
struct work_struct usb_work;
unsigned long usb_event;
char model_name[I2C_NAME_SIZE];
struct bq256xx_init_data init_data;
const struct bq256xx_chip_info *chip_info;
struct bq256xx_state state;
int watchdog_timer;
};
/**
* struct bq256xx_chip_info -
Annotation
- Immediate include surface: `linux/err.h`, `linux/i2c.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/power_supply.h`, `linux/regmap.h`.
- Detected declarations: `struct bq256xx_init_data`, `struct bq256xx_state`, `struct bq256xx_device`, `struct bq256xx_chip_info`, `enum bq256xx_id`, `function bq256xx_array_parse`, `function bq256xx_usb_notifier`, `function bq256xx_usb_work`, `function bq256xx_get_state`, `function bq256xx_set_charge_type`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.