1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * loongson-specific suspend support
5 * Copyright (C) 2009 Lemote Inc.
6 * Author: Wu Zhangjin <wuzhangjin@gmail.com>
8 #include <linux/suspend.h>
9 #include <linux/interrupt.h>
12 #include <asm/i8259.h>
13 #include <asm/mipsregs.h>
17 static unsigned int __maybe_unused cached_master_mask; /* i8259A */
18 static unsigned int __maybe_unused cached_slave_mask;
19 static unsigned int __maybe_unused cached_bonito_irq_mask; /* bonito */
21 void arch_suspend_disable_irqs(void)
23 /* disable all mips events */
27 /* disable all events of i8259A */
28 cached_slave_mask = inb(PIC_SLAVE_IMR);
29 cached_master_mask = inb(PIC_MASTER_IMR);
31 outb(0xff, PIC_SLAVE_IMR);
33 outb(0xff, PIC_MASTER_IMR);
36 /* disable all events of bonito */
37 cached_bonito_irq_mask = LOONGSON_INTEN;
38 LOONGSON_INTENCLR = 0xffff;
39 (void)LOONGSON_INTENCLR;
42 void arch_suspend_enable_irqs(void)
44 /* enable all mips events */
47 /* only enable the cached events of i8259A */
48 outb(cached_slave_mask, PIC_SLAVE_IMR);
49 outb(cached_master_mask, PIC_MASTER_IMR);
51 /* enable all cached events of bonito */
52 LOONGSON_INTENSET = cached_bonito_irq_mask;
53 (void)LOONGSON_INTENSET;
57 * Setup the board-specific events for waking up loongson from wait mode
59 void __weak setup_wakeup_events(void)
63 void __weak mach_suspend(void)
67 void __weak mach_resume(void)
71 static int loongson_pm_enter(suspend_state_t state)
80 static int loongson_pm_valid_state(suspend_state_t state)
84 case PM_SUSPEND_STANDBY:
93 static const struct platform_suspend_ops loongson_pm_ops = {
94 .valid = loongson_pm_valid_state,
95 .enter = loongson_pm_enter,
98 static int __init loongson_pm_init(void)
100 suspend_set_ops(&loongson_pm_ops);
104 arch_initcall(loongson_pm_init);