Merge tag 'x86-urgent-2025-01-28' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / arch / mips / loongson64 / pm.c
blob5f0604af8f13647b25d871eefaff64440f49f6d4
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * loongson-specific suspend support
5 * Copyright (C) 2009 Lemote Inc.
6 * Author: Wu Zhangjin <wuzhangjin@gmail.com>
7 */
8 #include <linux/suspend.h>
9 #include <linux/pm.h>
11 #include <asm/mipsregs.h>
13 #include <loongson.h>
15 asmlinkage void loongson_lefi_sleep(unsigned long sleep_addr);
17 static int lefi_pm_enter(suspend_state_t state)
19 switch (state) {
20 case PM_SUSPEND_MEM:
21 pm_set_suspend_via_firmware();
22 loongson_lefi_sleep(loongson_sysconf.suspend_addr);
23 pm_set_resume_via_firmware();
24 return 0;
25 default:
26 return -EINVAL;
30 static int lefi_pm_valid_state(suspend_state_t state)
32 switch (state) {
33 case PM_SUSPEND_MEM:
34 return !!loongson_sysconf.suspend_addr;
35 default:
36 return 0;
40 static const struct platform_suspend_ops lefi_pm_ops = {
41 .valid = lefi_pm_valid_state,
42 .enter = lefi_pm_enter,
45 static int __init loongson_pm_init(void)
47 if (loongson_sysconf.fw_interface == LOONGSON_LEFI)
48 suspend_set_ops(&lefi_pm_ops);
50 return 0;
52 arch_initcall(loongson_pm_init);