Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 1 | /* |
Bin Meng | a187559 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 2 | * U-Boot - flash-defines.h |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 3 | * |
Aubrey Li | 155fd76 | 2007-04-05 18:31:18 +0800 | [diff] [blame] | 4 | * Copyright (c) 2005-2007 Analog Devices Inc. |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 5 | * |
| 6 | * (C) Copyright 2000-2004 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 8 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 10 | */ |
| 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 Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 19 | #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 Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 29 | #define FLASH_START_L 0x0000 |
| 30 | #define FLASH_START_H 0x2000 |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 31 | #define FLASH_TOT_SECT 40 |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 32 | #define FLASH_SIZE 0x220000 |
| 33 | #define FLASH_MAN_ST 2 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 34 | #define CONFIG_SYS_FLASH0_BASE 0x20000000 |
Mike Frysinger | 65ba1ab | 2008-10-11 20:30:28 -0400 | [diff] [blame] | 35 | #define CONFIG_SYS_FLASH1_BASE 0x20200000 |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 36 | #define RESET_VAL 0xF0 |
| 37 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 38 | flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 39 | |
| 40 | int get_codes(void); |
| 41 | int poll_toggle_bit(long lOffset); |
| 42 | void reset_flash(void); |
| 43 | int erase_flash(void); |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 44 | int erase_block_flash(int, unsigned long); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 45 | void unlock_flash(long lOffset); |
Aubrey Li | dfeeab2 | 2007-04-05 18:28:34 +0800 | [diff] [blame] | 46 | int write_data(long lStart, long lCount, uchar *pnData); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 47 | int FillData(long lStart, long lCount, long lStride, int *pnData); |
| 48 | int read_data(long lStart, long lCount, long lStride, int *pnData); |
| 49 | int read_flash(long nOffset, int *pnValue); |
| 50 | int write_flash(long nOffset, int nValue); |
| 51 | void get_sector_number(long lOffset, int *pnSector); |
| 52 | int GetSectorProtectionStatus(flash_info_t * info, int nSector); |
| 53 | int GetOffset(int nBlock); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 54 | |
| 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 |