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