drivers/power/supply/bd99954-charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/bd99954-charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/bd99954-charger.c- Extension
.c- Size
- 29242 bytes
- Lines
- 1079
- 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/delay.hlinux/interrupt.hlinux/i2c.hlinux/kernel.hlinux/linear_range.hlinux/module.hlinux/mod_devicetable.hlinux/power_supply.hlinux/property.hlinux/regmap.hlinux/types.hbd99954-charger.h
Detected Declarations
struct bd9995x_init_datastruct bd9995x_statestruct bd9995x_devicestruct battery_initstruct dt_initenum bd9995x_chrg_faultfunction bd9995x_get_prop_batt_healthfunction bd9995x_get_prop_charge_typefunction bd9995x_get_prop_batt_presentfunction bd9995x_get_prop_batt_voltagefunction bd9995x_get_prop_batt_currentfunction bd9995x_get_prop_batt_tempfunction bd9995x_power_supply_get_propertyfunction bd9995x_get_chip_statefunction bd9995x_irq_handler_threadfunction for_each_set_bitfunction __bd9995x_chip_resetfunction bd9995x_hw_initfunction bd9995x_fw_probefunction bd9995x_chip_resetfunction bd9995x_probe
Annotated Snippet
struct bd9995x_init_data {
u16 vsysreg_set; /* VSYS Regulation Setting */
u16 ibus_lim_set; /* VBUS input current limitation */
u16 icc_lim_set; /* VCC/VACP Input Current Limit Setting */
u16 itrich_set; /* Trickle-charge Current Setting */
u16 iprech_set; /* Pre-Charge Current Setting */
u16 ichg_set; /* Fast-Charge constant current */
u16 vfastchg_reg_set1; /* Fast Charging Regulation Voltage */
u16 vprechg_th_set; /* Pre-charge Voltage Threshold Setting */
u16 vrechg_set; /* Re-charge Battery Voltage Setting */
u16 vbatovp_set; /* Battery Over Voltage Threshold Setting */
u16 iterm_set; /* Charging termination current */
};
struct bd9995x_state {
u8 online;
u16 chgstm_status;
u16 vbat_vsys_status;
u16 vbus_vcc_status;
};
struct bd9995x_device {
struct i2c_client *client;
struct device *dev;
struct power_supply *charger;
struct regmap *rmap;
struct regmap_field *rmap_fields[F_MAX_FIELDS];
int chip_id;
int chip_rev;
struct bd9995x_init_data init_data;
struct bd9995x_state state;
struct mutex lock; /* Protect state data */
};
static const struct regmap_range bd9995x_readonly_reg_ranges[] = {
regmap_reg_range(CHGSTM_STATUS, SEL_ILIM_VAL),
regmap_reg_range(IOUT_DACIN_VAL, IOUT_DACIN_VAL),
regmap_reg_range(VCC_UCD_STATUS, VCC_IDD_STATUS),
regmap_reg_range(VBUS_UCD_STATUS, VBUS_IDD_STATUS),
regmap_reg_range(CHIP_ID, CHIP_REV),
regmap_reg_range(SYSTEM_STATUS, SYSTEM_STATUS),
regmap_reg_range(IBATP_VAL, VBAT_AVE_VAL),
regmap_reg_range(VTH_VAL, EXTIADP_AVE_VAL),
};
static const struct regmap_access_table bd9995x_writeable_regs = {
.no_ranges = bd9995x_readonly_reg_ranges,
.n_no_ranges = ARRAY_SIZE(bd9995x_readonly_reg_ranges),
};
static const struct regmap_range bd9995x_volatile_reg_ranges[] = {
regmap_reg_range(CHGSTM_STATUS, WDT_STATUS),
regmap_reg_range(VCC_UCD_STATUS, VCC_IDD_STATUS),
regmap_reg_range(VBUS_UCD_STATUS, VBUS_IDD_STATUS),
regmap_reg_range(INT0_STATUS, INT7_STATUS),
regmap_reg_range(SYSTEM_STATUS, SYSTEM_CTRL_SET),
regmap_reg_range(IBATP_VAL, EXTIADP_AVE_VAL), /* Measurement regs */
};
static const struct regmap_access_table bd9995x_volatile_regs = {
.yes_ranges = bd9995x_volatile_reg_ranges,
.n_yes_ranges = ARRAY_SIZE(bd9995x_volatile_reg_ranges),
};
static const struct regmap_range_cfg regmap_range_cfg[] = {
{
.selector_reg = MAP_SET,
.selector_mask = 0xFFFF,
.selector_shift = 0,
.window_start = 0,
.window_len = 0x100,
.range_min = 0 * 0x100,
.range_max = 3 * 0x100,
},
};
static const struct regmap_config bd9995x_regmap_config = {
.reg_bits = 8,
.val_bits = 16,
.reg_stride = 1,
.max_register = 3 * 0x100,
.cache_type = REGCACHE_MAPLE,
.ranges = regmap_range_cfg,
.num_ranges = ARRAY_SIZE(regmap_range_cfg),
.val_format_endian = REGMAP_ENDIAN_LITTLE,
Annotation
- Immediate include surface: `linux/delay.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/kernel.h`, `linux/linear_range.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/power_supply.h`.
- Detected declarations: `struct bd9995x_init_data`, `struct bd9995x_state`, `struct bd9995x_device`, `struct battery_init`, `struct dt_init`, `enum bd9995x_chrg_fault`, `function bd9995x_get_prop_batt_health`, `function bd9995x_get_prop_charge_type`, `function bd9995x_get_prop_batt_present`, `function bd9995x_get_prop_batt_voltage`.
- 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.