2019-05-27 08:55:01 +02:00
// SPDX-License-Identifier: GPL-2.0-or-later
MIPS: Loongson 2F: Add suspend support framework
This patch add basic suspend support for loongson2f family machines,
loongson2f have a specific feature: when we set it's frequency to ZERO,
it will go into a wait mode, and then can be waked up by the external
interrupt. so, if we setup suitable interrupts before putting it into
wait mode, we will be able wake it up whenever we want via sending the
relative interrupts to it.
These interrupts are board-specific, Yeeloong2F use the keyboard
interrupt and SCI interrupt, but LingLoong and Fuloong2F use the
interrupts connected to the processors directly. and BTW: some old
LingLoong and FuLoong2F have no such interrupts connected, so, there is
no way to wake them up from suspend mode. and therefore, please do not
enable the kernel support for them.
The board-specific support will be added in the coming patches.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: yanh@lemote.com
Cc: huhb@lemote.com
Cc: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: linux-pm@lists.linux-foundation.org
Patchwork: http://patchwork.linux-mips.org/patch/629/
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2009-11-11 14:57:05 +08:00
/*
* loongson - specific suspend support
*
* Copyright ( C ) 2009 Lemote Inc .
2010-01-04 17:16:51 +08:00
* Author : Wu Zhangjin < wuzhangjin @ gmail . com >
MIPS: Loongson 2F: Add suspend support framework
This patch add basic suspend support for loongson2f family machines,
loongson2f have a specific feature: when we set it's frequency to ZERO,
it will go into a wait mode, and then can be waked up by the external
interrupt. so, if we setup suitable interrupts before putting it into
wait mode, we will be able wake it up whenever we want via sending the
relative interrupts to it.
These interrupts are board-specific, Yeeloong2F use the keyboard
interrupt and SCI interrupt, but LingLoong and Fuloong2F use the
interrupts connected to the processors directly. and BTW: some old
LingLoong and FuLoong2F have no such interrupts connected, so, there is
no way to wake them up from suspend mode. and therefore, please do not
enable the kernel support for them.
The board-specific support will be added in the coming patches.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: yanh@lemote.com
Cc: huhb@lemote.com
Cc: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: linux-pm@lists.linux-foundation.org
Patchwork: http://patchwork.linux-mips.org/patch/629/
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2009-11-11 14:57:05 +08:00
*/
# include <linux/suspend.h>
# include <linux/interrupt.h>
# include <linux/pm.h>
# include <asm/i8259.h>
# include <asm/mipsregs.h>
# include <loongson.h>
static unsigned int __maybe_unused cached_master_mask ; /* i8259A */
static unsigned int __maybe_unused cached_slave_mask ;
static unsigned int __maybe_unused cached_bonito_irq_mask ; /* bonito */
void arch_suspend_disable_irqs ( void )
{
/* disable all mips events */
local_irq_disable ( ) ;
# ifdef CONFIG_I8259
/* disable all events of i8259A */
cached_slave_mask = inb ( PIC_SLAVE_IMR ) ;
cached_master_mask = inb ( PIC_MASTER_IMR ) ;
outb ( 0xff , PIC_SLAVE_IMR ) ;
inb ( PIC_SLAVE_IMR ) ;
outb ( 0xff , PIC_MASTER_IMR ) ;
inb ( PIC_MASTER_IMR ) ;
# endif
/* disable all events of bonito */
cached_bonito_irq_mask = LOONGSON_INTEN ;
LOONGSON_INTENCLR = 0xffff ;
( void ) LOONGSON_INTENCLR ;
}
void arch_suspend_enable_irqs ( void )
{
/* enable all mips events */
local_irq_enable ( ) ;
# ifdef CONFIG_I8259
/* only enable the cached events of i8259A */
outb ( cached_slave_mask , PIC_SLAVE_IMR ) ;
outb ( cached_master_mask , PIC_MASTER_IMR ) ;
# endif
/* enable all cached events of bonito */
LOONGSON_INTENSET = cached_bonito_irq_mask ;
( void ) LOONGSON_INTENSET ;
}
/*
* Setup the board - specific events for waking up loongson from wait mode
*/
void __weak setup_wakeup_events ( void )
{
}
void __weak mach_suspend ( void )
{
}
void __weak mach_resume ( void )
{
}
static int loongson_pm_enter ( suspend_state_t state )
{
mach_suspend ( ) ;
mach_resume ( ) ;
return 0 ;
}
static int loongson_pm_valid_state ( suspend_state_t state )
{
switch ( state ) {
case PM_SUSPEND_ON :
case PM_SUSPEND_STANDBY :
case PM_SUSPEND_MEM :
return 1 ;
default :
return 0 ;
}
}
2010-11-16 14:14:02 +01:00
static const struct platform_suspend_ops loongson_pm_ops = {
MIPS: Loongson 2F: Add suspend support framework
This patch add basic suspend support for loongson2f family machines,
loongson2f have a specific feature: when we set it's frequency to ZERO,
it will go into a wait mode, and then can be waked up by the external
interrupt. so, if we setup suitable interrupts before putting it into
wait mode, we will be able wake it up whenever we want via sending the
relative interrupts to it.
These interrupts are board-specific, Yeeloong2F use the keyboard
interrupt and SCI interrupt, but LingLoong and Fuloong2F use the
interrupts connected to the processors directly. and BTW: some old
LingLoong and FuLoong2F have no such interrupts connected, so, there is
no way to wake them up from suspend mode. and therefore, please do not
enable the kernel support for them.
The board-specific support will be added in the coming patches.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: yanh@lemote.com
Cc: huhb@lemote.com
Cc: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: linux-pm@lists.linux-foundation.org
Patchwork: http://patchwork.linux-mips.org/patch/629/
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2009-11-11 14:57:05 +08:00
. valid = loongson_pm_valid_state ,
. enter = loongson_pm_enter ,
} ;
static int __init loongson_pm_init ( void )
{
suspend_set_ops ( & loongson_pm_ops ) ;
return 0 ;
}
arch_initcall ( loongson_pm_init ) ;