-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MIPS: Loongson64: Add Loongson-2K1000 reset platform driver
Add power management register operations to support reboot and poweroff. Signed-off-by: Qing Zhang <zhangqing@loongson.cn> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
- Loading branch information
Qing Zhang
authored and
Thomas Bogendoerfer
committed
Jan 2, 2022
1 parent
fc5bb23
commit 7eb7819
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o | ||
obj-$(CONFIG_RS780E_ACPI) += rs780e-acpi.o | ||
obj-$(CONFIG_LS2K_RESET) += ls2k-reset.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// 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); | ||
if (!base) { | ||
pr_info("Failed to map PM register base address\n"); | ||
return -ENOMEM; | ||
} | ||
|
||
_machine_restart = ls2k_restart; | ||
pm_power_off = ls2k_poweroff; | ||
|
||
of_node_put(np); | ||
return 0; | ||
} | ||
|
||
arch_initcall(ls2k_reset_init); |