2003-07-16 21:53:01 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2004-04-18 23:32:11 +00:00
|
|
|
* (C) Copyright 2004
|
|
|
|
* Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
|
|
|
|
*
|
2003-07-16 21:53:01 +00:00
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <mpc5xxx.h>
|
2003-08-05 18:22:44 +00:00
|
|
|
#include <pci.h>
|
2006-03-29 11:17:09 +00:00
|
|
|
#include <asm/processor.h>
|
2007-09-06 15:46:23 +00:00
|
|
|
#include <libfdt.h>
|
2008-08-31 17:03:22 +00:00
|
|
|
#include <netdev.h>
|
2006-11-28 16:55:49 +00:00
|
|
|
|
2006-03-17 10:42:53 +00:00
|
|
|
#if defined(CONFIG_LITE5200B)
|
|
|
|
#include "mt46v32m16.h"
|
2004-04-18 23:32:11 +00:00
|
|
|
#else
|
2006-03-17 10:42:53 +00:00
|
|
|
# if defined(CONFIG_MPC5200_DDR)
|
|
|
|
# include "mt46v16m16-75.h"
|
|
|
|
# else
|
2004-04-18 23:32:11 +00:00
|
|
|
#include "mt48lc16m16a2-75.h"
|
2006-03-17 10:42:53 +00:00
|
|
|
# endif
|
2004-04-18 23:32:11 +00:00
|
|
|
#endif
|
2007-04-16 12:00:13 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_LITE5200B_PM
|
|
|
|
/* u-boot part of low-power mode implementation */
|
|
|
|
#define SAVED_ADDR (*(void **)0x00000000)
|
|
|
|
#define PSC2_4 0x02
|
|
|
|
|
|
|
|
void lite5200b_wakeup(void)
|
|
|
|
{
|
|
|
|
unsigned char wakeup_pin;
|
|
|
|
void (*linux_wakeup)(void);
|
|
|
|
|
|
|
|
/* check PSC2_4, if it's down "QT" is signaling we have a wakeup
|
|
|
|
* from low power mode */
|
|
|
|
*(vu_char *)MPC5XXX_WU_GPIO_ENABLE = PSC2_4;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
|
|
|
wakeup_pin = *(vu_char *)MPC5XXX_WU_GPIO_DATA_I;
|
|
|
|
if (wakeup_pin & PSC2_4)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* acknowledge to "QT"
|
|
|
|
* by holding pin at 1 for 10 uS */
|
|
|
|
*(vu_char *)MPC5XXX_WU_GPIO_DIR = PSC2_4;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
*(vu_char *)MPC5XXX_WU_GPIO_DATA_O = PSC2_4;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
/* put ram out of self-refresh */
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL |= 0x80000000; /* mode_en */
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL |= 0x50000000; /* cke ref_en */
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL &= ~0x80000000; /* !mode_en */
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
udelay(10); /* wait a bit */
|
|
|
|
|
|
|
|
/* jump back to linux kernel code */
|
|
|
|
linux_wakeup = SAVED_ADDR;
|
|
|
|
printf("\n\nLooks like we just woke, transferring control to 0x%08lx\n",
|
2010-10-24 13:37:12 +00:00
|
|
|
(unsigned long)linux_wakeup);
|
2007-04-16 12:00:13 +00:00
|
|
|
linux_wakeup();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define lite5200b_wakeup()
|
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_RAMBOOT
|
2003-08-17 18:55:18 +00:00
|
|
|
static void sdram_start (int hi_addr)
|
|
|
|
{
|
|
|
|
long hi_addr_bit = hi_addr ? 0x01000000 : 0;
|
2003-07-16 21:53:01 +00:00
|
|
|
|
2003-12-20 22:45:10 +00:00
|
|
|
/* unlock mode register */
|
2004-04-18 23:32:11 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
2004-04-23 20:32:05 +00:00
|
|
|
|
2003-12-20 22:45:10 +00:00
|
|
|
/* precharge all banks */
|
2004-04-18 23:32:11 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
|
|
|
#if SDRAM_DDR
|
2003-12-20 22:45:10 +00:00
|
|
|
/* set mode register: extended mode */
|
2004-04-18 23:32:11 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
2003-12-20 22:45:10 +00:00
|
|
|
/* set mode register: reset DLL */
|
2004-04-18 23:32:11 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
|
|
|
|
__asm__ volatile ("sync");
|
2003-08-17 18:55:18 +00:00
|
|
|
#endif
|
2004-04-18 23:32:11 +00:00
|
|
|
|
|
|
|
/* precharge all banks */
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
2004-03-02 14:05:39 +00:00
|
|
|
/* auto refresh */
|
2004-04-18 23:32:11 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
|
2003-07-16 21:53:01 +00:00
|
|
|
/* set mode register */
|
2004-04-18 23:32:11 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
|
|
|
|
__asm__ volatile ("sync");
|
2004-04-23 20:32:05 +00:00
|
|
|
|
2003-07-16 21:53:01 +00:00
|
|
|
/* normal operation */
|
2004-04-18 23:32:11 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
|
|
|
|
__asm__ volatile ("sync");
|
2003-08-17 18:55:18 +00:00
|
|
|
}
|
2003-08-28 09:41:22 +00:00
|
|
|
#endif
|
2003-08-17 18:55:18 +00:00
|
|
|
|
2004-04-18 23:32:11 +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-04-18 23:32:11 +00:00
|
|
|
* is something else than 0x00000000.
|
|
|
|
*/
|
|
|
|
|
2008-06-09 21:03:40 +00:00
|
|
|
phys_size_t initdram (int board_type)
|
2003-08-17 18:55:18 +00:00
|
|
|
{
|
2003-08-28 09:41:22 +00:00
|
|
|
ulong dramsize = 0;
|
2003-12-20 22:45:10 +00:00
|
|
|
ulong dramsize2 = 0;
|
2006-03-29 11:17:09 +00:00
|
|
|
uint svr, pvr;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_RAMBOOT
|
2003-08-28 09:41:22 +00:00
|
|
|
ulong test1, test2;
|
2004-04-23 20:32:05 +00:00
|
|
|
|
2004-04-18 23:32:11 +00:00
|
|
|
/* setup SDRAM chip selects */
|
2003-08-17 18:55:18 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */
|
2004-04-18 23:32:11 +00:00
|
|
|
__asm__ volatile ("sync");
|
2003-08-17 18:55:18 +00:00
|
|
|
|
2003-12-20 22:45:10 +00:00
|
|
|
/* setup config registers */
|
2004-04-18 23:32:11 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
|
|
|
|
__asm__ volatile ("sync");
|
2004-01-02 14:00:00 +00:00
|
|
|
|
2004-04-18 23:32:11 +00:00
|
|
|
#if SDRAM_DDR
|
|
|
|
/* set tap delay */
|
|
|
|
*(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
|
|
|
|
__asm__ volatile ("sync");
|
2003-12-20 22:45:10 +00:00
|
|
|
#endif
|
2003-08-17 18:55:18 +00:00
|
|
|
|
2004-04-18 23:32:11 +00:00
|
|
|
/* find RAM size using SDRAM CS0 only */
|
2003-08-17 18:55:18 +00:00
|
|
|
sdram_start(0);
|
2008-10-16 13:01:15 +00:00
|
|
|
test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
|
2003-08-17 18:55:18 +00:00
|
|
|
sdram_start(1);
|
2008-10-16 13:01:15 +00:00
|
|
|
test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
|
2003-08-17 18:55:18 +00:00
|
|
|
if (test1 > test2) {
|
|
|
|
sdram_start(0);
|
|
|
|
dramsize = test1;
|
|
|
|
} else {
|
|
|
|
dramsize = test2;
|
|
|
|
}
|
2004-04-18 23:32:11 +00:00
|
|
|
|
|
|
|
/* memory smaller than 1MB is impossible */
|
|
|
|
if (dramsize < (1 << 20)) {
|
|
|
|
dramsize = 0;
|
|
|
|
}
|
2004-04-23 20:32:05 +00:00
|
|
|
|
2004-04-18 23:32:11 +00:00
|
|
|
/* 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 */
|
2003-12-20 22:45:10 +00:00
|
|
|
*(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;/* 2G */
|
2004-04-18 23:32:11 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
2003-12-20 22:45:10 +00:00
|
|
|
if (test1 > test2) {
|
|
|
|
sdram_start(0);
|
|
|
|
dramsize2 = test1;
|
|
|
|
} else {
|
|
|
|
dramsize2 = test2;
|
|
|
|
}
|
2004-04-23 20:32:05 +00:00
|
|
|
|
2004-04-18 23:32:11 +00:00
|
|
|
/* memory smaller than 1MB is impossible */
|
|
|
|
if (dramsize2 < (1 << 20)) {
|
|
|
|
dramsize2 = 0;
|
|
|
|
}
|
2004-04-23 20:32:05 +00:00
|
|
|
|
2004-04-18 23:32:11 +00:00
|
|
|
/* 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-04-18 23:32:11 +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-04-18 23:32:11 +00:00
|
|
|
|
2006-03-29 11:17:09 +00:00
|
|
|
/*
|
2006-04-16 08:51:58 +00:00
|
|
|
* On MPC5200B we need to set the special configuration delay in the
|
|
|
|
* DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM
|
2006-03-29 11:17:09 +00:00
|
|
|
* Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190:
|
|
|
|
*
|
2006-04-16 08:51:58 +00:00
|
|
|
* "The SDelay should be written to a value of 0x00000004. It is
|
|
|
|
* required to account for changes caused by normal wafer processing
|
2006-03-29 11:17:09 +00:00
|
|
|
* parameters."
|
2006-04-16 08:51:58 +00:00
|
|
|
*/
|
2006-03-29 11:17:09 +00:00
|
|
|
svr = get_svr();
|
|
|
|
pvr = get_pvr();
|
2006-04-16 08:51:58 +00:00
|
|
|
if ((SVR_MJREV(svr) >= 2) &&
|
2006-03-29 11:17:09 +00:00
|
|
|
(PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4)) {
|
|
|
|
|
|
|
|
*(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04;
|
|
|
|
__asm__ volatile ("sync");
|
|
|
|
}
|
|
|
|
|
2007-04-16 12:00:13 +00:00
|
|
|
lite5200b_wakeup();
|
|
|
|
|
2004-04-18 23:32:11 +00:00
|
|
|
return dramsize + dramsize2;
|
|
|
|
}
|
|
|
|
|
2003-07-16 21:53:01 +00:00
|
|
|
int checkboard (void)
|
|
|
|
{
|
2006-03-17 10:42:53 +00:00
|
|
|
#if defined (CONFIG_LITE5200B)
|
|
|
|
puts ("Board: Freescale Lite5200B\n");
|
2010-03-12 09:01:12 +00:00
|
|
|
#else
|
2003-07-16 21:53:01 +00:00
|
|
|
puts ("Board: Motorola MPC5200 (IceCube)\n");
|
|
|
|
#endif
|
|
|
|
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 */
|
|
|
|
}
|
2003-08-05 18:22:44 +00:00
|
|
|
|
2003-09-05 23:19:14 +00:00
|
|
|
void flash_afterinit(ulong size)
|
|
|
|
{
|
|
|
|
if (size == 0x800000) { /* adjust mapping */
|
2003-10-15 23:53:47 +00:00
|
|
|
*(vu_long *)MPC5XXX_BOOTCS_START = *(vu_long *)MPC5XXX_CS0_START =
|
2008-10-16 13:01:15 +00:00
|
|
|
START_REG(CONFIG_SYS_BOOTCS_START | size);
|
2003-10-15 23:53:47 +00:00
|
|
|
*(vu_long *)MPC5XXX_BOOTCS_STOP = *(vu_long *)MPC5XXX_CS0_STOP =
|
2008-10-16 13:01:15 +00:00
|
|
|
STOP_REG(CONFIG_SYS_BOOTCS_START | size, size);
|
2003-09-05 23:19:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-05 18:22:44 +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-03-14 00:59:59 +00:00
|
|
|
|
2007-07-10 15:39:10 +00:00
|
|
|
#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
|
2004-03-14 00:59:59 +00:00
|
|
|
|
|
|
|
void init_ide_reset (void)
|
|
|
|
{
|
2004-03-14 14:09:05 +00:00
|
|
|
debug ("init_ide_reset\n");
|
2004-03-14 22:25:36 +00:00
|
|
|
|
2006-11-30 17:02:20 +00:00
|
|
|
/* Configure PSC1_4 as GPIO output for ATA reset */
|
2004-03-14 00:59:59 +00:00
|
|
|
*(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
|
2004-03-14 14:09:05 +00:00
|
|
|
*(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
|
2004-09-28 20:34:50 +00:00
|
|
|
/* Deassert reset */
|
2006-11-01 00:38:16 +00:00
|
|
|
*(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;
|
2004-03-14 00:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ide_set_reset (int idereset)
|
|
|
|
{
|
2004-03-14 14:09:05 +00:00
|
|
|
debug ("ide_reset(%d)\n", idereset);
|
|
|
|
|
2004-03-14 00:59:59 +00:00
|
|
|
if (idereset) {
|
2006-11-01 00:38:16 +00:00
|
|
|
*(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4;
|
2004-09-28 20:34:50 +00:00
|
|
|
/* Make a delay. MPC5200 spec says 25 usec min */
|
|
|
|
udelay(500000);
|
2004-03-14 00:59:59 +00:00
|
|
|
} else {
|
2006-11-01 00:38:16 +00:00
|
|
|
*(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;
|
2004-03-14 00:59:59 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-10 15:39:10 +00:00
|
|
|
#endif
|
2006-11-28 16:55:49 +00:00
|
|
|
|
2007-09-06 15:46:23 +00:00
|
|
|
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
|
2006-11-28 16:55:49 +00:00
|
|
|
void
|
|
|
|
ft_board_setup(void *blob, bd_t *bd)
|
|
|
|
{
|
|
|
|
ft_cpu_setup(blob, bd);
|
|
|
|
}
|
|
|
|
#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);
|
|
|
|
}
|