]>
Commit | Line | Data |
---|---|---|
6e7fb6ea SR |
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 | * | |
1a459660 | 8 | * SPDX-License-Identifier: GPL-2.0+ |
6e7fb6ea SR |
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> | |
b36df561 | 19 | #include <asm/ppc4xx.h> |
6e7fb6ea SR |
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 | ||
6d0f6bcf | 29 | static unsigned long flash_addr_table[1][CONFIG_SYS_MAX_FLASH_BANKS] = { |
6e7fb6ea SR |
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; | |
6d0f6bcf | 46 | unsigned long size_b[CONFIG_SYS_MAX_FLASH_BANKS]; |
6e7fb6ea SR |
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 */ | |
6d0f6bcf | 56 | for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) { |
6e7fb6ea SR |
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 */ | |
6d0f6bcf JCPV |
79 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_MONITOR_BASE, |
80 | CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1, | |
6e7fb6ea | 81 | &flash_info[2]); |
5a1aceb0 | 82 | #ifdef CONFIG_ENV_IS_IN_FLASH |
0e8d1586 JCPV |
83 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR, |
84 | CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, | |
6e7fb6ea | 85 | &flash_info[2]); |
0e8d1586 JCPV |
86 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR_REDUND, |
87 | CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1, | |
6e7fb6ea SR |
88 | &flash_info[2]); |
89 | #endif | |
90 | ||
91 | total_b += flash_info[i].size; | |
92 | } | |
93 | ||
94 | return total_b; | |
95 | } |