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

TOMOYO Linux Cross Reference
Linux/arch/m68k/68000/timers.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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/m68k/68000/timers.c (Architecture sparc64) and /arch/m68k/68000/timers.c (Architecture m68k)


  1 /*********************************************      1 /***************************************************************************/
  2                                                     2 
  3 /*                                                  3 /*
  4  *  timers.c - Generic hardware timer support.      4  *  timers.c - Generic hardware timer support.
  5  *                                                  5  *
  6  *  Copyright (C) 1993 Hamish Macdonald             6  *  Copyright (C) 1993 Hamish Macdonald
  7  *  Copyright (C) 1999 D. Jeff Dionne               7  *  Copyright (C) 1999 D. Jeff Dionne
  8  *  Copyright (C) 2001 Georges Menie, Ken Desm      8  *  Copyright (C) 2001 Georges Menie, Ken Desmet
  9  *                                                  9  *
 10  * This file is subject to the terms and condi     10  * This file is subject to the terms and conditions of the GNU General Public
 11  * License.  See the file COPYING in the main      11  * License.  See the file COPYING in the main directory of this archive
 12  * for more details.                               12  * for more details.
 13  */                                                13  */
 14                                                    14 
 15 /*********************************************     15 /***************************************************************************/
 16                                                    16 
 17 #include <linux/types.h>                           17 #include <linux/types.h>
 18 #include <linux/kernel.h>                          18 #include <linux/kernel.h>
 19 #include <linux/mm.h>                              19 #include <linux/mm.h>
 20 #include <linux/interrupt.h>                       20 #include <linux/interrupt.h>
 21 #include <linux/irq.h>                             21 #include <linux/irq.h>
 22 #include <linux/clocksource.h>                     22 #include <linux/clocksource.h>
 23 #include <linux/rtc.h>                             23 #include <linux/rtc.h>
 24 #include <asm/setup.h>                             24 #include <asm/setup.h>
 25 #include <asm/machdep.h>                           25 #include <asm/machdep.h>
 26 #include <asm/MC68VZ328.h>                         26 #include <asm/MC68VZ328.h>
 27                                                    27 
 28 #include "m68328.h"                                28 #include "m68328.h"
 29                                                    29 
 30 /*********************************************     30 /***************************************************************************/
 31                                                    31 
 32 #if defined(CONFIG_DRAGEN2)                        32 #if defined(CONFIG_DRAGEN2)
 33 /* with a 33.16 MHz clock, this will give usec     33 /* with a 33.16 MHz clock, this will give usec resolution to the time functions */
 34 #define CLOCK_SOURCE    TCTL_CLKSOURCE_SYSCLK      34 #define CLOCK_SOURCE    TCTL_CLKSOURCE_SYSCLK
 35 #define CLOCK_PRE       7                          35 #define CLOCK_PRE       7
 36 #define TICKS_PER_JIFFY 41450                      36 #define TICKS_PER_JIFFY 41450
 37                                                    37 
 38 #elif defined(CONFIG_XCOPILOT_BUGS)                38 #elif defined(CONFIG_XCOPILOT_BUGS)
 39 /*                                                 39 /*
 40  * The only thing I know is that CLK32 is not      40  * The only thing I know is that CLK32 is not available on Xcopilot
 41  * I have little idea about what frequency SYS     41  * I have little idea about what frequency SYSCLK has on Xcopilot.
 42  * The values for prescaler and compare regist     42  * The values for prescaler and compare registers were simply
 43  * taken from the original source                  43  * taken from the original source
 44  */                                                44  */
 45 #define CLOCK_SOURCE    TCTL_CLKSOURCE_SYSCLK      45 #define CLOCK_SOURCE    TCTL_CLKSOURCE_SYSCLK
 46 #define CLOCK_PRE       2                          46 #define CLOCK_PRE       2
 47 #define TICKS_PER_JIFFY 0xd7e4                     47 #define TICKS_PER_JIFFY 0xd7e4
 48                                                    48 
 49 #else                                              49 #else
 50 /* default to using the 32Khz clock */             50 /* default to using the 32Khz clock */
 51 #define CLOCK_SOURCE    TCTL_CLKSOURCE_32KHZ       51 #define CLOCK_SOURCE    TCTL_CLKSOURCE_32KHZ
 52 #define CLOCK_PRE       31                         52 #define CLOCK_PRE       31
 53 #define TICKS_PER_JIFFY 10                         53 #define TICKS_PER_JIFFY 10
 54 #endif                                             54 #endif
 55                                                    55 
 56 static u32 m68328_tick_cnt;                        56 static u32 m68328_tick_cnt;
 57                                                    57 
 58 /*********************************************     58 /***************************************************************************/
 59                                                    59 
 60 static irqreturn_t hw_tick(int irq, void *dumm     60 static irqreturn_t hw_tick(int irq, void *dummy)
 61 {                                                  61 {
 62         /* Reset Timer1 */                         62         /* Reset Timer1 */
 63         TSTAT &= 0;                                63         TSTAT &= 0;
 64                                                    64 
 65         m68328_tick_cnt += TICKS_PER_JIFFY;        65         m68328_tick_cnt += TICKS_PER_JIFFY;
 66         legacy_timer_tick(1);                      66         legacy_timer_tick(1);
 67         return IRQ_HANDLED;                        67         return IRQ_HANDLED;
 68 }                                                  68 }
 69                                                    69 
 70 /*********************************************     70 /***************************************************************************/
 71                                                    71 
 72 static u64 m68328_read_clk(struct clocksource      72 static u64 m68328_read_clk(struct clocksource *cs)
 73 {                                                  73 {
 74         unsigned long flags;                       74         unsigned long flags;
 75         u32 cycles;                                75         u32 cycles;
 76                                                    76 
 77         local_irq_save(flags);                     77         local_irq_save(flags);
 78         cycles = m68328_tick_cnt + TCN;            78         cycles = m68328_tick_cnt + TCN;
 79         local_irq_restore(flags);                  79         local_irq_restore(flags);
 80                                                    80 
 81         return cycles;                             81         return cycles;
 82 }                                                  82 }
 83                                                    83 
 84 /*********************************************     84 /***************************************************************************/
 85                                                    85 
 86 static struct clocksource m68328_clk = {           86 static struct clocksource m68328_clk = {
 87         .name   = "timer",                         87         .name   = "timer",
 88         .rating = 250,                             88         .rating = 250,
 89         .read   = m68328_read_clk,                 89         .read   = m68328_read_clk,
 90         .mask   = CLOCKSOURCE_MASK(32),            90         .mask   = CLOCKSOURCE_MASK(32),
 91         .flags  = CLOCK_SOURCE_IS_CONTINUOUS,      91         .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
 92 };                                                 92 };
 93                                                    93 
 94 /*********************************************     94 /***************************************************************************/
 95                                                    95 
 96 void hw_timer_init(void)                           96 void hw_timer_init(void)
 97 {                                                  97 {
 98         int ret;                                   98         int ret;
 99                                                    99 
100         /* disable timer 1 */                     100         /* disable timer 1 */
101         TCTL = 0;                                 101         TCTL = 0;
102                                                   102 
103         /* set ISR */                             103         /* set ISR */
104         ret = request_irq(TMR_IRQ_NUM, hw_tick    104         ret = request_irq(TMR_IRQ_NUM, hw_tick, IRQF_TIMER, "timer", NULL);
105         if (ret) {                                105         if (ret) {
106                 pr_err("Failed to request irq     106                 pr_err("Failed to request irq %d (timer): %pe\n", TMR_IRQ_NUM,
107                        ERR_PTR(ret));             107                        ERR_PTR(ret));
108         }                                         108         }
109                                                   109 
110         /* Restart mode, Enable int, Set clock    110         /* Restart mode, Enable int, Set clock source */
111         TCTL = TCTL_OM | TCTL_IRQEN | CLOCK_SO    111         TCTL = TCTL_OM | TCTL_IRQEN | CLOCK_SOURCE;
112         TPRER = CLOCK_PRE;                        112         TPRER = CLOCK_PRE;
113         TCMP = TICKS_PER_JIFFY;                   113         TCMP = TICKS_PER_JIFFY;
114                                                   114 
115         /* Enable timer 1 */                      115         /* Enable timer 1 */
116         TCTL |= TCTL_TEN;                         116         TCTL |= TCTL_TEN;
117         clocksource_register_hz(&m68328_clk, T    117         clocksource_register_hz(&m68328_clk, TICKS_PER_JIFFY*HZ);
118 }                                                 118 }
119                                                   119 
120 /*********************************************    120 /***************************************************************************/
121                                                   121 
122 int m68328_hwclk(int set, struct rtc_time *t)     122 int m68328_hwclk(int set, struct rtc_time *t)
123 {                                                 123 {
124         if (!set) {                               124         if (!set) {
125                 long now = RTCTIME;               125                 long now = RTCTIME;
126                 t->tm_year = 1;                   126                 t->tm_year = 1;
127                 t->tm_mon = 0;                    127                 t->tm_mon = 0;
128                 t->tm_mday = 1;                   128                 t->tm_mday = 1;
129                 t->tm_hour = (now >> 24) % 24;    129                 t->tm_hour = (now >> 24) % 24;
130                 t->tm_min = (now >> 16) % 60;     130                 t->tm_min = (now >> 16) % 60;
131                 t->tm_sec = now % 60;             131                 t->tm_sec = now % 60;
132         }                                         132         }
133                                                   133 
134         return 0;                                 134         return 0;
135 }                                                 135 }
136                                                   136 
137 /*********************************************    137 /***************************************************************************/
138                                                   138 

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