cleanup
[linux-2.4.git] / include / asm-ppc64 / nvram.h
1 /*
2  * PreP compliant NVRAM access
3  * This needs to be updated for PPC64
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version
8  * 2 of the License, or (at your option) any later version.
9  */
10
11 #ifndef _PPC64_NVRAM_H
12 #define _PPC64_NVRAM_H
13
14 #define NVRW_CNT 0x20
15 #define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */
16 #define NVRAM_BLOCK_LEN 16
17 #define NVRAM_MAX_REQ (2080/NVRAM_BLOCK_LEN)
18 #define NVRAM_MIN_REQ (1056/NVRAM_BLOCK_LEN)
19
20 #define NVRAM_AS0  0x74
21 #define NVRAM_AS1  0x75
22 #define NVRAM_DATA 0x77
23
24
25 /* RTC Offsets */
26
27 #define MOTO_RTC_SECONDS        0x1FF9
28 #define MOTO_RTC_MINUTES        0x1FFA
29 #define MOTO_RTC_HOURS          0x1FFB
30 #define MOTO_RTC_DAY_OF_WEEK    0x1FFC
31 #define MOTO_RTC_DAY_OF_MONTH   0x1FFD
32 #define MOTO_RTC_MONTH          0x1FFE
33 #define MOTO_RTC_YEAR           0x1FFF
34 #define MOTO_RTC_CONTROLA       0x1FF8
35 #define MOTO_RTC_CONTROLB       0x1FF9
36
37 #ifndef BCD_TO_BIN
38 #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
39 #endif
40
41 #ifndef BIN_TO_BCD
42 #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
43 #endif
44
45 #define NVRAM_SIG_SP    0x02    /* support processor */
46 #define NVRAM_SIG_OF    0x50    /* open firmware config */
47 #define NVRAM_SIG_FW    0x51    /* general firmware */
48 #define NVRAM_SIG_HW    0x52    /* hardware (VPD) */
49 #define NVRAM_SIG_SYS   0x70    /* system env vars */
50 #define NVRAM_SIG_CFG   0x71    /* config data */
51 #define NVRAM_SIG_ELOG  0x72    /* error log */
52 #define NVRAM_SIG_VEND  0x7e    /* vendor defined */
53 #define NVRAM_SIG_FREE  0x7f    /* Free space */
54 #define NVRAM_SIG_OS    0xa0    /* OS defined */
55
56 /* If change this size, then change the size of NVRAM_HEADER_LEN */
57 struct nvram_header {
58         unsigned char signature;
59         unsigned char checksum;
60         unsigned short length;
61         char name[12];
62 };
63
64 struct nvram_partition {
65         struct list_head partition;
66         struct nvram_header header;
67         unsigned int index;
68 };
69
70
71 ssize_t read_nvram(char *buf, size_t count, loff_t *index);
72 ssize_t write_nvram(char *buf, size_t count, loff_t *index);
73 int write_error_log_nvram(char * buff, int length, unsigned int err_type);
74 int read_error_log_nvram(char * buff, int length, unsigned int * err_type);
75 int clear_error_log_nvram(void);
76 void print_nvram_partitions(char * label);
77
78 #endif /* _PPC64_NVRAM_H */