1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2021, Qing Zhang <zhangqing@loongson.cn>
4 * Loongson-2K1000 reset support
7 #include <linux/of_address.h>
9 #include <asm/reboot.h>
11 #define PM1_STS 0x0c /* Power Management 1 Status Register */
12 #define PM1_CNT 0x14 /* Power Management 1 Control Register */
13 #define RST_CNT 0x30 /* Reset Control Register */
15 static void __iomem
*base
;
17 static void ls2k_restart(char *command
)
19 writel(0x1, base
+ RST_CNT
);
22 static void ls2k_poweroff(void)
25 writel((readl(base
+ PM1_STS
) & 0xffffffff), base
+ PM1_STS
);
26 /* Sleep Enable | Soft Off*/
27 writel(GENMASK(12, 10) | BIT(13), base
+ PM1_CNT
);
30 static int ls2k_reset_init(void)
32 struct device_node
*np
;
34 np
= of_find_compatible_node(NULL
, NULL
, "loongson,ls2k-pm");
36 pr_info("Failed to get PM node\n");
40 base
= of_iomap(np
, 0);
43 pr_info("Failed to map PM register base address\n");
47 _machine_restart
= ls2k_restart
;
48 pm_power_off
= ls2k_poweroff
;
53 arch_initcall(ls2k_reset_init
);