blob: 1fa7a10bdac7a9c275280f956a80edbb1a7376f9 [file] [log] [blame]
Aubrey Li26bf7de2007-03-19 01:24:52 +08001/*
2 * U-boot - flash-defines.h
3 *
Aubrey Li155fd762007-04-05 18:31:18 +08004 * Copyright (c) 2005-2007 Analog Devices Inc.
Aubrey Li26bf7de2007-03-19 01:24:52 +08005 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
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.
16 *
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.
21 *
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
Aubrey Li155fd762007-04-05 18:31:18 +080024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
25 * MA 02110-1301 USA
Aubrey Li26bf7de2007-03-19 01:24:52 +080026 */
27
28#ifndef __FLASHDEFINES_H__
29#define __FLASHDEFINES_H__
30
31#include <common.h>
32
33#define V_ULONG(a) (*(volatile unsigned long *)( a ))
34#define V_BYTE(a) (*(volatile unsigned char *)( a ))
35#define TRUE 0x1
36#define FALSE 0x0
37#define BUFFER_SIZE 0x80000
38#define NO_COMMAND 0
39#define GET_CODES 1
40#define RESET 2
41#define WRITE 3
42#define FILL 4
43#define ERASE_ALL 5
44#define ERASE_SECT 6
45#define READ 7
46#define GET_SECTNUM 8
Wolfgang Denk1636d1c2007-06-22 23:59:00 +020047#define FLASH_START_L 0x0000
48#define FLASH_START_H 0x2000
49#define FLASH_MAN_ST 2
Aubrey Li26bf7de2007-03-19 01:24:52 +080050#define RESET_VAL 0xF0
51
52flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
53
54int get_codes(void);
55int poll_toggle_bit(long lOffset);
56void reset_flash(void);
57int erase_flash(void);
58int erase_block_flash(int);
59void unlock_flash(long lOffset);
60int write_data(long lStart, long lCount, uchar * pnData);
61int read_flash(long nOffset, int *pnValue);
62int write_flash(long nOffset, int nValue);
63void get_sector_number(long lOffset, int *pnSector);
64int GetSectorProtectionStatus(flash_info_t * info, int nSector);
65int GetOffset(int nBlock);
66int AFP_NumSectors = 71;
67long AFP_SectorSize2 = 0x10000;
68int AFP_SectorSize1 = 0x2000;
69
70#define NUM_SECTORS 71
71
72#define WRITESEQ1 0x0AAA
73#define WRITESEQ2 0x0554
74#define WRITESEQ3 0x0AAA
75#define WRITESEQ4 0x0AAA
76#define WRITESEQ5 0x0554
77#define WRITESEQ6 0x0AAA
78#define WRITEDATA1 0xaa
79#define WRITEDATA2 0x55
80#define WRITEDATA3 0x80
81#define WRITEDATA4 0xaa
82#define WRITEDATA5 0x55
83#define WRITEDATA6 0x10
84#define PriFlashABegin 0
85#define SecFlashABegin 8
86#define SecFlashBBegin 36
87#define PriFlashAOff 0x0
88#define PriFlashBOff 0x100000
89#define SecFlashAOff 0x10000
90#define SecFlashBOff 0x280000
91#define INVALIDLOCNSTART 0x20270000
92#define INVALIDLOCNEND 0x20280000
93#define BlockEraseVal 0x30
94#define UNLOCKDATA1 0xaa
95#define UNLOCKDATA2 0x55
96#define UNLOCKDATA3 0xa0
97#define GETCODEDATA1 0xaa
98#define GETCODEDATA2 0x55
99#define GETCODEDATA3 0x90
100#define SecFlashASec1Off 0x200000
101#define SecFlashASec2Off 0x204000
102#define SecFlashASec3Off 0x206000
103#define SecFlashASec4Off 0x208000
104#define SecFlashAEndOff 0x210000
105#define SecFlashBSec1Off 0x280000
106#define SecFlashBSec2Off 0x284000
107#define SecFlashBSec3Off 0x286000
108#define SecFlashBSec4Off 0x288000
109#define SecFlashBEndOff 0x290000
110
111#define SECT32 32
112#define SECT33 33
113#define SECT34 34
114#define SECT35 35
115#define SECT36 36
116#define SECT37 37
117#define SECT38 38
118#define SECT39 39
119
120#define FLASH_SUCCESS 0
121#define FLASH_FAIL -1
122
123#endif