3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * (C) Copyright 2002 Jun Gu <jung@artesyncp.com>
6 * Add support for Am29F016D and dynamic switch setting.
8 * See file CREDITS for list of people who contributed to this
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.
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.
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,
29 * Wait for completion of each sector erase command issued
31 * Chris Hallinan - DS4.COM, Inc. - clh@net1plus.com
36 #include <asm/processor.h>
40 #define DEBUGF(x...) printf(x)
45 static unsigned long flash_addr_table[1][CFG_MAX_FLASH_BANKS] = {
46 {0xff900000, 0xff980000, 0xffc00000}, /* 0:000: configuraton 3 */
50 * include common flash code (for amcc boards)
52 #include "../common/flash.c"
54 /*-----------------------------------------------------------------------
57 static ulong flash_get_size(vu_long * addr, flash_info_t * info);
59 unsigned long flash_init(void)
61 unsigned long total_b = 0;
62 unsigned long size_b[CFG_MAX_FLASH_BANKS];
63 unsigned short index = 0;
66 /* read FPGA base register FPGA_REG0 */
69 DEBUGF("FLASH: Index: %d\n", index);
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;
77 /* check whether the address is 0 */
78 if (flash_addr_table[index][i] == 0) {
82 /* call flash_get_size() to initialize sector address */
83 size_b[i] = flash_get_size((vu_long *)
84 flash_addr_table[index][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;
94 /* Monitor protection ON by default */
95 (void)flash_protect(FLAG_PROTECT_SET, CFG_MONITOR_BASE,
96 CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1,
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,
102 (void)flash_protect(FLAG_PROTECT_SET, CFG_ENV_ADDR_REDUND,
103 CFG_ENV_ADDR_REDUND + CFG_ENV_SECT_SIZE - 1,
107 total_b += flash_info[i].size;