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

TOMOYO Linux Cross Reference
Linux/arch/mips/include/asm/mc146818-time.h

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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/mips/include/asm/mc146818-time.h (Version linux-6.12-rc7) and /arch/i386/include/asm-i386/mc146818-time.h (Version linux-5.2.21)


  1 /*                                                  1 
  2  * This file is subject to the terms and condi    
  3  * License.  See the file "COPYING" in the mai    
  4  * for more details.                              
  5  *                                                
  6  * Machine dependent access functions for RTC     
  7  */                                               
  8 #ifndef __ASM_MC146818_TIME_H                     
  9 #define __ASM_MC146818_TIME_H                     
 10                                                   
 11 #include <linux/bcd.h>                            
 12 #include <linux/mc146818rtc.h>                    
 13 #include <linux/time.h>                           
 14                                                   
 15 /*                                                
 16  * For check timing call set_rtc_mmss() 500ms;    
 17  */                                               
 18 #define USEC_AFTER      500000                    
 19 #define USEC_BEFORE     500000                    
 20                                                   
 21 /*                                                
 22  * In order to set the CMOS clock precisely, s    
 23  * called 500 ms after the second nowtime has     
 24  * nowtime is written into the registers of th    
 25  * jump to the next second precisely 500 ms la    
 26  * MC146818A or Dallas DS12887 data sheet for     
 27  *                                                
 28  * BUG: This routine does not handle hour over    
 29  *      sets the minutes. Usually you'll only     
 30  */                                               
 31 static inline int mc146818_set_rtc_mmss(unsign    
 32 {                                                 
 33         int real_seconds, real_minutes, cmos_m    
 34         unsigned char save_control, save_freq_    
 35         int retval = 0;                           
 36         unsigned long flags;                      
 37                                                   
 38         spin_lock_irqsave(&rtc_lock, flags);      
 39         save_control = CMOS_READ(RTC_CONTROL);    
 40         CMOS_WRITE((save_control|RTC_SET), RTC    
 41                                                   
 42         save_freq_select = CMOS_READ(RTC_FREQ_    
 43         CMOS_WRITE((save_freq_select|RTC_DIV_R    
 44                                                   
 45         cmos_minutes = CMOS_READ(RTC_MINUTES);    
 46         if (!(save_control & RTC_DM_BINARY) ||    
 47                 cmos_minutes = bcd2bin(cmos_mi    
 48                                                   
 49         /*                                        
 50          * since we're only adjusting minutes     
 51          * don't interfere with hour overflow.    
 52          * messing with unknown time zones but    
 53          * RTC not to be off by more than 15 m    
 54          */                                       
 55         real_seconds = nowtime % 60;              
 56         real_minutes = nowtime / 60;              
 57         if (((abs(real_minutes - cmos_minutes)    
 58                 real_minutes += 30;               
 59         real_minutes %= 60;                       
 60                                                   
 61         if (abs(real_minutes - cmos_minutes) <    
 62                 if (!(save_control & RTC_DM_BI    
 63                         real_seconds = bin2bcd    
 64                         real_minutes = bin2bcd    
 65                 }                                 
 66                 CMOS_WRITE(real_seconds, RTC_S    
 67                 CMOS_WRITE(real_minutes, RTC_M    
 68         } else {                                  
 69                 printk_once(KERN_NOTICE           
 70                        "set_rtc_mmss: can't up    
 71                        cmos_minutes, real_minu    
 72                 retval = -1;                      
 73         }                                         
 74                                                   
 75         /* The following flags have to be rele    
 76          * otherwise the DS12887 (popular MC14    
 77          * battery and quartz) will not reset     
 78          * update precisely 500 ms later. You     
 79          * the Dallas Semiconductor data sheet    
 80          * sheets anyway ...                      
 81          */                                       
 82         CMOS_WRITE(save_control, RTC_CONTROL);    
 83         CMOS_WRITE(save_freq_select, RTC_FREQ_    
 84         spin_unlock_irqrestore(&rtc_lock, flag    
 85                                                   
 86         return retval;                            
 87 }                                                 
 88                                                   
 89 static inline time64_t mc146818_get_cmos_time(    
 90 {                                                 
 91         unsigned int year, mon, day, hour, min    
 92         unsigned long flags;                      
 93                                                   
 94         spin_lock_irqsave(&rtc_lock, flags);      
 95                                                   
 96         do {                                      
 97                 sec = CMOS_READ(RTC_SECONDS);     
 98                 min = CMOS_READ(RTC_MINUTES);     
 99                 hour = CMOS_READ(RTC_HOURS);      
100                 day = CMOS_READ(RTC_DAY_OF_MON    
101                 mon = CMOS_READ(RTC_MONTH);       
102                 year = CMOS_READ(RTC_YEAR);       
103         } while (sec != CMOS_READ(RTC_SECONDS)    
104                                                   
105         if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_    
106                 sec = bcd2bin(sec);               
107                 min = bcd2bin(min);               
108                 hour = bcd2bin(hour);             
109                 day = bcd2bin(day);               
110                 mon = bcd2bin(mon);               
111                 year = bcd2bin(year);             
112         }                                         
113         spin_unlock_irqrestore(&rtc_lock, flag    
114         year = mc146818_decode_year(year);        
115                                                   
116         return mktime64(year, mon, day, hour,     
117 }                                                 
118                                                   
119 #endif /* __ASM_MC146818_TIME_H */                
120                                                   

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