drivers/power/supply/wm831x_power.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/wm831x_power.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/wm831x_power.c- Extension
.c- Size
- 19311 bytes
- Lines
- 741
- 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.
- 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/err.hlinux/platform_device.hlinux/power_supply.hlinux/slab.hlinux/usb/phy.hlinux/mfd/wm831x/core.hlinux/mfd/wm831x/auxadc.hlinux/mfd/wm831x/pmu.hlinux/mfd/wm831x/pdata.h
Detected Declarations
struct wm831x_powerstruct chg_mapfunction wm831x_power_check_onlinefunction wm831x_power_read_voltagefunction wm831x_wall_get_propfunction wm831x_usb_get_propfunction wm831x_usb_limit_changefunction wm831x_battery_apply_configfunction wm831x_config_batteryfunction wm831x_bat_check_statusfunction wm831x_bat_check_typefunction wm831x_bat_check_healthfunction wm831x_bat_get_propfunction wm831x_bat_irqfunction wm831x_syslo_irqfunction wm831x_pwr_src_irqfunction wm831x_power_probefunction wm831x_power_remove
Annotated Snippet
struct wm831x_power {
struct wm831x *wm831x;
struct power_supply *wall;
struct power_supply *usb;
struct power_supply *battery;
struct power_supply_desc wall_desc;
struct power_supply_desc usb_desc;
struct power_supply_desc battery_desc;
char wall_name[20];
char usb_name[20];
char battery_name[20];
bool have_battery;
struct usb_phy *usb_phy;
struct notifier_block usb_notify;
};
static int wm831x_power_check_online(struct wm831x *wm831x, int supply,
union power_supply_propval *val)
{
int ret;
ret = wm831x_reg_read(wm831x, WM831X_SYSTEM_STATUS);
if (ret < 0)
return ret;
if (ret & supply)
val->intval = 1;
else
val->intval = 0;
return 0;
}
static int wm831x_power_read_voltage(struct wm831x *wm831x,
enum wm831x_auxadc src,
union power_supply_propval *val)
{
int ret;
ret = wm831x_auxadc_read_uv(wm831x, src);
if (ret >= 0)
val->intval = ret;
return ret;
}
/*********************************************************************
* WALL Power
*********************************************************************/
static int wm831x_wall_get_prop(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct wm831x_power *wm831x_power = dev_get_drvdata(psy->dev.parent);
struct wm831x *wm831x = wm831x_power->wm831x;
int ret = 0;
switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
ret = wm831x_power_check_online(wm831x, WM831X_PWR_WALL, val);
break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
ret = wm831x_power_read_voltage(wm831x, WM831X_AUX_WALL, val);
break;
default:
ret = -EINVAL;
break;
}
return ret;
}
static const enum power_supply_property wm831x_wall_props[] = {
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
};
/*********************************************************************
* USB Power
*********************************************************************/
static int wm831x_usb_get_prop(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct wm831x_power *wm831x_power = dev_get_drvdata(psy->dev.parent);
struct wm831x *wm831x = wm831x_power->wm831x;
int ret = 0;
switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
Annotation
- Immediate include surface: `linux/module.h`, `linux/err.h`, `linux/platform_device.h`, `linux/power_supply.h`, `linux/slab.h`, `linux/usb/phy.h`, `linux/mfd/wm831x/core.h`, `linux/mfd/wm831x/auxadc.h`.
- Detected declarations: `struct wm831x_power`, `struct chg_map`, `function wm831x_power_check_online`, `function wm831x_power_read_voltage`, `function wm831x_wall_get_prop`, `function wm831x_usb_get_prop`, `function wm831x_usb_limit_change`, `function wm831x_battery_apply_config`, `function wm831x_config_battery`, `function wm831x_bat_check_status`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
- 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.