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 * See file CREDITS for list of people who contributed to this
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #include <asm-ppc/io.h>
35 #include "mt46v32m16-75.h"
37 #ifndef CONFIG_SYS_RAMBOOT
38 static void sdram_start(int hi_addr)
40 volatile struct mpc5xxx_cdm *cdm =
41 (struct mpc5xxx_cdm *)MPC5XXX_CDM;
42 volatile struct mpc5xxx_sdram *sdram =
43 (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
45 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
47 /* unlock mode register */
48 out_be32 (&sdram->ctrl,
49 (SDRAM_CONTROL | 0x80000000 | hi_addr_bit));
51 /* precharge all banks */
52 out_be32 (&sdram->ctrl,
53 (SDRAM_CONTROL | 0x80000002 | hi_addr_bit));
56 /* set mode register: extended mode */
57 out_be32 (&sdram->mode, (SDRAM_EMODE));
59 /* set mode register: reset DLL */
60 out_be32 (&sdram->mode,
61 (SDRAM_MODE | 0x04000000));
64 /* precharge all banks */
65 out_be32 (&sdram->ctrl,
66 (SDRAM_CONTROL | 0x80000002 | hi_addr_bit));
69 out_be32 (&sdram->ctrl,
70 (SDRAM_CONTROL | 0x80000004 | hi_addr_bit));
72 /* set mode register */
73 out_be32 (&sdram->mode, (SDRAM_MODE));
75 /* normal operation */
76 out_be32 (&sdram->ctrl,
77 (SDRAM_CONTROL | hi_addr_bit));
79 /* set CDM clock enable register, set MPC5200B SDRAM bus */
80 /* to reduced driver strength */
81 out_be32 (&cdm->clock_enable, (0x00CFFFFF));
86 * ATTENTION: Although partially referenced initdram does NOT make
87 * real use of CONFIG_SYS_SDRAM_BASE. The code does not
88 * work if CONFIG_SYS_SDRAM_BASE
89 * is something else than 0x00000000.
92 phys_size_t initdram(int board_type)
94 volatile struct mpc5xxx_mmap_ctl *mm =
95 (struct mpc5xxx_mmap_ctl *)CONFIG_SYS_MBAR;
96 volatile struct mpc5xxx_cdm *cdm =
97 (struct mpc5xxx_cdm *)MPC5XXX_CDM;
98 volatile struct mpc5xxx_sdram *sdram =
99 (struct mpc5xxx_sdram *)MPC5XXX_SDRAM;
102 #ifndef CONFIG_SYS_RAMBOOT
105 /* setup SDRAM chip selects */
107 out_be32 (&mm->sdram0, 0x0000001b);
109 out_be32 (&mm->sdram1, 0x10000000);
111 /* setup config registers */
112 out_be32 (&sdram->config1, SDRAM_CONFIG1);
113 out_be32 (&sdram->config2, SDRAM_CONFIG2);
115 #if defined(SDRAM_DDR) && defined(SDRAM_TAPDELAY)
117 out_be32 (&cdm->porcfg, SDRAM_TAPDELAY);
120 /* find RAM size using SDRAM CS0 only */
122 test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
124 test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
131 /* memory smaller than 1MB is impossible */
132 if (dramsize < (1 << 20))
135 /* set SDRAM CS0 size according to the amount of RAM found */
137 out_be32 (&mm->sdram0,
138 (0x13 + __builtin_ffs(dramsize >> 20) - 1));
141 out_be32 (&mm->sdram0, 0);
144 #else /* CONFIG_SYS_RAMBOOT */
146 /* retrieve size of memory connected to SDRAM CS0 */
147 dramsize = in_be32(&mm->sdram0) & 0xFF;
148 if (dramsize >= 0x13)
149 dramsize = (1 << (dramsize - 0x13)) << 20;
153 /* retrieve size of memory connected to SDRAM CS1 */
154 dramsize2 = in_be32(&mm->sdram1) & 0xFF;
155 if (dramsize2 >= 0x13)
156 dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
160 #endif /* CONFIG_SYS_RAMBOOT */
162 return dramsize + dramsize2;
167 puts("Board: phyCORE-MPC5200B-tiny\n");
172 static struct pci_controller hose;
174 extern void pci_mpc5xxx_init(struct pci_controller *);
176 void pci_init_board(void)
178 pci_mpc5xxx_init(&hose);
182 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
183 void ft_board_setup(void *blob, bd_t * bd)
185 ft_cpu_setup(blob, bd);
187 #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
189 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
191 #define GPIO_PSC2_4 0x02000000UL
193 void init_ide_reset(void)
195 volatile struct mpc5xxx_wu_gpio *wu_gpio =
196 (struct mpc5xxx_wu_gpio *)MPC5XXX_WU_GPIO;
197 debug("init_ide_reset\n");
199 /* Configure PSC2_4 as GPIO output for ATA reset */
200 setbits_be32(&wu_gpio->enable, GPIO_PSC2_4);
201 setbits_be32(&wu_gpio->ddr, GPIO_PSC2_4);
203 setbits_be32(&wu_gpio->dvo, GPIO_PSC2_4);
206 void ide_set_reset(int idereset)
208 volatile struct mpc5xxx_wu_gpio *wu_gpio =
209 (struct mpc5xxx_wu_gpio *)MPC5XXX_WU_GPIO;
210 debug("ide_reset(%d)\n", idereset);
213 clrbits_be32(&wu_gpio->dvo, GPIO_PSC2_4);
214 /* Make a delay. MPC5200 spec says 25 usec min */
217 setbits_be32(&wu_gpio->dvo, GPIO_PSC2_4);
219 #endif /* defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET) */