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