Home | History | Annotate | Download | only in m54451evb
      1 // SPDX-License-Identifier: GPL-2.0+
      2 /*
      3  * (C) Copyright 2000-2003
      4  * Wolfgang Denk, DENX Software Engineering, wd (at) denx.de.
      5  *
      6  * Copyright (C) 2004-2008, 2012 Freescale Semiconductor, Inc.
      7  * TsiChung Liew (Tsi-Chung.Liew (at) freescale.com)
      8  */
      9 
     10 #include <common.h>
     11 #include <spi.h>
     12 #include <asm/immap.h>
     13 #include <asm/io.h>
     14 
     15 DECLARE_GLOBAL_DATA_PTR;
     16 
     17 int checkboard(void)
     18 {
     19 	/*
     20 	 * need to to:
     21 	 * Check serial flash size. if 2mb evb, else 8mb demo
     22 	 */
     23 	puts("Board: ");
     24 	puts("Freescale M54451 EVB\n");
     25 	return 0;
     26 };
     27 
     28 int dram_init(void)
     29 {
     30 	u32 dramsize;
     31 #ifdef CONFIG_CF_SBF
     32 	/*
     33 	 * Serial Boot: The dram is already initialized in start.S
     34 	 * only require to return DRAM size
     35 	 */
     36 	dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
     37 #else
     38 	sdramc_t *sdram = (sdramc_t *)(MMAP_SDRAM);
     39 	gpio_t *gpio = (gpio_t *)(MMAP_GPIO);
     40 	u32 i;
     41 
     42 	dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
     43 
     44 	if ((in_be32(&sdram->sdcfg1) == CONFIG_SYS_SDRAM_CFG1) &&
     45 	    (in_be32(&sdram->sdcfg2) == CONFIG_SYS_SDRAM_CFG2))
     46 		return dramsize;
     47 
     48 	for (i = 0x13; i < 0x20; i++) {
     49 		if (dramsize == (1 << i))
     50 			break;
     51 	}
     52 	i--;
     53 
     54 	out_8(&gpio->mscr_sdram, CONFIG_SYS_SDRAM_DRV_STRENGTH);
     55 
     56 	out_be32(&sdram->sdcs0, CONFIG_SYS_SDRAM_BASE | i);
     57 
     58 	out_be32(&sdram->sdcfg1, CONFIG_SYS_SDRAM_CFG1);
     59 	out_be32(&sdram->sdcfg2, CONFIG_SYS_SDRAM_CFG2);
     60 
     61 	udelay(200);
     62 
     63 	/* Issue PALL */
     64 	out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 2);
     65 	__asm__("nop");
     66 
     67 	/* Perform two refresh cycles */
     68 	out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
     69 	__asm__("nop");
     70 	out_be32(&sdram->sdcr, CONFIG_SYS_SDRAM_CTRL | 4);
     71 	__asm__("nop");
     72 
     73 	/* Issue LEMR */
     74 	out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE);
     75 	__asm__("nop");
     76 	out_be32(&sdram->sdmr, CONFIG_SYS_SDRAM_MODE);
     77 	__asm__("nop");
     78 
     79 	out_be32(&sdram->sdcr,
     80 		(CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000000);
     81 
     82 	udelay(100);
     83 #endif
     84 	gd->ram_size = dramsize;
     85 
     86 	return 0;
     87 };
     88 
     89 int testdram(void)
     90 {
     91 	/* TODO: XXX XXX XXX */
     92 	printf("DRAM test not implemented!\n");
     93 
     94 	return (0);
     95 }
     96