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 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * Modified 4/5/2001 |
| 13 | * Wait for completion of each sector erase command issued |
| 14 | * 4/5/2001 |
| 15 | * Chris Hallinan - DS4.COM, Inc. - clh@net1plus.com |
| 16 | */ |
| 17 | |
| 18 | #include <common.h> |
Stefan Roese | 247e9d7 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 19 | #include <asm/ppc4xx.h> |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 20 | #include <asm/processor.h> |
| 21 | |
| 22 | #undef DEBUG |
| 23 | #ifdef DEBUG |
| 24 | #define DEBUGF(x...) printf(x) |
| 25 | #else |
| 26 | #define DEBUGF(x...) |
| 27 | #endif /* DEBUG */ |
| 28 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 29 | static unsigned long flash_addr_table[1][CONFIG_SYS_MAX_FLASH_BANKS] = { |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 30 | {0xff900000, 0xff980000, 0xffc00000}, /* 0:000: configuraton 3 */ |
| 31 | }; |
| 32 | |
| 33 | /* |
| 34 | * include common flash code (for amcc boards) |
| 35 | */ |
| 36 | #include "../common/flash.c" |
| 37 | |
| 38 | /*----------------------------------------------------------------------- |
| 39 | * Functions |
| 40 | */ |
| 41 | static ulong flash_get_size(vu_long * addr, flash_info_t * info); |
| 42 | |
| 43 | unsigned long flash_init(void) |
| 44 | { |
| 45 | unsigned long total_b = 0; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 46 | unsigned long size_b[CONFIG_SYS_MAX_FLASH_BANKS]; |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 47 | unsigned short index = 0; |
| 48 | int i; |
| 49 | |
| 50 | /* read FPGA base register FPGA_REG0 */ |
| 51 | |
| 52 | DEBUGF("\n"); |
| 53 | DEBUGF("FLASH: Index: %d\n", index); |
| 54 | |
| 55 | /* Init: no FLASHes known */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 56 | for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) { |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 57 | flash_info[i].flash_id = FLASH_UNKNOWN; |
| 58 | flash_info[i].sector_count = -1; |
| 59 | flash_info[i].size = 0; |
| 60 | |
| 61 | /* check whether the address is 0 */ |
| 62 | if (flash_addr_table[index][i] == 0) { |
| 63 | continue; |
| 64 | } |
| 65 | |
| 66 | /* call flash_get_size() to initialize sector address */ |
| 67 | size_b[i] = flash_get_size((vu_long *) |
| 68 | flash_addr_table[index][i], |
| 69 | &flash_info[i]); |
| 70 | flash_info[i].size = size_b[i]; |
| 71 | if (flash_info[i].flash_id == FLASH_UNKNOWN) { |
| 72 | printf("## Unknown FLASH on Bank %d - Size = 0x%08lx = %ld MB\n", |
| 73 | i, size_b[i], size_b[i] << 20); |
| 74 | flash_info[i].sector_count = -1; |
| 75 | flash_info[i].size = 0; |
| 76 | } |
| 77 | |
| 78 | /* Monitor protection ON by default */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 79 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_MONITOR_BASE, |
| 80 | CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1, |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 81 | &flash_info[2]); |
Jean-Christophe PLAGNIOL-VILLARD | 53db4cd | 2008-09-10 22:48:04 +0200 | [diff] [blame] | 82 | #ifdef CONFIG_ENV_IS_IN_FLASH |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 83 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR, |
| 84 | CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 85 | &flash_info[2]); |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 86 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR_REDUND, |
| 87 | CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1, |
Stefan Roese | 9964474 | 2005-11-29 18:18:21 +0100 | [diff] [blame] | 88 | &flash_info[2]); |
| 89 | #endif |
| 90 | |
| 91 | total_b += flash_info[i].size; |
| 92 | } |
| 93 | |
| 94 | return total_b; |
| 95 | } |