drivers/reset/reset-sunplus.c
Source file repositories/reference/linux-study-clean/drivers/reset/reset-sunplus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/reset/reset-sunplus.c- Extension
.c- Size
- 3655 bytes
- Lines
- 208
- 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/io.hlinux/init.hlinux/mod_devicetable.hlinux/platform_device.hlinux/reset-controller.hlinux/reboot.h
Detected Declarations
struct sp_resetfunction sp_reset_updatefunction sp_reset_assertfunction sp_reset_deassertfunction sp_reset_statusfunction sp_restartfunction sp_reset_probe
Annotated Snippet
struct sp_reset {
struct reset_controller_dev rcdev;
void __iomem *base;
};
static inline struct sp_reset *to_sp_reset(struct reset_controller_dev *rcdev)
{
return container_of(rcdev, struct sp_reset, rcdev);
}
static int sp_reset_update(struct reset_controller_dev *rcdev,
unsigned long id, bool assert)
{
struct sp_reset *reset = to_sp_reset(rcdev);
int index = sp_resets[id] / BITS_PER_HWM_REG;
int shift = sp_resets[id] % BITS_PER_HWM_REG;
u32 val;
val = (1 << (16 + shift)) | (assert << shift);
writel(val, reset->base + (index * 4));
return 0;
}
static int sp_reset_assert(struct reset_controller_dev *rcdev,
unsigned long id)
{
return sp_reset_update(rcdev, id, true);
}
static int sp_reset_deassert(struct reset_controller_dev *rcdev,
unsigned long id)
{
return sp_reset_update(rcdev, id, false);
}
static int sp_reset_status(struct reset_controller_dev *rcdev,
unsigned long id)
{
struct sp_reset *reset = to_sp_reset(rcdev);
int index = sp_resets[id] / BITS_PER_HWM_REG;
int shift = sp_resets[id] % BITS_PER_HWM_REG;
u32 reg;
reg = readl(reset->base + (index * 4));
return !!(reg & BIT(shift));
}
static const struct reset_control_ops sp_reset_ops = {
.assert = sp_reset_assert,
.deassert = sp_reset_deassert,
.status = sp_reset_status,
};
static int sp_restart(struct sys_off_data *data)
{
struct sp_reset *reset = data->cb_data;
sp_reset_assert(&reset->rcdev, 0);
sp_reset_deassert(&reset->rcdev, 0);
return NOTIFY_DONE;
}
static int sp_reset_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct sp_reset *reset;
struct resource *res;
int ret;
reset = devm_kzalloc(dev, sizeof(*reset), GFP_KERNEL);
if (!reset)
return -ENOMEM;
reset->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(reset->base))
return PTR_ERR(reset->base);
reset->rcdev.ops = &sp_reset_ops;
reset->rcdev.owner = THIS_MODULE;
reset->rcdev.of_node = dev->of_node;
reset->rcdev.nr_resets = resource_size(res) / 4 * BITS_PER_HWM_REG;
ret = devm_reset_controller_register(dev, &reset->rcdev);
if (ret)
return ret;
return devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
Annotation
- Immediate include surface: `linux/io.h`, `linux/init.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/reset-controller.h`, `linux/reboot.h`.
- Detected declarations: `struct sp_reset`, `function sp_reset_update`, `function sp_reset_assert`, `function sp_reset_deassert`, `function sp_reset_status`, `function sp_restart`, `function sp_reset_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.