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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-sparc/] [mostek.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/* $Id: mostek.h,v 1.1 2005-12-20 11:32:11 jcastillo Exp $
2
 * mostek.h:  Describes the various Mostek time of day clock registers.
3
 *
4
 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5
 */
6
#ifndef _SPARC_MOSTEK_H
7
#define _SPARC_MOSTEK_H
8
 
9
#include <asm/idprom.h>
10
 
11
/* First the Mostek 48t02 clock chip.  The registers other than the
12
 * control register are in binary coded decimal.
13
 */
14
struct mostek48t02 {
15
        char eeprom[2008];            /* This is the eeprom, don't touch! */
16
        struct idp_struct idprom;     /* The idprom lives here. */
17
        volatile unsigned char creg;  /* Control register */
18
        volatile unsigned char sec;   /* Seconds (0-59) */
19
        volatile unsigned char min;   /* Minutes (0-59) */
20
        volatile unsigned char hour;  /* Hour (0-23) */
21
        volatile unsigned char dow;   /* Day of the week (1-7) */
22
        volatile unsigned char dom;   /* Day of the month (1-31) */
23
        volatile unsigned char mnth;  /* Month of year (1-12) */
24
        volatile unsigned char yr;    /* Year (0-99) */
25
};
26
 
27
extern struct mostek48t02 *mstk48t02_regs;
28
 
29
/* Control register values. */
30
#define MSTK_CREG_WRITE    0x80   /* Must set this before placing values. */
31
#define MSTK_CREG_READ     0x40   /* Stop the clock, I want to fetch values. */
32
#define MSTK_CREG_SIGN     0x20   /* Grrr... what's this??? */
33
 
34
#define MSTK_YR_ZERO       1968   /* If year reg has zero, it is 1968 */
35
#define MSTK_CVT_YEAR(yr)  ((yr) + MSTK_YR_ZERO)
36
 
37
/* Fun with masks. */
38
#define MSTK_SEC_MASK      0x7f
39
#define MSTK_MIN_MASK      0x7f
40
#define MSTK_HOUR_MASK     0x3f
41
#define MSTK_DOW_MASK      0x07
42
#define MSTK_DOM_MASK      0x3f
43
#define MSTK_MNTH_MASK     0x1f
44
#define MSTK_YR_MASK       0xff
45
 
46
/* Conversion routines. */
47
#define MSTK_REGVAL_TO_DECIMAL(x)  (((x) & 0xf) + 0xa * ((x) >> 0x4))
48
#define MSTK_DECIMAL_TO_REGVAL(x)  ((((x) / 0xa) << 0x4) + ((x) % 0xa))
49
 
50
/* Macros to make register access easier on our fingers. These give you
51
 * the decimal value of the register requested if applicable.  You pass
52
 * the a pointer to a 'struct mostek48t02'.
53
 */
54
#define MSTK_REG_CREG(ptr)  (ptr->creg)
55
#define MSTK_REG_SEC(ptr)   (MSTK_REGVAL_TO_DECIMAL((ptr->sec & MSTK_SEC_MASK)))
56
#define MSTK_REG_MIN(ptr)   (MSTK_REGVAL_TO_DECIMAL((ptr->min & MSTK_MIN_MASK)))
57
#define MSTK_REG_HOUR(ptr)  (MSTK_REGVAL_TO_DECIMAL((ptr->hour & MSTK_HOUR_MASK)))
58
#define MSTK_REG_DOW(ptr)   (MSTK_REGVAL_TO_DECIMAL((ptr->dow & MSTK_DOW_MASK)))
59
#define MSTK_REG_DOM(ptr)   (MSTK_REGVAL_TO_DECIMAL((ptr->dom & MSTK_DOM_MASK)))
60
#define MSTK_REG_MNTH(ptr)  (MSTK_REGVAL_TO_DECIMAL((ptr->mnth & MSTK_MNTH_MASK)))
61
#define MSTK_REG_YR(ptr)    (MSTK_REGVAL_TO_DECIMAL((ptr->yr & MSTK_YR_MASK)))
62
 
63
/* The Mostek 48t02 clock chip.  Found on Sun4m's I think.  It has the
64
 * same (basically) layout of the 48t02 chip.
65
 */
66
struct mostek48t08 {
67
        char offset[6*1024];         /* Magic things may be here, who knows? */
68
        struct mostek48t02 regs;     /* Here is what we are interested in.   */
69
};
70
extern struct mostek48t08 *mstk48t08_regs;
71
 
72
enum sparc_clock_type { MSTK48T02, MSTK48T08, MSTK_INVALID };
73
extern enum sparc_clock_type sp_clock_typ;
74
 
75
#endif /* !(_SPARC_MOSTEK_H) */

powered by: WebSVN 2.1.0

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