drivers/power/supply/qcom_battmgr.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/qcom_battmgr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/qcom_battmgr.c- Extension
.c- Size
- 50258 bytes
- Lines
- 1742
- 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.
- 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/auxiliary_bus.hlinux/module.hlinux/mutex.hlinux/nvmem-consumer.hlinux/of_device.hlinux/power_supply.hlinux/property.hlinux/soc/qcom/pdr.hlinux/soc/qcom/pmic_glink.hlinux/math.hlinux/units.h
Detected Declarations
struct qcom_battmgr_enable_requeststruct qcom_battmgr_property_requeststruct qcom_battmgr_update_requeststruct qcom_battmgr_charge_time_requeststruct qcom_battmgr_discharge_time_requeststruct qcom_battmgr_charge_ctrl_requeststruct qcom_battmgr_messagestruct qcom_battmgr_infostruct qcom_battmgr_statusstruct qcom_battmgr_acstruct qcom_battmgr_usbstruct qcom_battmgr_wirelessstruct qcom_battmgrenum qcom_battmgr_variantenum qcom_battmgr_unitfunction qcom_battmgr_requestfunction qcom_battmgr_request_propertyfunction qcom_battmgr_update_statusfunction qcom_battmgr_update_infofunction qcom_battmgr_update_charge_timefunction qcom_battmgr_update_discharge_timefunction qcom_battmgr_bat_sm8350_updatefunction qcom_battmgr_bat_sc8280xp_updatefunction qcom_battmgr_bat_get_propertyfunction qcom_battmgr_set_charge_controlfunction qcom_battmgr_set_charge_start_thresholdfunction stepfunction qcom_battmgr_set_charge_end_thresholdfunction qcom_battmgr_charge_control_thresholds_initfunction qcom_battmgr_bat_is_writeablefunction qcom_battmgr_bat_set_propertyfunction qcom_battmgr_ac_get_propertyfunction qcom_battmgr_usb_sm8350_updatefunction qcom_battmgr_usb_get_propertyfunction qcom_battmgr_wls_sm8350_updatefunction qcom_battmgr_wls_get_propertyfunction qcom_battmgr_notificationfunction qcom_battmgr_sc8280xp_strcpyfunction qcom_battmgr_sc8280xp_parse_technologyfunction qcom_battmgr_sc8280xp_convert_tempfunction qcom_battmgr_sc8280xp_callbackfunction qcom_battmgr_sm8350_callbackfunction qcom_battmgr_callbackfunction qcom_battmgr_enable_workerfunction qcom_battmgr_pdr_notifyfunction qcom_battmgr_probe
Annotated Snippet
struct qcom_battmgr_enable_request {
struct pmic_glink_hdr hdr;
__le32 battery_id;
__le32 power_state;
__le32 low_capacity;
__le32 high_capacity;
};
struct qcom_battmgr_property_request {
struct pmic_glink_hdr hdr;
__le32 battery;
__le32 property;
__le32 value;
};
struct qcom_battmgr_update_request {
struct pmic_glink_hdr hdr;
__le32 battery_id;
};
struct qcom_battmgr_charge_time_request {
struct pmic_glink_hdr hdr;
__le32 battery_id;
__le32 percent;
__le32 reserved;
};
struct qcom_battmgr_discharge_time_request {
struct pmic_glink_hdr hdr;
__le32 battery_id;
__le32 rate; /* 0 for current rate */
__le32 reserved;
};
struct qcom_battmgr_charge_ctrl_request {
struct pmic_glink_hdr hdr;
__le32 enable;
__le32 target_soc;
__le32 delta_soc;
};
struct qcom_battmgr_message {
struct pmic_glink_hdr hdr;
union {
struct {
__le32 property;
__le32 value;
__le32 result;
} intval;
struct {
__le32 property;
char model[BATTMGR_STRING_LEN];
} strval;
struct {
/*
* 0: mWh
* 1: mAh
*/
__le32 power_unit;
__le32 design_capacity;
__le32 last_full_capacity;
/*
* 0 nonrechargable
* 1 rechargable
*/
__le32 battery_tech;
__le32 design_voltage; /* mV */
__le32 capacity_low;
__le32 capacity_warning;
__le32 cycle_count;
/* thousandth of percent */
__le32 accuracy;
__le32 max_sample_time_ms;
__le32 min_sample_time_ms;
__le32 max_average_interval_ms;
__le32 min_average_interval_ms;
/* granularity between low and warning */
__le32 capacity_granularity1;
/* granularity between warning and full */
__le32 capacity_granularity2;
/*
* 0: no
* 1: cold
* 2: hot
*/
__le32 swappable;
__le32 capabilities;
char model_number[BATTMGR_STRING_LEN];
char serial_number[BATTMGR_STRING_LEN];
char battery_type[BATTMGR_STRING_LEN];
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/module.h`, `linux/mutex.h`, `linux/nvmem-consumer.h`, `linux/of_device.h`, `linux/power_supply.h`, `linux/property.h`, `linux/soc/qcom/pdr.h`.
- Detected declarations: `struct qcom_battmgr_enable_request`, `struct qcom_battmgr_property_request`, `struct qcom_battmgr_update_request`, `struct qcom_battmgr_charge_time_request`, `struct qcom_battmgr_discharge_time_request`, `struct qcom_battmgr_charge_ctrl_request`, `struct qcom_battmgr_message`, `struct qcom_battmgr_info`, `struct qcom_battmgr_status`, `struct qcom_battmgr_ac`.
- 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.
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.