drivers/mfd/tps65218.c
Source file repositories/reference/linux-study-clean/drivers/mfd/tps65218.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/tps65218.c- Extension
.c- Size
- 8262 bytes
- Lines
- 358
- Domain
- Driver Families
- Bucket
- drivers/mfd
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/platform_device.hlinux/init.hlinux/i2c.hlinux/slab.hlinux/regmap.hlinux/err.hlinux/of.hlinux/irq.hlinux/interrupt.hlinux/mutex.hlinux/mfd/core.hlinux/mfd/tps65218.h
Detected Declarations
function tps65218_reg_writefunction tps65218_update_bitsfunction tps65218_set_bitsfunction tps65218_clear_bitsfunction tps65218_voltage_set_strictfunction tps65218_voltage_set_uv_hystfunction tps65218_voltage_set_uvlofunction tps65218_probeexport tps65218_reg_writeexport tps65218_set_bitsexport tps65218_clear_bits
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Driver for TPS65218 Integrated power management chipsets
*
* Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com/
*/
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/regmap.h>
#include <linux/err.h>
#include <linux/of.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/mfd/core.h>
#include <linux/mfd/tps65218.h>
#define TPS65218_PASSWORD_REGS_UNLOCK 0x7D
static const struct mfd_cell tps65218_cells[] = {
{
.name = "tps65218-pwrbutton",
.of_compatible = "ti,tps65218-pwrbutton",
},
{
.name = "tps65218-gpio",
.of_compatible = "ti,tps65218-gpio",
},
{ .name = "tps65218-regulator", },
};
/**
* tps65218_reg_write: Write a single tps65218 register.
*
* @tps: Device to write to.
* @reg: Register to write to.
* @val: Value to write.
* @level: Password protected level
*/
int tps65218_reg_write(struct tps65218 *tps, unsigned int reg,
unsigned int val, unsigned int level)
{
int ret;
unsigned int xor_reg_val;
switch (level) {
case TPS65218_PROTECT_NONE:
return regmap_write(tps->regmap, reg, val);
case TPS65218_PROTECT_L1:
xor_reg_val = reg ^ TPS65218_PASSWORD_REGS_UNLOCK;
ret = regmap_write(tps->regmap, TPS65218_REG_PASSWORD,
xor_reg_val);
if (ret < 0)
return ret;
return regmap_write(tps->regmap, reg, val);
default:
return -EINVAL;
}
}
EXPORT_SYMBOL_GPL(tps65218_reg_write);
/**
* tps65218_update_bits: Modify bits w.r.t mask, val and level.
*
* @tps: Device to write to.
* @reg: Register to read-write to.
* @mask: Mask.
* @val: Value to write.
* @level: Password protected level
*/
static int tps65218_update_bits(struct tps65218 *tps, unsigned int reg,
unsigned int mask, unsigned int val, unsigned int level)
{
int ret;
unsigned int data;
ret = regmap_read(tps->regmap, reg, &data);
if (ret) {
dev_err(tps->dev, "Read from reg 0x%x failed\n", reg);
return ret;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/device.h`, `linux/module.h`, `linux/platform_device.h`, `linux/init.h`, `linux/i2c.h`, `linux/slab.h`, `linux/regmap.h`.
- Detected declarations: `function tps65218_reg_write`, `function tps65218_update_bits`, `function tps65218_set_bits`, `function tps65218_clear_bits`, `function tps65218_voltage_set_strict`, `function tps65218_voltage_set_uv_hyst`, `function tps65218_voltage_set_uvlo`, `function tps65218_probe`, `export tps65218_reg_write`, `export tps65218_set_bits`.
- Atlas domain: Driver Families / drivers/mfd.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.