Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 1 | /* |
| 2 | * U-boot - flash-defines.h |
| 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 | * |
| 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 Li | 155fd76 | 2007-04-05 18:31:18 +0800 | [diff] [blame] | 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 25 | * MA 02110-1301 USA |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 26 | */ |
| 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 Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 47 | #define FLASH_START_L 0x0000 |
| 48 | #define FLASH_START_H 0x2000 |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 49 | #define FLASH_TOT_SECT 40 |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 50 | #define FLASH_SIZE 0x220000 |
| 51 | #define FLASH_MAN_ST 2 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | #define CONFIG_SYS_FLASH0_BASE 0x20000000 |
Mike Frysinger | 65ba1ab | 2008-10-11 20:30:28 -0400 | [diff] [blame] | 53 | #define CONFIG_SYS_FLASH1_BASE 0x20200000 |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 54 | #define RESET_VAL 0xF0 |
| 55 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 56 | flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 57 | |
| 58 | int get_codes(void); |
| 59 | int poll_toggle_bit(long lOffset); |
| 60 | void reset_flash(void); |
| 61 | int erase_flash(void); |
Aubrey.Li | 3f0606a | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 62 | int erase_block_flash(int, unsigned long); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 63 | void unlock_flash(long lOffset); |
Aubrey Li | dfeeab2 | 2007-04-05 18:28:34 +0800 | [diff] [blame] | 64 | int write_data(long lStart, long lCount, uchar *pnData); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 65 | int FillData(long lStart, long lCount, long lStride, int *pnData); |
| 66 | int read_data(long lStart, long lCount, long lStride, int *pnData); |
| 67 | int read_flash(long nOffset, int *pnValue); |
| 68 | int write_flash(long nOffset, int nValue); |
| 69 | void get_sector_number(long lOffset, int *pnSector); |
| 70 | int GetSectorProtectionStatus(flash_info_t * info, int nSector); |
| 71 | int GetOffset(int nBlock); |
Wolfgang Denk | 6cb142f | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 72 | |
| 73 | #define WRITESEQ1 0x0AAA |
| 74 | #define WRITESEQ2 0x0554 |
| 75 | #define WRITESEQ3 0x0AAA |
| 76 | #define WRITESEQ4 0x0AAA |
| 77 | #define WRITESEQ5 0x0554 |
| 78 | #define WRITESEQ6 0x0AAA |
| 79 | #define WRITEDATA1 0xaa |
| 80 | #define WRITEDATA2 0x55 |
| 81 | #define WRITEDATA3 0x80 |
| 82 | #define WRITEDATA4 0xaa |
| 83 | #define WRITEDATA5 0x55 |
| 84 | #define WRITEDATA6 0x10 |
| 85 | #define PriFlashABegin 0 |
| 86 | #define SecFlashABegin 32 |
| 87 | #define SecFlashBBegin 36 |
| 88 | #define PriFlashAOff 0x0 |
| 89 | #define PriFlashBOff 0x100000 |
| 90 | #define SecFlashAOff 0x200000 |
| 91 | #define SecFlashBOff 0x280000 |
| 92 | #define INVALIDLOCNSTART 0x20270000 |
| 93 | #define INVALIDLOCNEND 0x20280000 |
| 94 | #define BlockEraseVal 0x30 |
| 95 | #define UNLOCKDATA1 0xaa |
| 96 | #define UNLOCKDATA2 0x55 |
| 97 | #define UNLOCKDATA3 0xa0 |
| 98 | #define GETCODEDATA1 0xaa |
| 99 | #define GETCODEDATA2 0x55 |
| 100 | #define GETCODEDATA3 0x90 |
| 101 | #define SecFlashASec1Off 0x200000 |
| 102 | #define SecFlashASec2Off 0x204000 |
| 103 | #define SecFlashASec3Off 0x206000 |
| 104 | #define SecFlashASec4Off 0x208000 |
| 105 | #define SecFlashAEndOff 0x210000 |
| 106 | #define SecFlashBSec1Off 0x280000 |
| 107 | #define SecFlashBSec2Off 0x284000 |
| 108 | #define SecFlashBSec3Off 0x286000 |
| 109 | #define SecFlashBSec4Off 0x288000 |
| 110 | #define SecFlashBEndOff 0x290000 |
| 111 | |
| 112 | #define SECT32 32 |
| 113 | #define SECT33 33 |
| 114 | #define SECT34 34 |
| 115 | #define SECT35 35 |
| 116 | #define SECT36 36 |
| 117 | #define SECT37 37 |
| 118 | #define SECT38 38 |
| 119 | #define SECT39 39 |
| 120 | |
| 121 | #define FLASH_SUCCESS 0 |
| 122 | #define FLASH_FAIL -1 |
| 123 | |
| 124 | #endif |