blob: 7822a9dfd72461bdf35b64049a71f38bd56ea484 [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001/*
Bin Menga1875592016-02-05 19:30:11 -08002 * U-Boot - flash-defines.h
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01003 *
Aubrey Li155fd762007-04-05 18:31:18 +08004 * Copyright (c) 2005-2007 Analog Devices Inc.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01005 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010010 */
11
12#ifndef __FLASHDEFINES_H__
13#define __FLASHDEFINES_H__
14
15#include <common.h>
16
17#define V_ULONG(a) (*(volatile unsigned long *)( a ))
18#define V_BYTE(a) (*(volatile unsigned char *)( a ))
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010019#define BUFFER_SIZE 0x80000
20#define NO_COMMAND 0
21#define GET_CODES 1
22#define RESET 2
23#define WRITE 3
24#define FILL 4
25#define ERASE_ALL 5
26#define ERASE_SECT 6
27#define READ 7
28#define GET_SECTNUM 8
Wolfgang Denk53677ef2008-05-20 16:00:29 +020029#define FLASH_START_L 0x0000
30#define FLASH_START_H 0x2000
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010031#define FLASH_TOT_SECT 40
Wolfgang Denk53677ef2008-05-20 16:00:29 +020032#define FLASH_SIZE 0x220000
33#define FLASH_MAN_ST 2
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020034#define CONFIG_SYS_FLASH0_BASE 0x20000000
Mike Frysinger65ba1ab2008-10-11 20:30:28 -040035#define CONFIG_SYS_FLASH1_BASE 0x20200000
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010036#define RESET_VAL 0xF0
37
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020038flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010039
40int get_codes(void);
41int poll_toggle_bit(long lOffset);
42void reset_flash(void);
43int erase_flash(void);
Aubrey.Li3f0606a2007-03-09 13:38:44 +080044int erase_block_flash(int, unsigned long);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010045void unlock_flash(long lOffset);
Aubrey Lidfeeab22007-04-05 18:28:34 +080046int write_data(long lStart, long lCount, uchar *pnData);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010047int FillData(long lStart, long lCount, long lStride, int *pnData);
48int read_data(long lStart, long lCount, long lStride, int *pnData);
49int read_flash(long nOffset, int *pnValue);
50int write_flash(long nOffset, int nValue);
51void get_sector_number(long lOffset, int *pnSector);
52int GetSectorProtectionStatus(flash_info_t * info, int nSector);
53int GetOffset(int nBlock);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010054
55#define WRITESEQ1 0x0AAA
56#define WRITESEQ2 0x0554
57#define WRITESEQ3 0x0AAA
58#define WRITESEQ4 0x0AAA
59#define WRITESEQ5 0x0554
60#define WRITESEQ6 0x0AAA
61#define WRITEDATA1 0xaa
62#define WRITEDATA2 0x55
63#define WRITEDATA3 0x80
64#define WRITEDATA4 0xaa
65#define WRITEDATA5 0x55
66#define WRITEDATA6 0x10
67#define PriFlashABegin 0
68#define SecFlashABegin 32
69#define SecFlashBBegin 36
70#define PriFlashAOff 0x0
71#define PriFlashBOff 0x100000
72#define SecFlashAOff 0x200000
73#define SecFlashBOff 0x280000
74#define INVALIDLOCNSTART 0x20270000
75#define INVALIDLOCNEND 0x20280000
76#define BlockEraseVal 0x30
77#define UNLOCKDATA1 0xaa
78#define UNLOCKDATA2 0x55
79#define UNLOCKDATA3 0xa0
80#define GETCODEDATA1 0xaa
81#define GETCODEDATA2 0x55
82#define GETCODEDATA3 0x90
83#define SecFlashASec1Off 0x200000
84#define SecFlashASec2Off 0x204000
85#define SecFlashASec3Off 0x206000
86#define SecFlashASec4Off 0x208000
87#define SecFlashAEndOff 0x210000
88#define SecFlashBSec1Off 0x280000
89#define SecFlashBSec2Off 0x284000
90#define SecFlashBSec3Off 0x286000
91#define SecFlashBSec4Off 0x288000
92#define SecFlashBEndOff 0x290000
93
94#define SECT32 32
95#define SECT33 33
96#define SECT34 34
97#define SECT35 35
98#define SECT36 36
99#define SECT37 37
100#define SECT38 38
101#define SECT39 39
102
103#define FLASH_SUCCESS 0
104#define FLASH_FAIL -1
105
106#endif