drivers/power/supply/da9150-charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/da9150-charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/da9150-charger.c- Extension
.c- Size
- 16419 bytes
- Lines
- 647
- 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/kernel.hlinux/slab.hlinux/module.hlinux/platform_device.hlinux/interrupt.hlinux/power_supply.hlinux/notifier.hlinux/usb/phy.hlinux/iio/consumer.hlinux/mfd/da9150/core.hlinux/mfd/da9150/registers.h
Detected Declarations
struct da9150_chargerfunction da9150_charger_supply_onlinefunction da9150_charger_vbus_voltage_nowfunction da9150_charger_ibus_current_avgfunction da9150_charger_tjunc_tempfunction da9150_charger_get_propfunction da9150_charger_battery_statusfunction da9150_charger_battery_healthfunction da9150_charger_battery_presentfunction da9150_charger_battery_charge_typefunction da9150_charger_battery_voltage_minfunction da9150_charger_battery_voltage_nowfunction da9150_charger_battery_current_maxfunction da9150_charger_battery_voltage_maxfunction da9150_charger_battery_get_propfunction da9150_charger_chg_irqfunction da9150_charger_tjunc_irqfunction da9150_charger_vfault_irqfunction da9150_charger_vbus_irqfunction da9150_charger_otg_workfunction da9150_charger_otg_ncbfunction da9150_charger_register_irqfunction da9150_charger_unregister_irqfunction da9150_charger_probefunction da9150_charger_remove
Annotated Snippet
struct da9150_charger {
struct da9150 *da9150;
struct device *dev;
struct power_supply *usb;
struct power_supply *battery;
struct power_supply *supply_online;
struct usb_phy *usb_phy;
struct notifier_block otg_nb;
struct work_struct otg_work;
unsigned long usb_event;
struct iio_channel *ibus_chan;
struct iio_channel *vbus_chan;
struct iio_channel *tjunc_chan;
struct iio_channel *vbat_chan;
};
static inline int da9150_charger_supply_online(struct da9150_charger *charger,
struct power_supply *psy,
union power_supply_propval *val)
{
val->intval = (psy == charger->supply_online) ? 1 : 0;
return 0;
}
/* Charger Properties */
static int da9150_charger_vbus_voltage_now(struct da9150_charger *charger,
union power_supply_propval *val)
{
int v_val, ret;
/* Read processed value - mV units */
ret = iio_read_channel_processed(charger->vbus_chan, &v_val);
if (ret < 0)
return ret;
/* Convert voltage to expected uV units */
val->intval = v_val * 1000;
return 0;
}
static int da9150_charger_ibus_current_avg(struct da9150_charger *charger,
union power_supply_propval *val)
{
int i_val, ret;
/* Read processed value - mA units */
ret = iio_read_channel_processed(charger->ibus_chan, &i_val);
if (ret < 0)
return ret;
/* Convert current to expected uA units */
val->intval = i_val * 1000;
return 0;
}
static int da9150_charger_tjunc_temp(struct da9150_charger *charger,
union power_supply_propval *val)
{
int t_val, ret;
/* Read processed value - 0.001 degrees C units */
ret = iio_read_channel_processed(charger->tjunc_chan, &t_val);
if (ret < 0)
return ret;
/* Convert temp to expect 0.1 degrees C units */
val->intval = t_val / 100;
return 0;
}
static enum power_supply_property da9150_charger_props[] = {
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_CURRENT_AVG,
POWER_SUPPLY_PROP_TEMP,
};
static int da9150_charger_get_prop(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct da9150_charger *charger = dev_get_drvdata(psy->dev.parent);
int ret;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/module.h`, `linux/platform_device.h`, `linux/interrupt.h`, `linux/power_supply.h`, `linux/notifier.h`, `linux/usb/phy.h`.
- Detected declarations: `struct da9150_charger`, `function da9150_charger_supply_online`, `function da9150_charger_vbus_voltage_now`, `function da9150_charger_ibus_current_avg`, `function da9150_charger_tjunc_temp`, `function da9150_charger_get_prop`, `function da9150_charger_battery_status`, `function da9150_charger_battery_health`, `function da9150_charger_battery_present`, `function da9150_charger_battery_charge_type`.
- 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.