Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * (C) Copyright 2002 Jun Gu <jung@artesyncp.com> |
| 6 | * Add support for Am29F016D and dynamic switch setting. |
| 7 | * |
| 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | /* |
| 28 | * Modified 4/5/2001 |
| 29 | * Wait for completion of each sector erase command issued |
| 30 | * 4/5/2001 |
| 31 | * Chris Hallinan - DS4.COM, Inc. - clh@net1plus.com |
| 32 | */ |
| 33 | |
| 34 | #include <common.h> |
| 35 | #include <ppc4xx.h> |
| 36 | #include <asm/processor.h> |
| 37 | |
| 38 | #undef DEBUG |
| 39 | #ifdef DEBUG |
| 40 | #define DEBUGF(x...) printf(x) |
| 41 | #else |
| 42 | #define DEBUGF(x...) |
| 43 | #endif /* DEBUG */ |
| 44 | |
| 45 | static unsigned long flash_addr_table[1][CFG_MAX_FLASH_BANKS] = { |
| 46 | {0xff900000, 0xff980000, 0xffc00000}, /* 0:000: configuraton 3 */ |
| 47 | }; |
| 48 | |
| 49 | /* |
| 50 | * include common flash code (for amcc boards) |
| 51 | */ |
| 52 | #include "../common/flash.c" |
| 53 | |
| 54 | /*----------------------------------------------------------------------- |
| 55 | * Functions |
| 56 | */ |
| 57 | static ulong flash_get_size(vu_long * addr, flash_info_t * info); |
| 58 | |
| 59 | unsigned long flash_init(void) |
| 60 | { |
| 61 | unsigned long total_b = 0; |
| 62 | unsigned long size_b[CFG_MAX_FLASH_BANKS]; |
| 63 | unsigned short index = 0; |
| 64 | int i; |
| 65 | |
| 66 | /* read FPGA base register FPGA_REG0 */ |
| 67 | |
| 68 | DEBUGF("\n"); |
| 69 | DEBUGF("FLASH: Index: %d\n", index); |
| 70 | |
| 71 | /* Init: no FLASHes known */ |
| 72 | for (i = 0; i < CFG_MAX_FLASH_BANKS; ++i) { |
| 73 | flash_info[i].flash_id = FLASH_UNKNOWN; |
| 74 | flash_info[i].sector_count = -1; |
| 75 | flash_info[i].size = 0; |
| 76 | |
| 77 | /* check whether the address is 0 */ |
| 78 | if (flash_addr_table[index][i] == 0) { |
| 79 | continue; |
| 80 | } |
| 81 | |
| 82 | /* call flash_get_size() to initialize sector address */ |
| 83 | size_b[i] = flash_get_size((vu_long *) |
| 84 | flash_addr_table[index][i], |
| 85 | &flash_info[i]); |
| 86 | flash_info[i].size = size_b[i]; |
| 87 | if (flash_info[i].flash_id == FLASH_UNKNOWN) { |
| 88 | printf("## Unknown FLASH on Bank %d - Size = 0x%08lx = %ld MB\n", |
| 89 | i, size_b[i], size_b[i] << 20); |
| 90 | flash_info[i].sector_count = -1; |
| 91 | flash_info[i].size = 0; |
| 92 | } |
| 93 | |
| 94 | /* Monitor protection ON by default */ |
| 95 | (void)flash_protect(FLAG_PROTECT_SET, CFG_MONITOR_BASE, |
| 96 | CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1, |
| 97 | &flash_info[2]); |
| 98 | #ifdef CFG_ENV_IS_IN_FLASH |
| 99 | (void)flash_protect(FLAG_PROTECT_SET, CFG_ENV_ADDR, |
| 100 | CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1, |
| 101 | &flash_info[2]); |
| 102 | (void)flash_protect(FLAG_PROTECT_SET, CFG_ENV_ADDR_REDUND, |
| 103 | CFG_ENV_ADDR_REDUND + CFG_ENV_SECT_SIZE - 1, |
| 104 | &flash_info[2]); |
| 105 | #endif |
| 106 | |
| 107 | total_b += flash_info[i].size; |
| 108 | } |
| 109 | |
| 110 | return total_b; |
| 111 | } |