drivers/regulator/mp8859.c
Source file repositories/reference/linux-study-clean/drivers/regulator/mp8859.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/mp8859.c- Extension
.c- Size
- 9704 bytes
- Lines
- 409
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/i2c.hlinux/of.hlinux/regulator/driver.hlinux/regmap.h
Detected Declarations
function mp8859_set_voltage_selfunction mp8859_get_voltage_selfunction mp8859_set_voltage_time_selfunction mp8859_get_modefunction mp8859_set_modefunction mp8859_set_current_limitfunction mp8859_get_statusfunction mp8859_get_error_flagsfunction mp8859_readablefunction mp8859_volatilefunction mp8859_i2c_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
//
// Copyright (c) 2019 five technologies GmbH
// Author: Markus Reichl <m.reichl@fivetechno.de>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/of.h>
#include <linux/regulator/driver.h>
#include <linux/regmap.h>
#define VOL_MIN_IDX 0x00
#define VOL_MAX_IDX 0x7ff
/* Register definitions */
#define MP8859_VOUT_L_REG 0 //3 lo Bits
#define MP8859_VOUT_H_REG 1 //8 hi Bits
#define MP8859_VOUT_GO_REG 2
#define MP8859_IOUT_LIM_REG 3
#define MP8859_CTL1_REG 4
#define MP8859_CTL2_REG 5
#define MP8859_RESERVED1_REG 6
#define MP8859_RESERVED2_REG 7
#define MP8859_RESERVED3_REG 8
#define MP8859_STATUS_REG 9
#define MP8859_INTERRUPT_REG 0x0A
#define MP8859_MASK_REG 0x0B
#define MP8859_ID1_REG 0x0C
#define MP8859_MFR_ID_REG 0x27
#define MP8859_DEV_ID_REG 0x28
#define MP8859_IC_REV_REG 0x29
#define MP8859_MAX_REG 0x29
#define MP8859_GO_BIT 0x01
#define MP8859_IOUT_LIM_MASK 0x7f
#define MP8859_ENABLE_MASK 0x80
#define MP8859_DISCHG_EN_MASK 0x10
#define MP8859_MODE_MASK 0x08
#define MP8859_PG_MASK 0x80
#define MP8859_OTP_MASK 0x40
#define MP8859_OTW_MASK 0x20
#define MP8859_CC_CV_MASK 0x10
static int mp8859_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel)
{
int ret;
ret = regmap_write(rdev->regmap, MP8859_VOUT_L_REG, sel & 0x7);
if (ret)
return ret;
ret = regmap_write(rdev->regmap, MP8859_VOUT_H_REG, sel >> 3);
if (ret)
return ret;
ret = regmap_update_bits(rdev->regmap, MP8859_VOUT_GO_REG,
MP8859_GO_BIT, 1);
return ret;
}
static int mp8859_get_voltage_sel(struct regulator_dev *rdev)
{
unsigned int val_tmp;
unsigned int val;
int ret;
ret = regmap_read(rdev->regmap, MP8859_VOUT_H_REG, &val_tmp);
if (ret)
return ret;
val = val_tmp << 3;
ret = regmap_read(rdev->regmap, MP8859_VOUT_L_REG, &val_tmp);
if (ret)
return ret;
val |= val_tmp & 0x07;
return val;
}
static int mp8859_set_voltage_time_sel(struct regulator_dev *rdev,
unsigned int from, unsigned int to)
{
int change;
Annotation
- Immediate include surface: `linux/module.h`, `linux/i2c.h`, `linux/of.h`, `linux/regulator/driver.h`, `linux/regmap.h`.
- Detected declarations: `function mp8859_set_voltage_sel`, `function mp8859_get_voltage_sel`, `function mp8859_set_voltage_time_sel`, `function mp8859_get_mode`, `function mp8859_set_mode`, `function mp8859_set_current_limit`, `function mp8859_get_status`, `function mp8859_get_error_flags`, `function mp8859_readable`, `function mp8859_volatile`.
- Atlas domain: Driver Families / drivers/regulator.
- Implementation status: source implementation candidate.
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.