drivers/power/supply/rn5t618_power.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/rn5t618_power.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/rn5t618_power.c- Extension
.c- Size
- 19829 bytes
- Lines
- 824
- 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/device.hlinux/bitops.hlinux/errno.hlinux/iio/consumer.hlinux/init.hlinux/interrupt.hlinux/module.hlinux/mfd/rn5t618.hlinux/platform_device.hlinux/power_supply.hlinux/regmap.hlinux/slab.h
Detected Declarations
struct rn5t618_power_infofunction rn5t618_battery_read_doubleregfunction rn5t618_decode_statusfunction rn5t618_battery_statusfunction rn5t618_battery_presentfunction rn5t618_battery_voltage_nowfunction rn5t618_battery_current_nowfunction rn5t618_battery_capacityfunction rn5t618_battery_tempfunction rn5t618_battery_ttefunction rn5t618_battery_ttffunction rn5t618_battery_set_current_limitfunction rn5t618_battery_get_current_limitfunction rn5t618_battery_charge_fullfunction rn5t618_battery_charge_nowfunction rn5t618_battery_get_propertyfunction rn5t618_battery_set_propertyfunction rn5t618_battery_property_is_writeablefunction rn5t618_adp_get_propertyfunction rn5t618_adp_set_propertyfunction rn5t618_adp_property_is_writeablefunction rc5t619_usb_get_typefunction rn5t618_usb_get_propertyfunction rn5t618_usb_set_propertyfunction rn5t618_usb_property_is_writeablefunction rn5t618_charger_irqfunction rn5t618_power_probe
Annotated Snippet
struct rn5t618_power_info {
struct rn5t618 *rn5t618;
struct platform_device *pdev;
struct power_supply *battery;
struct power_supply *usb;
struct power_supply *adp;
struct iio_channel *channel_vusb;
struct iio_channel *channel_vadp;
int irq;
};
static enum power_supply_property rn5t618_usb_props[] = {
/* input current limit is not very accurate */
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_USB_TYPE,
POWER_SUPPLY_PROP_ONLINE,
};
static enum power_supply_property rn5t618_adp_props[] = {
/* input current limit is not very accurate */
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_ONLINE,
};
static enum power_supply_property rn5t618_battery_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_TEMP,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
POWER_SUPPLY_PROP_CHARGE_FULL,
POWER_SUPPLY_PROP_CHARGE_NOW,
};
static int rn5t618_battery_read_doublereg(struct rn5t618_power_info *info,
u8 reg, u16 *result)
{
int ret, i;
u8 data[2];
u16 old, new;
old = 0;
/* Prevent races when registers are changing. */
for (i = 0; i < 3; i++) {
ret = regmap_bulk_read(info->rn5t618->regmap,
reg, data, sizeof(data));
if (ret)
return ret;
new = data[0] << 8;
new |= data[1];
if (new == old)
break;
old = new;
}
*result = new;
return 0;
}
static int rn5t618_decode_status(unsigned int status)
{
switch (status & CHG_STATE_MASK) {
case CHG_STATE_CHG_OFF:
case CHG_STATE_SUSPEND:
case CHG_STATE_VCHG_OVER_VOL:
case CHG_STATE_DIE_SHUTDOWN:
return POWER_SUPPLY_STATUS_DISCHARGING;
case CHG_STATE_CHG_TRICKLE:
case CHG_STATE_CHG_RAPID:
return POWER_SUPPLY_STATUS_CHARGING;
case CHG_STATE_CHG_COMPLETE:
return POWER_SUPPLY_STATUS_FULL;
default:
return POWER_SUPPLY_STATUS_NOT_CHARGING;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/device.h`, `linux/bitops.h`, `linux/errno.h`, `linux/iio/consumer.h`, `linux/init.h`, `linux/interrupt.h`, `linux/module.h`.
- Detected declarations: `struct rn5t618_power_info`, `function rn5t618_battery_read_doublereg`, `function rn5t618_decode_status`, `function rn5t618_battery_status`, `function rn5t618_battery_present`, `function rn5t618_battery_voltage_now`, `function rn5t618_battery_current_now`, `function rn5t618_battery_capacity`, `function rn5t618_battery_temp`, `function rn5t618_battery_tte`.
- 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.