3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/ppc4xx.h>
10 #include <asm/processor.h>
13 * include common flash code (for esd boards)
15 #include "../common/flash.c"
17 /*-----------------------------------------------------------------------
20 static ulong flash_get_size (vu_long * addr, flash_info_t * info);
21 static void flash_get_offsets (ulong base, flash_info_t * info);
23 /*-----------------------------------------------------------------------
26 unsigned long flash_init (void)
28 #ifdef __DEBUG_START_FROM_SRAM__
29 return CONFIG_SYS_DUMMY_FLASH_SIZE;
37 debug("[%s, %d] Entering ...\n", __FUNCTION__, __LINE__);
38 debug("[%s, %d] flash_info = 0x%p ...\n", __func__, __LINE__,
41 /* Init: no FLASHes known */
42 for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
43 flash_info[i].flash_id = FLASH_UNKNOWN;
46 /* Static FLASH Bank configuration here - FIXME XXX */
48 debug("[%s, %d] Calling flash_get_size ...\n", __FUNCTION__, __LINE__);
49 size = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
51 if (flash_info[0].flash_id == FLASH_UNKNOWN) {
52 printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
56 debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
59 flash_get_offsets (-size, &flash_info[0]);
60 debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
62 /* Re-do sizing to get full correct info */
63 mtdcr(EBC0_CFGADDR, PB0CR);
64 pbcr = mfdcr(EBC0_CFGDATA);
65 mtdcr(EBC0_CFGADDR, PB0CR);
84 pbcr = (pbcr & 0x0001ffff) | base | (size_val << 17);
85 mtdcr(EBC0_CFGDATA, pbcr);
86 debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
88 /* Monitor protection ON by default */
89 (void)flash_protect(FLAG_PROTECT_SET,
90 -CONFIG_SYS_MONITOR_LEN,
94 debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
95 flash_info[0].size = size;