drivers/mfd/rt5033.c
Source file repositories/reference/linux-study-clean/drivers/mfd/rt5033.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/rt5033.c- Extension
.c- Size
- 3496 bytes
- Lines
- 135
- 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/err.hlinux/mod_devicetable.hlinux/module.hlinux/interrupt.hlinux/mfd/core.hlinux/mfd/rt5033.hlinux/mfd/rt5033-private.h
Detected Declarations
function rt5033_i2c_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* MFD core driver for the Richtek RT5033.
*
* RT5033 comprises multiple sub-devices switcing charger, fuel gauge,
* flash LED, current source, LDO and BUCK regulators.
*
* Copyright (C) 2014 Samsung Electronics, Co., Ltd.
* Author: Beomho Seo <beomho.seo@samsung.com>
*/
#include <linux/err.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/mfd/core.h>
#include <linux/mfd/rt5033.h>
#include <linux/mfd/rt5033-private.h>
static const struct regmap_irq rt5033_irqs[] = {
{ .mask = RT5033_PMIC_IRQ_BUCKOCP, },
{ .mask = RT5033_PMIC_IRQ_BUCKLV, },
{ .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
{ .mask = RT5033_PMIC_IRQ_LDOLV, },
{ .mask = RT5033_PMIC_IRQ_OT, },
{ .mask = RT5033_PMIC_IRQ_VDDA_UV, },
};
static const struct regmap_irq_chip rt5033_irq_chip = {
.name = "rt5033",
.status_base = RT5033_REG_PMIC_IRQ_STAT,
.unmask_base = RT5033_REG_PMIC_IRQ_CTRL,
.num_regs = 1,
.irqs = rt5033_irqs,
.num_irqs = ARRAY_SIZE(rt5033_irqs),
};
static const struct mfd_cell rt5033_devs[] = {
{ .name = "rt5033-regulator", },
{
.name = "rt5033-charger",
.of_compatible = "richtek,rt5033-charger",
}, {
.name = "rt5033-led",
.of_compatible = "richtek,rt5033-led",
},
};
static const struct regmap_config rt5033_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = RT5033_REG_END,
};
static int rt5033_i2c_probe(struct i2c_client *i2c)
{
struct rt5033_dev *rt5033;
unsigned int dev_id, chip_rev;
int ret;
rt5033 = devm_kzalloc(&i2c->dev, sizeof(*rt5033), GFP_KERNEL);
if (!rt5033)
return -ENOMEM;
i2c_set_clientdata(i2c, rt5033);
rt5033->dev = &i2c->dev;
rt5033->irq = i2c->irq;
rt5033->wakeup = true;
rt5033->regmap = devm_regmap_init_i2c(i2c, &rt5033_regmap_config);
if (IS_ERR(rt5033->regmap)) {
dev_err(&i2c->dev, "Failed to allocate register map.\n");
return PTR_ERR(rt5033->regmap);
}
ret = regmap_read(rt5033->regmap, RT5033_REG_DEVICE_ID, &dev_id);
if (ret) {
dev_err(&i2c->dev, "Device not found\n");
return -ENODEV;
}
chip_rev = dev_id & RT5033_CHIP_REV_MASK;
dev_info(&i2c->dev, "Device found (rev. %d)\n", chip_rev);
ret = devm_regmap_add_irq_chip(rt5033->dev, rt5033->regmap,
rt5033->irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
0, &rt5033_irq_chip, &rt5033->irq_data);
if (ret) {
dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
rt5033->irq, ret);
return ret;
Annotation
- Immediate include surface: `linux/err.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/interrupt.h`, `linux/mfd/core.h`, `linux/mfd/rt5033.h`, `linux/mfd/rt5033-private.h`.
- Detected declarations: `function rt5033_i2c_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.