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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [m68k/] [sun3x/] [time.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *  linux/arch/m68k/sun3x/time.c
3
 *
4
 *  Sun3x-specific time handling
5
 */
6
 
7
#include <linux/types.h>
8
#include <linux/kd.h>
9
#include <linux/init.h>
10
#include <linux/sched.h>
11
#include <linux/kernel_stat.h>
12
#include <linux/interrupt.h>
13
#include <linux/rtc.h>
14
 
15
#include <asm/irq.h>
16
#include <asm/io.h>
17
#include <asm/system.h>
18
#include <asm/traps.h>
19
#include <asm/sun3x.h>
20
#include <asm/sun3ints.h>
21
#include <asm/rtc.h>
22
 
23
#include "time.h"
24
 
25
#define M_CONTROL 0xf8
26
#define M_SEC     0xf9
27
#define M_MIN     0xfa
28
#define M_HOUR    0xfb
29
#define M_DAY     0xfc
30
#define M_DATE    0xfd
31
#define M_MONTH   0xfe
32
#define M_YEAR    0xff
33
 
34
#define C_WRITE   0x80
35
#define C_READ    0x40
36
#define C_SIGN    0x20
37
#define C_CALIB   0x1f
38
 
39
#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10)
40
#define BIN_TO_BCD(val) (((val/10) << 4) | (val % 10))
41
 
42
/* Read the Mostek */
43
void sun3x_gettod (int *yearp, int *monp, int *dayp,
44
                   int *hourp, int *minp, int *secp)
45
{
46
    volatile unsigned char *eeprom = (unsigned char *)SUN3X_EEPROM;
47
 
48
    /* Stop updates */
49
    *(eeprom + M_CONTROL) |= C_READ;
50
 
51
    /* Read values */
52
    *yearp = BCD_TO_BIN(*(eeprom + M_YEAR));
53
    *monp  = BCD_TO_BIN(*(eeprom + M_MONTH)) +1;
54
    *dayp  = BCD_TO_BIN(*(eeprom + M_DATE));
55
    *hourp = BCD_TO_BIN(*(eeprom + M_HOUR));
56
    *minp  = BCD_TO_BIN(*(eeprom + M_MIN));
57
    *secp  = BCD_TO_BIN(*(eeprom + M_SEC));
58
 
59
    /* Restart updates */
60
    *(eeprom + M_CONTROL) &= ~C_READ;
61
}
62
 
63
int sun3x_hwclk(int set, struct rtc_time *t)
64
{
65
        volatile struct mostek_dt *h =
66
                (struct mostek_dt *)(SUN3X_EEPROM+M_CONTROL);
67
        unsigned long flags;
68
 
69
        save_and_cli(flags);
70
 
71
        if(set) {
72
                h->csr |= C_WRITE;
73
                h->sec = BIN_TO_BCD(t->tm_sec);
74
                h->min = BIN_TO_BCD(t->tm_min);
75
                h->hour = BIN_TO_BCD(t->tm_hour);
76
                h->wday = BIN_TO_BCD(t->tm_wday);
77
                h->mday = BIN_TO_BCD(t->tm_mday);
78
                h->month = BIN_TO_BCD(t->tm_mon);
79
                h->year = BIN_TO_BCD(t->tm_year);
80
                h->csr &= ~C_WRITE;
81
        } else {
82
                h->csr |= C_READ;
83
                t->tm_sec = BCD_TO_BIN(h->sec);
84
                t->tm_min = BCD_TO_BIN(h->min);
85
                t->tm_hour = BCD_TO_BIN(h->hour);
86
                t->tm_wday = BCD_TO_BIN(h->wday);
87
                t->tm_mday = BCD_TO_BIN(h->mday);
88
                t->tm_mon = BCD_TO_BIN(h->month);
89
                t->tm_year = BCD_TO_BIN(h->year);
90
                h->csr &= ~C_READ;
91
        }
92
 
93
        restore_flags(flags);
94
 
95
        return 0;
96
}
97
/* Not much we can do here */
98
unsigned long sun3x_gettimeoffset (void)
99
{
100
    return 0L;
101
}
102
 
103
#if 0
104
static void sun3x_timer_tick(int irq, void *dev_id, struct pt_regs *regs)
105
{
106
    void (*vector)(int, void *, struct pt_regs *) = dev_id;
107
 
108
    /* Clear the pending interrupt - pulse the enable line low */
109
    disable_irq(5);
110
    enable_irq(5);
111
 
112
    vector(irq, NULL, regs);
113
}
114
#endif
115
 
116
void __init sun3x_sched_init(void (*vector)(int, void *, struct pt_regs *))
117
{
118
 
119
        sun3_disable_interrupts();
120
 
121
 
122
    /* Pulse enable low to get the clock started */
123
        sun3_disable_irq(5);
124
        sun3_enable_irq(5);
125
        sun3_enable_interrupts();
126
}

powered by: WebSVN 2.1.0

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