2003-09-02 22:48:03 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2001
|
|
|
|
* Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2003-09-02 22:48:03 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2010-09-09 17:18:00 +00:00
|
|
|
#include <asm/ppc4xx.h>
|
2003-09-02 22:48:03 +00:00
|
|
|
#include <asm/processor.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* include common flash code (for esd boards)
|
|
|
|
*/
|
|
|
|
#include "../common/flash.c"
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------
|
|
|
|
* Functions
|
|
|
|
*/
|
|
|
|
static ulong flash_get_size (vu_long * addr, flash_info_t * info);
|
|
|
|
static void flash_get_offsets (ulong base, flash_info_t * info);
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
unsigned long flash_init (void)
|
|
|
|
{
|
|
|
|
#ifdef __DEBUG_START_FROM_SRAM__
|
2008-10-16 13:01:15 +00:00
|
|
|
return CONFIG_SYS_DUMMY_FLASH_SIZE;
|
2003-09-02 22:48:03 +00:00
|
|
|
#else
|
2004-06-17 18:50:45 +00:00
|
|
|
unsigned long size;
|
2003-09-02 22:48:03 +00:00
|
|
|
int i;
|
2003-10-15 23:53:47 +00:00
|
|
|
uint pbcr;
|
2004-06-17 18:50:45 +00:00
|
|
|
unsigned long base;
|
2003-09-02 22:48:03 +00:00
|
|
|
int size_val = 0;
|
|
|
|
|
2004-07-01 21:40:08 +00:00
|
|
|
debug("[%s, %d] Entering ...\n", __FUNCTION__, __LINE__);
|
2011-10-21 14:17:29 +00:00
|
|
|
debug("[%s, %d] flash_info = 0x%p ...\n", __func__, __LINE__,
|
|
|
|
flash_info);
|
2004-07-01 21:40:08 +00:00
|
|
|
|
2003-09-02 22:48:03 +00:00
|
|
|
/* Init: no FLASHes known */
|
2008-10-16 13:01:15 +00:00
|
|
|
for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
|
2003-09-02 22:48:03 +00:00
|
|
|
flash_info[i].flash_id = FLASH_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Static FLASH Bank configuration here - FIXME XXX */
|
|
|
|
|
2004-07-01 21:40:08 +00:00
|
|
|
debug("[%s, %d] Calling flash_get_size ...\n", __FUNCTION__, __LINE__);
|
2004-06-17 18:50:45 +00:00
|
|
|
size = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
|
2003-09-02 22:48:03 +00:00
|
|
|
|
|
|
|
if (flash_info[0].flash_id == FLASH_UNKNOWN) {
|
|
|
|
printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
|
2004-06-17 18:50:45 +00:00
|
|
|
size, size<<20);
|
2003-09-02 22:48:03 +00:00
|
|
|
}
|
|
|
|
|
2004-07-01 21:40:08 +00:00
|
|
|
debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
|
|
|
|
|
2003-10-15 23:53:47 +00:00
|
|
|
/* Setup offsets */
|
2004-06-17 18:50:45 +00:00
|
|
|
flash_get_offsets (-size, &flash_info[0]);
|
2004-07-01 21:40:08 +00:00
|
|
|
debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
|
2003-09-02 22:48:03 +00:00
|
|
|
|
2003-10-15 23:53:47 +00:00
|
|
|
/* Re-do sizing to get full correct info */
|
2009-09-09 14:25:29 +00:00
|
|
|
mtdcr(EBC0_CFGADDR, PB0CR);
|
|
|
|
pbcr = mfdcr(EBC0_CFGDATA);
|
|
|
|
mtdcr(EBC0_CFGADDR, PB0CR);
|
2004-06-17 18:50:45 +00:00
|
|
|
base = -size;
|
|
|
|
switch (size) {
|
2003-09-02 22:48:03 +00:00
|
|
|
case 1 << 20:
|
|
|
|
size_val = 0;
|
|
|
|
break;
|
|
|
|
case 2 << 20:
|
|
|
|
size_val = 1;
|
|
|
|
break;
|
|
|
|
case 4 << 20:
|
|
|
|
size_val = 2;
|
|
|
|
break;
|
|
|
|
case 8 << 20:
|
|
|
|
size_val = 3;
|
|
|
|
break;
|
|
|
|
case 16 << 20:
|
|
|
|
size_val = 4;
|
|
|
|
break;
|
|
|
|
}
|
2004-06-17 18:50:45 +00:00
|
|
|
pbcr = (pbcr & 0x0001ffff) | base | (size_val << 17);
|
2009-09-09 14:25:29 +00:00
|
|
|
mtdcr(EBC0_CFGDATA, pbcr);
|
2004-07-01 21:40:08 +00:00
|
|
|
debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
|
2003-09-02 22:48:03 +00:00
|
|
|
|
2003-10-15 23:53:47 +00:00
|
|
|
/* Monitor protection ON by default */
|
|
|
|
(void)flash_protect(FLAG_PROTECT_SET,
|
2008-10-16 13:01:15 +00:00
|
|
|
-CONFIG_SYS_MONITOR_LEN,
|
2003-10-15 23:53:47 +00:00
|
|
|
0xffffffff,
|
|
|
|
&flash_info[0]);
|
2003-09-02 22:48:03 +00:00
|
|
|
|
2004-07-01 21:40:08 +00:00
|
|
|
debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
|
2004-06-17 18:50:45 +00:00
|
|
|
flash_info[0].size = size;
|
2003-09-02 22:48:03 +00:00
|
|
|
|
2004-06-17 18:50:45 +00:00
|
|
|
return (size);
|
2003-09-02 22:48:03 +00:00
|
|
|
#endif
|
|
|
|
}
|