summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/ppcn_60x/tod/cmos.h
blob: 1d544133bc544491874a1829a1a2eeea225fe99d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* Structure map for CMOS on PowerPC Reference Platform */
/*
 *  COPYRIGHT (c) 1998 by Radstone Technology
 *
 *
 * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
 * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU.
 *
 * You are hereby granted permission to use, copy, modify, and distribute
 * this file, provided that this notice, plus the above copyright notice
 * and disclaimer, appears in all copies. Radstone Technology will provide
 * no support for this code.
 *
 */
/* CMOS is the 64 bytes of RAM in the DS1385 chip */
/* The CRC's are computed with x**16+x**12+x**5 + 1 polynomial */
/* The clock is kept in 24 hour BCD mode and should be set to UT(GMT) */

#ifndef _CMOS_
#define _CMOS_

/*
 * Address port is at 0x70, data at 0x71
 */
#define RTC_PORT 0x70

/* Define Realtime Clock register numbers. */

#define RTC_SECOND 0                    /* second of minute [0..59] */
#define RTC_SECOND_ALARM 1              /* seconds to alarm */
#define RTC_MINUTE 2                    /* minute of hour [0..59] */
#define RTC_MINUTE_ALARM 3              /* minutes to alarm */
#define RTC_HOUR 4                      /* hour of day [0..23] */
#define RTC_HOUR_ALARM 5                /* hours to alarm */
#define RTC_DAY_OF_WEEK 6               /* day of week [1..7] */
#define RTC_DAY_OF_MONTH 7              /* day of month [1..31] */
#define RTC_MONTH 8                     /* month of year [1..12] */
#define RTC_YEAR 9                      /* year [00..99] */
#define RTC_CONTROL_REGISTERA 10        /* control register A */
#define RTC_CONTROL_REGISTERB 11        /* control register B */
#define RTC_CONTROL_REGISTERC 12        /* control register C */
#define RTC_CONTROL_REGISTERD 13        /* control register D */
#define RTC_BATTERY_BACKED_UP_RAM 14    /* battery backed up RAM [0..49] */

/* Define Control Register A structure. */
#define DS1385_REGA_UIP		0x80

/* Define Control Register B structure. */
#define DS1385_REGB_SET_TIME	0x80
#define DS1385_REGB_TIM_IRQ_EN	0x40
#define DS1385_REGB_ALM_IRQ_EN	0x20
#define DS1385_REGB_UPD_IRQ_EN	0x10
#define DS1385_REGB_SQR_EN	0x08
#define DS1385_REGB_DATA_M	0x04
#define DS1385_REGB_HOURS_FMT	0x02
#define DS1385_REGB_DLS_EN	0x01

/* Define Control Register C structure. */
#define DS1385_REGC_IRQ_REQ	0x08
#define DS1385_REGC_IRQ_TIME	0x04
#define DS1385_REGC_IRQ_ALM	0x02
#define DS1385_REGC_IRQ_UPD	0x01

/* Define Control Register D structure. */
#define DS1385_REGD_VALID	0x80

typedef struct _CMOS_MAP {
    volatile uint8_t         DateAndTime[14];

    uint8_t         SystemDependentArea1[2];
    uint8_t         SystemDependentArea2[8];
    uint8_t         FeatureByte0[1];
    uint8_t         FeatureByte1[1]; /* 19 = PW Flag;
    attribute = write protect */
    uint8_t         Century[1]; /* century byte in BCD, e.g. 0x19 currently */
    uint8_t         FeatureByte3[1];
    uint8_t         FeatureByte4[1];
    uint8_t         FeatureByte5[1];
    uint8_t         FeatureByte6[1];
    uint8_t         FeatureByte7[1]; /* 1F = Alternate PW Flag;
    attribute = write protect */
    uint8_t         BootPW[14]; /* Power-on password needed to boot system;
    reset value = 0x00000000000000005a5a5a5a5a5a);
    attribute = lock */
    uint8_t         BootCrc[2]; /* CRC on BootPW */
    uint8_t         ConfigPW[14]; /* Configuration Password needed to
    change configuration of system;
    reset value = 0x00000000000000005a5a5a5a5a5a);
    attribute = lock */
    uint8_t         ConfigCrc[2]; /* CRC on ConfigPW */
} CMOS_MAP, *PCMOS_MAP;

#endif /* _CMOS_ */