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

TOMOYO Linux Cross Reference
Linux/arch/sh/boards/mach-dreamcast/rtc.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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/sh/boards/mach-dreamcast/rtc.c (Version linux-6.11-rc3) and /arch/i386/boards/mach-dreamcast/rtc.c (Version linux-5.11.22)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  * arch/sh/boards/dreamcast/rtc.c                 
  4  *                                                
  5  * Dreamcast AICA RTC routines.                   
  6  *                                                
  7  * Copyright (c) 2001, 2002 M. R. Brown <mrbro    
  8  * Copyright (c) 2002 Paul Mundt <lethal@chaot    
  9  */                                               
 10                                                   
 11 #include <linux/time.h>                           
 12 #include <linux/rtc.h>                            
 13 #include <linux/io.h>                             
 14 #include <linux/platform_device.h>                
 15                                                   
 16 /* The AICA RTC has an Epoch of 1/1/1950, so w    
 17    seconds) to get the standard Unix Epoch whe    
 18    20 years when setting the time. */             
 19 #define TWENTY_YEARS ((20 * 365LU + 5) * 86400    
 20                                                   
 21 /* The AICA RTC is represented by a 32-bit sec    
 22    registers.*/                                   
 23 #define AICA_RTC_SECS_H         0xa0710000        
 24 #define AICA_RTC_SECS_L         0xa0710004        
 25                                                   
 26 /**                                               
 27  * aica_rtc_gettimeofday - Get the time from t    
 28  * @dev: the RTC device (ignored)                 
 29  * @tm: pointer to resulting RTC time structur    
 30  *                                                
 31  * Grabs the current RTC seconds counter and a    
 32  */                                               
 33 static int aica_rtc_gettimeofday(struct device    
 34 {                                                 
 35         unsigned long val1, val2;                 
 36         time64_t t;                               
 37                                                   
 38         do {                                      
 39                 val1 = ((__raw_readl(AICA_RTC_    
 40                         (__raw_readl(AICA_RTC_    
 41                                                   
 42                 val2 = ((__raw_readl(AICA_RTC_    
 43                         (__raw_readl(AICA_RTC_    
 44         } while (val1 != val2);                   
 45                                                   
 46         /* normalize to 1970..2106 time range     
 47         t = (u32)(val1 - TWENTY_YEARS);           
 48                                                   
 49         rtc_time64_to_tm(t, tm);                  
 50                                                   
 51         return 0;                                 
 52 }                                                 
 53                                                   
 54 /**                                               
 55  * aica_rtc_settimeofday - Set the AICA RTC to    
 56  * @dev: the RTC device (ignored)                 
 57  * @tm: pointer to new RTC time structure         
 58  *                                                
 59  * Adjusts the given @tv to the AICA Epoch and    
 60  */                                               
 61 static int aica_rtc_settimeofday(struct device    
 62 {                                                 
 63         unsigned long val1, val2;                 
 64         time64_t secs = rtc_tm_to_time64(tm);     
 65         u32 adj = secs + TWENTY_YEARS;            
 66                                                   
 67         do {                                      
 68                 __raw_writel((adj & 0xffff0000    
 69                 __raw_writel((adj & 0xffff), A    
 70                                                   
 71                 val1 = ((__raw_readl(AICA_RTC_    
 72                         (__raw_readl(AICA_RTC_    
 73                                                   
 74                 val2 = ((__raw_readl(AICA_RTC_    
 75                         (__raw_readl(AICA_RTC_    
 76         } while (val1 != val2);                   
 77                                                   
 78         return 0;                                 
 79 }                                                 
 80                                                   
 81 static const struct rtc_class_ops rtc_generic_    
 82         .read_time = aica_rtc_gettimeofday,       
 83         .set_time = aica_rtc_settimeofday,        
 84 };                                                
 85                                                   
 86 static int __init aica_time_init(void)            
 87 {                                                 
 88         struct platform_device *pdev;             
 89                                                   
 90         pdev = platform_device_register_data(N    
 91                                              &    
 92                                              s    
 93                                                   
 94         return PTR_ERR_OR_ZERO(pdev);             
 95 }                                                 
 96 arch_initcall(aica_time_init);                    
 97                                                   

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