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 * SPDX-License-Identifier: GPL-2.0+
13 * Wait for completion of each sector erase command issued
15 * Chris Hallinan - DS4.COM, Inc. - clh@net1plus.com
19 #include <asm/ppc4xx.h>
20 #include <asm/processor.h>
24 #define DEBUGF(x...) printf(x)
29 static unsigned long flash_addr_table
[1][CONFIG_SYS_MAX_FLASH_BANKS
] = {
30 {0xff900000, 0xff980000, 0xffc00000}, /* 0:000: configuraton 3 */
34 * include common flash code (for amcc boards)
36 #include "../common/flash.c"
38 /*-----------------------------------------------------------------------
41 static ulong
flash_get_size(vu_long
* addr
, flash_info_t
* info
);
43 unsigned long flash_init(void)
45 unsigned long total_b
= 0;
46 unsigned long size_b
[CONFIG_SYS_MAX_FLASH_BANKS
];
47 unsigned short index
= 0;
50 /* read FPGA base register FPGA_REG0 */
53 DEBUGF("FLASH: Index: %d\n", index
);
55 /* Init: no FLASHes known */
56 for (i
= 0; i
< CONFIG_SYS_MAX_FLASH_BANKS
; ++i
) {
57 flash_info
[i
].flash_id
= FLASH_UNKNOWN
;
58 flash_info
[i
].sector_count
= -1;
59 flash_info
[i
].size
= 0;
61 /* check whether the address is 0 */
62 if (flash_addr_table
[index
][i
] == 0) {
66 /* call flash_get_size() to initialize sector address */
67 size_b
[i
] = flash_get_size((vu_long
*)
68 flash_addr_table
[index
][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;
78 /* Monitor protection ON by default */
79 (void)flash_protect(FLAG_PROTECT_SET
, CONFIG_SYS_MONITOR_BASE
,
80 CONFIG_SYS_MONITOR_BASE
+ CONFIG_SYS_MONITOR_LEN
- 1,
82 #ifdef CONFIG_ENV_IS_IN_FLASH
83 (void)flash_protect(FLAG_PROTECT_SET
, CONFIG_ENV_ADDR
,
84 CONFIG_ENV_ADDR
+ CONFIG_ENV_SECT_SIZE
- 1,
86 (void)flash_protect(FLAG_PROTECT_SET
, CONFIG_ENV_ADDR_REDUND
,
87 CONFIG_ENV_ADDR_REDUND
+ CONFIG_ENV_SECT_SIZE
- 1,
91 total_b
+= flash_info
[i
].size
;