OpenCores
URL https://opencores.org/ocsvn/aor3000/aor3000/trunk

Subversion Repositories aor3000

[/] [aor3000/] [trunk/] [linux/] [arch/] [mips/] [aor3000/] [time.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/*
2
 * This file is subject to the terms and conditions of the GNU General Public
3
 * License.  See the file "COPYING" in the main directory of this archive
4
 * for more details.
5
 *
6
 * Copyright (C) 2014 Aleksander Osman
7
 */
8
 
9
#include <linux/interrupt.h>
10
#include <linux/irq.h>
11
#include <linux/time.h>
12
#include <linux/init.h>
13
#include <linux/clockchips.h>
14
 
15
#include <asm/time.h>
16
 
17
#define SIMPLE_TIMER_IRQ_NUMBER     2
18
#define SIMPLE_TIMER_ACK_ADDRESS    0xBFFFFFF8
19
 
20
static void simple_timer_set_mode(enum clock_event_mode mode,
21
              struct clock_event_device *evt)
22
{
23
    switch (mode) {
24
    case CLOCK_EVT_MODE_PERIODIC:
25
        break;
26
    case CLOCK_EVT_MODE_ONESHOT:
27
    case CLOCK_EVT_MODE_UNUSED:
28
    case CLOCK_EVT_MODE_SHUTDOWN:
29
        break;
30
    case CLOCK_EVT_MODE_RESUME:
31
        break;
32
    }
33
}
34
 
35
static struct clock_event_device simple_clockevent_device = {
36
    .name       = "simple-timer",
37
    .features   = CLOCK_EVT_FEAT_PERIODIC,
38
 
39
    /* .set_mode, .mult, .shift, .max_delta_ns and .min_delta_ns left uninitialized */
40
 
41
    .rating     = 300,
42
    .irq        = SIMPLE_TIMER_IRQ_NUMBER,
43
    .cpumask    = cpu_all_mask,
44
    .set_mode   = simple_timer_set_mode,
45
};
46
 
47
static irqreturn_t simple_timer_interrupt(int irq, void *dev_id)
48
{
49
    struct clock_event_device *cd = dev_id;
50
 
51
    *(volatile u8 *)SIMPLE_TIMER_ACK_ADDRESS = 0;
52
 
53
    cd->event_handler(cd);
54
 
55
    return IRQ_HANDLED;
56
}
57
 
58
static struct irqaction simple_timer_irqaction = {
59
    .handler    = simple_timer_interrupt,
60
    .flags      = IRQF_PERCPU | IRQF_TIMER,
61
    .name       = "simple-timer",
62
};
63
 
64
void __init plat_time_init(void)
65
{
66
    struct clock_event_device *cd = &simple_clockevent_device;
67
    struct irqaction *action = &simple_timer_irqaction;
68
 
69
    clockevent_set_clock(cd, 100);
70
 
71
    clockevents_register_device(cd);
72
    action->dev_id = cd;
73
    setup_irq(SIMPLE_TIMER_IRQ_NUMBER, &simple_timer_irqaction);
74
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.