drivers/regulator/pf0900-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/pf0900-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/pf0900-regulator.c- Extension
.c- Size
- 29861 bytes
- Lines
- 976
- Domain
- Driver Families
- Bucket
- drivers/regulator
- 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/bitfield.hlinux/crc8.hlinux/err.hlinux/gpio/consumer.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_device.hlinux/platform_device.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/of_regulator.h
Detected Declarations
struct pf0900_regulator_descstruct pf0900_drvdatastruct pf0900struct pf0900_regulator_irqenum pf0900_regulatorsenum pf0900_regulator_typefunction crc8_j1850function pf0900_regmap_readfunction pf0900_regmap_writefunction pf0900_suspend_enablefunction pf0900_suspend_disablefunction pf0900_set_suspend_voltagefunction pf0900_irq_handlerfunction pf0900_i2c_probe
Annotated Snippet
struct pf0900_regulator_desc {
struct regulator_desc desc;
unsigned int suspend_enable_mask;
unsigned int suspend_voltage_reg;
unsigned int suspend_voltage_cache;
};
struct pf0900_drvdata {
const struct pf0900_regulator_desc *desc;
unsigned int rcnt;
};
struct pf0900 {
struct device *dev;
struct regmap *regmap;
const struct pf0900_drvdata *drvdata;
struct regulator_dev *rdevs[PF0900_REGULATOR_CNT];
int irq;
unsigned short addr;
bool crc_en;
};
enum pf0900_regulator_type {
PF0900_SW = 0,
PF0900_LDO,
};
#define PF0900_REGU_IRQ(_reg, _type, _event) \
{ \
.reg = _reg, \
.type = _type, \
.event = _event, \
}
struct pf0900_regulator_irq {
unsigned int reg;
unsigned int type;
unsigned int event;
};
static const struct regmap_range pf0900_range = {
.range_min = PF0900_REG_DEV_ID,
.range_max = PF0900_REG_SYS_DIAG,
};
static const struct regmap_access_table pf0900_volatile_regs = {
.yes_ranges = &pf0900_range,
.n_yes_ranges = 1,
};
static const struct regmap_config pf0900_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.volatile_table = &pf0900_volatile_regs,
.max_register = PF0900_MAX_REGISTER - 1,
.cache_type = REGCACHE_MAPLE,
};
static uint8_t crc8_j1850(unsigned short addr, unsigned int reg,
unsigned int val)
{
uint8_t crcBuf[3];
uint8_t t_crc;
uint8_t i, j;
crcBuf[0] = addr;
crcBuf[1] = reg;
crcBuf[2] = val;
t_crc = 0xFF;
/*
* The CRC calculation is based on the standard CRC-8-SAE as
* defined in the SAE-J1850 specification with the following
* characteristics.
* Polynomial = 0x1D
* Initial Value = 0xFF
* The CRC byte is calculated by shifting 24-bit data through
* the CRC polynomial.The 24-bits package is built as follows:
* DEVICE_ADDR[b8] + REGISTER_ADDR [b8] +DATA[b8]
* The DEVICE_ADDR is calculated as the 7-bit slave address
* shifted left one space plus the corresponding read/write bit.
* (7Bit Address [b7] << 1 ) + R/W = DEVICE_ADDR[b8]
*/
for (i = 0; i < sizeof(crcBuf); i++) {
t_crc ^= crcBuf[i];
for (j = 0; j < 8; j++) {
if ((t_crc & 0x80) != 0) {
t_crc <<= 1;
t_crc ^= 0x1D;
} else {
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/crc8.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `struct pf0900_regulator_desc`, `struct pf0900_drvdata`, `struct pf0900`, `struct pf0900_regulator_irq`, `enum pf0900_regulators`, `enum pf0900_regulator_type`, `function crc8_j1850`, `function pf0900_regmap_read`, `function pf0900_regmap_write`, `function pf0900_suspend_enable`.
- Atlas domain: Driver Families / drivers/regulator.
- 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.