drivers/mfd/tps65010.c
Source file repositories/reference/linux-study-clean/drivers/mfd/tps65010.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/tps65010.c- Extension
.c- Size
- 27601 bytes
- Lines
- 1056
- Domain
- Driver Families
- Bucket
- drivers/mfd
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/kernel.hlinux/module.hlinux/init.hlinux/slab.hlinux/interrupt.hlinux/i2c.hlinux/delay.hlinux/workqueue.hlinux/debugfs.hlinux/seq_file.hlinux/string_choices.hlinux/mutex.hlinux/platform_device.hlinux/mfd/tps65010.hlinux/gpio/driver.h
Detected Declarations
struct tps65010enum tps_modelfunction dbg_chgstatfunction dbg_regstatfunction dbg_chgconffunction show_chgstatusfunction show_regstatusfunction show_chgconfigfunction show_chgstatusfunction dbg_tps_openfunction tps65010_interruptfunction tps65010_workfunction tps65010_irqfunction tps65010_gpio_setfunction tps65010_outputfunction tps65010_gpio_getfunction tps65010_removefunction tps65010_probefunction tps65010_set_vbus_drawfunction tps65010_set_gpio_out_valuefunction tps65010_set_ledfunction tps65010_set_vibfunction tps65010_set_low_pwrfunction tps65010_config_vregs1function tps65010_config_vdcdc2function tps65013_set_low_pwrfunction tps_initfunction tps_exitmodule init tps_initexport tps65010_set_vbus_drawexport tps65010_set_gpio_out_valueexport tps65010_set_ledexport tps65010_set_vibexport tps65010_set_low_pwrexport tps65010_config_vregs1export tps65010_config_vdcdc2export tps65013_set_low_pwr
Annotated Snippet
static const struct file_operations debug_fops = {
.open = dbg_tps_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#define DEBUG_FOPS &debug_fops
#else
#define DEBUG_FOPS NULL
#endif
/*-------------------------------------------------------------------------*/
/* handle IRQS in a task context, so we can use I2C calls */
static void tps65010_interrupt(struct tps65010 *tps)
{
u8 tmp = 0, mask, poll;
/* IRQs won't trigger for certain events, but we can get
* others by polling (normally, with external power applied).
*/
poll = 0;
/* regstatus irqs */
if (tps->nmask2) {
tmp = i2c_smbus_read_byte_data(tps->client, TPS_REGSTATUS);
mask = tmp ^ tps->regstatus;
tps->regstatus = tmp;
mask &= tps->nmask2;
} else
mask = 0;
if (mask) {
tps->regstatus = tmp;
/* may need to shut something down ... */
/* "off" usually means deep sleep */
if (tmp & TPS_REG_ONOFF) {
pr_info("%s: power off button\n", DRIVER_NAME);
#if 0
/* REVISIT: this might need its own workqueue
* plus tweaks including deadlock avoidance ...
* also needs to get error handling and probably
* an #ifdef CONFIG_HIBERNATION
*/
hibernate();
#endif
poll = 1;
}
}
/* chgstatus irqs */
if (tps->nmask1) {
tmp = i2c_smbus_read_byte_data(tps->client, TPS_CHGSTATUS);
mask = tmp ^ tps->chgstatus;
tps->chgstatus = tmp;
mask &= tps->nmask1;
} else
mask = 0;
if (mask) {
unsigned charging = 0;
show_chgstatus("chg/irq", tmp);
if (tmp & (TPS_CHG_USB|TPS_CHG_AC))
show_chgconfig(tps->por, "conf", tps->chgconf);
/* Unless it was turned off or disabled, we charge any
* battery whenever there's power available for it
* and the charger hasn't been disabled.
*/
if (!(tps->chgstatus & ~(TPS_CHG_USB|TPS_CHG_AC))
&& (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))
&& (tps->chgconf & TPS_CHARGE_ENABLE)
) {
if (tps->chgstatus & TPS_CHG_USB) {
/* VBUS options are readonly until reconnect */
if (mask & TPS_CHG_USB)
set_bit(FLAG_VBUS_CHANGED, &tps->flags);
charging = 1;
} else if (tps->chgstatus & TPS_CHG_AC)
charging = 1;
}
if (charging != tps->charging) {
tps->charging = charging;
pr_info("%s: battery %scharging\n",
DRIVER_NAME, charging ? "" :
((tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))
? "NOT " : "dis"));
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/delay.h`, `linux/workqueue.h`.
- Detected declarations: `struct tps65010`, `enum tps_model`, `function dbg_chgstat`, `function dbg_regstat`, `function dbg_chgconf`, `function show_chgstatus`, `function show_regstatus`, `function show_chgconfig`, `function show_chgstatus`, `function dbg_tps_open`.
- Atlas domain: Driver Families / drivers/mfd.
- Implementation status: pattern 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.