2 * (C) Copyright 2000 - 2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
13 DECLARE_GLOBAL_DATA_PTR;
17 unsigned int pvr = get_pvr ();
18 unsigned int version = pvr >> 16;
19 unsigned char revision;
20 ulong clock = gd->cpu_clk;
35 return -1; /*not valid for this source */
38 CONFIG_READ_BYTE (REVID, revision);
41 printf (" Revision %d.%d",
42 (revision & 0xf0) >> 4,
45 return -1; /* no valid CPU revision info */
48 printf (" at %s MHz:", strmhz (buf, clock));
50 printf (" %u kB I-Cache", checkicache () >> 10);
51 printf (" %u kB D-Cache", checkdcache () >> 10);
58 /* ------------------------------------------------------------------------- */
61 int checkicache (void)
67 /* ------------------------------------------------------------------------- */
70 int checkdcache (void)
77 /*------------------------------------------------------------------- */
79 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
83 /* Interrupts and MMU off */
84 __asm__ ("mtspr 81, 0");
86 /* Interrupts and MMU off */
87 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
90 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
93 * Trying to execute the next instruction at a non-existing address
94 * should cause a machine check, resulting in reset
96 #ifdef CONFIG_SYS_RESET_ADDRESS
97 addr = CONFIG_SYS_RESET_ADDRESS;
100 * note: when CONFIG_SYS_MONITOR_BASE points to a RAM address,
101 * CONFIG_SYS_MONITOR_BASE - sizeof (ulong) is usually a valid
102 * address. Better pick an address known to be invalid on
103 * your system and assign it to CONFIG_SYS_RESET_ADDRESS.
104 * "(ulong)-1" used to be a good choice for many systems...
106 addr = CONFIG_SYS_MONITOR_BASE - sizeof (ulong);
108 ((void (*)(void)) addr) ();
113 /* ------------------------------------------------------------------------- */
116 * Get timebase clock frequency (like cpu_clk in Hz)
117 * This is the sys_logic_clk (memory bus) divided by 4
119 unsigned long get_tbclk (void)
121 return ((get_bus_freq (0) + 2L) / 4L);
124 /* ------------------------------------------------------------------------- */
127 * The MPC824x has an integrated PCI controller known as the MPC107.
128 * The following are MPC107 Bridge Controller and PCI Support functions
133 * This procedure reads a 32-bit address MPC107 register, and returns
134 * a 32 bit value. It swaps the address to little endian before
135 * writing it to config address, and swaps the value to big endian
136 * before returning to the caller.
138 unsigned int mpc824x_mpc107_getreg (unsigned int regNum)
142 /* swap the addr. to little endian */
143 *(volatile unsigned int *) CHRP_REG_ADDR = PCISWAP (regNum);
144 temp = *(volatile unsigned int *) CHRP_REG_DATA;
145 return PCISWAP (temp); /* swap the data upon return */
149 * This procedure writes a 32-bit address MPC107 register. It swaps
150 * the address to little endian before writing it to config address.
153 void mpc824x_mpc107_setreg (unsigned int regNum, unsigned int regVal)
155 /* swap the addr. to little endian */
156 *(volatile unsigned int *) CHRP_REG_ADDR = PCISWAP (regNum);
157 *(volatile unsigned int *) CHRP_REG_DATA = PCISWAP (regVal);
163 * Write a byte (8 bits) to a memory location.
165 void mpc824x_mpc107_write8 (unsigned int addr, unsigned char data)
167 *(unsigned char *) addr = data;
172 * Write a word (16 bits) to a memory location after the value
173 * has been byte swapped (big to little endian or vice versa)
176 void mpc824x_mpc107_write16 (unsigned int address, unsigned short data)
178 *(volatile unsigned short *) address = BYTE_SWAP_16_BIT (data);
183 * Write a long word (32 bits) to a memory location after the value
184 * has been byte swapped (big to little endian or vice versa)
187 void mpc824x_mpc107_write32 (unsigned int address, unsigned int data)
189 *(volatile unsigned int *) address = LONGSWAP (data);
194 * Read a byte (8 bits) from a memory location.
196 unsigned char mpc824x_mpc107_read8 (unsigned int addr)
198 return *(volatile unsigned char *) addr;
203 * Read a word (16 bits) from a memory location, and byte swap the
204 * value before returning to the caller.
206 unsigned short mpc824x_mpc107_read16 (unsigned int address)
208 unsigned short retVal;
210 retVal = BYTE_SWAP_16_BIT (*(unsigned short *) address);
216 * Read a long word (32 bits) from a memory location, and byte
217 * swap the value before returning to the caller.
219 unsigned int mpc824x_mpc107_read32 (unsigned int address)
223 retVal = LONGSWAP (*(unsigned int *) address);
229 * Read a register in the Embedded Utilities Memory Block address
231 * Input: regNum - register number + utility base address. Example,
232 * the base address of EPIC is 0x40000, the register number
233 * being passed is 0x40000+the address of the target register.
234 * (See epic.h for register addresses).
235 * Output: The 32 bit little endian value of the register.
238 unsigned int mpc824x_eummbar_read (unsigned int regNum)
242 temp = *(volatile unsigned int *) (EUMBBAR_VAL + regNum);
243 temp = PCISWAP (temp);
249 * Write a value to a register in the Embedded Utilities Memory
250 * Block address space.
251 * Input: regNum - register number + utility base address. Example,
252 * the base address of EPIC is 0x40000, the register
253 * number is 0x40000+the address of the target register.
254 * (See epic.h for register addresses).
255 * regVal - value to be written to the register.
258 void mpc824x_eummbar_write (unsigned int regNum, unsigned int regVal)
260 *(volatile unsigned int *) (EUMBBAR_VAL + regNum) = PCISWAP (regVal);
264 /* ------------------------------------------------------------------------- */