drivers/reset/reset-k210.c
Source file repositories/reference/linux-study-clean/drivers/reset/reset-k210.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/reset/reset-k210.c- Extension
.c- Size
- 3017 bytes
- Lines
- 132
- Domain
- Driver Families
- Bucket
- drivers/reset
- 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/of.hlinux/platform_device.hlinux/reset-controller.hlinux/delay.hlinux/mfd/syscon.hlinux/regmap.hsoc/canaan/k210-sysctl.hdt-bindings/reset/k210-rst.h
Detected Declarations
struct k210_rstfunction to_k210_rstfunction k210_rst_assertfunction k210_rst_deassertfunction k210_rst_resetfunction k210_rst_statusfunction k210_rst_xlatefunction k210_rst_probe
Annotated Snippet
struct k210_rst {
struct regmap *map;
struct reset_controller_dev rcdev;
};
static inline struct k210_rst *
to_k210_rst(struct reset_controller_dev *rcdev)
{
return container_of(rcdev, struct k210_rst, rcdev);
}
static inline int k210_rst_assert(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct k210_rst *ksr = to_k210_rst(rcdev);
return regmap_update_bits(ksr->map, K210_SYSCTL_PERI_RESET, BIT(id), 1);
}
static inline int k210_rst_deassert(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct k210_rst *ksr = to_k210_rst(rcdev);
return regmap_update_bits(ksr->map, K210_SYSCTL_PERI_RESET, BIT(id), 0);
}
static int k210_rst_reset(struct reset_controller_dev *rcdev,
unsigned long id)
{
int ret;
ret = k210_rst_assert(rcdev, id);
if (ret == 0) {
udelay(10);
ret = k210_rst_deassert(rcdev, id);
}
return ret;
}
static int k210_rst_status(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct k210_rst *ksr = to_k210_rst(rcdev);
u32 reg, bit = BIT(id);
int ret;
ret = regmap_read(ksr->map, K210_SYSCTL_PERI_RESET, ®);
if (ret)
return ret;
return reg & bit;
}
static int k210_rst_xlate(struct reset_controller_dev *rcdev,
const struct of_phandle_args *reset_spec)
{
unsigned long id = reset_spec->args[0];
if (!(BIT(id) & K210_RST_MASK))
return -EINVAL;
return id;
}
static const struct reset_control_ops k210_rst_ops = {
.assert = k210_rst_assert,
.deassert = k210_rst_deassert,
.reset = k210_rst_reset,
.status = k210_rst_status,
};
static int k210_rst_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *parent_np;
struct k210_rst *ksr;
dev_info(dev, "K210 reset controller\n");
ksr = devm_kzalloc(dev, sizeof(*ksr), GFP_KERNEL);
if (!ksr)
return -ENOMEM;
parent_np = of_get_parent(dev->of_node);
ksr->map = syscon_node_to_regmap(parent_np);
of_node_put(parent_np);
if (IS_ERR(ksr->map))
return PTR_ERR(ksr->map);
Annotation
- Immediate include surface: `linux/of.h`, `linux/platform_device.h`, `linux/reset-controller.h`, `linux/delay.h`, `linux/mfd/syscon.h`, `linux/regmap.h`, `soc/canaan/k210-sysctl.h`, `dt-bindings/reset/k210-rst.h`.
- Detected declarations: `struct k210_rst`, `function to_k210_rst`, `function k210_rst_assert`, `function k210_rst_deassert`, `function k210_rst_reset`, `function k210_rst_status`, `function k210_rst_xlate`, `function k210_rst_probe`.
- Atlas domain: Driver Families / drivers/reset.
- 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.