3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
9 * Eric Schumann, Phytec Messtechnik GmbH
11 * SPDX-License-Identifier: GPL-2.0+
19 #include "mt46v32m16-75.h"
21 DECLARE_GLOBAL_DATA_PTR;
23 #ifndef CONFIG_SYS_RAMBOOT
24 static void sdram_start(int hi_addr)
26 volatile struct mpc5xxx_cdm *cdm =
27 (struct mpc5xxx_cdm *)MPC5XXX_CDM;
28 volatile struct mpc5xxx_sdram *sdram =
29 (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
31 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
33 /* unlock mode register */
34 out_be32 (&sdram->ctrl,
35 (SDRAM_CONTROL | 0x80000000 | hi_addr_bit));
37 /* precharge all banks */
38 out_be32 (&sdram->ctrl,
39 (SDRAM_CONTROL | 0x80000002 | hi_addr_bit));
42 /* set mode register: extended mode */
43 out_be32 (&sdram->mode, (SDRAM_EMODE));
45 /* set mode register: reset DLL */
46 out_be32 (&sdram->mode,
47 (SDRAM_MODE | 0x04000000));
50 /* precharge all banks */
51 out_be32 (&sdram->ctrl,
52 (SDRAM_CONTROL | 0x80000002 | hi_addr_bit));
55 out_be32 (&sdram->ctrl,
56 (SDRAM_CONTROL | 0x80000004 | hi_addr_bit));
58 /* set mode register */
59 out_be32 (&sdram->mode, (SDRAM_MODE));
61 /* normal operation */
62 out_be32 (&sdram->ctrl,
63 (SDRAM_CONTROL | hi_addr_bit));
65 /* set CDM clock enable register, set MPC5200B SDRAM bus */
66 /* to reduced driver strength */
67 out_be32 (&cdm->clock_enable, (0x00CFFFFF));
72 * ATTENTION: Although partially referenced initdram does NOT make
73 * real use of CONFIG_SYS_SDRAM_BASE. The code does not
74 * work if CONFIG_SYS_SDRAM_BASE
75 * is something else than 0x00000000.
80 volatile struct mpc5xxx_mmap_ctl *mm =
81 (struct mpc5xxx_mmap_ctl *)CONFIG_SYS_MBAR;
82 volatile struct mpc5xxx_cdm *cdm =
83 (struct mpc5xxx_cdm *)MPC5XXX_CDM;
84 volatile struct mpc5xxx_sdram *sdram =
85 (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
88 #ifndef CONFIG_SYS_RAMBOOT
91 /* setup SDRAM chip selects */
93 out_be32 (&mm->sdram0, 0x0000001b);
95 out_be32 (&mm->sdram1, 0x10000000);
97 /* setup config registers */
98 out_be32 (&sdram->config1, SDRAM_CONFIG1);
99 out_be32 (&sdram->config2, SDRAM_CONFIG2);
101 #if defined(SDRAM_DDR) && defined(SDRAM_TAPDELAY)
103 out_be32 (&cdm->porcfg, SDRAM_TAPDELAY);
106 /* find RAM size using SDRAM CS0 only */
108 test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
110 test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
117 /* memory smaller than 1MB is impossible */
118 if (dramsize < (1 << 20))
121 /* set SDRAM CS0 size according to the amount of RAM found */
123 out_be32 (&mm->sdram0,
124 (0x13 + __builtin_ffs(dramsize >> 20) - 1));
127 out_be32 (&mm->sdram0, 0);
130 #else /* CONFIG_SYS_RAMBOOT */
132 /* retrieve size of memory connected to SDRAM CS0 */
133 dramsize = in_be32(&mm->sdram0) & 0xFF;
134 if (dramsize >= 0x13)
135 dramsize = (1 << (dramsize - 0x13)) << 20;
139 /* retrieve size of memory connected to SDRAM CS1 */
140 dramsize2 = in_be32(&mm->sdram1) & 0xFF;
141 if (dramsize2 >= 0x13)
142 dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
146 #endif /* CONFIG_SYS_RAMBOOT */
148 gd->ram_size = dramsize + dramsize2;
155 puts("Board: phyCORE-MPC5200B-tiny\n");
160 static struct pci_controller hose;
162 extern void pci_mpc5xxx_init(struct pci_controller *);
164 void pci_init_board(void)
166 pci_mpc5xxx_init(&hose);
170 #ifdef CONFIG_OF_BOARD_SETUP
171 int ft_board_setup(void *blob, bd_t *bd)
173 ft_cpu_setup(blob, bd);
177 #endif /* CONFIG_OF_BOARD_SETUP */
179 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
181 #define GPIO_PSC2_4 0x02000000UL
183 void init_ide_reset(void)
185 volatile struct mpc5xxx_wu_gpio *wu_gpio =
186 (struct mpc5xxx_wu_gpio *)MPC5XXX_WU_GPIO;
187 debug("init_ide_reset\n");
189 /* Configure PSC2_4 as GPIO output for ATA reset */
190 setbits_be32(&wu_gpio->enable, GPIO_PSC2_4);
191 setbits_be32(&wu_gpio->ddr, GPIO_PSC2_4);
193 setbits_be32(&wu_gpio->dvo, GPIO_PSC2_4);
196 void ide_set_reset(int idereset)
198 volatile struct mpc5xxx_wu_gpio *wu_gpio =
199 (struct mpc5xxx_wu_gpio *)MPC5XXX_WU_GPIO;
200 debug("ide_reset(%d)\n", idereset);
203 clrbits_be32(&wu_gpio->dvo, GPIO_PSC2_4);
204 /* Make a delay. MPC5200 spec says 25 usec min */
207 setbits_be32(&wu_gpio->dvo, GPIO_PSC2_4);
209 #endif /* defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET) */