]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cpu/mpc5xx/cpu.c
3 * Martin Winistoerfer, martinwinistoerfer@gmx.ch.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
26 * Discription: Some cpu specific function for watchdog,
27 * cpu version test, clock setting ...
37 DECLARE_GLOBAL_DATA_PTR
;
39 #if (defined(CONFIG_MPC555))
40 # define ID_STR "MPC555/556"
43 * Check version of cpu with Processor Version Register (PVR)
45 static int check_cpu_version ( long clock
, uint pvr
, uint immr
)
48 /* The highest 16 bits should be 0x0002 for a MPC555/556 */
49 if (( pvr
>> 16 ) == 0x0002 ) {
50 printf ( " " ID_STR
" Version %x" , ( pvr
>> 16 ));
51 printf ( " at %s MHz:" , strmhz ( buf
, clock
));
53 printf ( "Not supported cpu version" );
58 #endif /* CONFIG_MPC555 */
62 * Check version of mpc5xx
66 ulong clock
= gd
-> cpu_clk
;
67 uint immr
= get_immr ( 0 ); /* Return full IMMR contents */
68 uint pvr
= get_pvr (); /* Retrieve PVR register */
72 return check_cpu_version ( clock
, pvr
, immr
);
76 * Called by macro WATCHDOG_RESET
78 #if defined(CONFIG_WATCHDOG)
79 void watchdog_reset ( void )
81 int re_enable
= disable_interrupts ();
83 reset_5xx_watchdog (( immap_t
*) CONFIG_SYS_IMMR
);
89 * Will clear software reset
91 void reset_5xx_watchdog ( volatile immap_t
* immr
)
93 /* Use the MPC5xx Internal Watchdog */
94 immr
-> im_siu_conf
. sc_swsr
= 0x556c ; /* Prevent SW time-out */
95 immr
-> im_siu_conf
. sc_swsr
= 0xaa39 ;
98 #endif /* CONFIG_WATCHDOG */
102 * Get timebase clock frequency
104 unsigned long get_tbclk ( void )
106 volatile immap_t
* immr
= ( volatile immap_t
*) CONFIG_SYS_IMMR
;
107 ulong oscclk
, factor
;
109 if ( immr
-> im_clkrst
. car_sccr
& SCCR_TBS
) {
110 return ( gd
-> cpu_clk
/ 16 );
113 factor
= ((( CONFIG_SYS_PLPRCR
) & PLPRCR_MF_MSK
) >> PLPRCR_MF_SHIFT
) + 1 ;
115 oscclk
= gd
-> cpu_clk
/ factor
;
117 if (( immr
-> im_clkrst
. car_sccr
& SCCR_RTSEL
) == 0 || factor
> 2 ) {
120 return ( oscclk
/ 16 );
123 void dcache_enable ( void )
128 void dcache_disable ( void )
133 int dcache_status ( void )
135 return 0 ; /* always off */
141 int do_reset ( cmd_tbl_t
* cmdtp
, int flag
, int argc
, char * argv
[])
143 #if defined(CONFIG_PATI)
144 volatile ulong
* addr
= ( ulong
*) CONFIG_SYS_RESET_ADDRESS
;
149 /* Interrupts off, enable reset */
150 __asm__
volatile ( " mtspr 81, %r0 \n\t "
152 " rlwinm %r31,%r3,0,25,23 \n\t "
155 * Trying to execute the next instruction at a non-existing address
156 * should cause a machine check, resulting in reset
158 #ifdef CONFIG_SYS_RESET_ADDRESS
159 addr
= CONFIG_SYS_RESET_ADDRESS
;
162 * note: when CONFIG_SYS_MONITOR_BASE points to a RAM address, CONFIG_SYS_MONITOR_BASE * - sizeof (ulong) is usually a valid address. Better pick an address
163 * known to be invalid on your system and assign it to CONFIG_SYS_RESET_ADDRESS.
164 * "(ulong)-1" used to be a good choice for many systems...
166 addr
= CONFIG_SYS_MONITOR_BASE
- sizeof ( ulong
);
168 (( void (*) ( void )) addr
) ();
169 #endif /* #if defined(CONFIG_PATI) */