]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/motionpro/motionpro.c
2 * (C) Copyright 2003-2007
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * modified for Promess PRO - by Andy Joseph, andy@promessdev.com
6 * modified for Promess PRO-Motion - by Robert McCullough, rob@promessdev.com
7 * modified by Chris M. Tumas 6/20/06 Change CAS latency to 2 from 3
8 * Also changed the refresh for 100Mhz operation
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 #if defined(CONFIG_OF_FLAT_TREE)
36 #if defined(CONFIG_STATUS_LED)
37 #include <status_led.h>
38 #endif /* CONFIG_STATUS_LED */
40 /* Kollmorgen DPR initialization data */
46 {0x500003F2, 2, "\x86\x00"}, /* HW parameter */
47 {0x500003F0, 2, "\x00\x00"},
48 {0x500003EC, 4, "\x00\x80\xc1\x52"}, /* Magic word */
52 * Initialize Kollmorgen DPR
54 static void kollmorgen_init(void)
59 for (i
= 0; i
< sizeof(init_seq
) / sizeof(struct init_elem
); ++i
) {
60 p
= (vu_char
*)init_seq
[i
].addr
;
61 for (j
= 0; j
< init_seq
[i
].len
; ++j
)
62 *(p
+ j
) = *(init_seq
[i
].data
+ j
);
65 printf("DPR: Kollmorgen DPR initialized\n");
70 * Early board initalization.
72 int board_early_init_r(void)
74 /* Now, when we are in RAM, disable Boot Chipselect and enable CS0 */
75 *(vu_long
*)MPC5XXX_ADDECR
&= ~(1 << 25);
76 *(vu_long
*)MPC5XXX_ADDECR
|= (1 << 16);
78 /* Initialize Kollmorgen DPR */
86 * Additional PHY intialization. After being reset in mpc5xxx_fec_init_phy(),
87 * PHY goes into FX mode. To take it out of the FX mode and switch into
88 * desired TX operation, one needs to clear the FX_SEL bit of Mode Control
93 unsigned short mode_control
;
95 miiphy_read("FEC ETHERNET", CONFIG_PHY_ADDR
, 0x15, &mode_control
);
96 miiphy_write("FEC ETHERNET", CONFIG_PHY_ADDR
, 0x15,
97 mode_control
& 0xfffe);
103 * Helper function to initialize SDRAM controller.
105 static void sdram_start(int hi_addr
)
107 long hi_addr_bit
= hi_addr
? 0x01000000 : 0;
109 /* unlock mode register */
110 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000000 |
113 /* precharge all banks */
114 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000002 |
118 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000004 |
121 /* auto refresh, second time */
122 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000004 |
125 /* set mode register */
126 *(vu_long
*)MPC5XXX_SDRAM_MODE
= SDRAM_MODE
;
128 /* normal operation */
129 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| hi_addr_bit
;
131 #endif /* !CFG_RAMBOOT */
135 * Initalize SDRAM - configure SDRAM controller, detect memory size.
137 long int initdram(int board_type
)
143 /* configure SDRAM start/end for detection */
144 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0x0000001e; /* 2G at 0x0 */
145 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= 0x80000000; /* disabled */
147 /* setup config registers */
148 *(vu_long
*)MPC5XXX_SDRAM_CONFIG1
= SDRAM_CONFIG1
;
149 *(vu_long
*)MPC5XXX_SDRAM_CONFIG2
= SDRAM_CONFIG2
;
152 test1
= get_ram_size((long *)CFG_SDRAM_BASE
, 0x80000000);
154 test2
= get_ram_size((long *)CFG_SDRAM_BASE
, 0x80000000);
162 /* memory smaller than 1MB is impossible */
163 if (dramsize
< (1 << 20))
166 /* set SDRAM CS0 size according to the amount of RAM found */
168 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0x13 +
169 __builtin_ffs(dramsize
>> 20) - 1;
171 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0; /* disabled */
174 /* let SDRAM CS1 start right after CS0 and disable it */
175 *(vu_long
*) MPC5XXX_SDRAM_CS1CFG
= dramsize
;
177 #else /* !CFG_RAMBOOT */
178 /* retrieve size of memory connected to SDRAM CS0 */
179 dramsize
= *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
& 0xFF;
180 if (dramsize
>= 0x13)
181 dramsize
= (1 << (dramsize
- 0x13)) << 20;
184 #endif /* CFG_RAMBOOT */
186 /* return total ram size */
193 uchar rev
= *(vu_char
*)CPLD_REV_REGISTER
;
194 printf("Board: Promess Motion-PRO board (CPLD rev. 0x%02x)\n", rev
);
199 #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
200 void ft_board_setup(void *blob
, bd_t
*bd
)
202 ft_cpu_setup(blob
, bd
);
204 #endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */
207 #if defined(CONFIG_STATUS_LED)
208 void __led_init(led_id_t regaddr
, int state
)
210 *((vu_long
*) regaddr
) |= ENABLE_GPIO_OUT
;
212 if (state
== STATUS_LED_ON
)
213 *((vu_long
*) regaddr
) |= LED_ON
;
215 *((vu_long
*) regaddr
) &= ~LED_ON
;
218 void __led_set(led_id_t regaddr
, int state
)
220 if (state
== STATUS_LED_ON
)
221 *((vu_long
*) regaddr
) |= LED_ON
;
223 *((vu_long
*) regaddr
) &= ~LED_ON
;
226 void __led_toggle(led_id_t regaddr
)
228 *((vu_long
*) regaddr
) ^= LED_ON
;
230 #endif /* CONFIG_STATUS_LED */