drivers/clk/mediatek/reset.c
Source file repositories/reference/linux-study-clean/drivers/clk/mediatek/reset.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/mediatek/reset.c- Extension
.c- Size
- 4290 bytes
- Lines
- 175
- Domain
- Driver Families
- Bucket
- drivers/clk
- 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.
- 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/mfd/syscon.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/slab.hreset.h
Detected Declarations
function Copyrightfunction mtk_reset_updatefunction mtk_reset_assertfunction mtk_reset_deassertfunction mtk_resetfunction mtk_reset_update_set_clrfunction mtk_reset_assert_set_clrfunction mtk_reset_deassert_set_clrfunction mtk_reset_set_clrfunction reset_xlatefunction mtk_register_reset_controller_with_devexport mtk_register_reset_controller_with_dev
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2014 MediaTek Inc.
*/
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include "reset.h"
static inline struct mtk_clk_rst_data *to_mtk_clk_rst_data(struct reset_controller_dev *rcdev)
{
return container_of(rcdev, struct mtk_clk_rst_data, rcdev);
}
static int mtk_reset_update(struct reset_controller_dev *rcdev,
unsigned long id, bool deassert)
{
struct mtk_clk_rst_data *data = to_mtk_clk_rst_data(rcdev);
unsigned int val = deassert ? 0 : ~0;
return regmap_update_bits(data->regmap,
data->desc->rst_bank_ofs[id / RST_NR_PER_BANK],
BIT(id % RST_NR_PER_BANK), val);
}
static int mtk_reset_assert(struct reset_controller_dev *rcdev,
unsigned long id)
{
return mtk_reset_update(rcdev, id, false);
}
static int mtk_reset_deassert(struct reset_controller_dev *rcdev,
unsigned long id)
{
return mtk_reset_update(rcdev, id, true);
}
static int mtk_reset(struct reset_controller_dev *rcdev, unsigned long id)
{
int ret;
ret = mtk_reset_assert(rcdev, id);
if (ret)
return ret;
return mtk_reset_deassert(rcdev, id);
}
static int mtk_reset_update_set_clr(struct reset_controller_dev *rcdev,
unsigned long id, bool deassert)
{
struct mtk_clk_rst_data *data = to_mtk_clk_rst_data(rcdev);
unsigned int deassert_ofs = deassert ? 0x4 : 0;
return regmap_write(data->regmap,
data->desc->rst_bank_ofs[id / RST_NR_PER_BANK] +
deassert_ofs,
BIT(id % RST_NR_PER_BANK));
}
static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev,
unsigned long id)
{
return mtk_reset_update_set_clr(rcdev, id, false);
}
static int mtk_reset_deassert_set_clr(struct reset_controller_dev *rcdev,
unsigned long id)
{
return mtk_reset_update_set_clr(rcdev, id, true);
}
static int mtk_reset_set_clr(struct reset_controller_dev *rcdev,
unsigned long id)
{
int ret;
ret = mtk_reset_assert_set_clr(rcdev, id);
if (ret)
return ret;
return mtk_reset_deassert_set_clr(rcdev, id);
}
static const struct reset_control_ops mtk_reset_ops = {
.assert = mtk_reset_assert,
Annotation
- Immediate include surface: `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/slab.h`, `reset.h`.
- Detected declarations: `function Copyright`, `function mtk_reset_update`, `function mtk_reset_assert`, `function mtk_reset_deassert`, `function mtk_reset`, `function mtk_reset_update_set_clr`, `function mtk_reset_assert_set_clr`, `function mtk_reset_deassert_set_clr`, `function mtk_reset_set_clr`, `function reset_xlate`.
- Atlas domain: Driver Families / drivers/clk.
- 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.