]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - cpu/mpc86xx/cpu.c
32d06d20ebd00d0e0aeacd0d71625c690164e90b
[karo-tx-uboot.git] / cpu / mpc86xx / cpu.c
1 /*
2  * Copyright 2006,2009 Freescale Semiconductor, Inc.
3  * Jeff Brown
4  * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA
23  */
24
25 #include <common.h>
26 #include <watchdog.h>
27 #include <command.h>
28 #include <asm/cache.h>
29 #include <asm/mmu.h>
30 #include <mpc86xx.h>
31 #include <asm/fsl_law.h>
32
33 /*
34  * Default board reset function
35  */
36 static void
37 __board_reset(void)
38 {
39         /* Do nothing */
40 }
41 void board_reset(void) __attribute__((weak, alias("__board_reset")));
42
43
44 int
45 checkcpu(void)
46 {
47         sys_info_t sysinfo;
48         uint pvr, svr;
49         uint ver;
50         uint major, minor;
51         char buf1[32], buf2[32];
52         volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
53         volatile ccsr_gur_t *gur = &immap->im_gur;
54         struct cpu_type *cpu;
55         uint msscr0 = mfspr(MSSCR0);
56
57         svr = get_svr();
58         ver = SVR_SOC_VER(svr);
59         major = SVR_MAJ(svr);
60         minor = SVR_MIN(svr);
61
62         puts("CPU:   ");
63
64         cpu = identify_cpu(ver);
65         if (cpu) {
66                 puts(cpu->name);
67         } else {
68                 puts("Unknown");
69         }
70
71         printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
72         puts("Core:  ");
73
74         pvr = get_pvr();
75         ver = PVR_E600_VER(pvr);
76         major = PVR_E600_MAJ(pvr);
77         minor = PVR_E600_MIN(pvr);
78
79         printf("E600 Core %d", (msscr0 & 0x20) ? 1 : 0 );
80         if (gur->pordevsr & MPC86xx_PORDEVSR_CORE1TE)
81                 puts("\n    Core1Translation Enabled");
82         debug(" (MSSCR0=%x, PORDEVSR=%x)", msscr0, gur->pordevsr);
83
84         printf(", Version: %d.%d, (0x%08x)\n", major, minor, pvr);
85
86         get_sys_info(&sysinfo);
87
88         puts("Clock Configuration:\n");
89         printf("       CPU:%-4s MHz, ", strmhz(buf1, sysinfo.freqProcessor));
90         printf("MPX:%-4s MHz\n", strmhz(buf1, sysinfo.freqSystemBus));
91         printf("       DDR:%-4s MHz (%s MT/s data rate), ",
92                 strmhz(buf1, sysinfo.freqSystemBus / 2),
93                 strmhz(buf2, sysinfo.freqSystemBus));
94
95         if (sysinfo.freqLocalBus > LCRR_CLKDIV) {
96                 printf("LBC:%-4s MHz\n", strmhz(buf1, sysinfo.freqLocalBus));
97         } else {
98                 printf("LBC: unknown (LCRR[CLKDIV] = 0x%02lx)\n",
99                        sysinfo.freqLocalBus);
100         }
101
102         puts("L1:    D-cache 32 KB enabled\n");
103         puts("       I-cache 32 KB enabled\n");
104
105         puts("L2:    ");
106         if (get_l2cr() & 0x80000000) {
107 #if defined(CONFIG_MPC8610)
108                 puts("256");
109 #elif defined(CONFIG_MPC8641)
110                 puts("512");
111 #endif
112                 puts(" KB enabled\n");
113         } else {
114                 puts("Disabled\n");
115         }
116
117         return 0;
118 }
119
120
121 void
122 do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
123 {
124         volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
125         volatile ccsr_gur_t *gur = &immap->im_gur;
126
127         /* Attempt board-specific reset */
128         board_reset();
129
130         /* Next try asserting HRESET_REQ */
131         out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ);
132
133         while (1)
134                 ;
135 }
136
137
138 /*
139  * Get timebase clock frequency
140  */
141 unsigned long
142 get_tbclk(void)
143 {
144         sys_info_t sys_info;
145
146         get_sys_info(&sys_info);
147         return (sys_info.freqSystemBus + 3L) / 4L;
148 }
149
150
151 #if defined(CONFIG_WATCHDOG)
152 void
153 watchdog_reset(void)
154 {
155 #if defined(CONFIG_MPC8610)
156         /*
157          * This actually feed the hard enabled watchdog.
158          */
159         volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
160         volatile ccsr_wdt_t *wdt = &immap->im_wdt;
161         volatile ccsr_gur_t *gur = &immap->im_gur;
162         u32 tmp = gur->pordevsr;
163
164         if (tmp & 0x4000) {
165                 wdt->swsrr = 0x556c;
166                 wdt->swsrr = 0xaa39;
167         }
168 #endif
169 }
170 #endif  /* CONFIG_WATCHDOG */
171
172 /*
173  * Print out the state of various machine registers.
174  * Currently prints out LAWs, BR0/OR0, and BATs
175  */
176 void mpc86xx_reginfo(void)
177 {
178         immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
179         ccsr_lbc_t *lbc = &immap->im_lbc;
180
181         print_bats();
182         print_laws();
183
184         printf ("Local Bus Controller Registers\n"
185                 "\tBR0\t0x%08X\tOR0\t0x%08X \n", in_be32(&lbc->br0), in_be32(&lbc->or0));
186         printf("\tBR1\t0x%08X\tOR1\t0x%08X \n", in_be32(&lbc->br1), in_be32(&lbc->or1));
187         printf("\tBR2\t0x%08X\tOR2\t0x%08X \n", in_be32(&lbc->br2), in_be32(&lbc->or2));
188         printf("\tBR3\t0x%08X\tOR3\t0x%08X \n", in_be32(&lbc->br3), in_be32(&lbc->or3));
189         printf("\tBR4\t0x%08X\tOR4\t0x%08X \n", in_be32(&lbc->br4), in_be32(&lbc->or4));
190         printf("\tBR5\t0x%08X\tOR5\t0x%08X \n", in_be32(&lbc->br5), in_be32(&lbc->or5));
191         printf("\tBR6\t0x%08X\tOR6\t0x%08X \n", in_be32(&lbc->br6), in_be32(&lbc->or6));
192         printf("\tBR7\t0x%08X\tOR7\t0x%08X \n", in_be32(&lbc->br7), in_be32(&lbc->or7));
193
194 }