drivers/platform/mips/ls2k-reset.c
Source file repositories/reference/linux-study-clean/drivers/platform/mips/ls2k-reset.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/mips/ls2k-reset.c- Extension
.c- Size
- 1133 bytes
- Lines
- 54
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/of_address.hlinux/pm.hasm/reboot.h
Detected Declarations
function ls2k_restartfunction ls2k_powerofffunction ls2k_reset_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2021, Qing Zhang <zhangqing@loongson.cn>
* Loongson-2K1000 reset support
*/
#include <linux/of_address.h>
#include <linux/pm.h>
#include <asm/reboot.h>
#define PM1_STS 0x0c /* Power Management 1 Status Register */
#define PM1_CNT 0x14 /* Power Management 1 Control Register */
#define RST_CNT 0x30 /* Reset Control Register */
static void __iomem *base;
static void ls2k_restart(char *command)
{
writel(0x1, base + RST_CNT);
}
static void ls2k_poweroff(void)
{
/* Clear */
writel((readl(base + PM1_STS) & 0xffffffff), base + PM1_STS);
/* Sleep Enable | Soft Off*/
writel(GENMASK(12, 10) | BIT(13), base + PM1_CNT);
}
static int ls2k_reset_init(void)
{
struct device_node *np;
np = of_find_compatible_node(NULL, NULL, "loongson,ls2k-pm");
if (!np) {
pr_info("Failed to get PM node\n");
return -ENODEV;
}
base = of_iomap(np, 0);
of_node_put(np);
if (!base) {
pr_info("Failed to map PM register base address\n");
return -ENOMEM;
}
_machine_restart = ls2k_restart;
pm_power_off = ls2k_poweroff;
return 0;
}
arch_initcall(ls2k_reset_init);
Annotation
- Immediate include surface: `linux/of_address.h`, `linux/pm.h`, `asm/reboot.h`.
- Detected declarations: `function ls2k_restart`, `function ls2k_poweroff`, `function ls2k_reset_init`.
- Atlas domain: Driver Families / drivers/platform.
- 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.