drivers/power/supply/bq24190_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/bq24190_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/bq24190_charger.c- Extension
.c- Size
- 64563 bytes
- Lines
- 2350
- 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/mod_devicetable.hlinux/module.hlinux/interrupt.hlinux/delay.hlinux/devm-helpers.hlinux/pm_runtime.hlinux/power_supply.hlinux/power/bq24190_charger.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/workqueue.hlinux/i2c.hlinux/extcon-provider.h
Detected Declarations
struct bq24190_dev_infostruct bq24190_chip_infostruct bq24190_sysfs_field_infoenum bq24190_chipfunction bq24190_find_idxfunction bq24190_readfunction bq24190_writefunction bq24190_read_maskfunction bq24190_write_maskfunction bq24190_get_field_valfunction bq24190_set_field_valfunction bq24190_sysfs_init_attrsfunction bq24190_sysfs_showfunction bq24190_sysfs_storefunction bq24190_set_otg_vbusfunction bq24296_set_otg_vbusfunction bq24190_vbus_enablefunction bq24190_vbus_disablefunction bq24190_vbus_is_enabledfunction bq24296_vbus_enablefunction bq24296_vbus_disablefunction bq24296_vbus_is_enabledfunction bq24190_register_vbus_regulatorfunction bq24190_register_vbus_regulatorfunction bq24190_set_configfunction bq24190_register_resetfunction bq24190_charger_get_charge_typefunction bq24190_battery_set_chg_configfunction bq24296_battery_set_chg_configfunction bq24190_charger_set_charge_typefunction bq24190_charger_get_ntc_statusfunction bq24296_charger_get_ntc_statusfunction bq24190_charger_get_healthfunction bq24190_charger_get_onlinefunction bq24190_charger_set_onlinefunction bq24190_charger_get_statusfunction bq24190_charger_get_temp_alert_maxfunction bq24190_charger_set_temp_alert_maxfunction bq24190_charger_get_prechargefunction bq24190_charger_get_charge_termfunction bq24190_charger_get_currentfunction bq24190_charger_set_currentfunction bq24190_charger_get_voltagefunction bq24190_charger_set_voltagefunction bq24190_charger_get_iinlimitfunction bq24190_charger_set_iinlimitfunction bq24190_charger_get_propertyfunction bq24190_charger_set_property
Annotated Snippet
struct bq24190_dev_info {
struct i2c_client *client;
struct device *dev;
struct extcon_dev *edev;
struct power_supply *charger;
struct power_supply *battery;
struct delayed_work input_current_limit_work;
char model_name[I2C_NAME_SIZE];
bool initialized;
bool irq_event;
bool otg_vbus_enabled;
int charge_type;
u16 sys_min;
u16 iprechg;
u16 iterm;
u32 ichg;
u32 ichg_max;
u32 vreg;
u32 vreg_max;
struct mutex f_reg_lock;
u8 f_reg;
u8 ss_reg;
u8 watchdog;
const struct bq24190_chip_info *info;
};
struct bq24190_chip_info {
int ichg_array_size;
#ifdef CONFIG_REGULATOR
const struct regulator_desc *vbus_desc;
#endif
int (*check_chip)(struct bq24190_dev_info *bdi);
int (*set_chg_config)(struct bq24190_dev_info *bdi, const u8 chg_config);
int (*set_otg_vbus)(struct bq24190_dev_info *bdi, bool enable);
u8 ntc_fault_mask;
int (*get_ntc_status)(const u8 value);
};
static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi,
const union power_supply_propval *val);
static const unsigned int bq24190_usb_extcon_cable[] = {
EXTCON_USB,
EXTCON_NONE,
};
/*
* Return the index in 'tbl' of greatest value that is less than or equal to
* 'val'. The index range returned is 0 to 'tbl_size' - 1. Assumes that
* the values in 'tbl' are sorted from smallest to largest and 'tbl_size'
* is less than 2^8.
*/
static u8 bq24190_find_idx(const int tbl[], int tbl_size, int v)
{
int i;
for (i = 1; i < tbl_size; i++)
if (v < tbl[i])
break;
return i - 1;
}
/* Basic driver I/O routines */
static int bq24190_read(struct bq24190_dev_info *bdi, u8 reg, u8 *data)
{
int ret;
ret = i2c_smbus_read_byte_data(bdi->client, reg);
if (ret < 0)
return ret;
*data = ret;
return 0;
}
static int bq24190_write(struct bq24190_dev_info *bdi, u8 reg, u8 data)
{
return i2c_smbus_write_byte_data(bdi->client, reg, data);
}
static int bq24190_read_mask(struct bq24190_dev_info *bdi, u8 reg,
u8 mask, u8 shift, u8 *data)
{
u8 v;
int ret;
ret = bq24190_read(bdi, reg, &v);
Annotation
- Immediate include surface: `linux/mod_devicetable.h`, `linux/module.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/devm-helpers.h`, `linux/pm_runtime.h`, `linux/power_supply.h`, `linux/power/bq24190_charger.h`.
- Detected declarations: `struct bq24190_dev_info`, `struct bq24190_chip_info`, `struct bq24190_sysfs_field_info`, `enum bq24190_chip`, `function bq24190_find_idx`, `function bq24190_read`, `function bq24190_write`, `function bq24190_read_mask`, `function bq24190_write_mask`, `function bq24190_get_field_val`.
- 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.