drivers/regulator/mc13xxx-regulator-core.c
Source file repositories/reference/linux-study-clean/drivers/regulator/mc13xxx-regulator-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/mc13xxx-regulator-core.c- Extension
.c- Size
- 6201 bytes
- Lines
- 221
- Domain
- Driver Families
- Bucket
- drivers/regulator
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mfd/mc13xxx.hlinux/regulator/machine.hlinux/regulator/driver.hlinux/regulator/of_regulator.hlinux/platform_device.hlinux/kernel.hlinux/slab.hlinux/init.hlinux/err.hlinux/module.hlinux/of.hmc13xxx.h
Detected Declarations
function mc13xxx_regulator_enablefunction mc13xxx_regulator_disablefunction mc13xxx_regulator_is_enabledfunction mc13xxx_regulator_set_voltage_selfunction mc13xxx_regulator_get_voltagefunction mc13xxx_fixed_regulator_set_voltagefunction mc13xxx_get_num_regulators_dtfunction for_each_child_of_nodeexport mc13xxx_regulator_opsexport mc13xxx_fixed_regulator_set_voltageexport mc13xxx_fixed_regulator_opsexport mc13xxx_get_num_regulators_dtexport mc13xxx_parse_regulators_dt
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
//
// Regulator Driver for Freescale MC13xxx PMIC
//
// Copyright 2010 Yong Shen <yong.shen@linaro.org>
//
// Based on mc13783 regulator driver :
// Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
// Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
//
// Regs infos taken from mc13xxx drivers from freescale and mc13xxx.pdf file
// from freescale
#include <linux/mfd/mc13xxx.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/of.h>
#include "mc13xxx.h"
static int mc13xxx_regulator_enable(struct regulator_dev *rdev)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int id = rdev_get_id(rdev);
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
return mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].reg,
mc13xxx_regulators[id].enable_bit,
mc13xxx_regulators[id].enable_bit);
}
static int mc13xxx_regulator_disable(struct regulator_dev *rdev)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int id = rdev_get_id(rdev);
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
return mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].reg,
mc13xxx_regulators[id].enable_bit, 0);
}
static int mc13xxx_regulator_is_enabled(struct regulator_dev *rdev)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int ret, id = rdev_get_id(rdev);
unsigned int val;
ret = mc13xxx_reg_read(priv->mc13xxx, mc13xxx_regulators[id].reg, &val);
if (ret)
return ret;
return (val & mc13xxx_regulators[id].enable_bit) != 0;
}
static int mc13xxx_regulator_set_voltage_sel(struct regulator_dev *rdev,
unsigned selector)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int id = rdev_get_id(rdev);
return mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].vsel_reg,
mc13xxx_regulators[id].vsel_mask,
selector << mc13xxx_regulators[id].vsel_shift);
}
static int mc13xxx_regulator_get_voltage(struct regulator_dev *rdev)
{
struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev);
struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators;
int ret, id = rdev_get_id(rdev);
unsigned int val;
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
ret = mc13xxx_reg_read(priv->mc13xxx,
mc13xxx_regulators[id].vsel_reg, &val);
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/mfd/mc13xxx.h`, `linux/regulator/machine.h`, `linux/regulator/driver.h`, `linux/regulator/of_regulator.h`, `linux/platform_device.h`, `linux/kernel.h`, `linux/slab.h`, `linux/init.h`.
- Detected declarations: `function mc13xxx_regulator_enable`, `function mc13xxx_regulator_disable`, `function mc13xxx_regulator_is_enabled`, `function mc13xxx_regulator_set_voltage_sel`, `function mc13xxx_regulator_get_voltage`, `function mc13xxx_fixed_regulator_set_voltage`, `function mc13xxx_get_num_regulators_dt`, `function for_each_child_of_node`, `export mc13xxx_regulator_ops`, `export mc13xxx_fixed_regulator_set_voltage`.
- Atlas domain: Driver Families / drivers/regulator.
- Implementation status: integration 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.