drivers/mfd/hi6421-pmic-core.c
Source file repositories/reference/linux-study-clean/drivers/mfd/hi6421-pmic-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/hi6421-pmic-core.c- Extension
.c- Size
- 3056 bytes
- Lines
- 124
- Domain
- Driver Families
- Bucket
- drivers/mfd
- 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/device.hlinux/err.hlinux/mfd/core.hlinux/mfd/hi6421-pmic.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/property.hlinux/regmap.h
Detected Declarations
function hi6421_pmic_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Device driver for Hi6421 PMIC
*
* Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd.
* http://www.hisilicon.com
* Copyright (c) <2013-2017> Linaro Ltd.
* https://www.linaro.org
*
* Author: Guodong Xu <guodong.xu@linaro.org>
*/
#include <linux/device.h>
#include <linux/err.h>
#include <linux/mfd/core.h>
#include <linux/mfd/hi6421-pmic.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/regmap.h>
static const struct mfd_cell hi6421_devs[] = {
{ .name = "hi6421-regulator", },
};
static const struct mfd_cell hi6421v530_devs[] = {
{ .name = "hi6421v530-regulator", },
};
static const struct regmap_config hi6421_regmap_config = {
.reg_bits = 32,
.reg_stride = 4,
.val_bits = 8,
.max_register = HI6421_REG_TO_BUS_ADDR(HI6421_REG_MAX),
};
static const struct of_device_id of_hi6421_pmic_match[] = {
{
.compatible = "hisilicon,hi6421-pmic",
.data = (void *)HI6421
},
{
.compatible = "hisilicon,hi6421v530-pmic",
.data = (void *)HI6421_V530
},
{ },
};
MODULE_DEVICE_TABLE(of, of_hi6421_pmic_match);
static int hi6421_pmic_probe(struct platform_device *pdev)
{
struct hi6421_pmic *pmic;
const struct mfd_cell *subdevs;
enum hi6421_type type;
void __iomem *base;
int n_subdevs, ret;
type = (uintptr_t)device_get_match_data(&pdev->dev);
pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
if (!pmic)
return -ENOMEM;
base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(base))
return PTR_ERR(base);
pmic->regmap = devm_regmap_init_mmio_clk(&pdev->dev, NULL, base,
&hi6421_regmap_config);
if (IS_ERR(pmic->regmap)) {
dev_err(&pdev->dev, "Failed to initialise Regmap: %ld\n",
PTR_ERR(pmic->regmap));
return PTR_ERR(pmic->regmap);
}
platform_set_drvdata(pdev, pmic);
switch (type) {
case HI6421:
/* set over-current protection debounce 8ms */
regmap_update_bits(pmic->regmap, HI6421_OCP_DEB_CTRL_REG,
(HI6421_OCP_DEB_SEL_MASK
| HI6421_OCP_EN_DEBOUNCE_MASK
| HI6421_OCP_AUTO_STOP_MASK),
(HI6421_OCP_DEB_SEL_8MS
| HI6421_OCP_EN_DEBOUNCE_ENABLE));
subdevs = hi6421_devs;
n_subdevs = ARRAY_SIZE(hi6421_devs);
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/mfd/core.h`, `linux/mfd/hi6421-pmic.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/property.h`.
- Detected declarations: `function hi6421_pmic_probe`.
- Atlas domain: Driver Families / drivers/mfd.
- 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.