3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
9 * Eric Schumann, Phytec Messtechnik GmbH
12 * Eric Millbrandt, DEKA Research and Development Corporation
14 * SPDX-License-Identifier: GPL-2.0+
22 #ifndef CONFIG_SYS_RAMBOOT
23 static void sdram_start(int hi_addr)
25 volatile struct mpc5xxx_cdm *cdm =
26 (struct mpc5xxx_cdm *)MPC5XXX_CDM;
27 volatile struct mpc5xxx_sdram *sdram =
28 (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
30 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
32 /* unlock mode register */
33 out_be32 (&sdram->ctrl,
34 (SDRAM_CONTROL | 0x80000000 | hi_addr_bit));
36 /* precharge all banks */
37 out_be32 (&sdram->ctrl,
38 (SDRAM_CONTROL | 0x80000002 | hi_addr_bit));
41 /* set mode register: extended mode */
42 out_be32 (&sdram->mode, (SDRAM_EMODE));
44 /* set mode register: reset DLL */
45 out_be32 (&sdram->mode, (SDRAM_MODE | 0x04000000));
48 /* precharge all banks */
49 out_be32 (&sdram->ctrl,
50 (SDRAM_CONTROL | 0x80000002 | hi_addr_bit));
53 out_be32 (&sdram->ctrl,
54 (SDRAM_CONTROL | 0x80000004 | hi_addr_bit));
56 /* set mode register */
57 out_be32 (&sdram->mode, (SDRAM_MODE));
59 /* normal operation */
60 out_be32 (&sdram->ctrl,
61 (SDRAM_CONTROL | hi_addr_bit));
63 /* set CDM clock enable register, set MPC5200B SDRAM bus */
64 /* to reduced driver strength */
65 out_be32 (&cdm->clock_enable, (0x00CFFFFF));
70 * ATTENTION: Although partially referenced initdram does NOT make
71 * real use of CONFIG_SYS_SDRAM_BASE. The code does not
72 * work if CONFIG_SYS_SDRAM_BASE
73 * is something else than 0x00000000.
76 phys_size_t initdram(int board_type)
78 volatile struct mpc5xxx_mmap_ctl *mm =
79 (struct mpc5xxx_mmap_ctl *)CONFIG_SYS_MBAR;
80 volatile struct mpc5xxx_sdram *sdram =
81 (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
84 #ifndef CONFIG_SYS_RAMBOOT
87 /* setup SDRAM chip selects */
89 out_be32 (&mm->sdram0, 0x0000001b);
91 out_be32 (&mm->sdram1, 0x10000000);
93 /* setup config registers */
94 out_be32 (&sdram->config1, SDRAM_CONFIG1);
95 out_be32 (&sdram->config2, SDRAM_CONFIG2);
97 /* find RAM size using SDRAM CS0 only */
99 test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
101 test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
108 /* memory smaller than 1MB is impossible */
109 if (dramsize < (1 << 20))
112 /* set SDRAM CS0 size according to the amount of RAM found */
114 out_be32 (&mm->sdram0,
115 (0x13 + __builtin_ffs(dramsize >> 20) - 1));
118 out_be32 (&mm->sdram0, 0);
121 #else /* CONFIG_SYS_RAMBOOT */
123 /* retrieve size of memory connected to SDRAM CS0 */
124 dramsize = in_be32(&mm->sdram0) & 0xFF;
125 if (dramsize >= 0x13)
126 dramsize = (1 << (dramsize - 0x13)) << 20;
130 /* retrieve size of memory connected to SDRAM CS1 */
131 dramsize2 = in_be32(&mm->sdram1) & 0xFF;
132 if (dramsize2 >= 0x13)
133 dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
137 #endif /* CONFIG_SYS_RAMBOOT */
139 return dramsize + dramsize2;
144 puts("Board: galaxy5200\n");
148 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
149 void ft_board_setup(void *blob, bd_t * bd)
151 ft_cpu_setup(blob, bd);
153 #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
155 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
157 void init_ide_reset (void)
159 volatile struct mpc5xxx_gpt *gpt = (struct mpc5xxx_gpt *)MPC5XXX_GPT;
160 debug ("init_ide_reset\n");
162 /* Configure TIMER_5 as GPIO output for ATA reset */
164 gpt[5].emsr = MPC5XXX_GPT_GPIO_OUT1 | MPC5XXX_GPT_TMS_GPIO;
167 void ide_set_reset (int idereset)
169 volatile struct mpc5xxx_gpt *gpt = (struct mpc5xxx_gpt *)MPC5XXX_GPT;
170 debug ("ide_reset(%d)\n", idereset);
172 /* Configure TIMER_5 as GPIO output for ATA reset */
174 gpt[5].emsr = MPC5XXX_GPT_GPIO_OUT0 | MPC5XXX_GPT_TMS_GPIO;
176 /* Make a delay. MPC5200 spec says 25 usec min */
179 gpt[5].emsr = MPC5XXX_GPT_GPIO_OUT1 | MPC5XXX_GPT_TMS_GPIO;
183 #endif /* defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET) */