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 print_size(checkicache(), " I-Cache ");
51 print_size(checkdcache(), " D-Cache\n");
56 /* ------------------------------------------------------------------------- */
59 int checkicache (void)
65 /* ------------------------------------------------------------------------- */
68 int checkdcache (void)
75 /*------------------------------------------------------------------- */
77 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
81 /* Interrupts and MMU off */
82 __asm__ ("mtspr 81, 0");
84 /* Interrupts and MMU off */
85 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
88 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
91 * Trying to execute the next instruction at a non-existing address
92 * should cause a machine check, resulting in reset
94 #ifdef CONFIG_SYS_RESET_ADDRESS
95 addr = CONFIG_SYS_RESET_ADDRESS;
98 * note: when CONFIG_SYS_MONITOR_BASE points to a RAM address,
99 * CONFIG_SYS_MONITOR_BASE - sizeof (ulong) is usually a valid
100 * address. Better pick an address known to be invalid on
101 * your system and assign it to CONFIG_SYS_RESET_ADDRESS.
102 * "(ulong)-1" used to be a good choice for many systems...
104 addr = CONFIG_SYS_MONITOR_BASE - sizeof (ulong);
106 ((void (*)(void)) addr) ();
111 /* ------------------------------------------------------------------------- */
114 * Get timebase clock frequency (like cpu_clk in Hz)
115 * This is the sys_logic_clk (memory bus) divided by 4
117 unsigned long get_tbclk (void)
119 return ((get_bus_freq (0) + 2L) / 4L);
122 /* ------------------------------------------------------------------------- */
125 * The MPC824x has an integrated PCI controller known as the MPC107.
126 * The following are MPC107 Bridge Controller and PCI Support functions
131 * This procedure reads a 32-bit address MPC107 register, and returns
132 * a 32 bit value. It swaps the address to little endian before
133 * writing it to config address, and swaps the value to big endian
134 * before returning to the caller.
136 unsigned int mpc824x_mpc107_getreg (unsigned int regNum)
140 /* swap the addr. to little endian */
141 *(volatile unsigned int *) CHRP_REG_ADDR = PCISWAP (regNum);
142 temp = *(volatile unsigned int *) CHRP_REG_DATA;
143 return PCISWAP (temp); /* swap the data upon return */
147 * This procedure writes a 32-bit address MPC107 register. It swaps
148 * the address to little endian before writing it to config address.
151 void mpc824x_mpc107_setreg (unsigned int regNum, unsigned int regVal)
153 /* swap the addr. to little endian */
154 *(volatile unsigned int *) CHRP_REG_ADDR = PCISWAP (regNum);
155 *(volatile unsigned int *) CHRP_REG_DATA = PCISWAP (regVal);
161 * Write a byte (8 bits) to a memory location.
163 void mpc824x_mpc107_write8 (unsigned int addr, unsigned char data)
165 *(unsigned char *) addr = data;
170 * Write a word (16 bits) to a memory location after the value
171 * has been byte swapped (big to little endian or vice versa)
174 void mpc824x_mpc107_write16 (unsigned int address, unsigned short data)
176 *(volatile unsigned short *) address = BYTE_SWAP_16_BIT (data);
181 * Write a long word (32 bits) to a memory location after the value
182 * has been byte swapped (big to little endian or vice versa)
185 void mpc824x_mpc107_write32 (unsigned int address, unsigned int data)
187 *(volatile unsigned int *) address = LONGSWAP (data);
192 * Read a byte (8 bits) from a memory location.
194 unsigned char mpc824x_mpc107_read8 (unsigned int addr)
196 return *(volatile unsigned char *) addr;
201 * Read a word (16 bits) from a memory location, and byte swap the
202 * value before returning to the caller.
204 unsigned short mpc824x_mpc107_read16 (unsigned int address)
206 unsigned short retVal;
208 retVal = BYTE_SWAP_16_BIT (*(unsigned short *) address);
214 * Read a long word (32 bits) from a memory location, and byte
215 * swap the value before returning to the caller.
217 unsigned int mpc824x_mpc107_read32 (unsigned int address)
221 retVal = LONGSWAP (*(unsigned int *) address);
227 * Read a register in the Embedded Utilities Memory Block address
229 * Input: regNum - register number + utility base address. Example,
230 * the base address of EPIC is 0x40000, the register number
231 * being passed is 0x40000+the address of the target register.
232 * (See epic.h for register addresses).
233 * Output: The 32 bit little endian value of the register.
236 unsigned int mpc824x_eummbar_read (unsigned int regNum)
240 temp = *(volatile unsigned int *) (EUMBBAR_VAL + regNum);
241 temp = PCISWAP (temp);
247 * Write a value to a register in the Embedded Utilities Memory
248 * Block address space.
249 * Input: regNum - register number + utility base address. Example,
250 * the base address of EPIC is 0x40000, the register
251 * number is 0x40000+the address of the target register.
252 * (See epic.h for register addresses).
253 * regVal - value to be written to the register.
256 void mpc824x_eummbar_write (unsigned int regNum, unsigned int regVal)
258 *(volatile unsigned int *) (EUMBBAR_VAL + regNum) = PCISWAP (regVal);
262 /* ------------------------------------------------------------------------- */