blob: caa7807573570a7dbe30c8ea84d352be6ef22ccd [file] [log] [blame]
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001/*
Uwe Hermannd1107642007-08-29 17:52:32 +00002 * This file is part of the flashrom project.
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00003 *
Uwe Hermannd22a1d42007-09-09 20:21:05 +00004 * Copyright (C) 2003 Niki W. Waibel <niki.waibel@gmx.net>
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00005 *
Uwe Hermannd1107642007-08-29 17:52:32 +00006 * 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.
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000010 *
Uwe Hermannd1107642007-08-29 17:52:32 +000011 * 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.
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000015 *
Uwe Hermannd1107642007-08-29 17:52:32 +000016 * 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
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000019 */
20
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000021#ifndef __MSYS_DOC_H__
22#define __MSYS_DOC_H__ 1
23
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000024/* 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
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000064#define doc_read(base,reg) \
Ollie Lho184a4042005-11-26 21:55:36 +000065 (*(volatile uint8_t *)(base + MSYSTEMS_DOC_R_##reg))
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000066
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) \
Ollie Lho184a4042005-11-26 21:55:36 +000077 (*(volatile uint8_t *)(base + MSYSTEMS_DOC_W_##reg)) = data
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000078
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
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000094extern int probe_md2802(struct flashchip *flash);
Ollie Lho184a4042005-11-26 21:55:36 +000095extern int read_md2802(struct flashchip *flash, uint8_t *buf);
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000096extern int erase_md2802(struct flashchip *flash);
Ollie Lho184a4042005-11-26 21:55:36 +000097extern int write_md2802(struct flashchip *flash, uint8_t *buf);
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000098
Ollie Lho761bf1b2004-03-20 16:46:10 +000099#endif /* !__MSYS_DOC_H__ */