drivers/power/supply/bq25890_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/bq25890_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/bq25890_charger.c- Extension
.c- Size
- 44394 bytes
- Lines
- 1662
- 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/module.hlinux/i2c.hlinux/power_supply.hlinux/power/bq25890_charger.hlinux/regmap.hlinux/regulator/driver.hlinux/types.hlinux/gpio/consumer.hlinux/interrupt.hlinux/delay.hlinux/usb/phy.hlinux/acpi.hlinux/of.h
Detected Declarations
struct bq25890_init_datastruct bq25890_statestruct bq25890_devicestruct bq25890_rangestruct bq25890_lookupenum bq25890_chip_versionenum bq25890_fieldsenum bq25890_table_idsenum bq25890_statusenum bq25890_chrg_faultenum bq25890_ntc_faultfunction bq25890_field_readfunction bq25890_field_writefunction bq25890_find_idxfunction bq25890_find_valfunction bq25890_is_adc_propertyfunction bq25890_get_vbus_voltagefunction bq25890_update_statefunction bq25890_power_supply_get_propertyfunction bq25890_power_supply_set_propertyfunction bq25890_power_supply_property_is_writeablefunction bq25890_charger_get_scaled_iinlim_regvalfunction bq25890_charger_external_power_changedfunction bq25890_get_chip_statefunction __bq25890_handle_irqfunction bq25890_irq_handler_threadfunction bq25890_chip_resetfunction bq25890_rw_init_datafunction bq25890_hw_initfunction bq25890_power_supply_initfunction bq25890_set_otg_cfgfunction bq25890_pump_express_workfunction bq25890_usb_workfunction bq25890_usb_notifierfunction bq25890_vbus_enablefunction bq25890_vbus_disablefunction bq25890_vbus_is_enabledfunction bq25890_vbus_get_voltagefunction bq25890_vsys_get_voltagefunction bq25890_register_regulatorfunction bq25890_register_regulatorfunction bq25890_get_chip_versionfunction bq25890_irq_probefunction bq25890_fw_read_u32_propsfunction bq25890_fw_probefunction bq25890_non_devm_cleanupfunction bq25890_probefunction bq25890_remove
Annotated Snippet
struct bq25890_init_data {
u8 ichg; /* charge current */
u8 vreg; /* regulation voltage */
u8 iterm; /* termination current */
u8 iprechg; /* precharge current */
u8 sysvmin; /* minimum system voltage limit */
u8 boostv; /* boost regulation voltage */
u8 boosti; /* boost current limit */
u8 boostf; /* boost frequency */
u8 ilim_en; /* enable ILIM pin */
u8 treg; /* thermal regulation threshold */
u8 rbatcomp; /* IBAT sense resistor value */
u8 vclamp; /* IBAT compensation voltage limit */
};
struct bq25890_state {
u8 online;
u8 hiz;
u8 chrg_status;
u8 chrg_fault;
u8 vsys_status;
u8 boost_fault;
u8 bat_fault;
u8 ntc_fault;
};
struct bq25890_device {
struct i2c_client *client;
struct device *dev;
struct power_supply *charger;
struct power_supply *secondary_chrg;
struct power_supply_desc desc;
char name[28]; /* "bq25890-charger-%d" */
int id;
struct usb_phy *usb_phy;
struct notifier_block usb_nb;
struct work_struct usb_work;
struct delayed_work pump_express_work;
unsigned long usb_event;
struct regmap *rmap;
struct regmap_field *rmap_fields[F_MAX_FIELDS];
bool skip_reset;
bool read_back_init_data;
bool force_hiz;
u32 pump_express_vbus_max;
u32 iinlim_percentage;
enum bq25890_chip_version chip_version;
struct bq25890_init_data init_data;
struct bq25890_state state;
struct mutex lock; /* protect state data */
};
static DEFINE_IDR(bq25890_id);
static DEFINE_MUTEX(bq25890_id_mutex);
static const struct regmap_range bq25890_readonly_reg_ranges[] = {
regmap_reg_range(0x0b, 0x0c),
regmap_reg_range(0x0e, 0x13),
};
static const struct regmap_access_table bq25890_writeable_regs = {
.no_ranges = bq25890_readonly_reg_ranges,
.n_no_ranges = ARRAY_SIZE(bq25890_readonly_reg_ranges),
};
static const struct regmap_range bq25890_volatile_reg_ranges[] = {
regmap_reg_range(0x00, 0x00),
regmap_reg_range(0x02, 0x02),
regmap_reg_range(0x09, 0x09),
regmap_reg_range(0x0b, 0x14),
};
static const struct regmap_access_table bq25890_volatile_regs = {
.yes_ranges = bq25890_volatile_reg_ranges,
.n_yes_ranges = ARRAY_SIZE(bq25890_volatile_reg_ranges),
};
static const struct regmap_config bq25890_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0x14,
.cache_type = REGCACHE_MAPLE,
.wr_table = &bq25890_writeable_regs,
.volatile_table = &bq25890_volatile_regs,
Annotation
- Immediate include surface: `linux/module.h`, `linux/i2c.h`, `linux/power_supply.h`, `linux/power/bq25890_charger.h`, `linux/regmap.h`, `linux/regulator/driver.h`, `linux/types.h`, `linux/gpio/consumer.h`.
- Detected declarations: `struct bq25890_init_data`, `struct bq25890_state`, `struct bq25890_device`, `struct bq25890_range`, `struct bq25890_lookup`, `enum bq25890_chip_version`, `enum bq25890_fields`, `enum bq25890_table_ids`, `enum bq25890_status`, `enum bq25890_chrg_fault`.
- 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.