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

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-omap2/cpuidle34xx.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/arm/mach-omap2/cpuidle34xx.c (Architecture m68k) and /arch/mips/mach-omap2/cpuidle34xx.c (Architecture mips)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * linux/arch/arm/mach-omap2/cpuidle34xx.c        
  4  *                                                
  5  * OMAP3 CPU IDLE Routines                        
  6  *                                                
  7  * Copyright (C) 2008 Texas Instruments, Inc.     
  8  * Rajendra Nayak <rnayak@ti.com>                 
  9  *                                                
 10  * Copyright (C) 2007 Texas Instruments, Inc.     
 11  * Karthik Dasu <karthik-dp@ti.com>               
 12  *                                                
 13  * Copyright (C) 2006 Nokia Corporation           
 14  * Tony Lindgren <tony@atomide.com>               
 15  *                                                
 16  * Copyright (C) 2005 Texas Instruments, Inc.     
 17  * Richard Woodruff <r-woodruff2@ti.com>          
 18  *                                                
 19  * Based on pm.c for omap2                        
 20  */                                               
 21                                                   
 22 #include <linux/sched.h>                          
 23 #include <linux/cpuidle.h>                        
 24 #include <linux/export.h>                         
 25 #include <linux/cpu_pm.h>                         
 26 #include <asm/cpuidle.h>                          
 27                                                   
 28 #include "powerdomain.h"                          
 29 #include "clockdomain.h"                          
 30                                                   
 31 #include "pm.h"                                   
 32 #include "control.h"                              
 33 #include "common.h"                               
 34 #include "soc.h"                                  
 35                                                   
 36 /* Mach specific information to be recorded in    
 37 struct omap3_idle_statedata {                     
 38         u8 mpu_state;                             
 39         u8 core_state;                            
 40         u8 per_min_state;                         
 41         u8 flags;                                 
 42 };                                                
 43                                                   
 44 static struct powerdomain *mpu_pd, *core_pd, *    
 45                                                   
 46 /*                                                
 47  * Possible flag bits for struct omap3_idle_st    
 48  *                                                
 49  * OMAP_CPUIDLE_CX_NO_CLKDM_IDLE: don't allow     
 50  *    inactive.  This in turn prevents the MPU    
 51  *    mode, so wakeup latency is greatly reduc    
 52  *    energy consumption.  This also prevents     
 53  *    entering idle.                              
 54  */                                               
 55 #define OMAP_CPUIDLE_CX_NO_CLKDM_IDLE             
 56                                                   
 57 /*                                                
 58  * Prevent PER OFF if CORE is not in RETention    
 59  * disable PER wakeups completely.                
 60  */                                               
 61 static struct omap3_idle_statedata omap3_idle_    
 62         {                                         
 63                 .mpu_state = PWRDM_POWER_ON,      
 64                 .core_state = PWRDM_POWER_ON,     
 65                 /* In C1 do not allow PER stat    
 66                 .per_min_state = PWRDM_POWER_O    
 67                 .flags = OMAP_CPUIDLE_CX_NO_CL    
 68         },                                        
 69         {                                         
 70                 .mpu_state = PWRDM_POWER_ON,      
 71                 .core_state = PWRDM_POWER_ON,     
 72                 .per_min_state = PWRDM_POWER_R    
 73         },                                        
 74         {                                         
 75                 .mpu_state = PWRDM_POWER_RET,     
 76                 .core_state = PWRDM_POWER_ON,     
 77                 .per_min_state = PWRDM_POWER_R    
 78         },                                        
 79         {                                         
 80                 .mpu_state = PWRDM_POWER_OFF,     
 81                 .core_state = PWRDM_POWER_ON,     
 82                 .per_min_state = PWRDM_POWER_R    
 83         },                                        
 84         {                                         
 85                 .mpu_state = PWRDM_POWER_RET,     
 86                 .core_state = PWRDM_POWER_RET,    
 87                 .per_min_state = PWRDM_POWER_O    
 88         },                                        
 89         {                                         
 90                 .mpu_state = PWRDM_POWER_OFF,     
 91                 .core_state = PWRDM_POWER_RET,    
 92                 .per_min_state = PWRDM_POWER_O    
 93         },                                        
 94         {                                         
 95                 .mpu_state = PWRDM_POWER_OFF,     
 96                 .core_state = PWRDM_POWER_OFF,    
 97                 .per_min_state = PWRDM_POWER_O    
 98         },                                        
 99 };                                                
100                                                   
101 /**                                               
102  * omap3_enter_idle - Programs OMAP3 to enter     
103  * @dev: cpuidle device                           
104  * @drv: cpuidle driver                           
105  * @index: the index of state to be entered       
106  */                                               
107 static int omap3_enter_idle(struct cpuidle_dev    
108                             struct cpuidle_dri    
109                             int index)            
110 {                                                 
111         struct omap3_idle_statedata *cx = &oma    
112         int error;                                
113                                                   
114         if (omap_irq_pending() || need_resched    
115                 goto return_sleep_time;           
116                                                   
117         /* Deny idle for C1 */                    
118         if (cx->flags & OMAP_CPUIDLE_CX_NO_CLK    
119                 clkdm_deny_idle(mpu_pd->pwrdm_    
120         } else {                                  
121                 pwrdm_set_next_pwrst(mpu_pd, c    
122                 pwrdm_set_next_pwrst(core_pd,     
123         }                                         
124                                                   
125         /*                                        
126          * Call idle CPU PM enter notifier cha    
127          * VFP context is saved.                  
128          */                                       
129         if (cx->mpu_state == PWRDM_POWER_OFF)     
130                 error = cpu_pm_enter();           
131                 if (error)                        
132                         goto out_clkdm_set;       
133         }                                         
134                                                   
135         /* Execute ARM wfi */                     
136         omap_sram_idle(true);                     
137                                                   
138         /*                                        
139          * Call idle CPU PM enter notifier cha    
140          * VFP context.                           
141          */                                       
142         if (cx->mpu_state == PWRDM_POWER_OFF &    
143             pwrdm_read_prev_pwrst(mpu_pd) == P    
144                 cpu_pm_exit();                    
145                                                   
146 out_clkdm_set:                                    
147         /* Re-allow idle for C1 */                
148         if (cx->flags & OMAP_CPUIDLE_CX_NO_CLK    
149                 clkdm_allow_idle(mpu_pd->pwrdm    
150                                                   
151 return_sleep_time:                                
152                                                   
153         return index;                             
154 }                                                 
155                                                   
156 /**                                               
157  * next_valid_state - Find next valid C-state     
158  * @dev: cpuidle device                           
159  * @drv: cpuidle driver                           
160  * @index: Index of currently selected c-state    
161  *                                                
162  * If the state corresponding to index is vali    
163  * to the caller. Else, this function searches    
164  * still valid (as defined in omap3_power_stat    
165  *                                                
166  * A state is valid if the 'valid' field is en    
167  * if it satisfies the enable_off_mode conditi    
168  */                                               
169 static int next_valid_state(struct cpuidle_dev    
170                             struct cpuidle_dri    
171 {                                                 
172         struct omap3_idle_statedata *cx = &oma    
173         u32 mpu_deepest_state = PWRDM_POWER_RE    
174         u32 core_deepest_state = PWRDM_POWER_R    
175         int idx;                                  
176         int next_index = 0; /* C1 is the defau    
177                                                   
178         if (enable_off_mode) {                    
179                 mpu_deepest_state = PWRDM_POWE    
180                 /*                                
181                  * Erratum i583: valable for E    
182                  * CORE OFF mode is not suppor    
183                  * instead the CORE state to R    
184                  */                               
185                 if (!IS_PM34XX_ERRATUM(PM_SDRC    
186                         core_deepest_state = P    
187         }                                         
188                                                   
189         /* Check if current state is valid */     
190         if ((cx->mpu_state >= mpu_deepest_stat    
191             (cx->core_state >= core_deepest_st    
192                 return index;                     
193                                                   
194         /*                                        
195          * Drop to next valid state.              
196          * Start search from the next (lower)     
197          */                                       
198         for (idx = index - 1; idx >= 0; idx--)    
199                 cx = &omap3_idle_data[idx];       
200                 if ((cx->mpu_state >= mpu_deep    
201                     (cx->core_state >= core_de    
202                         next_index = idx;         
203                         break;                    
204                 }                                 
205         }                                         
206                                                   
207         return next_index;                        
208 }                                                 
209                                                   
210 /**                                               
211  * omap3_enter_idle_bm - Checks for any bus ac    
212  * @dev: cpuidle device                           
213  * @drv: cpuidle driver                           
214  * @index: array index of target state to be p    
215  *                                                
216  * This function checks for any pending activi    
217  * the device to the specified or a safer stat    
218  */                                               
219 static int omap3_enter_idle_bm(struct cpuidle_    
220                                struct cpuidle_    
221                                int index)         
222 {                                                 
223         int new_state_idx, ret;                   
224         u8 per_next_state, per_saved_state;       
225         struct omap3_idle_statedata *cx;          
226                                                   
227         /*                                        
228          * Use only C1 if CAM is active.          
229          * CAM does not have wakeup capability    
230          */                                       
231         if (pwrdm_read_pwrst(cam_pd) == PWRDM_    
232                 new_state_idx = drv->safe_stat    
233         else                                      
234                 new_state_idx = next_valid_sta    
235                                                   
236         /*                                        
237          * FIXME: we currently manage device-s    
238          *        for PER and CORE in combinat    
239          *        idle states.  This is wrong,    
240          *        idle management needs to be     
241          *        its own code.                   
242          */                                       
243                                                   
244         /* Program PER state */                   
245         cx = &omap3_idle_data[new_state_idx];     
246                                                   
247         per_next_state = pwrdm_read_next_pwrst    
248         per_saved_state = per_next_state;         
249         if (per_next_state < cx->per_min_state    
250                 per_next_state = cx->per_min_s    
251                 pwrdm_set_next_pwrst(per_pd, p    
252         }                                         
253                                                   
254         ret = omap3_enter_idle(dev, drv, new_s    
255                                                   
256         /* Restore original PER state if it wa    
257         if (per_next_state != per_saved_state)    
258                 pwrdm_set_next_pwrst(per_pd, p    
259                                                   
260         return ret;                               
261 }                                                 
262                                                   
263 static struct cpuidle_driver omap3_idle_driver    
264         .name             = "omap3_idle",         
265         .owner            = THIS_MODULE,          
266         .states = {                               
267                 {                                 
268                         .flags            = CP    
269                         .enter            = om    
270                         .exit_latency     = 2     
271                         .target_residency = 5,    
272                         .name             = "C    
273                         .desc             = "M    
274                 },                                
275                 {                                 
276                         .flags            = CP    
277                         .enter            = om    
278                         .exit_latency     = 10    
279                         .target_residency = 30    
280                         .name             = "C    
281                         .desc             = "M    
282                 },                                
283                 {                                 
284                         .flags            = CP    
285                         .enter            = om    
286                         .exit_latency     = 50    
287                         .target_residency = 30    
288                         .name             = "C    
289                         .desc             = "M    
290                 },                                
291                 {                                 
292                         .flags            = CP    
293                         .enter            = om    
294                         .exit_latency     = 15    
295                         .target_residency = 40    
296                         .name             = "C    
297                         .desc             = "M    
298                 },                                
299                 {                                 
300                         .flags            = CP    
301                         .enter            = om    
302                         .exit_latency     = 25    
303                         .target_residency = 12    
304                         .name             = "C    
305                         .desc             = "M    
306                 },                                
307                 {                                 
308                         .flags            = CP    
309                         .enter            = om    
310                         .exit_latency     = 30    
311                         .target_residency = 15    
312                         .name             = "C    
313                         .desc             = "M    
314                 },                                
315                 {                                 
316                         .flags            = CP    
317                         .enter            = om    
318                         .exit_latency     = 10    
319                         .target_residency = 30    
320                         .name             = "C    
321                         .desc             = "M    
322                 },                                
323         },                                        
324         .state_count = ARRAY_SIZE(omap3_idle_d    
325         .safe_state_index = 0,                    
326 };                                                
327                                                   
328 /*                                                
329  * Numbers based on measurements made in Octob    
330  * with CPU freq enabled on device Nokia N900.    
331  * and worst case latencies).                     
332  */                                               
333 static struct cpuidle_driver omap3430_idle_dri    
334         .name             = "omap3430_idle",      
335         .owner            = THIS_MODULE,          
336         .states = {                               
337                 {                                 
338                         .flags            = CP    
339                         .enter            = om    
340                         .exit_latency     = 11    
341                         .target_residency = 5,    
342                         .name             = "C    
343                         .desc             = "M    
344                 },                                
345                 {                                 
346                         .flags            = CP    
347                         .enter            = om    
348                         .exit_latency     = 10    
349                         .target_residency = 30    
350                         .name             = "C    
351                         .desc             = "M    
352                 },                                
353                 {                                 
354                         .flags            = CP    
355                         .enter            = om    
356                         .exit_latency     = 10    
357                         .target_residency = 46    
358                         .name             = "C    
359                         .desc             = "M    
360                 },                                
361                 {                                 
362                         .flags            = CP    
363                         .enter            = om    
364                         .exit_latency     = 12    
365                         .target_residency = 46    
366                         .name             = "C    
367                         .desc             = "M    
368                 },                                
369                 {                                 
370                         .flags            = CP    
371                         .enter            = om    
372                         .exit_latency     = 85    
373                         .target_residency = 46    
374                         .name             = "C    
375                         .desc             = "M    
376                 },                                
377                 {                                 
378                         .flags            = CP    
379                         .enter            = om    
380                         .exit_latency     = 75    
381                         .target_residency = 48    
382                         .name             = "C    
383                         .desc             = "M    
384                 },                                
385                 {                                 
386                         .flags            = CP    
387                         .enter            = om    
388                         .exit_latency     = 75    
389                         .target_residency = 48    
390                         .name             = "C    
391                         .desc             = "M    
392                 },                                
393         },                                        
394         .state_count = ARRAY_SIZE(omap3_idle_d    
395         .safe_state_index = 0,                    
396 };                                                
397                                                   
398 /* Public functions */                            
399                                                   
400 /**                                               
401  * omap3_idle_init - Init routine for OMAP3 id    
402  *                                                
403  * Registers the OMAP3 specific cpuidle driver    
404  * framework with the valid set of states.        
405  */                                               
406 int __init omap3_idle_init(void)                  
407 {                                                 
408         mpu_pd = pwrdm_lookup("mpu_pwrdm");       
409         core_pd = pwrdm_lookup("core_pwrdm");     
410         per_pd = pwrdm_lookup("per_pwrdm");       
411         cam_pd = pwrdm_lookup("cam_pwrdm");       
412                                                   
413         if (!mpu_pd || !core_pd || !per_pd ||     
414                 return -ENODEV;                   
415                                                   
416         if (cpu_is_omap3430())                    
417                 return cpuidle_register(&omap3    
418         else                                      
419                 return cpuidle_register(&omap3    
420 }                                                 
421                                                   

~ [ 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