~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/loongson2ef/common/pm.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/mips/loongson2ef/common/pm.c (Architecture ppc) and /arch/sparc64/loongson2ef/common/pm.c (Architecture sparc64)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 
  2 /*                                                
  3  * loongson-specific suspend support              
  4  *                                                
  5  *  Copyright (C) 2009 Lemote Inc.                
  6  *  Author: Wu Zhangjin <wuzhangjin@gmail.com>    
  7  */                                               
  8 #include <linux/suspend.h>                        
  9 #include <linux/interrupt.h>                      
 10 #include <linux/pm.h>                             
 11                                                   
 12 #include <asm/i8259.h>                            
 13 #include <asm/mipsregs.h>                         
 14                                                   
 15 #include <loongson.h>                             
 16                                                   
 17 static unsigned int __maybe_unused cached_mast    
 18 static unsigned int __maybe_unused cached_slav    
 19 static unsigned int __maybe_unused cached_boni    
 20                                                   
 21 void arch_suspend_disable_irqs(void)              
 22 {                                                 
 23         /* disable all mips events */             
 24         local_irq_disable();                      
 25                                                   
 26 #ifdef CONFIG_I8259                               
 27         /* disable all events of i8259A */        
 28         cached_slave_mask = inb(PIC_SLAVE_IMR)    
 29         cached_master_mask = inb(PIC_MASTER_IM    
 30                                                   
 31         outb(0xff, PIC_SLAVE_IMR);                
 32         inb(PIC_SLAVE_IMR);                       
 33         outb(0xff, PIC_MASTER_IMR);               
 34         inb(PIC_MASTER_IMR);                      
 35 #endif                                            
 36         /* disable all events of bonito */        
 37         cached_bonito_irq_mask = LOONGSON_INTE    
 38         LOONGSON_INTENCLR = 0xffff;               
 39         (void)LOONGSON_INTENCLR;                  
 40 }                                                 
 41                                                   
 42 void arch_suspend_enable_irqs(void)               
 43 {                                                 
 44         /* enable all mips events */              
 45         local_irq_enable();                       
 46 #ifdef CONFIG_I8259                               
 47         /* only enable the cached events of i8    
 48         outb(cached_slave_mask, PIC_SLAVE_IMR)    
 49         outb(cached_master_mask, PIC_MASTER_IM    
 50 #endif                                            
 51         /* enable all cached events of bonito     
 52         LOONGSON_INTENSET = cached_bonito_irq_    
 53         (void)LOONGSON_INTENSET;                  
 54 }                                                 
 55                                                   
 56 /*                                                
 57  * Setup the board-specific events for waking     
 58  */                                               
 59 void __weak setup_wakeup_events(void)             
 60 {                                                 
 61 }                                                 
 62                                                   
 63 /*                                                
 64  * Check wakeup events                            
 65  */                                               
 66 int __weak wakeup_loongson(void)                  
 67 {                                                 
 68         return 1;                                 
 69 }                                                 
 70                                                   
 71 /*                                                
 72  * If the events are really what we want to wa    
 73  * otherwise put the CPU asleep again.            
 74  */                                               
 75 static void wait_for_wakeup_events(void)          
 76 {                                                 
 77         while (!wakeup_loongson())                
 78                 writel(readl(LOONGSON_CHIPCFG)    
 79 }                                                 
 80                                                   
 81 /*                                                
 82  * Stop all perf counters                         
 83  *                                                
 84  * $24 is the control register of Loongson per    
 85  */                                               
 86 static inline void stop_perf_counters(void)       
 87 {                                                 
 88         __write_64bit_c0_register($24, 0, 0);     
 89 }                                                 
 90                                                   
 91                                                   
 92 static void loongson_suspend_enter(void)          
 93 {                                                 
 94         unsigned int cached_cpu_freq;             
 95                                                   
 96         /* setup wakeup events via enabling th    
 97         setup_wakeup_events();                    
 98                                                   
 99         stop_perf_counters();                     
100                                                   
101         cached_cpu_freq = readl(LOONGSON_CHIPC    
102                                                   
103         /* Put CPU into wait mode */              
104         writel(readl(LOONGSON_CHIPCFG) & ~0x7,    
105                                                   
106         /* wait for the given events to wakeup    
107         wait_for_wakeup_events();                 
108                                                   
109         writel(cached_cpu_freq, LOONGSON_CHIPC    
110                                                   
111         mmiowb();                                 
112 }                                                 
113                                                   
114 void __weak mach_suspend(void)                    
115 {                                                 
116 }                                                 
117                                                   
118 void __weak mach_resume(void)                     
119 {                                                 
120 }                                                 
121                                                   
122 static int loongson_pm_enter(suspend_state_t s    
123 {                                                 
124         mach_suspend();                           
125                                                   
126         /* processor specific suspend */          
127         loongson_suspend_enter();                 
128                                                   
129         mach_resume();                            
130                                                   
131         return 0;                                 
132 }                                                 
133                                                   
134 static int loongson_pm_valid_state(suspend_sta    
135 {                                                 
136         switch (state) {                          
137         case PM_SUSPEND_ON:                       
138         case PM_SUSPEND_STANDBY:                  
139         case PM_SUSPEND_MEM:                      
140                 return 1;                         
141                                                   
142         default:                                  
143                 return 0;                         
144         }                                         
145 }                                                 
146                                                   
147 static const struct platform_suspend_ops loong    
148         .valid  = loongson_pm_valid_state,        
149         .enter  = loongson_pm_enter,              
150 };                                                
151                                                   
152 static int __init loongson_pm_init(void)          
153 {                                                 
154         suspend_set_ops(&loongson_pm_ops);        
155                                                   
156         return 0;                                 
157 }                                                 
158 arch_initcall(loongson_pm_init);                  
159                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php