powerpc, 8xx: remove support for 8xx
[oweals/u-boot.git] / arch / powerpc / cpu / mpc8260 / cpu.c
1 /*
2  * (C) Copyright 2000-2006
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 /*
9  * CPU specific code for the MPC825x / MPC826x / MPC827x / MPC828x
10  *
11  * written or collected and sometimes rewritten by
12  * Magnus Damm <damm@bitsmart.com>
13  *
14  * modified by
15  * Wolfgang Denk <wd@denx.de>
16  *
17  * modified for 8260 by
18  * Murray Jensen <Murray.Jensen@cmst.csiro.au>
19  *
20  * added 8260 masks by
21  * Marius Groeger <mag@sysgo.de>
22  *
23  * added HiP7 (824x/827x/8280) processors support by
24  * Yuli Barcohen <yuli@arabellasw.com>
25  */
26
27 #include <common.h>
28 #include <watchdog.h>
29 #include <command.h>
30 #include <mpc8260.h>
31 #include <netdev.h>
32 #include <asm/processor.h>
33 #include <asm/cpm_8260.h>
34
35 #if defined(CONFIG_OF_LIBFDT)
36 #include <libfdt.h>
37 #include <fdt_support.h>
38 #endif
39
40 DECLARE_GLOBAL_DATA_PTR;
41
42 #if defined(CONFIG_GET_CPU_STR_F)
43 extern int get_cpu_str_f (char *buf);
44 #endif
45
46 int checkcpu (void)
47 {
48         volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
49         ulong clock = gd->cpu_clk;
50         uint pvr = get_pvr ();
51         uint immr, rev, m, k;
52         char buf[32];
53         int ret;
54
55         ret = prt_8260_rsr();
56         if (ret)
57                 return ret;
58         ret = prt_8260_clks();
59         if (ret)
60                 return ret;
61         puts ("CPU:   ");
62
63         switch (pvr) {
64         case PVR_8260:
65         case PVR_8260_HIP3:
66                 k = 3;
67                 break;
68         case PVR_8260_HIP4:
69                 k = 4;
70                 break;
71         case PVR_8260_HIP7R1:
72         case PVR_8260_HIP7RA:
73         case PVR_8260_HIP7:
74                 k = 7;
75                 break;
76         default:
77                 return -1;      /* whoops! not an MPC8260 */
78         }
79         rev = pvr & 0xff;
80
81         immr = immap->im_memctl.memc_immr;
82         if ((immr & IMMR_ISB_MSK) != CONFIG_SYS_IMMR)
83                 return -1;      /* whoops! someone moved the IMMR */
84
85 #if defined(CONFIG_GET_CPU_STR_F)
86         get_cpu_str_f (buf);
87         printf ("%s (HiP%d Rev %02x, Mask ", buf, k, rev);
88 #else
89         printf (CPU_ID_STR " (HiP%d Rev %02x, Mask ", k, rev);
90 #endif
91
92         /*
93          * the bottom 16 bits of the immr are the Part Number and Mask Number
94          * (4-34); the 16 bits at PROFF_REVNUM (0x8af0) in dual port ram is the
95          * RISC Microcode Revision Number (13-10).
96          * For the 8260, Motorola doesn't include the Microcode Revision
97          * in the mask.
98          */
99         m = immr & (IMMR_PARTNUM_MSK | IMMR_MASKNUM_MSK);
100         k = immap->im_dprambase16[PROFF_REVNUM / sizeof(u16)];
101
102         switch (m) {
103         case 0x0000:
104                 puts ("0.2 2J24M");
105                 break;
106         case 0x0010:
107                 puts ("A.0 K22A");
108                 break;
109         case 0x0011:
110                 puts ("A.1 1K22A-XC");
111                 break;
112         case 0x0001:
113                 puts ("B.1 1K23A");
114                 break;
115         case 0x0021:
116                 puts ("B.2 2K23A-XC");
117                 break;
118         case 0x0023:
119                 puts ("B.3 3K23A");
120                 break;
121         case 0x0024:
122                 puts ("C.2 6K23A");
123                 break;
124         case 0x0060:
125                 puts ("A.0(A) 2K25A");
126                 break;
127         case 0x0062:
128                 puts ("B.1 4K25A");
129                 break;
130         case 0x0064:
131                 puts ("C.0 5K25A");
132                 break;
133         case 0x0A00:
134                 puts ("0.0 0K49M");
135                 break;
136         case 0x0A01:
137                 puts ("0.1 1K49M");
138                 break;
139         case 0x0A10:
140                 puts ("1.0 1K49M");
141                 break;
142         case 0x0C00:
143                 puts ("0.0 0K50M");
144                 break;
145         case 0x0C10:
146                 puts ("1.0 1K50M");
147                 break;
148         case 0x0D00:
149                 puts ("0.0 0K50M");
150                 break;
151         case 0x0D10:
152                 puts ("1.0 1K50M");
153                 break;
154         default:
155                 printf ("unknown [immr=0x%04x,k=0x%04x]", m, k);
156                 break;
157         }
158
159         printf (") at %s MHz\n", strmhz (buf, clock));
160
161         return 0;
162 }
163
164 /* ------------------------------------------------------------------------- */
165 /* configures a UPM by writing into the UPM RAM array                        */
166 /* uses bank 11 and a dummy physical address (=BRx_BA_MSK)                   */
167 /* NOTE: the physical address chosen must not overlap into any other area    */
168 /* mapped by the memory controller because bank 11 has the lowest priority   */
169
170 void upmconfig (uint upm, uint * table, uint size)
171 {
172         volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
173         volatile memctl8260_t *memctl = &immap->im_memctl;
174         volatile uchar *dummy = (uchar *) BRx_BA_MSK;   /* set all BA bits */
175         uint i;
176
177         /* first set up bank 11 to reference the correct UPM at a dummy address */
178
179         memctl->memc_or11 = ORxU_AM_MSK;        /* set all AM bits */
180
181         switch (upm) {
182
183         case UPMA:
184                 memctl->memc_br11 =
185                         ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMA |
186                         BRx_V;
187                 memctl->memc_mamr = MxMR_OP_WARR;
188                 break;
189
190         case UPMB:
191                 memctl->memc_br11 =
192                         ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMB |
193                         BRx_V;
194                 memctl->memc_mbmr = MxMR_OP_WARR;
195                 break;
196
197         case UPMC:
198                 memctl->memc_br11 =
199                         ((uint)dummy & BRx_BA_MSK) | BRx_PS_32 | BRx_MS_UPMC |
200                         BRx_V;
201                 memctl->memc_mcmr = MxMR_OP_WARR;
202                 break;
203
204         default:
205                 panic ("upmconfig passed invalid UPM number (%u)\n", upm);
206                 break;
207
208         }
209
210         /*
211          * at this point, the dummy address is set up to access the selected UPM,
212          * the MAD pointer is zero, and the MxMR OP is set for writing to RAM
213          *
214          * now we simply load the mdr with each word and poke the dummy address.
215          * the MAD is incremented on each access.
216          */
217
218         for (i = 0; i < size; i++) {
219                 memctl->memc_mdr = table[i];
220                 *dummy = 0;
221         }
222
223         /* now kill bank 11 */
224         memctl->memc_br11 = 0;
225 }
226
227 /* ------------------------------------------------------------------------- */
228
229 #if !defined(CONFIG_HAVE_OWN_RESET)
230 int
231 do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
232 {
233         ulong msr, addr;
234
235         volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
236
237         immap->im_clkrst.car_rmr = RMR_CSRE;    /* Checkstop Reset enable */
238
239         /* Interrupts and MMU off */
240         __asm__ __volatile__ ("mfmsr    %0":"=r" (msr):);
241
242         msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
243         __asm__ __volatile__ ("mtmsr    %0"::"r" (msr));
244
245         /*
246          * Trying to execute the next instruction at a non-existing address
247          * should cause a machine check, resulting in reset
248          */
249 #ifdef CONFIG_SYS_RESET_ADDRESS
250         addr = CONFIG_SYS_RESET_ADDRESS;
251 #else
252         /*
253          * note: when CONFIG_SYS_MONITOR_BASE points to a RAM address, CONFIG_SYS_MONITOR_BASE
254          * - sizeof (ulong) is usually a valid address. Better pick an address
255          * known to be invalid on your system and assign it to CONFIG_SYS_RESET_ADDRESS.
256          */
257         addr = CONFIG_SYS_MONITOR_BASE - sizeof (ulong);
258 #endif
259         ((void (*)(void)) addr) ();
260         return 1;
261
262 }
263 #endif  /* CONFIG_HAVE_OWN_RESET */
264
265 /* ------------------------------------------------------------------------- */
266
267 /*
268  * Get timebase clock frequency (like cpu_clk in Hz)
269  *
270  */
271 unsigned long get_tbclk (void)
272 {
273         ulong tbclk;
274
275         tbclk = (gd->bus_clk + 3L) / 4L;
276
277         return (tbclk);
278 }
279
280 /* ------------------------------------------------------------------------- */
281
282 #if defined(CONFIG_WATCHDOG)
283 void watchdog_reset (void)
284 {
285         int re_enable = disable_interrupts ();
286
287         reset_8260_watchdog ((immap_t *) CONFIG_SYS_IMMR);
288         if (re_enable)
289                 enable_interrupts ();
290 }
291 #endif /* CONFIG_WATCHDOG */
292
293 /* ------------------------------------------------------------------------- */
294 #ifdef CONFIG_OF_BOARD_SETUP
295 void ft_cpu_setup (void *blob, bd_t *bd)
296 {
297         do_fixup_by_compat_u32(blob, "fsl,cpm2-brg",
298                                "clock-frequency", bd->bi_brgfreq, 1);
299
300         do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
301                 "bus-frequency", bd->bi_busfreq, 1);
302         do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
303                 "timebase-frequency", OF_TBCLK, 1);
304         do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
305                 "clock-frequency", bd->bi_intfreq, 1);
306         fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
307 }
308 #endif /* CONFIG_OF_BOARD_SETUP */
309
310 /*
311  * Initializes on-chip ethernet controllers.
312  * to override, implement board_eth_init()
313  */
314 int cpu_eth_init(bd_t *bis)
315 {
316 #if defined(CONFIG_ETHER_ON_FCC)
317         fec_initialize(bis);
318 #endif
319 #if defined(CONFIG_ETHER_ON_SCC)
320         mpc82xx_scc_enet_initialize(bis);
321 #endif
322         return 0;
323 }