Add ICH9 detection to flashrom. Straight from the datasheet, untested.
[coreboot.git] / util / flashrom / msys_doc.h
1 /*
2  * This file is part of the flashrom project.
3  *
4  * Copyright (C) 2003 Niki W. Waibel <niki.waibel@gmx.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #ifndef __MSYS_DOC_H__
22 #define __MSYS_DOC_H__ 1
23
24 /* idea from include/linux/mtd/doc2000.h */
25 /* registers with __ should not be read/written directly */
26 #define MSYSTEMS_DOC_R__ChipID                    0x1000
27 #define MSYSTEMS_DOC_R__DOCStatus                 0x1001
28 #define MSYSTEMS_DOC_W_DOCControl                 0x1002
29 #define MSYSTEMS_DOC_R_FloorSelect                0x1003
30 #define MSYSTEMS_DOC_W_FloorSelect                0x1003
31 #define MSYSTEMS_DOC_R__CDSNControl               0x1004
32 #define MSYSTEMS_DOC_W__CDSNControl               0x1004
33 #define MSYSTEMS_DOC_R_CDSNDeviceSelect           0x1005
34 #define MSYSTEMS_DOC_W_CDSNDeviceSelect           0x1005
35 #define MSYSTEMS_DOC_R_ECCConfiguration           0x1006
36 #define MSYSTEMS_DOC_W_ECCConfiguration           0x1006
37 #define MSYSTEMS_DOC_R_CDSNSlowIO                 0x100d
38 #define MSYSTEMS_DOC_W_CDSNSlowIO                 0x100d
39 #define MSYSTEMS_DOC_R_ECCSyndrome0               0x1010
40 #define MSYSTEMS_DOC_R_ECCSyndrome1               0x1011
41 #define MSYSTEMS_DOC_R_ECCSyndrome2               0x1012
42 #define MSYSTEMS_DOC_R_ECCSyndrome3               0x1013
43 #define MSYSTEMS_DOC_R_ECCSyndrome4               0x1014
44 #define MSYSTEMS_DOC_R_ECCSyndrome5               0x1015
45 #define MSYSTEMS_DOC_R_AliasResolution            0x101b
46 #define MSYSTEMS_DOC_W_AliasResolution            0x101b
47 #define MSYSTEMS_DOC_R_ConfigurationInput         0x101c
48 #define MSYSTEMS_DOC_W_ConfigurationInput         0x101c
49 #define MSYSTEMS_DOC_R_ReadPipelineInitialization 0x101d
50 #define MSYSTEMS_DOC_W_WritePipelineTermination   0x101e
51 #define MSYSTEMS_DOC_R_LastDataRead               0x101f
52 #define MSYSTEMS_DOC_W_LastDataRead               0x101f
53 #define MSYSTEMS_DOC_R_NOP                        0x1020
54 #define MSYSTEMS_DOC_W_NOP                        0x1020
55
56 #define MSYSTEMS_DOC_R_IPL_0x0000                 0x0000
57 #define MSYSTEMS_DOC_R_IPL_0x0001                 0x0001
58 #define MSYSTEMS_DOC_R_IPL_0x0002                 0x0002
59 #define MSYSTEMS_DOC_R_IPL_0x0003                 0x0003
60
61 #define MSYSTEMS_DOC_R_CDSNIO_BASE                0x0800
62 #define MSYSTEMS_DOC_W_CDSNIO_BASE                0x0800
63
64 #define doc_read(base,reg) \
65         (*(volatile uint8_t *)(base + MSYSTEMS_DOC_R_##reg))
66
67 #define doc_read_nop(base) \
68         doc_read(base, NOP)
69
70 #define doc_read_2nop(base) \
71         { doc_read_nop(base); doc_read_nop(base); }
72
73 #define doc_read_4nop(base) \
74         { doc_read_2nop(base); doc_read_2nop(base); }
75
76 #define doc_write(data,base,reg) \
77         (*(volatile uint8_t *)(base + MSYSTEMS_DOC_W_##reg)) = data
78
79 #define doc_write_nop(base) \
80         doc_write(0, base, NOP)
81
82 #define doc_write_2nop(base) \
83         { doc_write_nop(base); doc_write_nop(base); }
84
85 #define doc_write_4nop(base) \
86         { doc_write_2nop(base); doc_write_2nop(base); }
87
88 #define _doc_busy(base)   /* 0: ready; -1: busy */ \
89         ( ((doc_read(base, _CDSNControl) & 0x80) >> 7) - 1)
90
91 #define doc_toggle(base)   /* 0, 1, 0, 1, 0, 1, ... if a doc is present */ \
92         ( (doc_read(base, ECCConfiguration) & 0x04) >> 2 )
93
94 int probe_md2802(struct flashchip *flash);
95 int read_md2802(struct flashchip *flash, uint8_t *buf);
96 int erase_md2802(struct flashchip *flash);
97 int write_md2802(struct flashchip *flash, uint8_t *buf);
98
99 #endif                          /* !__MSYS_DOC_H__ */