summaryrefslogtreecommitdiff
path: root/board/ezkit533/flash-defines.h
blob: 8f9dff5de815742ec611cc9a556d9a442257b274 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * U-boot - flash-defines.h
 *
 * Copyright (c) 2005 blackfin.uclinux.org
 *
 * (C) Copyright 2000-2004
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#ifndef __FLASHDEFINES_H__
#define __FLASHDEFINES_H__

#include <common.h>

#define V_ULONG(a)		(*(volatile unsigned long *)( a ))
#define V_BYTE(a)		(*(volatile unsigned char *)( a ))
#define TRUE			0x1
#define FALSE			0x0
#define BUFFER_SIZE		0x80000
#define NO_COMMAND		0
#define GET_CODES		1
#define RESET			2
#define WRITE			3
#define FILL			4
#define ERASE_ALL		5
#define ERASE_SECT		6
#define READ			7
#define GET_SECTNUM		8
#define FLASH_START_L 		0x0000
#define FLASH_START_H 		0x2000
#define FLASH_TOT_SECT		40
#define FLASH_SIZE 		0x220000
#define FLASH_MAN_ST 		2
#define CFG_FLASH0_BASE		0x20000000
#define RESET_VAL		0xF0


asm("#define FLASH_START_L 0x0000");
asm("#define FLASH_START_H 0x2000");

flash_info_t flash_info[CFG_MAX_FLASH_BANKS];

int get_codes(void);
int poll_toggle_bit(long lOffset);
void reset_flash(void);
int erase_flash(void);
int erase_block_flash(int,unsigned long);
void unlock_flash(long lOffset);
int write_data(long lStart, long lCount, long lStride, int *pnData);
int FillData(long lStart, long lCount, long lStride, int *pnData);
int read_data(long lStart, long lCount, long lStride, int *pnData);
int read_flash(long nOffset, int *pnValue);
int write_flash(long nOffset, int nValue);
void get_sector_number(long lOffset, int *pnSector);
int GetSectorProtectionStatus(flash_info_t * info, int nSector);
int GetOffset(int nBlock);
int AFP_NumSectors = 40;
long AFP_SectorSize1 = 0x10000;
int AFP_SectorSize2 = 0x4000;

#define WRITESEQ1		0x0AAA
#define WRITESEQ2		0x0554
#define WRITESEQ3		0x0AAA
#define WRITESEQ4		0x0AAA
#define WRITESEQ5		0x0554
#define WRITESEQ6		0x0AAA
#define WRITEDATA1		0xaa
#define WRITEDATA2		0x55
#define WRITEDATA3		0x80
#define WRITEDATA4		0xaa
#define WRITEDATA5		0x55
#define WRITEDATA6		0x10
#define PriFlashABegin		0
#define SecFlashABegin		32
#define SecFlashBBegin		36
#define PriFlashAOff		0x0
#define PriFlashBOff		0x100000
#define SecFlashAOff		0x200000
#define SecFlashBOff		0x280000
#define INVALIDLOCNSTART	0x20270000
#define INVALIDLOCNEND		0x20280000
#define BlockEraseVal		0x30
#define UNLOCKDATA1		0xaa
#define UNLOCKDATA2		0x55
#define UNLOCKDATA3		0xa0
#define GETCODEDATA1		0xaa
#define GETCODEDATA2		0x55
#define GETCODEDATA3		0x90
#define SecFlashASec1Off	0x200000
#define SecFlashASec2Off	0x204000
#define SecFlashASec3Off	0x206000
#define SecFlashASec4Off	0x208000
#define SecFlashAEndOff		0x210000
#define SecFlashBSec1Off	0x280000
#define SecFlashBSec2Off	0x284000
#define SecFlashBSec3Off	0x286000
#define SecFlashBSec4Off	0x288000
#define SecFlashBEndOff		0x290000

#define SECT32			32
#define SECT33			33
#define SECT34			34
#define SECT35			35
#define SECT36			36
#define SECT37			37
#define SECT38			38
#define SECT39			39

#define FLASH_SUCCESS	0
#define FLASH_FAIL	-1

#endif