drivers/power/supply/qcom_smbb.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/qcom_smbb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/qcom_smbb.c- Extension
.c- Size
- 25738 bytes
- Lines
- 1031
- 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/errno.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/of.hlinux/platform_device.hlinux/power_supply.hlinux/regmap.hlinux/slab.hlinux/extcon-provider.hlinux/regulator/driver.h
Detected Declarations
struct smbb_chargerenum smbb_attrfunction smbb_vbat_weak_fnfunction smbb_vin_fnfunction smbb_vmax_fnfunction smbb_vbat_det_fnfunction smbb_imax_fnfunction smbb_bat_imax_fnfunction smbb_hw_lookupfunction smbb_charger_attr_writefunction smbb_charger_attr_readfunction smbb_charger_attr_parsefunction smbb_set_line_flagfunction smbb_usb_valid_handlerfunction smbb_dc_valid_handlerfunction smbb_bat_temp_handlerfunction smbb_bat_present_handlerfunction smbb_chg_done_handlerfunction smbb_chg_gone_handlerfunction smbb_chg_fast_handlerfunction smbb_chg_trkl_handlerfunction smbb_usbin_get_propertyfunction smbb_usbin_set_propertyfunction smbb_dcin_get_propertyfunction smbb_dcin_set_propertyfunction smbb_charger_writable_propertyfunction smbb_battery_get_propertyfunction smbb_battery_set_propertyfunction smbb_battery_writable_propertyfunction smbb_chg_otg_enablefunction smbb_chg_otg_disablefunction smbb_chg_otg_is_enabledfunction smbb_charger_probefunction smbb_charger_remove
Annotated Snippet
struct smbb_charger {
unsigned int revision;
unsigned int addr;
struct device *dev;
struct extcon_dev *edev;
bool dc_disabled;
bool jeita_ext_temp;
unsigned long status;
struct mutex statlock;
unsigned int attr[_ATTR_CNT];
struct power_supply *usb_psy;
struct power_supply *dc_psy;
struct power_supply *bat_psy;
struct regmap *regmap;
struct regulator_desc otg_rdesc;
struct regulator_dev *otg_reg;
};
static const unsigned int smbb_usb_extcon_cable[] = {
EXTCON_USB,
EXTCON_NONE,
};
static int smbb_vbat_weak_fn(unsigned int index)
{
return 2100000 + index * 100000;
}
static int smbb_vin_fn(unsigned int index)
{
if (index > 42)
return 5600000 + (index - 43) * 200000;
return 3400000 + index * 50000;
}
static int smbb_vmax_fn(unsigned int index)
{
return 3240000 + index * 10000;
}
static int smbb_vbat_det_fn(unsigned int index)
{
return 3240000 + index * 20000;
}
static int smbb_imax_fn(unsigned int index)
{
if (index < 2)
return 100000 + index * 50000;
return index * 100000;
}
static int smbb_bat_imax_fn(unsigned int index)
{
return index * 50000;
}
static unsigned int smbb_hw_lookup(unsigned int val, int (*fn)(unsigned int))
{
unsigned int widx;
unsigned int sel;
for (widx = sel = 0; (*fn)(widx) <= val; ++widx)
sel = widx;
return sel;
}
static const struct smbb_charger_attr {
const char *name;
unsigned int reg;
unsigned int safe_reg;
unsigned int max;
unsigned int min;
unsigned int fail_ok;
int (*hw_fn)(unsigned int);
} smbb_charger_attrs[] = {
[ATTR_BAT_ISAFE] = {
.name = "qcom,fast-charge-safe-current",
.reg = SMBB_CHG_ISAFE,
.max = 3000000,
.min = 200000,
.hw_fn = smbb_bat_imax_fn,
.fail_ok = 1,
},
[ATTR_BAT_IMAX] = {
Annotation
- Immediate include surface: `linux/errno.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/of.h`, `linux/platform_device.h`, `linux/power_supply.h`.
- Detected declarations: `struct smbb_charger`, `enum smbb_attr`, `function smbb_vbat_weak_fn`, `function smbb_vin_fn`, `function smbb_vmax_fn`, `function smbb_vbat_det_fn`, `function smbb_imax_fn`, `function smbb_bat_imax_fn`, `function smbb_hw_lookup`, `function smbb_charger_attr_write`.
- 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.