File tree Expand file tree Collapse file tree 13 files changed +260
-3
lines changed Expand file tree Collapse file tree 13 files changed +260
-3
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ config LOONGARCH
56
56
select ARCH_WANTS_NO_INSTR
57
57
select BUILDTIME_TABLE_SORT
58
58
select COMMON_CLK
59
+ select CPU_PM
59
60
select EFI
60
61
select GENERIC_CLOCKEVENTS
61
62
select GENERIC_CMOS_UPDATE
@@ -517,6 +518,10 @@ config ARCH_MMAP_RND_BITS_MAX
517
518
518
519
menu "Power management options"
519
520
521
+ config ARCH_SUSPEND_POSSIBLE
522
+ def_bool y
523
+
524
+ source "kernel/power/Kconfig"
520
525
source "drivers/acpi/Kconfig"
521
526
522
527
endmenu
Original file line number Diff line number Diff line change @@ -104,6 +104,9 @@ endif
104
104
libs-y += arch/loongarch/lib/
105
105
libs-$(CONFIG_EFI_STUB) += $(objtree ) /drivers/firmware/efi/libstub/lib.a
106
106
107
+ # suspend and hibernation support
108
+ drivers-$(CONFIG_PM) += arch/loongarch/power/
109
+
107
110
ifeq ($(KBUILD_EXTMOD ) ,)
108
111
prepare : vdso_prepare
109
112
vdso_prepare : prepare0
Original file line number Diff line number Diff line change @@ -35,4 +35,14 @@ extern struct list_head acpi_wakeup_device_list;
35
35
36
36
#define ACPI_TABLE_UPGRADE_MAX_PHYS ARCH_LOW_ADDRESS_LIMIT
37
37
38
+ extern int loongarch_acpi_suspend (void );
39
+ extern int (* acpi_suspend_lowlevel )(void );
40
+ extern void loongarch_suspend_enter (void );
41
+
42
+ static inline unsigned long acpi_get_wakeup_address (void )
43
+ {
44
+ extern void loongarch_wakeup_start (void );
45
+ return (unsigned long )loongarch_wakeup_start ;
46
+ }
47
+
38
48
#endif /* _ASM_LOONGARCH_ACPI_H */
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ struct loongson_system_configuration {
32
32
int cores_per_node ;
33
33
int cores_per_package ;
34
34
unsigned long cores_io_master ;
35
+ unsigned long suspend_addr ;
35
36
const char * cpuname ;
36
37
};
37
38
Original file line number Diff line number Diff line change @@ -136,4 +136,7 @@ typedef enum {
136
136
#define ls7a_writel (val , addr ) *(volatile unsigned int *)TO_UNCACHE(addr) = (val)
137
137
#define ls7a_writeq (val , addr ) *(volatile unsigned long *)TO_UNCACHE(addr) = (val)
138
138
139
+ void enable_gpe_wakeup (void );
140
+ void enable_pci_wakeup (void );
141
+
139
142
#endif /* __ASM_LOONGSON_H */
Original file line number Diff line number Diff line change 12
12
extern u64 cpu_clock_freq ;
13
13
extern u64 const_clock_freq ;
14
14
15
+ extern void save_counter (void );
15
16
extern void sync_counter (void );
16
17
17
18
static inline unsigned int calc_const_freq (void )
Original file line number Diff line number Diff line change @@ -140,6 +140,12 @@ static void __init acpi_process_madt(void)
140
140
loongson_sysconf .nr_cpus = num_processors ;
141
141
}
142
142
143
+ #ifndef CONFIG_SUSPEND
144
+ int (* acpi_suspend_lowlevel )(void );
145
+ #else
146
+ int (* acpi_suspend_lowlevel )(void ) = loongarch_acpi_suspend ;
147
+ #endif
148
+
143
149
void __init acpi_boot_table_init (void )
144
150
{
145
151
/*
Original file line number Diff line number Diff line change 16
16
#include <linux/smp.h>
17
17
#include <linux/threads.h>
18
18
#include <linux/export.h>
19
+ #include <linux/syscore_ops.h>
19
20
#include <linux/time.h>
20
21
#include <linux/tracepoint.h>
21
22
#include <linux/sched/hotplug.h>
Original file line number Diff line number Diff line change @@ -115,12 +115,17 @@ static unsigned long __init get_loops_per_jiffy(void)
115
115
return lpj ;
116
116
}
117
117
118
- static long init_timeval ;
118
+ static long init_offset __nosavedata ;
119
+
120
+ void save_counter (void )
121
+ {
122
+ init_offset = drdtime ();
123
+ }
119
124
120
125
void sync_counter (void )
121
126
{
122
127
/* Ensure counter begin at 0 */
123
- csr_write64 (- init_timeval , LOONGARCH_CSR_CNTC );
128
+ csr_write64 (init_offset , LOONGARCH_CSR_CNTC );
124
129
}
125
130
126
131
static int get_timer_irq (void )
@@ -219,7 +224,7 @@ void __init time_init(void)
219
224
else
220
225
const_clock_freq = calc_const_freq ();
221
226
222
- init_timeval = drdtime () - csr_read64 (LOONGARCH_CSR_CNTC );
227
+ init_offset = - ( drdtime () - csr_read64 (LOONGARCH_CSR_CNTC ) );
223
228
224
229
constant_clockevent_init ();
225
230
constant_clocksource_init ();
Original file line number Diff line number Diff line change
1
+ obj-y += platform.o
2
+
3
+ obj-$(CONFIG_SUSPEND) += suspend.o suspend_asm.o
You can’t perform that action at this time.
0 commit comments