2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2006-04-20 06:42:42 +00:00
|
|
|
/*
|
2009-07-24 08:31:48 +00:00
|
|
|
* (C) Copyright 2005-2009
|
2006-04-20 06:42:42 +00:00
|
|
|
* BuS Elektronik GmbH & Co.KG <esw@bus-elektonik.de>
|
|
|
|
*
|
|
|
|
* (C) Copyright 2000-2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2006-04-20 06:42:42 +00:00
|
|
|
#include "asm/m5282.h"
|
2009-07-24 08:31:48 +00:00
|
|
|
#include <bmp_layout.h>
|
2019-08-01 15:46:52 +00:00
|
|
|
#include <env.h>
|
2019-12-28 17:45:06 +00:00
|
|
|
#include <init.h>
|
2009-07-24 08:31:48 +00:00
|
|
|
#include <status_led.h>
|
|
|
|
#include <bus_vcxk.h>
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2006-04-20 06:42:42 +00:00
|
|
|
|
|
|
|
int checkboard (void)
|
|
|
|
{
|
2012-10-30 00:46:05 +00:00
|
|
|
puts("Board: EB+CPU5282 (BuS Elektronik GmbH & Co. KG)\n");
|
2022-11-16 18:10:41 +00:00
|
|
|
#if (CONFIG_TEXT_BASE == CFG_SYS_INT_FLASH_BASE)
|
2012-10-30 00:46:05 +00:00
|
|
|
puts(" Boot from Internal FLASH\n");
|
2006-04-20 06:42:42 +00:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-06 18:47:05 +00:00
|
|
|
int dram_init(void)
|
2006-04-20 06:42:42 +00:00
|
|
|
{
|
2008-07-14 18:38:26 +00:00
|
|
|
int size, i;
|
2006-04-20 06:42:42 +00:00
|
|
|
|
|
|
|
size = 0;
|
2012-10-30 00:46:05 +00:00
|
|
|
MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6 |
|
2022-11-16 18:10:41 +00:00
|
|
|
MCFSDRAMC_DCR_RC((15 * CFG_SYS_CLK / 1000000) >> 4);
|
2012-10-30 00:46:05 +00:00
|
|
|
asm (" nop");
|
2022-11-16 18:10:37 +00:00
|
|
|
#ifdef CFG_SYS_SDRAM_BASE0
|
|
|
|
MCFSDRAMC_DACR0 = MCFSDRAMC_DACR_BASE(CFG_SYS_SDRAM_BASE0)|
|
2012-10-30 00:46:05 +00:00
|
|
|
MCFSDRAMC_DACR_CASL(1) | MCFSDRAMC_DACR_CBM(3) |
|
|
|
|
MCFSDRAMC_DACR_PS_32;
|
|
|
|
asm (" nop");
|
2008-07-14 18:38:26 +00:00
|
|
|
|
|
|
|
MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
|
2012-10-30 00:46:05 +00:00
|
|
|
asm (" nop");
|
2008-07-14 18:38:26 +00:00
|
|
|
|
|
|
|
MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
|
2012-10-30 00:46:05 +00:00
|
|
|
asm (" nop");
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
asm (" nop");
|
2008-07-14 18:38:26 +00:00
|
|
|
|
2022-11-16 18:10:37 +00:00
|
|
|
*(unsigned long *)(CFG_SYS_SDRAM_BASE0) = 0xA5A5A5A5;
|
2012-10-30 00:46:05 +00:00
|
|
|
asm (" nop");
|
2008-07-14 18:38:26 +00:00
|
|
|
MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE;
|
2012-10-30 00:46:05 +00:00
|
|
|
asm (" nop");
|
|
|
|
|
2008-07-14 18:38:26 +00:00
|
|
|
for (i = 0; i < 2000; i++)
|
|
|
|
asm (" nop");
|
2012-10-30 00:46:05 +00:00
|
|
|
|
|
|
|
MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IMRS;
|
|
|
|
asm (" nop");
|
|
|
|
/* write SDRAM mode register */
|
2022-11-16 18:10:37 +00:00
|
|
|
*(unsigned long *)(CFG_SYS_SDRAM_BASE0 + 0x80440) = 0xA5A5A5A5;
|
2012-10-30 00:46:05 +00:00
|
|
|
asm (" nop");
|
2022-11-16 18:10:37 +00:00
|
|
|
size += CFG_SYS_SDRAM_SIZE0 * 1024 * 1024;
|
2008-07-14 18:38:26 +00:00
|
|
|
#endif
|
2022-11-16 18:10:37 +00:00
|
|
|
#ifdef CFG_SYS_SDRAM_BASE1xx
|
|
|
|
MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CFG_SYS_SDRAM_BASE1)
|
2008-07-14 18:38:26 +00:00
|
|
|
| MCFSDRAMC_DACR_CASL (1)
|
|
|
|
| MCFSDRAMC_DACR_CBM (3)
|
|
|
|
| MCFSDRAMC_DACR_PS_16;
|
|
|
|
|
|
|
|
MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
|
|
|
|
|
|
|
|
MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP;
|
|
|
|
|
2022-11-16 18:10:37 +00:00
|
|
|
*(unsigned short *) (CFG_SYS_SDRAM_BASE1) = 0xA5A5;
|
2008-07-14 18:38:26 +00:00
|
|
|
MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_RE;
|
|
|
|
|
|
|
|
for (i = 0; i < 2000; i++)
|
|
|
|
asm (" nop");
|
|
|
|
|
|
|
|
MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IMRS;
|
2022-11-16 18:10:37 +00:00
|
|
|
*(unsigned int *) (CFG_SYS_SDRAM_BASE1 + 0x220) = 0xA5A5;
|
|
|
|
size += CFG_SYS_SDRAM_SIZE1 * 1024 * 1024;
|
2008-07-14 18:38:26 +00:00
|
|
|
#endif
|
2017-03-31 14:40:25 +00:00
|
|
|
gd->ram_size = size;
|
|
|
|
|
|
|
|
return 0;
|
2006-04-20 06:42:42 +00:00
|
|
|
}
|
|
|
|
|
2022-11-16 18:10:41 +00:00
|
|
|
#if defined(CFG_SYS_DRAM_TEST)
|
2019-12-28 17:45:06 +00:00
|
|
|
int testdram(void)
|
2006-04-20 06:42:42 +00:00
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
|
|
|
|
uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
|
2006-04-20 06:42:42 +00:00
|
|
|
uint *p;
|
|
|
|
|
|
|
|
printf("SDRAM test phase 1:\n");
|
|
|
|
for (p = pstart; p < pend; p++)
|
|
|
|
*p = 0xaaaaaaaa;
|
|
|
|
|
|
|
|
for (p = pstart; p < pend; p++) {
|
|
|
|
if (*p != 0xaaaaaaaa) {
|
|
|
|
printf ("SDRAM test fails at: %08x\n", (uint) p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("SDRAM test phase 2:\n");
|
|
|
|
for (p = pstart; p < pend; p++)
|
|
|
|
*p = 0x55555555;
|
|
|
|
|
|
|
|
for (p = pstart; p < pend; p++) {
|
|
|
|
if (*p != 0x55555555) {
|
|
|
|
printf ("SDRAM test fails at: %08x\n", (uint) p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("SDRAM test passed.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-10-30 00:46:05 +00:00
|
|
|
#if defined(CONFIG_HW_WATCHDOG)
|
|
|
|
|
|
|
|
void hw_watchdog_init(void)
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
int enable;
|
|
|
|
|
|
|
|
enable = 1;
|
2017-08-03 18:22:12 +00:00
|
|
|
s = env_get("watchdog");
|
2012-10-30 00:46:05 +00:00
|
|
|
if (s != NULL)
|
|
|
|
if ((strncmp(s, "off", 3) == 0) || (strncmp(s, "0", 1) == 0))
|
|
|
|
enable = 0;
|
|
|
|
if (enable)
|
|
|
|
MCFGPTA_GPTDDR |= (1<<2);
|
|
|
|
else
|
|
|
|
MCFGPTA_GPTDDR &= ~(1<<2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void hw_watchdog_reset(void)
|
|
|
|
{
|
|
|
|
MCFGPTA_GPTPORT ^= (1<<2);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-04-20 06:42:42 +00:00
|
|
|
int misc_init_r(void)
|
|
|
|
{
|
2009-07-24 08:31:48 +00:00
|
|
|
#ifdef CONFIG_HW_WATCHDOG
|
|
|
|
hw_watchdog_init();
|
|
|
|
#endif
|
2006-04-20 06:42:42 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-10-30 00:46:05 +00:00
|
|
|
void __led_toggle(led_id_t mask)
|
|
|
|
{
|
|
|
|
MCFGPTA_GPTPORT ^= (1 << 3);
|
|
|
|
}
|
2009-07-24 08:31:48 +00:00
|
|
|
|
2012-10-30 00:46:05 +00:00
|
|
|
void __led_init(led_id_t mask, int state)
|
|
|
|
{
|
|
|
|
__led_set(mask, state);
|
|
|
|
MCFGPTA_GPTDDR |= (1 << 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void __led_set(led_id_t mask, int state)
|
|
|
|
{
|
2017-01-19 08:51:45 +00:00
|
|
|
if (state == CONFIG_LED_STATUS_ON)
|
2012-10-30 00:46:05 +00:00
|
|
|
MCFGPTA_GPTPORT |= (1 << 3);
|
|
|
|
else
|
|
|
|
MCFGPTA_GPTPORT &= ~(1 << 3);
|
|
|
|
}
|
|
|
|
|
2009-07-24 08:31:48 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2006-04-20 06:42:42 +00:00
|
|
|
|
2009-07-24 08:31:48 +00:00
|
|
|
|
|
|
|
/* EOF EB+MCF-EV123.c */
|