drivers/regulator/qcom-refgen-regulator.c
Source file repositories/reference/linux-study-clean/drivers/regulator/qcom-refgen-regulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/qcom-refgen-regulator.c- Extension
.c- Size
- 4248 bytes
- Lines
- 155
- 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/bitfield.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/of_regulator.h
Detected Declarations
function qcom_sdm845_refgen_enablefunction qcom_sdm845_refgen_disablefunction qcom_sdm845_refgen_is_enabledfunction qcom_refgen_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2017, 2019-2020, The Linux Foundation. All rights reserved.
// Copyright (c) 2023, Linaro Limited
#include <linux/bitfield.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#define REFGEN_REG_BIAS_EN 0x08
#define REFGEN_BIAS_EN_MASK GENMASK(2, 0)
#define REFGEN_BIAS_EN_ENABLE 0x7
#define REFGEN_BIAS_EN_DISABLE 0x6
#define REFGEN_REG_BG_CTRL 0x14
#define REFGEN_BG_CTRL_MASK GENMASK(2, 1)
#define REFGEN_BG_CTRL_ENABLE 0x3
#define REFGEN_BG_CTRL_DISABLE 0x2
#define REFGEN_REG_PWRDWN_CTRL5 0x80
#define REFGEN_PWRDWN_CTRL5_MASK BIT(0)
#define REFGEN_PWRDWN_CTRL5_ENABLE 0x1
static int qcom_sdm845_refgen_enable(struct regulator_dev *rdev)
{
regmap_update_bits(rdev->regmap, REFGEN_REG_BG_CTRL, REFGEN_BG_CTRL_MASK,
FIELD_PREP(REFGEN_BG_CTRL_MASK, REFGEN_BG_CTRL_ENABLE));
regmap_write(rdev->regmap, REFGEN_REG_BIAS_EN,
FIELD_PREP(REFGEN_BIAS_EN_MASK, REFGEN_BIAS_EN_ENABLE));
return 0;
}
static int qcom_sdm845_refgen_disable(struct regulator_dev *rdev)
{
regmap_write(rdev->regmap, REFGEN_REG_BIAS_EN,
FIELD_PREP(REFGEN_BIAS_EN_MASK, REFGEN_BIAS_EN_DISABLE));
regmap_update_bits(rdev->regmap, REFGEN_REG_BG_CTRL, REFGEN_BG_CTRL_MASK,
FIELD_PREP(REFGEN_BG_CTRL_MASK, REFGEN_BG_CTRL_DISABLE));
return 0;
}
static int qcom_sdm845_refgen_is_enabled(struct regulator_dev *rdev)
{
u32 val;
regmap_read(rdev->regmap, REFGEN_REG_BG_CTRL, &val);
if (FIELD_GET(REFGEN_BG_CTRL_MASK, val) != REFGEN_BG_CTRL_ENABLE)
return 0;
regmap_read(rdev->regmap, REFGEN_REG_BIAS_EN, &val);
if (FIELD_GET(REFGEN_BIAS_EN_MASK, val) != REFGEN_BIAS_EN_ENABLE)
return 0;
return 1;
}
static const struct regulator_desc sdm845_refgen_desc = {
.enable_time = 5,
.name = "refgen",
.owner = THIS_MODULE,
.type = REGULATOR_VOLTAGE,
.ops = &(const struct regulator_ops) {
.enable = qcom_sdm845_refgen_enable,
.disable = qcom_sdm845_refgen_disable,
.is_enabled = qcom_sdm845_refgen_is_enabled,
},
};
static const struct regulator_desc sm8250_refgen_desc = {
.enable_reg = REFGEN_REG_PWRDWN_CTRL5,
.enable_mask = REFGEN_PWRDWN_CTRL5_MASK,
.enable_val = REFGEN_PWRDWN_CTRL5_ENABLE,
.disable_val = 0,
.enable_time = 5,
.name = "refgen",
.owner = THIS_MODULE,
.type = REGULATOR_VOLTAGE,
.ops = &(const struct regulator_ops) {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
},
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/regulator/driver.h`, `linux/regulator/machine.h`, `linux/regulator/of_regulator.h`.
- Detected declarations: `function qcom_sdm845_refgen_enable`, `function qcom_sdm845_refgen_disable`, `function qcom_sdm845_refgen_is_enabled`, `function qcom_refgen_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.