Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 22 | #ifndef __MSYS_DOC_H__ |
| 23 | #define __MSYS_DOC_H__ 1 |
| 24 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 25 | /* idea from include/linux/mtd/doc2000.h */ |
| 26 | /* registers with __ should not be read/written directly */ |
| 27 | #define MSYSTEMS_DOC_R__ChipID 0x1000 |
| 28 | #define MSYSTEMS_DOC_R__DOCStatus 0x1001 |
| 29 | #define MSYSTEMS_DOC_W_DOCControl 0x1002 |
| 30 | #define MSYSTEMS_DOC_R_FloorSelect 0x1003 |
| 31 | #define MSYSTEMS_DOC_W_FloorSelect 0x1003 |
| 32 | #define MSYSTEMS_DOC_R__CDSNControl 0x1004 |
| 33 | #define MSYSTEMS_DOC_W__CDSNControl 0x1004 |
| 34 | #define MSYSTEMS_DOC_R_CDSNDeviceSelect 0x1005 |
| 35 | #define MSYSTEMS_DOC_W_CDSNDeviceSelect 0x1005 |
| 36 | #define MSYSTEMS_DOC_R_ECCConfiguration 0x1006 |
| 37 | #define MSYSTEMS_DOC_W_ECCConfiguration 0x1006 |
| 38 | #define MSYSTEMS_DOC_R_CDSNSlowIO 0x100d |
| 39 | #define MSYSTEMS_DOC_W_CDSNSlowIO 0x100d |
| 40 | #define MSYSTEMS_DOC_R_ECCSyndrome0 0x1010 |
| 41 | #define MSYSTEMS_DOC_R_ECCSyndrome1 0x1011 |
| 42 | #define MSYSTEMS_DOC_R_ECCSyndrome2 0x1012 |
| 43 | #define MSYSTEMS_DOC_R_ECCSyndrome3 0x1013 |
| 44 | #define MSYSTEMS_DOC_R_ECCSyndrome4 0x1014 |
| 45 | #define MSYSTEMS_DOC_R_ECCSyndrome5 0x1015 |
| 46 | #define MSYSTEMS_DOC_R_AliasResolution 0x101b |
| 47 | #define MSYSTEMS_DOC_W_AliasResolution 0x101b |
| 48 | #define MSYSTEMS_DOC_R_ConfigurationInput 0x101c |
| 49 | #define MSYSTEMS_DOC_W_ConfigurationInput 0x101c |
| 50 | #define MSYSTEMS_DOC_R_ReadPipelineInitialization 0x101d |
| 51 | #define MSYSTEMS_DOC_W_WritePipelineTermination 0x101e |
| 52 | #define MSYSTEMS_DOC_R_LastDataRead 0x101f |
| 53 | #define MSYSTEMS_DOC_W_LastDataRead 0x101f |
| 54 | #define MSYSTEMS_DOC_R_NOP 0x1020 |
| 55 | #define MSYSTEMS_DOC_W_NOP 0x1020 |
| 56 | |
| 57 | #define MSYSTEMS_DOC_R_IPL_0x0000 0x0000 |
| 58 | #define MSYSTEMS_DOC_R_IPL_0x0001 0x0001 |
| 59 | #define MSYSTEMS_DOC_R_IPL_0x0002 0x0002 |
| 60 | #define MSYSTEMS_DOC_R_IPL_0x0003 0x0003 |
| 61 | |
| 62 | #define MSYSTEMS_DOC_R_CDSNIO_BASE 0x0800 |
| 63 | #define MSYSTEMS_DOC_W_CDSNIO_BASE 0x0800 |
| 64 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 65 | #define doc_read(base,reg) \ |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 66 | (*(volatile uint8_t *)(base + MSYSTEMS_DOC_R_##reg)) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 67 | |
| 68 | #define doc_read_nop(base) \ |
| 69 | doc_read(base, NOP) |
| 70 | |
| 71 | #define doc_read_2nop(base) \ |
| 72 | { doc_read_nop(base); doc_read_nop(base); } |
| 73 | |
| 74 | #define doc_read_4nop(base) \ |
| 75 | { doc_read_2nop(base); doc_read_2nop(base); } |
| 76 | |
| 77 | #define doc_write(data,base,reg) \ |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 78 | (*(volatile uint8_t *)(base + MSYSTEMS_DOC_W_##reg)) = data |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 79 | |
| 80 | #define doc_write_nop(base) \ |
| 81 | doc_write(0, base, NOP) |
| 82 | |
| 83 | #define doc_write_2nop(base) \ |
| 84 | { doc_write_nop(base); doc_write_nop(base); } |
| 85 | |
| 86 | #define doc_write_4nop(base) \ |
| 87 | { doc_write_2nop(base); doc_write_2nop(base); } |
| 88 | |
| 89 | #define _doc_busy(base) /* 0: ready; -1: busy */ \ |
| 90 | ( ((doc_read(base, _CDSNControl) & 0x80) >> 7) - 1) |
| 91 | |
| 92 | #define doc_toggle(base) /* 0, 1, 0, 1, 0, 1, ... if a doc is present */ \ |
| 93 | ( (doc_read(base, ECCConfiguration) & 0x04) >> 2 ) |
| 94 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 95 | extern int probe_md2802(struct flashchip *flash); |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 96 | extern int read_md2802(struct flashchip *flash, uint8_t *buf); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 97 | extern int erase_md2802(struct flashchip *flash); |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 98 | extern int write_md2802(struct flashchip *flash, uint8_t *buf); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 99 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 100 | #endif /* !__MSYS_DOC_H__ */ |