drivers/regulator/rt8092.c
Source file repositories/reference/linux-study-clean/drivers/regulator/rt8092.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/rt8092.c- Extension
.c- Size
- 8900 bytes
- Lines
- 314
- 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.
- 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/bits.hlinux/gpio/consumer.hlinux/i2c.hlinux/mod_devicetable.hlinux/module.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/regulator/driver.hlinux/regulator/of_regulator.h
Detected Declarations
function rt8092_get_vbank_indexfunction rt8092_set_operating_modefunction rt8092_get_operating_modefunction rt8092_get_error_flagsfunction rt8092_set_suspend_voltagefunction rt8092_set_suspend_enablefunction rt8092_set_suspend_disablefunction rt8092_set_suspend_modefunction rt8092_of_map_modefunction rt8092_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
//
// Copyright (c) 2025 Richtek Technology Corp.
//
// Author: ChiYuan Huang <cy_huang@richtek.com>
#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
#define RT8092_REG_MNTRPT 0x00
#define RT8092_REG_VOUTH 0x10
#define RT8092_REG_VOUTL 0x11
#define RT8092_REG_PWMMODE 0x14
#define RT8092_REG_EVENT 0x18
#define RT8092_REG_VBANKH 0x1C
#define RT8092_REG_VBANKL 0x1D
#define RT8092_REG_VBOUND 0x1E
#define RT8092_TSDEVT_MASK BIT(7)
#define RT8092_PGEVT_MASK BIT(0)
#define RT8092_VSEL_MASK GENMASK(6, 0)
#define RT8092_VOUTEN_MASK BIT(7)
#define RT8092_FPWML_MASK BIT(7)
#define RT8092_FPWMH_MASK BIT(6)
#define RT8092_OCPEVT_MASK BIT(7)
#define RT8092_SCPEVT_MASK BIT(4)
#define RT8092_VINUVEVT_MASK BIT(1)
#define RT8092_VBANK_MASK GENMASK(1, 0)
#define RT8092_MODE_AUTO 0
#define RT8092_MODE_FPWM 1
#define RT8092_VOUT_BASEUV 303125
#define RT8092_VOUT_STEPUV 3125
#define RT8092_VOUT_MINSEL 15
#define RT8092_NUM_VOLTS 128
#define RT8092_INITSS_US 400
static int rt8092_get_vbank_index(struct regmap *regmap, bool vsel_high, unsigned int *vbank_idx)
{
unsigned int vbank_reg = vsel_high ? RT8092_REG_VBANKH : RT8092_REG_VBANKL;
unsigned int index;
int ret;
ret = regmap_read(regmap, vbank_reg, &index);
if (ret)
return ret;
*vbank_idx = FIELD_GET(RT8092_VBANK_MASK, index);
return 0;
}
static int rt8092_set_operating_mode(struct regulator_dev *rdev, unsigned int mode)
{
const struct regulator_desc *desc = rdev->desc;
struct regmap *regmap = rdev_get_regmap(rdev);
unsigned int mode_mask, mode_val;
mode_mask = desc->vsel_reg == RT8092_REG_VOUTH ? RT8092_FPWMH_MASK : RT8092_FPWML_MASK;
switch (mode) {
case REGULATOR_MODE_FAST:
mode_val = mode_mask;
break;
case REGULATOR_MODE_NORMAL:
mode_val = 0;
break;
default:
return -EINVAL;
}
return regmap_update_bits(regmap, RT8092_REG_PWMMODE, mode_mask, mode_val);
}
static unsigned int rt8092_get_operating_mode(struct regulator_dev *rdev)
{
const struct regulator_desc *desc = rdev->desc;
struct regmap *regmap = rdev_get_regmap(rdev);
unsigned int mode_mask, mode_val;
int ret;
mode_mask = desc->vsel_reg == RT8092_REG_VOUTH ? RT8092_FPWMH_MASK : RT8092_FPWML_MASK;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/property.h`, `linux/regmap.h`.
- Detected declarations: `function rt8092_get_vbank_index`, `function rt8092_set_operating_mode`, `function rt8092_get_operating_mode`, `function rt8092_get_error_flags`, `function rt8092_set_suspend_voltage`, `function rt8092_set_suspend_enable`, `function rt8092_set_suspend_disable`, `function rt8092_set_suspend_mode`, `function rt8092_of_map_mode`, `function rt8092_probe`.
- 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.