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

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-sa1100/time.c

Version: ~ [ linux-5.2-rc6 ] ~ [ linux-5.1.15 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.56 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.130 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.183 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.183 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.69 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * linux/arch/arm/mach-sa1100/time.c
  3  *
  4  * Copyright (C) 1998 Deborah Wallach.
  5  * Twiddles  (C) 1999 Hugo Fiennes <hugo@empeg.com>
  6  *
  7  * 2000/03/29 (C) Nicolas Pitre <nico@fluxnic.net>
  8  *      Rewritten: big cleanup, much simpler, better HZ accuracy.
  9  *
 10  */
 11 #include <linux/init.h>
 12 #include <linux/errno.h>
 13 #include <linux/interrupt.h>
 14 #include <linux/irq.h>
 15 #include <linux/timex.h>
 16 #include <linux/clockchips.h>
 17 
 18 #include <asm/mach/time.h>
 19 #include <mach/hardware.h>
 20 
 21 #define MIN_OSCR_DELTA 2
 22 
 23 static irqreturn_t sa1100_ost0_interrupt(int irq, void *dev_id)
 24 {
 25         struct clock_event_device *c = dev_id;
 26 
 27         /* Disarm the compare/match, signal the event. */
 28         OIER &= ~OIER_E0;
 29         OSSR = OSSR_M0;
 30         c->event_handler(c);
 31 
 32         return IRQ_HANDLED;
 33 }
 34 
 35 static int
 36 sa1100_osmr0_set_next_event(unsigned long delta, struct clock_event_device *c)
 37 {
 38         unsigned long flags, next, oscr;
 39 
 40         raw_local_irq_save(flags);
 41         OIER |= OIER_E0;
 42         next = OSCR + delta;
 43         OSMR0 = next;
 44         oscr = OSCR;
 45         raw_local_irq_restore(flags);
 46 
 47         return (signed)(next - oscr) <= MIN_OSCR_DELTA ? -ETIME : 0;
 48 }
 49 
 50 static void
 51 sa1100_osmr0_set_mode(enum clock_event_mode mode, struct clock_event_device *c)
 52 {
 53         unsigned long flags;
 54 
 55         switch (mode) {
 56         case CLOCK_EVT_MODE_ONESHOT:
 57         case CLOCK_EVT_MODE_UNUSED:
 58         case CLOCK_EVT_MODE_SHUTDOWN:
 59                 raw_local_irq_save(flags);
 60                 OIER &= ~OIER_E0;
 61                 OSSR = OSSR_M0;
 62                 raw_local_irq_restore(flags);
 63                 break;
 64 
 65         case CLOCK_EVT_MODE_RESUME:
 66         case CLOCK_EVT_MODE_PERIODIC:
 67                 break;
 68         }
 69 }
 70 
 71 static struct clock_event_device ckevt_sa1100_osmr0 = {
 72         .name           = "osmr0",
 73         .features       = CLOCK_EVT_FEAT_ONESHOT,
 74         .shift          = 32,
 75         .rating         = 200,
 76         .set_next_event = sa1100_osmr0_set_next_event,
 77         .set_mode       = sa1100_osmr0_set_mode,
 78 };
 79 
 80 static cycle_t sa1100_read_oscr(struct clocksource *s)
 81 {
 82         return OSCR;
 83 }
 84 
 85 static struct clocksource cksrc_sa1100_oscr = {
 86         .name           = "oscr",
 87         .rating         = 200,
 88         .read           = sa1100_read_oscr,
 89         .mask           = CLOCKSOURCE_MASK(32),
 90         .shift          = 20,
 91         .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 92 };
 93 
 94 static struct irqaction sa1100_timer_irq = {
 95         .name           = "ost0",
 96         .flags          = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
 97         .handler        = sa1100_ost0_interrupt,
 98         .dev_id         = &ckevt_sa1100_osmr0,
 99 };
100 
101 static void __init sa1100_timer_init(void)
102 {
103         OIER = 0;               /* disable any timer interrupts */
104         OSSR = 0xf;             /* clear status on all timers */
105 
106         ckevt_sa1100_osmr0.mult =
107                 div_sc(3686400, NSEC_PER_SEC, ckevt_sa1100_osmr0.shift);
108         ckevt_sa1100_osmr0.max_delta_ns =
109                 clockevent_delta2ns(0x7fffffff, &ckevt_sa1100_osmr0);
110         ckevt_sa1100_osmr0.min_delta_ns =
111                 clockevent_delta2ns(MIN_OSCR_DELTA * 2, &ckevt_sa1100_osmr0) + 1;
112         ckevt_sa1100_osmr0.cpumask = cpumask_of(0);
113 
114         cksrc_sa1100_oscr.mult =
115                 clocksource_hz2mult(CLOCK_TICK_RATE, cksrc_sa1100_oscr.shift);
116 
117         setup_irq(IRQ_OST0, &sa1100_timer_irq);
118 
119         clocksource_register(&cksrc_sa1100_oscr);
120         clockevents_register_device(&ckevt_sa1100_osmr0);
121 }
122 
123 #ifdef CONFIG_PM
124 unsigned long osmr[4], oier;
125 
126 static void sa1100_timer_suspend(void)
127 {
128         osmr[0] = OSMR0;
129         osmr[1] = OSMR1;
130         osmr[2] = OSMR2;
131         osmr[3] = OSMR3;
132         oier = OIER;
133 }
134 
135 static void sa1100_timer_resume(void)
136 {
137         OSSR = 0x0f;
138         OSMR0 = osmr[0];
139         OSMR1 = osmr[1];
140         OSMR2 = osmr[2];
141         OSMR3 = osmr[3];
142         OIER = oier;
143 
144         /*
145          * OSMR0 is the system timer: make sure OSCR is sufficiently behind
146          */
147         OSCR = OSMR0 - LATCH;
148 }
149 #else
150 #define sa1100_timer_suspend NULL
151 #define sa1100_timer_resume NULL
152 #endif
153 
154 struct sys_timer sa1100_timer = {
155         .init           = sa1100_timer_init,
156         .suspend        = sa1100_timer_suspend,
157         .resume         = sa1100_timer_resume,
158 };
159 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp