2 * (C) Copyright 2000 - 2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 DECLARE_GLOBAL_DATA_PTR;
33 unsigned int pvr = get_pvr ();
34 unsigned int version = pvr >> 16;
35 unsigned char revision;
36 ulong clock = gd->cpu_clk;
51 return -1; /*not valid for this source */
54 CONFIG_READ_BYTE (REVID, revision);
57 printf (" Revision %d.%d",
58 (revision & 0xf0) >> 4,
61 return -1; /* no valid CPU revision info */
64 printf (" at %s MHz:", strmhz (buf, clock));
66 printf (" %u kB I-Cache", checkicache () >> 10);
67 printf (" %u kB D-Cache", checkdcache () >> 10);
74 /* ------------------------------------------------------------------------- */
77 int checkicache (void)
83 /* ------------------------------------------------------------------------- */
86 int checkdcache (void)
93 /*------------------------------------------------------------------- */
95 #ifndef CONFIG_LINKSTATION
96 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
101 /* Interrupts and MMU off */
102 __asm__ ("mtspr 81, 0");
104 /* Interrupts and MMU off */
105 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
108 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
111 * Trying to execute the next instruction at a non-existing address
112 * should cause a machine check, resulting in reset
114 #ifdef CFG_RESET_ADDRESS
115 addr = CFG_RESET_ADDRESS;
118 * note: when CFG_MONITOR_BASE points to a RAM address,
119 * CFG_MONITOR_BASE - sizeof (ulong) is usually a valid
120 * address. Better pick an address known to be invalid on
121 * your system and assign it to CFG_RESET_ADDRESS.
122 * "(ulong)-1" used to be a good choice for many systems...
124 addr = CFG_MONITOR_BASE - sizeof (ulong);
126 ((void (*)(void)) addr) ();
133 /* ------------------------------------------------------------------------- */
136 * Get timebase clock frequency (like cpu_clk in Hz)
137 * This is the sys_logic_clk (memory bus) divided by 4
139 unsigned long get_tbclk (void)
141 return ((get_bus_freq (0) + 2L) / 4L);
144 /* ------------------------------------------------------------------------- */
147 * The MPC824x has an integrated PCI controller known as the MPC107.
148 * The following are MPC107 Bridge Controller and PCI Support functions
153 * This procedure reads a 32-bit address MPC107 register, and returns
154 * a 32 bit value. It swaps the address to little endian before
155 * writing it to config address, and swaps the value to big endian
156 * before returning to the caller.
158 unsigned int mpc824x_mpc107_getreg (unsigned int regNum)
162 /* swap the addr. to little endian */
163 *(volatile unsigned int *) CHRP_REG_ADDR = PCISWAP (regNum);
164 temp = *(volatile unsigned int *) CHRP_REG_DATA;
165 return PCISWAP (temp); /* swap the data upon return */
169 * This procedure writes a 32-bit address MPC107 register. It swaps
170 * the address to little endian before writing it to config address.
173 void mpc824x_mpc107_setreg (unsigned int regNum, unsigned int regVal)
175 /* swap the addr. to little endian */
176 *(volatile unsigned int *) CHRP_REG_ADDR = PCISWAP (regNum);
177 *(volatile unsigned int *) CHRP_REG_DATA = PCISWAP (regVal);
183 * Write a byte (8 bits) to a memory location.
185 void mpc824x_mpc107_write8 (unsigned int addr, unsigned char data)
187 *(unsigned char *) addr = data;
192 * Write a word (16 bits) to a memory location after the value
193 * has been byte swapped (big to little endian or vice versa)
196 void mpc824x_mpc107_write16 (unsigned int address, unsigned short data)
198 *(volatile unsigned short *) address = BYTE_SWAP_16_BIT (data);
203 * Write a long word (32 bits) to a memory location after the value
204 * has been byte swapped (big to little endian or vice versa)
207 void mpc824x_mpc107_write32 (unsigned int address, unsigned int data)
209 *(volatile unsigned int *) address = LONGSWAP (data);
214 * Read a byte (8 bits) from a memory location.
216 unsigned char mpc824x_mpc107_read8 (unsigned int addr)
218 return *(volatile unsigned char *) addr;
223 * Read a word (16 bits) from a memory location, and byte swap the
224 * value before returning to the caller.
226 unsigned short mpc824x_mpc107_read16 (unsigned int address)
228 unsigned short retVal;
230 retVal = BYTE_SWAP_16_BIT (*(unsigned short *) address);
236 * Read a long word (32 bits) from a memory location, and byte
237 * swap the value before returning to the caller.
239 unsigned int mpc824x_mpc107_read32 (unsigned int address)
243 retVal = LONGSWAP (*(unsigned int *) address);
249 * Read a register in the Embedded Utilities Memory Block address
251 * Input: regNum - register number + utility base address. Example,
252 * the base address of EPIC is 0x40000, the register number
253 * being passed is 0x40000+the address of the target register.
254 * (See epic.h for register addresses).
255 * Output: The 32 bit little endian value of the register.
258 unsigned int mpc824x_eummbar_read (unsigned int regNum)
262 temp = *(volatile unsigned int *) (EUMBBAR_VAL + regNum);
263 temp = PCISWAP (temp);
269 * Write a value to a register in the Embedded Utilities Memory
270 * Block address space.
271 * Input: regNum - register number + utility base address. Example,
272 * the base address of EPIC is 0x40000, the register
273 * number is 0x40000+the address of the target register.
274 * (See epic.h for register addresses).
275 * regVal - value to be written to the register.
278 void mpc824x_eummbar_write (unsigned int regNum, unsigned int regVal)
280 *(volatile unsigned int *) (EUMBBAR_VAL + regNum) = PCISWAP (regVal);
284 /* ------------------------------------------------------------------------- */