2004-03-23 20:18:25 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2003-2004
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2004-06-19 21:19:10 +00:00
|
|
|
* (C) Copyright 2004
|
|
|
|
* Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2004-03-23 20:18:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <mpc5xxx.h>
|
|
|
|
#include <pci.h>
|
2008-08-31 17:03:22 +00:00
|
|
|
#include <netdev.h>
|
2004-03-23 20:18:25 +00:00
|
|
|
|
2004-06-19 21:19:10 +00:00
|
|
|
#if defined(CONFIG_MPC5200_DDR)
|
|
|
|
#include "mt46v16m16-75.h"
|
|
|
|
#else
|
|
|
|
#include "mt48lc16m16a2-75.h"
|
|
|
|
#endif
|
2004-03-23 20:18:25 +00:00
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_RAMBOOT
|
2004-03-23 20:18:25 +00:00
|
|
|
static void sdram_start (int hi_addr)
|
|
|
|
{
|
|
|
|
long hi_addr_bit = hi_addr ? 0x01000000 : 0;
|
|
|
|
|
|
|
|
/* unlock mode register */
|
2004-06-19 21:19:10 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
2004-03-23 20:18:25 +00:00
|
|
|
/* precharge all banks */
|
2004-06-19 21:19:10 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
|
|
|
#if SDRAM_DDR
|
|
|
|
/* set mode register: extended mode */
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
|
|
|
/* set mode register: reset DLL */
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
|
|
|
|
__asm__ volatile ("sync");
|
2004-03-23 20:18:25 +00:00
|
|
|
#endif
|
2004-06-19 21:19:10 +00:00
|
|
|
|
2004-03-23 20:18:25 +00:00
|
|
|
/* precharge all banks */
|
2004-06-19 21:19:10 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
2004-03-23 20:18:25 +00:00
|
|
|
/* auto refresh */
|
2004-06-19 21:19:10 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
2004-03-23 20:18:25 +00:00
|
|
|
/* set mode register */
|
2004-06-19 21:19:10 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
2004-03-23 20:18:25 +00:00
|
|
|
/* normal operation */
|
2004-06-19 21:19:10 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
2004-03-23 20:18:25 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-19 21:19:10 +00:00
|
|
|
/*
|
|
|
|
* ATTENTION: Although partially referenced initdram does NOT make real use
|
2008-10-16 13:01:15 +00:00
|
|
|
* use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
|
2004-06-19 21:19:10 +00:00
|
|
|
* is something else than 0x00000000.
|
|
|
|
*/
|
|
|
|
|
2008-06-09 21:03:40 +00:00
|
|
|
phys_size_t initdram (int board_type)
|
2004-03-23 20:18:25 +00:00
|
|
|
{
|
|
|
|
ulong dramsize = 0;
|
2004-06-19 21:19:10 +00:00
|
|
|
ulong dramsize2 = 0;
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_RAMBOOT
|
2004-03-23 20:18:25 +00:00
|
|
|
ulong test1, test2;
|
|
|
|
|
2004-06-19 21:19:10 +00:00
|
|
|
/* setup SDRAM chip selects */
|
2004-03-23 20:18:25 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */
|
2004-06-19 21:19:10 +00:00
|
|
|
__asm__ volatile ("sync");
|
2004-03-23 20:18:25 +00:00
|
|
|
|
|
|
|
/* setup config registers */
|
2004-06-19 21:19:10 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
|
|
|
#if SDRAM_DDR
|
|
|
|
/* set tap delay */
|
|
|
|
*(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* find RAM size using SDRAM CS0 only */
|
|
|
|
sdram_start(0);
|
2008-10-16 13:01:15 +00:00
|
|
|
test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
|
2004-06-19 21:19:10 +00:00
|
|
|
sdram_start(1);
|
2008-10-16 13:01:15 +00:00
|
|
|
test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
|
2004-06-19 21:19:10 +00:00
|
|
|
if (test1 > test2) {
|
|
|
|
sdram_start(0);
|
|
|
|
dramsize = test1;
|
|
|
|
} else {
|
|
|
|
dramsize = test2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* memory smaller than 1MB is impossible */
|
|
|
|
if (dramsize < (1 << 20)) {
|
|
|
|
dramsize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set SDRAM CS0 size according to the amount of RAM found */
|
|
|
|
if (dramsize > 0) {
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + __builtin_ffs(dramsize >> 20) - 1;
|
|
|
|
} else {
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* let SDRAM CS1 start right after CS0 */
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;/* 2G */
|
|
|
|
|
|
|
|
/* find RAM size using SDRAM CS1 only */
|
2005-05-05 00:04:14 +00:00
|
|
|
if (!dramsize)
|
2005-04-21 21:10:22 +00:00
|
|
|
sdram_start(0);
|
2008-10-16 13:01:15 +00:00
|
|
|
test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
|
2005-04-21 21:10:22 +00:00
|
|
|
if (!dramsize) {
|
|
|
|
sdram_start(1);
|
2008-10-16 13:01:15 +00:00
|
|
|
test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
|
2005-04-21 21:10:22 +00:00
|
|
|
}
|
2004-06-19 21:19:10 +00:00
|
|
|
if (test1 > test2) {
|
|
|
|
sdram_start(0);
|
|
|
|
dramsize2 = test1;
|
|
|
|
} else {
|
|
|
|
dramsize2 = test2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* memory smaller than 1MB is impossible */
|
|
|
|
if (dramsize2 < (1 << 20)) {
|
|
|
|
dramsize2 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set SDRAM CS1 size according to the amount of RAM found */
|
|
|
|
if (dramsize2 > 0) {
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
|
|
|
|
| (0x13 + __builtin_ffs(dramsize2 >> 20) - 1);
|
|
|
|
} else {
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
|
|
|
|
}
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#else /* CONFIG_SYS_RAMBOOT */
|
2004-06-19 21:19:10 +00:00
|
|
|
|
|
|
|
/* retrieve size of memory connected to SDRAM CS0 */
|
|
|
|
dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
|
|
|
|
if (dramsize >= 0x13) {
|
|
|
|
dramsize = (1 << (dramsize - 0x13)) << 20;
|
|
|
|
} else {
|
|
|
|
dramsize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* retrieve size of memory connected to SDRAM CS1 */
|
|
|
|
dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF;
|
|
|
|
if (dramsize2 >= 0x13) {
|
|
|
|
dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
|
|
|
|
} else {
|
|
|
|
dramsize2 = 0;
|
|
|
|
}
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#endif /* CONFIG_SYS_RAMBOOT */
|
2004-06-19 21:19:10 +00:00
|
|
|
|
|
|
|
return dramsize + dramsize2;
|
|
|
|
}
|
2004-03-23 20:18:25 +00:00
|
|
|
|
|
|
|
int checkboard (void)
|
|
|
|
{
|
|
|
|
puts ("Board: MicroSys PM520 \n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void flash_preinit(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Now, when we are in RAM, enable flash write
|
|
|
|
* access for detection process.
|
|
|
|
* Note that CS_BOOT cannot be cleared when
|
|
|
|
* executing in flash.
|
|
|
|
*/
|
|
|
|
*(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
|
|
|
|
}
|
|
|
|
|
2004-06-19 21:19:10 +00:00
|
|
|
void flash_afterinit(ulong start, ulong size)
|
2004-03-23 20:18:25 +00:00
|
|
|
{
|
2004-06-19 21:19:10 +00:00
|
|
|
#if defined(CONFIG_BOOT_ROM)
|
|
|
|
/* adjust mapping */
|
|
|
|
*(vu_long *)MPC5XXX_CS1_START =
|
|
|
|
START_REG(start);
|
|
|
|
*(vu_long *)MPC5XXX_CS1_STOP =
|
|
|
|
STOP_REG(start, size);
|
|
|
|
#else
|
|
|
|
/* adjust mapping */
|
|
|
|
*(vu_long *)MPC5XXX_BOOTCS_START = *(vu_long *)MPC5XXX_CS0_START =
|
|
|
|
START_REG(start);
|
|
|
|
*(vu_long *)MPC5XXX_BOOTCS_STOP = *(vu_long *)MPC5XXX_CS0_STOP =
|
|
|
|
STOP_REG(start, size);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern flash_info_t flash_info[]; /* info for FLASH chips */
|
|
|
|
|
|
|
|
int misc_init_r (void)
|
|
|
|
{
|
|
|
|
/* adjust flash start */
|
|
|
|
gd->bd->bi_flashstart = flash_info[0].start[0];
|
|
|
|
return (0);
|
2004-03-23 20:18:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
static struct pci_controller hose;
|
|
|
|
|
|
|
|
extern void pci_mpc5xxx_init(struct pci_controller *);
|
|
|
|
|
|
|
|
void pci_init_board(void)
|
|
|
|
{
|
|
|
|
pci_mpc5xxx_init(&hose);
|
|
|
|
}
|
|
|
|
#endif
|
2004-06-19 21:19:10 +00:00
|
|
|
|
2007-07-10 15:48:22 +00:00
|
|
|
#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
|
2004-06-19 21:19:10 +00:00
|
|
|
|
|
|
|
void init_ide_reset (void)
|
|
|
|
{
|
|
|
|
debug ("init_ide_reset\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ide_set_reset (int idereset)
|
|
|
|
{
|
|
|
|
debug ("ide_reset(%d)\n", idereset);
|
|
|
|
|
|
|
|
}
|
2007-07-10 15:48:22 +00:00
|
|
|
#endif
|
2004-06-19 21:19:10 +00:00
|
|
|
|
2007-07-09 23:38:39 +00:00
|
|
|
#if defined(CONFIG_CMD_DOC)
|
2004-06-19 21:19:10 +00:00
|
|
|
void doc_init (void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
doc_probe (CONFIG_SYS_DOC_BASE);
|
2004-06-19 21:19:10 +00:00
|
|
|
}
|
|
|
|
#endif
|
2008-08-31 17:03:22 +00:00
|
|
|
|
|
|
|
int board_eth_init(bd_t *bis)
|
|
|
|
{
|
2008-08-31 17:39:12 +00:00
|
|
|
cpu_eth_init(bis); /* Built in FEC comes first */
|
2008-08-31 17:03:22 +00:00
|
|
|
return pci_eth_init(bis);
|
|
|
|
}
|