drivers/power/supply/tps65217_charger.c
Source file repositories/reference/linux-study-clean/drivers/power/supply/tps65217_charger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/supply/tps65217_charger.c- Extension
.c- Size
- 7219 bytes
- Lines
- 284
- 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/kthread.hlinux/device.hlinux/module.hlinux/platform_device.hlinux/init.hlinux/interrupt.hlinux/slab.hlinux/err.hlinux/of.hlinux/power_supply.hlinux/mfd/core.hlinux/mfd/tps65217.h
Detected Declarations
struct tps65217_chargerfunction tps65217_config_chargerfunction tps65217_enable_chargingfunction tps65217_charger_get_propertyfunction tps65217_charger_irqfunction tps65217_charger_poll_taskfunction tps65217_charger_probefunction tps65217_charger_remove
Annotated Snippet
struct tps65217_charger {
struct tps65217 *tps;
struct device *dev;
struct power_supply *psy;
int online;
int prev_online;
struct task_struct *poll_task;
};
static enum power_supply_property tps65217_charger_props[] = {
POWER_SUPPLY_PROP_ONLINE,
};
static int tps65217_config_charger(struct tps65217_charger *charger)
{
int ret;
/*
* tps65217 rev. G, p. 31 (see p. 32 for NTC schematic)
*
* The device can be configured to support a 100k NTC (B = 3960) by
* setting the NTC_TYPE bit in register CHGCONFIG1 to 1. However it
* is not recommended to do so. In sleep mode, the charger continues
* charging the battery, but all register values are reset to default
* values. Therefore, the charger would get the wrong temperature
* information. If 100k NTC setting is required, please contact the
* factory.
*
* ATTENTION, conflicting information, from p. 46
*
* NTC TYPE (for battery temperature measurement)
* 0 – 100k (curve 1, B = 3960)
* 1 – 10k (curve 2, B = 3480) (default on reset)
*
*/
ret = tps65217_clear_bits(charger->tps, TPS65217_REG_CHGCONFIG1,
TPS65217_CHGCONFIG1_NTC_TYPE,
TPS65217_PROTECT_NONE);
if (ret) {
dev_err(charger->dev,
"failed to set 100k NTC setting: %d\n", ret);
return ret;
}
return 0;
}
static int tps65217_enable_charging(struct tps65217_charger *charger)
{
int ret;
/* charger already enabled */
if (charger->online)
return 0;
dev_dbg(charger->dev, "%s: enable charging\n", __func__);
ret = tps65217_set_bits(charger->tps, TPS65217_REG_CHGCONFIG1,
TPS65217_CHGCONFIG1_CHG_EN,
TPS65217_CHGCONFIG1_CHG_EN,
TPS65217_PROTECT_NONE);
if (ret) {
dev_err(charger->dev,
"%s: Error in writing CHG_EN in reg 0x%x: %d\n",
__func__, TPS65217_REG_CHGCONFIG1, ret);
return ret;
}
charger->online = 1;
return 0;
}
static int tps65217_charger_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct tps65217_charger *charger = power_supply_get_drvdata(psy);
if (psp == POWER_SUPPLY_PROP_ONLINE) {
val->intval = charger->online;
return 0;
}
return -EINVAL;
}
static irqreturn_t tps65217_charger_irq(int irq, void *dev)
{
int ret, val;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/kthread.h`, `linux/device.h`, `linux/module.h`, `linux/platform_device.h`, `linux/init.h`, `linux/interrupt.h`, `linux/slab.h`.
- Detected declarations: `struct tps65217_charger`, `function tps65217_config_charger`, `function tps65217_enable_charging`, `function tps65217_charger_get_property`, `function tps65217_charger_irq`, `function tps65217_charger_poll_task`, `function tps65217_charger_probe`, `function tps65217_charger_remove`.
- 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.