Statistics
| Branch: | Revision:

scoutos / prex-0.9.0 / bsp / drv / dev / rtc / pl030.c @ 03e9c04a

History | View | Annotate | Download (2.61 KB)

1
/*-
2
 * Copyright (c) 2005-2009, Kohsuke Ohtani
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. Neither the name of the author nor the names of any co-contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29

    
30
/*
31
 * pl030.c - ARM PrimeCell PL030 RTC
32
 */
33

    
34
#include <sys/time.h>
35
#include <sys/ioctl.h>
36

    
37
#include <driver.h>
38
#include <rtc.h>
39

    
40
#define RTC_BASE        CONFIG_PL030_BASE
41

    
42
#define RTC_DR                (RTC_BASE + 0x00)
43
#define RTC_MR                (RTC_BASE + 0x04)
44
#define RTC_STAT        (RTC_BASE + 0x08)
45
#define RTC_EOI                (RTC_BASE + 0x08)
46
#define RTC_LR                (RTC_BASE + 0x0c)
47
#define RTC_CR                (RTC_BASE + 0x10)
48

    
49
static int        pl030_init(struct driver *);
50
static int        pl030_gettime(void *, struct timeval *);
51
static int        pl030_settime(void *, struct timeval *);
52

    
53

    
54
struct driver pl030_driver = {
55
        /* name */        "pl030",
56
        /* devops */        NULL,
57
        /* devsz */        0,
58
        /* flags */        0,
59
        /* probe */        NULL,
60
        /* init */        pl030_init,
61
        /* shutdown */        NULL,
62
};
63

    
64
struct rtc_ops pl030_ops = {
65
        /* gettime */        pl030_gettime,
66
        /* settime */        pl030_settime,
67
};
68

    
69
static int
70
pl030_gettime(void *aux, struct timeval *tv)
71
{
72

    
73
        tv->tv_usec = 0;
74
        tv->tv_sec = bus_read_32(RTC_DR);
75
        printf("******* sec=%d\n", tv->tv_sec);
76
        return 0;
77
}
78

    
79
static int
80
pl030_settime(void *aux, struct timeval *ts)
81
{
82
        return 0;
83
}
84

    
85
static int
86
pl030_init(struct driver *self)
87
{
88

    
89
        rtc_attach(&pl030_ops, NULL);
90
        return 0;
91
}