1
2
3
4
5 #ifndef _SPARC_MOSTEK_H
6 #define _SPARC_MOSTEK_H
7
8 #include <asm/idprom.h>
9
10
11
12
13 struct mostek48t02 {
14 char eeprom[2008];
15 struct idp_struct idprom;
16 volatile unsigned char creg;
17 volatile unsigned char sec;
18 volatile unsigned char min;
19 volatile unsigned char hour;
20 volatile unsigned char dow;
21 volatile unsigned char dom;
22 volatile unsigned char mnth;
23 volatile unsigned char yr;
24 };
25
26 extern struct mostek48t02 *mstk48t02_regs;
27
28
29 #define MSTK_CREG_WRITE 0x80
30 #define MSTK_CREG_READ 0x40
31 #define MSTK_CREG_SIGN 0x20
32
33 #define MSTK_YR_ZERO 1968
34 #define MSTK_CVT_YEAR(yr) ((yr) + MSTK_YR_ZERO)
35
36
37 #define MSTK_SEC_MASK 0x7f
38 #define MSTK_MIN_MASK 0x7f
39 #define MSTK_HOUR_MASK 0x3f
40 #define MSTK_DOW_MASK 0x07
41 #define MSTK_DOM_MASK 0x3f
42 #define MSTK_MNTH_MASK 0x1f
43 #define MSTK_YR_MASK 0xff
44
45
46 #define MSTK_REGVAL_TO_DECIMAL(x) (((x) & 0xf) + 0xa * ((x) >> 0x4))
47 #define MSTK_DECIMAL_TO_REGVAL(x) ((((x) / 0xa) << 0x4) + ((x) % 0xa))
48
49
50
51
52
53 #define MSTK_REG_CREG(ptr) (ptr->creg)
54 #define MSTK_REG_SEC(ptr) (MSTK_REGVAL_TO_DECIMAL((ptr->sec & MSTK_SEC_MASK)))
55 #define MSTK_REG_MIN(ptr) (MSTK_REGVAL_TO_DECIMAL((ptr->min & MSTK_MIN_MASK)))
56 #define MSTK_REG_HOUR(ptr) (MSTK_REGVAL_TO_DECIMAL((ptr->hour & MSTK_HOUR_MASK)))
57 #define MSTK_REG_DOW(ptr) (MSTK_REGVAL_TO_DECIMAL((ptr->dow & MSTK_DOW_MASK)))
58 #define MSTK_REG_DOM(ptr) (MSTK_REGVAL_TO_DECIMAL((ptr->dom & MSTK_DOM_MASK)))
59 #define MSTK_REG_MNTH(ptr) (MSTK_REGVAL_TO_DECIMAL((ptr->mnth & MSTK_MNTH_MASK)))
60 #define MSTK_REG_YR(ptr) (MSTK_REGVAL_TO_DECIMAL((ptr->yr & MSTK_YR_MASK)))
61
62
63
64
65 struct mostek48t08 {
66 char offset[6*1024];
67 struct mostek48t02 regs;
68 };
69 extern struct mostek48t08 *mstk48t08_regs;
70
71 enum sparc_clock_type { MSTK48T02, MSTK48T08, MSTK_INVALID };
72 extern enum sparc_clock_type sp_clock_typ;
73
74 #endif