summaryrefslogtreecommitdiff
path: root/board/mpc8560ads/mpc8560ads.c
diff options
context:
space:
mode:
authorwdenk <wdenk>2004-07-09 23:27:13 +0000
committerwdenk <wdenk>2004-07-09 23:27:13 +0000
commit0ac6f8b7498d3608bd1de2280a014e9e23d7b1f2 (patch)
treede6ad6c1ee05c1ebcee774a2e8c772e7b2e57586 /board/mpc8560ads/mpc8560ads.c
parent262381329b87511ed862cde139a3a1ff49e9d7eb (diff)
downloadu-boot-imx-0ac6f8b7498d3608bd1de2280a014e9e23d7b1f2.zip
u-boot-imx-0ac6f8b7498d3608bd1de2280a014e9e23d7b1f2.tar.gz
u-boot-imx-0ac6f8b7498d3608bd1de2280a014e9e23d7b1f2.tar.bz2
Patch by Jon Loeliger, 17 June 2004:
Completion of the 8540ADS/8560ADS updates: Fix some PCI and Rapid I/O memory maps, Initialize both TSEC 1 and 2, Initialize SDRAM Update MAINTAINER for 85xx boards and README.mpc85xxads
Diffstat (limited to 'board/mpc8560ads/mpc8560ads.c')
-rw-r--r--board/mpc8560ads/mpc8560ads.c241
1 files changed, 140 insertions, 101 deletions
diff --git a/board/mpc8560ads/mpc8560ads.c b/board/mpc8560ads/mpc8560ads.c
index 2fa96e0..a0f6b97 100644
--- a/board/mpc8560ads/mpc8560ads.c
+++ b/board/mpc8560ads/mpc8560ads.c
@@ -25,8 +25,6 @@
*/
-extern long int spd_sdram (void);
-
#include <common.h>
#include <asm/processor.h>
#include <asm/immap_85xx.h>
@@ -34,7 +32,15 @@ extern long int spd_sdram (void);
#include <spd.h>
#include <miiphy.h>
-long int fixed_sdram (void);
+#if defined(CONFIG_DDR_ECC)
+extern void ddr_enable_ecc(unsigned int dram_size);
+#endif
+
+extern long int spd_sdram(void);
+
+void sdram_init(void);
+long int fixed_sdram(void);
+
/*
* I/O Port configuration table
@@ -190,8 +196,11 @@ const iop_conf_t iop_conf_tab[4][32] = {
}
};
-/* MPC8560ADS Board Status & Control Registers */
-typedef struct bscr_ {
+
+/*
+ * MPC8560ADS Board Status & Control Registers
+ */
+typedef struct bcsr_ {
volatile unsigned char bcsr0;
volatile unsigned char bcsr1;
volatile unsigned char bcsr2;
@@ -203,11 +212,12 @@ typedef struct bscr_ {
int board_early_init_f (void)
{
#if defined(CONFIG_PCI)
- volatile immap_t *immr = (immap_t *)CFG_IMMR;
- volatile ccsr_pcix_t *pci = &immr->im_pcix;
+ volatile immap_t *immr = (immap_t *) CFG_IMMR;
+ volatile ccsr_pcix_t *pci = &immr->im_pcix;
- pci->peer &= 0xfffffffdf; /* disable master abort */
+ pci->peer &= 0xffffffdf; /* disable master abort */
#endif
+
return 0;
}
@@ -237,35 +247,41 @@ void reset_phy (void)
#endif /* CONFIG_MII */
}
-
int checkboard (void)
{
puts("Board: ADS\n");
+
+#ifdef CONFIG_PCI
+ printf(" PCI1: 32 bit, %d MHz (compiled)\n",
+ CONFIG_SYS_CLK_FREQ / 1000000);
+#else
+ printf(" PCI1: disabled\n");
+#endif
return 0;
}
-long int initdram (int board_type)
+long int
+initdram(int board_type)
{
long dram_size = 0;
extern long spd_sdram (void);
volatile immap_t *immap = (immap_t *)CFG_IMMR;
-#if !defined(CONFIG_RAM_AS_FLASH)
- volatile ccsr_lbc_t *lbc= &immap->im_lbc;
- sys_info_t sysinfo;
- uint temp_lbcdll = 0;
-#endif
-#if !defined(CONFIG_RAM_AS_FLASH) || defined(CONFIG_DDR_DLL)
- volatile ccsr_gur_t *gur= &immap->im_gur;
-#endif
-#if defined(CONFIG_DDR_DLL)
- uint temp_ddrdll = 0;
+ puts("Initializing\n");
- /* Work around to stabilize DDR DLL */
- temp_ddrdll = gur->ddrdllcr;
- gur->ddrdllcr = ((temp_ddrdll & 0xff) << 16) | 0x80000000;
- asm("sync;isync;msync");
+#if defined(CONFIG_DDR_DLL)
+ {
+ volatile ccsr_gur_t *gur= &immap->im_gur;
+ uint temp_ddrdll = 0;
+
+ /*
+ * Work around to stabilize DDR DLL
+ */
+ temp_ddrdll = gur->ddrdllcr;
+ gur->ddrdllcr = ((temp_ddrdll & 0xff) << 16) | 0x80000000;
+ asm("sync;isync;msync");
+ }
#endif
#if defined(CONFIG_SPD_EEPROM)
@@ -274,98 +290,120 @@ long int initdram (int board_type)
dram_size = fixed_sdram ();
#endif
-#if !defined(CONFIG_RAM_AS_FLASH) /* LocalBus SDRAM is not emulating flash */
- get_sys_info(&sysinfo);
- /* if localbus freq is less than 66Mhz,we use bypass mode,otherwise use DLL */
- if(sysinfo.freqSystemBus/(CFG_LBC_LCRR & 0x0f) < 66000000) {
- lbc->lcrr = (CFG_LBC_LCRR & 0x0fffffff)| 0x80000000;
+#if defined(CONFIG_DDR_ECC)
+ /*
+ * Initialize and enable DDR ECC.
+ */
+ ddr_enable_ecc(dram_size);
+#endif
+
+ /*
+ * Initialize SDRAM.
+ */
+ sdram_init();
+
+ puts(" DDR: ");
+ return dram_size;
+}
+
+
+/*
+ * Initialize SDRAM memory on the Local Bus.
+ */
+
+void sdram_init (void)
+{
+#if !defined(CONFIG_RAM_AS_FLASH)
+ sys_info_t sysinfo;
+ volatile immap_t *immap = (immap_t *) CFG_IMMR;
+ volatile ccsr_lbc_t *lbc = &immap->im_lbc;
+ uint *sdram_addr = (uint *) CFG_LBC_SDRAM_BASE;
+
+ puts (" SDRAM: ");
+ print_size (CFG_LBC_SDRAM_SIZE * 1024 * 1024, "\n");
+
+ /*
+ * LocalBus SDRAM is not emulating flash.
+ */
+
+ /*
+ * Fix Local Bus clock glitch. Errata LBC11.
+ *
+ * If localbus freq is less than 66Mhz, use bypass mode,
+ * otherwise use DLL.
+ * lcrr is the local-bus clock ratio register.
+ */
+ get_sys_info (&sysinfo);
+ if (sysinfo.freqSystemBus / (CFG_LBC_LCRR & 0x0f) < 66000000) {
+ lbc->lcrr = (CFG_LBC_LCRR & 0x0fffffff) | 0x80000000;
+
} else {
- uint pvr = get_pvr();
+ /*
+ * On REV1 boards, need to change CLKDIV before enable DLL.
+ * Default CLKDIV is 8, change it to 4 temporarily.
+ */
+ volatile ccsr_gur_t *gur = &immap->im_gur;
+ uint pvr = get_pvr ();
+ uint temp_lbcdll = 0;
if (pvr == PVR_85xx_REV1) {
- /*
- * Need change CLKDIV before enable DLL.
- * Default CLKDIV is 8, change it to 4
- * temporarily.
- */
- lbc->lcrr = 0x10000004;
+ lbc->lcrr = 0x10000004;
}
+
+ /* FIXME: jdl Should lcrr have 0x8000000 OR'ed in here too? */
lbc->lcrr = CFG_LBC_LCRR & 0x7fffffff;
- udelay(200);
+ udelay (200);
temp_lbcdll = gur->lbcdllcr;
- gur->lbcdllcr = ((temp_lbcdll & 0xff) << 16 ) | 0x80000000;
- asm("sync;isync;msync");
+ gur->lbcdllcr = ((temp_lbcdll & 0xff) << 16) | 0x80000000;
+ asm ("sync;isync;msync");
}
- lbc->or2 = CFG_OR2_PRELIM; /* 64MB SDRAM */
+
+ /*
+ * Setup SDRAM Base and Option Registers
+ */
+ lbc->or2 = CFG_OR2_PRELIM;
lbc->br2 = CFG_BR2_PRELIM;
lbc->lbcr = CFG_LBC_LBCR;
+ asm ("msync");
+
+ lbc->lsrt = CFG_LBC_LSRT;
+ lbc->mrtpr = CFG_LBC_MRTPR;
+ asm ("sync");
+
+ /*
+ * Configure the SDRAM controller.
+ */
lbc->lsdmr = CFG_LBC_LSDMR_1;
- asm("sync");
- (unsigned int) * (ulong *)0 = 0x000000ff;
+ asm ("sync");
+ *sdram_addr = 0xff;
+ ppcDcbf ((unsigned long) sdram_addr);
+ udelay (100);
+
lbc->lsdmr = CFG_LBC_LSDMR_2;
- asm("sync");
- (unsigned int) * (ulong *)0 = 0x000000ff;
+ asm ("sync");
+ *sdram_addr = 0xff;
+ ppcDcbf ((unsigned long) sdram_addr);
+ udelay (100);
+
lbc->lsdmr = CFG_LBC_LSDMR_3;
- asm("sync");
- (unsigned int) * (ulong *)0 = 0x000000ff;
- lbc->lsdmr = CFG_LBC_LSDMR_4;
- asm("sync");
- (unsigned int) * (ulong *)0 = 0x000000ff;
- lbc->lsdmr = CFG_LBC_LSDMR_5;
- asm("sync");
- lbc->lsrt = CFG_LBC_LSRT;
- asm("sync");
- lbc->mrtpr = CFG_LBC_MRTPR;
- asm("sync");
-#endif
+ asm ("sync");
+ *sdram_addr = 0xff;
+ ppcDcbf ((unsigned long) sdram_addr);
+ udelay (100);
-#if defined(CONFIG_DDR_ECC)
- {
- /* Initialize all of memory for ECC, then
- * enable errors */
- uint *p = 0;
- uint i = 0;
- volatile immap_t *immap = (immap_t *)CFG_IMMR;
- volatile ccsr_ddr_t *ddr= &immap->im_ddr;
- dma_init();
- for (*p = 0; p < (uint *)(8 * 1024); p++) {
- if (((unsigned int)p & 0x1f) == 0) { dcbz(p); }
- *p = (unsigned int)0xdeadbeef;
- if (((unsigned int)p & 0x1c) == 0x1c) { dcbf(p); }
- }
+ lbc->lsdmr = CFG_LBC_LSDMR_4;
+ asm ("sync");
+ *sdram_addr = 0xff;
+ ppcDcbf ((unsigned long) sdram_addr);
+ udelay (100);
- /* 8K */
- dma_xfer((uint *)0x2000,0x2000,(uint *)0);
- /* 16K */
- dma_xfer((uint *)0x4000,0x4000,(uint *)0);
- /* 32K */
- dma_xfer((uint *)0x8000,0x8000,(uint *)0);
- /* 64K */
- dma_xfer((uint *)0x10000,0x10000,(uint *)0);
- /* 128k */
- dma_xfer((uint *)0x20000,0x20000,(uint *)0);
- /* 256k */
- dma_xfer((uint *)0x40000,0x40000,(uint *)0);
- /* 512k */
- dma_xfer((uint *)0x80000,0x80000,(uint *)0);
- /* 1M */
- dma_xfer((uint *)0x100000,0x100000,(uint *)0);
- /* 2M */
- dma_xfer((uint *)0x200000,0x200000,(uint *)0);
- /* 4M */
- dma_xfer((uint *)0x400000,0x400000,(uint *)0);
-
- for (i = 1; i < dram_size / 0x800000; i++) {
- dma_xfer((uint *)(0x800000*i),0x800000,(uint *)0);
- }
+ lbc->lsdmr = CFG_LBC_LSDMR_5;
+ asm ("sync");
+ *sdram_addr = 0xff;
+ ppcDcbf ((unsigned long) sdram_addr);
+ udelay (100);
- /* Enable errors for ECC */
- ddr->err_disable = 0x00000000;
- asm("sync;isync;msync");
- }
#endif
-
- return dram_size;
}
@@ -403,6 +441,7 @@ int testdram (void)
}
#endif
+
#if !defined(CONFIG_SPD_EEPROM)
/*************************************************************************
* fixed sdram init -- doesn't use serial presence detect.
@@ -434,6 +473,6 @@ long int fixed_sdram (void)
asm("sync; isync; msync");
udelay(500);
#endif
- return ( CFG_SDRAM_SIZE * 1024 * 1024);
+ return CFG_SDRAM_SIZE * 1024 * 1024;
}
#endif /* !defined(CONFIG_SPD_EEPROM) */