common: Drop linux/delay.h from common header
[oweals/u-boot.git] / board / freescale / m548xevb / m548xevb.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 <config.h>
11 #include <common.h>
12 #include <init.h>
13 #include <pci.h>
14 #include <asm/immap.h>
15 #include <asm/io.h>
16 #include <linux/delay.h>
17
18 DECLARE_GLOBAL_DATA_PTR;
19
20 int checkboard(void)
21 {
22         puts("Board: ");
23         puts("Freescale FireEngine 5485 EVB\n");
24         return 0;
25 };
26
27 int dram_init(void)
28 {
29         siu_t *siu = (siu_t *) (MMAP_SIU);
30         sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
31         u32 dramsize, i;
32 #ifdef CONFIG_SYS_DRAMSZ1
33         u32 temp;
34 #endif
35
36         out_be32(&siu->drv, CONFIG_SYS_SDRAM_DRVSTRENGTH);
37
38         dramsize = CONFIG_SYS_DRAMSZ * 0x100000;
39         for (i = 0x13; i < 0x20; i++) {
40                 if (dramsize == (1 << i))
41                         break;
42         }
43         i--;
44         out_be32(&siu->cs0cfg, CONFIG_SYS_SDRAM_BASE | i);
45
46 #ifdef CONFIG_SYS_DRAMSZ1
47         temp = CONFIG_SYS_DRAMSZ1 * 0x100000;
48         for (i = 0x13; i < 0x20; i++) {
49                 if (temp == (1 << i))
50                         break;
51         }
52         i--;
53         dramsize += temp;
54         out_be32(&siu->cs1cfg, (CONFIG_SYS_SDRAM_BASE + temp) | i);
55 #endif
56
57         out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
58         out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
59
60         /* Issue PALL */
61         out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
62
63         /* Issue LEMR */
64         out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
65         out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE | 0x04000000);
66
67         udelay(500);
68
69         /* Issue PALL */
70         out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
71
72         /* Perform two refresh cycles */
73         out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
74         out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
75
76         out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
77
78         out_be32(&sdram->ctrl,
79                 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00);
80
81         udelay(100);
82
83         gd->ram_size = dramsize;
84
85         return 0;
86 };
87
88 int testdram(void)
89 {
90         /* TODO: XXX XXX XXX */
91         printf("DRAM test not implemented!\n");
92
93         return (0);
94 }
95
96 #if defined(CONFIG_PCI)
97 /*
98  * Initialize PCI devices, report devices found.
99  */
100 static struct pci_controller hose;
101 extern void pci_mcf547x_8x_init(struct pci_controller *hose);
102
103 void pci_init_board(void)
104 {
105         pci_mcf547x_8x_init(&hose);
106 }
107 #endif                          /* CONFIG_PCI */