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

TOMOYO Linux Cross Reference
Linux/arch/mips/sgi-ip22/ip22-time.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/mips/sgi-ip22/ip22-time.c (Version linux-6.11-rc3) and /arch/mips/sgi-ip22/ip22-time.c (Version linux-2.6.32.71)


  1 /*                                                  1 /*
  2  * This file is subject to the terms and condi      2  * This file is subject to the terms and conditions of the GNU General Public
  3  * License.  See the file "COPYING" in the mai      3  * License.  See the file "COPYING" in the main directory of this archive
  4  * for more details.                                4  * for more details.
  5  *                                                  5  *
  6  * Time operations for IP22 machines. Original      6  * Time operations for IP22 machines. Original code may come from
  7  * Ralf Baechle or David S. Miller (sorry guys      7  * Ralf Baechle or David S. Miller (sorry guys, i'm really not sure)
  8  *                                                  8  *
  9  * Copyright (C) 2001 by Ladislav Michl             9  * Copyright (C) 2001 by Ladislav Michl
 10  * Copyright (C) 2003, 06 Ralf Baechle (ralf@l     10  * Copyright (C) 2003, 06 Ralf Baechle (ralf@linux-mips.org)
 11  */                                                11  */
 12 #include <linux/bcd.h>                             12 #include <linux/bcd.h>
 13 #include <linux/i8253.h>                       << 
 14 #include <linux/init.h>                            13 #include <linux/init.h>
 15 #include <linux/irq.h>                             14 #include <linux/irq.h>
 16 #include <linux/kernel.h>                          15 #include <linux/kernel.h>
 17 #include <linux/interrupt.h>                       16 #include <linux/interrupt.h>
 18 #include <linux/kernel_stat.h>                     17 #include <linux/kernel_stat.h>
 19 #include <linux/time.h>                            18 #include <linux/time.h>
 20 #include <linux/ftrace.h>                      << 
 21                                                    19 
 22 #include <asm/cpu.h>                               20 #include <asm/cpu.h>
 23 #include <asm/mipsregs.h>                          21 #include <asm/mipsregs.h>
                                                   >>  22 #include <asm/i8253.h>
 24 #include <asm/io.h>                                23 #include <asm/io.h>
 25 #include <asm/irq.h>                               24 #include <asm/irq.h>
 26 #include <asm/time.h>                              25 #include <asm/time.h>
 27 #include <asm/sgialib.h>                           26 #include <asm/sgialib.h>
 28 #include <asm/sgi/ioc.h>                           27 #include <asm/sgi/ioc.h>
 29 #include <asm/sgi/hpc3.h>                          28 #include <asm/sgi/hpc3.h>
 30 #include <asm/sgi/ip22.h>                          29 #include <asm/sgi/ip22.h>
 31                                                    30 
 32 static unsigned long dosample(void)                31 static unsigned long dosample(void)
 33 {                                                  32 {
 34         u32 ct0, ct1;                              33         u32 ct0, ct1;
 35         u8 msb;                                !!  34         u8 msb, lsb;
 36                                                    35 
 37         /* Start the counter. */                   36         /* Start the counter. */
 38         sgint->tcword = (SGINT_TCWORD_CNT2 | S     37         sgint->tcword = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL |
 39                          SGINT_TCWORD_MRGEN);      38                          SGINT_TCWORD_MRGEN);
 40         sgint->tcnt2 = SGINT_TCSAMP_COUNTER &      39         sgint->tcnt2 = SGINT_TCSAMP_COUNTER & 0xff;
 41         sgint->tcnt2 = SGINT_TCSAMP_COUNTER >>     40         sgint->tcnt2 = SGINT_TCSAMP_COUNTER >> 8;
 42                                                    41 
 43         /* Get initial counter invariant */        42         /* Get initial counter invariant */
 44         ct0 = read_c0_count();                     43         ct0 = read_c0_count();
 45                                                    44 
 46         /* Latch and spin until top byte of co     45         /* Latch and spin until top byte of counter2 is zero */
 47         do {                                       46         do {
 48                 writeb(SGINT_TCWORD_CNT2 | SGI     47                 writeb(SGINT_TCWORD_CNT2 | SGINT_TCWORD_CLAT, &sgint->tcword);
 49                 (void) readb(&sgint->tcnt2);   !!  48                 lsb = readb(&sgint->tcnt2);
 50                 msb = readb(&sgint->tcnt2);        49                 msb = readb(&sgint->tcnt2);
 51                 ct1 = read_c0_count();             50                 ct1 = read_c0_count();
 52         } while (msb);                             51         } while (msb);
 53                                                    52 
 54         /* Stop the counter. */                    53         /* Stop the counter. */
 55         writeb(SGINT_TCWORD_CNT2 | SGINT_TCWOR     54         writeb(SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL | SGINT_TCWORD_MSWST,
 56                &sgint->tcword);                    55                &sgint->tcword);
 57         /*                                         56         /*
 58          * Return the difference, this is how      57          * Return the difference, this is how far the r4k counter increments
 59          * for every 1/HZ seconds. We round of     58          * for every 1/HZ seconds. We round off the nearest 1 MHz of master
 60          * clock (= 1000000 / HZ / 2).             59          * clock (= 1000000 / HZ / 2).
 61          */                                        60          */
 62                                                    61 
 63         return (ct1 - ct0) / (500000/HZ) * (50     62         return (ct1 - ct0) / (500000/HZ) * (500000/HZ);
 64 }                                                  63 }
 65                                                    64 
 66 /*                                                 65 /*
 67  * Here we need to calibrate the cycle counter     66  * Here we need to calibrate the cycle counter to at least be close.
 68  */                                                67  */
 69 __init void plat_time_init(void)                   68 __init void plat_time_init(void)
 70 {                                                  69 {
 71         unsigned long r4k_ticks[3];                70         unsigned long r4k_ticks[3];
 72         unsigned long r4k_tick;                    71         unsigned long r4k_tick;
 73                                                    72 
 74         /*                                         73         /*
 75          * Figure out the r4k offset, the algo     74          * Figure out the r4k offset, the algorithm is very simple and works in
 76          * _all_ cases as long as the 8254 cou     75          * _all_ cases as long as the 8254 counter register itself works ok (as
 77          * an interrupt driving timer it does      76          * an interrupt driving timer it does not because of bug, this is why
 78          * we are using the onchip r4k counter     77          * we are using the onchip r4k counter/compare register to serve this
 79          * purpose, but for r4k_offset calcula     78          * purpose, but for r4k_offset calculation it will work ok for us).
 80          * There are other very complicated wa     79          * There are other very complicated ways of performing this calculation
 81          * but this one works just fine so I a     80          * but this one works just fine so I am not going to futz around. ;-)
 82          */                                        81          */
 83         printk(KERN_INFO "Calibrating system t     82         printk(KERN_INFO "Calibrating system timer... ");
 84         dosample();     /* Prime cache. */         83         dosample();     /* Prime cache. */
 85         dosample();     /* Prime cache. */         84         dosample();     /* Prime cache. */
 86         /* Zero is NOT an option. */               85         /* Zero is NOT an option. */
 87         do {                                       86         do {
 88                 r4k_ticks[0] = dosample();         87                 r4k_ticks[0] = dosample();
 89         } while (!r4k_ticks[0]);                   88         } while (!r4k_ticks[0]);
 90         do {                                       89         do {
 91                 r4k_ticks[1] = dosample();         90                 r4k_ticks[1] = dosample();
 92         } while (!r4k_ticks[1]);                   91         } while (!r4k_ticks[1]);
 93                                                    92 
 94         if (r4k_ticks[0] != r4k_ticks[1]) {        93         if (r4k_ticks[0] != r4k_ticks[1]) {
 95                 printk("warning: timer counts      94                 printk("warning: timer counts differ, retrying... ");
 96                 r4k_ticks[2] = dosample();         95                 r4k_ticks[2] = dosample();
 97                 if (r4k_ticks[2] == r4k_ticks[     96                 if (r4k_ticks[2] == r4k_ticks[0]
 98                     || r4k_ticks[2] == r4k_tic     97                     || r4k_ticks[2] == r4k_ticks[1])
 99                         r4k_tick = r4k_ticks[2     98                         r4k_tick = r4k_ticks[2];
100                 else {                             99                 else {
101                         printk("disagreement,     100                         printk("disagreement, using average... ");
102                         r4k_tick = (r4k_ticks[    101                         r4k_tick = (r4k_ticks[0] + r4k_ticks[1]
103                                    + r4k_ticks    102                                    + r4k_ticks[2]) / 3;
104                 }                                 103                 }
105         } else                                    104         } else
106                 r4k_tick = r4k_ticks[0];          105                 r4k_tick = r4k_ticks[0];
107                                                   106 
108         printk("%d [%d.%04d MHz CPU]\n", (int)    107         printk("%d [%d.%04d MHz CPU]\n", (int) r4k_tick,
109                 (int) (r4k_tick / (500000 / HZ    108                 (int) (r4k_tick / (500000 / HZ)),
110                 (int) (r4k_tick % (500000 / HZ    109                 (int) (r4k_tick % (500000 / HZ)));
111                                                   110 
112         mips_hpt_frequency = r4k_tick * HZ;       111         mips_hpt_frequency = r4k_tick * HZ;
113                                                   112 
114         if (ip22_is_fullhouse())                  113         if (ip22_is_fullhouse())
115                 setup_pit_timer();                114                 setup_pit_timer();
116 }                                                 115 }
117                                                   116 
118 /* Generic SGI handler for (spurious) 8254 int    117 /* Generic SGI handler for (spurious) 8254 interrupts */
119 void __irq_entry indy_8254timer_irq(void)      !! 118 void indy_8254timer_irq(void)
120 {                                                 119 {
121         int irq = SGI_8254_0_IRQ;                 120         int irq = SGI_8254_0_IRQ;
122         ULONG cnt;                                121         ULONG cnt;
123         char c;                                   122         char c;
124                                                   123 
125         irq_enter();                              124         irq_enter();
126         kstat_incr_irq_this_cpu(irq);          !! 125         kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));
127         printk(KERN_ALERT "Oops, got 8254 inte    126         printk(KERN_ALERT "Oops, got 8254 interrupt.\n");
128         ArcRead(0, &c, 1, &cnt);                  127         ArcRead(0, &c, 1, &cnt);
129         ArcEnterInteractiveMode();                128         ArcEnterInteractiveMode();
130         irq_exit();                               129         irq_exit();
131 }                                                 130 }
132                                                   131 

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