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