2 * U-boot - flash-defines.h
4 * Copyright (c) 2005 blackfin.uclinux.org
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #ifndef __FLASHDEFINES_H__
29 #define __FLASHDEFINES_H__
33 #define V_ULONG(a) (*(volatile unsigned long *)( a ))
34 #define V_BYTE(a) (*(volatile unsigned char *)( a ))
37 #define BUFFER_SIZE 0x80000
47 #define FLASH_START_L 0x0000
48 #define FLASH_START_H 0x2000
49 #define FLASH_TOT_SECT 40
50 #define FLASH_SIZE 0x220000
51 #define FLASH_MAN_ST 2
52 #define CFG_FLASH0_BASE 0x20000000
53 #define RESET_VAL 0xF0
56 asm("#define FLASH_START_L 0x0000");
57 asm("#define FLASH_START_H 0x2000");
59 flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
62 int poll_toggle_bit(long lOffset);
63 void reset_flash(void);
64 int erase_flash(void);
65 int erase_block_flash(int,unsigned long);
66 void unlock_flash(long lOffset);
67 int write_data(long lStart, long lCount, long lStride, int *pnData);
68 int FillData(long lStart, long lCount, long lStride, int *pnData);
69 int read_data(long lStart, long lCount, long lStride, int *pnData);
70 int read_flash(long nOffset, int *pnValue);
71 int write_flash(long nOffset, int nValue);
72 void get_sector_number(long lOffset, int *pnSector);
73 int GetSectorProtectionStatus(flash_info_t * info, int nSector);
74 int GetOffset(int nBlock);
75 int AFP_NumSectors = 40;
76 long AFP_SectorSize1 = 0x10000;
77 int AFP_SectorSize2 = 0x4000;
79 #define WRITESEQ1 0x0AAA
80 #define WRITESEQ2 0x0554
81 #define WRITESEQ3 0x0AAA
82 #define WRITESEQ4 0x0AAA
83 #define WRITESEQ5 0x0554
84 #define WRITESEQ6 0x0AAA
85 #define WRITEDATA1 0xaa
86 #define WRITEDATA2 0x55
87 #define WRITEDATA3 0x80
88 #define WRITEDATA4 0xaa
89 #define WRITEDATA5 0x55
90 #define WRITEDATA6 0x10
91 #define PriFlashABegin 0
92 #define SecFlashABegin 32
93 #define SecFlashBBegin 36
94 #define PriFlashAOff 0x0
95 #define PriFlashBOff 0x100000
96 #define SecFlashAOff 0x200000
97 #define SecFlashBOff 0x280000
98 #define INVALIDLOCNSTART 0x20270000
99 #define INVALIDLOCNEND 0x20280000
100 #define BlockEraseVal 0x30
101 #define UNLOCKDATA1 0xaa
102 #define UNLOCKDATA2 0x55
103 #define UNLOCKDATA3 0xa0
104 #define GETCODEDATA1 0xaa
105 #define GETCODEDATA2 0x55
106 #define GETCODEDATA3 0x90
107 #define SecFlashASec1Off 0x200000
108 #define SecFlashASec2Off 0x204000
109 #define SecFlashASec3Off 0x206000
110 #define SecFlashASec4Off 0x208000
111 #define SecFlashAEndOff 0x210000
112 #define SecFlashBSec1Off 0x280000
113 #define SecFlashBSec2Off 0x284000
114 #define SecFlashBSec3Off 0x286000
115 #define SecFlashBSec4Off 0x288000
116 #define SecFlashBEndOff 0x290000
127 #define FLASH_SUCCESS 0
128 #define FLASH_FAIL -1