Stefan Roese | 6e7fb6e | 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> |
Stefan Roese | b36df56 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 35 | #include <asm/ppc4xx.h> |
Stefan Roese | 6e7fb6e | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 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 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 45 | static unsigned long flash_addr_table[1][CONFIG_SYS_MAX_FLASH_BANKS] = { |
Stefan Roese | 6e7fb6e | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 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; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 62 | unsigned long size_b[CONFIG_SYS_MAX_FLASH_BANKS]; |
Stefan Roese | 6e7fb6e | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 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 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 72 | for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) { |
Stefan Roese | 6e7fb6e | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 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 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 95 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_MONITOR_BASE, |
| 96 | CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1, |
Stefan Roese | 6e7fb6e | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 97 | &flash_info[2]); |
Jean-Christophe PLAGNIOL-VILLARD | 5a1aceb | 2008-09-10 22:48:04 +0200 | [diff] [blame] | 98 | #ifdef CONFIG_ENV_IS_IN_FLASH |
Jean-Christophe PLAGNIOL-VILLARD | 0e8d158 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 99 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR, |
| 100 | CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, |
Stefan Roese | 6e7fb6e | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 101 | &flash_info[2]); |
Jean-Christophe PLAGNIOL-VILLARD | 0e8d158 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 102 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR_REDUND, |
| 103 | CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1, |
Stefan Roese | 6e7fb6e | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 104 | &flash_info[2]); |
| 105 | #endif |
| 106 | |
| 107 | total_b += flash_info[i].size; |
| 108 | } |
| 109 | |
| 110 | return total_b; |
| 111 | } |