blob: 8c9b515fa5c72aa3346e1c282010f8b2e5c1aa9c [file] [log] [blame]
Eran Libertyf046ccd2005-07-28 10:08:46 -05001/*
2 * Copyright 2004 Freescale Semiconductor, Inc.
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 *
22 * Change log:
23 *
24 * 20050101: Eran Liberty (liberty@freescale.com)
Wolfgang Denk07a25052005-08-05 19:49:35 +020025 * Initial file creating (porting from 85XX & 8260)
Eran Libertyf046ccd2005-07-28 10:08:46 -050026 */
27
28/*
29 * CPU specific code for the MPC83xx family.
30 *
31 * Derived from the MPC8260 and MPC85xx.
32 */
33
34#include <common.h>
35#include <watchdog.h>
36#include <command.h>
37#include <mpc83xx.h>
38#include <asm/processor.h>
39
40
41int checkcpu(void)
42{
43 DECLARE_GLOBAL_DATA_PTR;
44 ulong clock = gd->cpu_clk;
45 u32 pvr = get_pvr();
46 char buf[32];
47
48 if ((pvr & 0xFFFF0000) != PVR_83xx) {
49 puts("Not MPC83xx Family!!!\n");
50 return -1;
51 }
52
Marian Balakowicze6f2e902005-10-11 19:09:42 +020053 puts("CPU: MPC83xx, ");
Eran Libertyf046ccd2005-07-28 10:08:46 -050054 switch(pvr) {
55 case PVR_8349_REV10:
56 break;
57 case PVR_8349_REV11:
58 break;
59 default:
60 puts("Rev: Unknown\n");
61 return -1; /* Not sure what this is */
62 }
Rafal Jaworowski6902df52005-10-17 02:39:53 +020063 printf("Rev: %d.%d at %s MHz\n", (pvr & 0xf0) >> 4,
64 (pvr & 0x0f), strmhz(buf, clock));
65
Eran Libertyf046ccd2005-07-28 10:08:46 -050066 return 0;
67}
68
69
70void upmconfig (uint upm, uint *table, uint size)
71{
72 hang(); /* FIXME: upconfig() needed? */
73}
74
75
76int
77do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
78{
Wolfgang Denk07a25052005-08-05 19:49:35 +020079 ulong msr;
80#ifndef MPC83xx_RESET
81 ulong addr;
82#endif
Eran Libertyf046ccd2005-07-28 10:08:46 -050083
84 volatile immap_t *immap = (immap_t *) CFG_IMMRBAR;
85
86#ifdef MPC83xx_RESET
87 /* Interrupts and MMU off */
88 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
89
90 msr &= ~( MSR_EE | MSR_IR | MSR_DR);
91 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
92
93 /* enable Reset Control Reg */
94 immap->reset.rpr = 0x52535445;
95
96 /* confirm Reset Control Reg is enabled */
97 while(!((immap->reset.rcer) & RCER_CRE));
98
99 printf("Resetting the board.");
100 printf("\n");
101
102 udelay(200);
103
104 /* perform reset, only one bit */
Wolfgang Denk07a25052005-08-05 19:49:35 +0200105 immap->reset.rcr = RCR_SWHR;
Eran Libertyf046ccd2005-07-28 10:08:46 -0500106
Wolfgang Denk07a25052005-08-05 19:49:35 +0200107#else /* ! MPC83xx_RESET */
108
109 immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
110
111 /* Interrupts and MMU off */
112 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
Eran Libertyf046ccd2005-07-28 10:08:46 -0500113
114 msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
115 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
116
117 /*
118 * Trying to execute the next instruction at a non-existing address
119 * should cause a machine check, resulting in reset
120 */
121 addr = CFG_RESET_ADDRESS;
122
123 printf("resetting the board.");
124 printf("\n");
125 ((void (*)(void)) addr) ();
Wolfgang Denk07a25052005-08-05 19:49:35 +0200126#endif /* MPC83xx_RESET */
127
Eran Libertyf046ccd2005-07-28 10:08:46 -0500128 return 1;
129}
130
131
132/*
133 * Get timebase clock frequency (like cpu_clk in Hz)
134 */
135
136unsigned long get_tbclk(void)
137{
138 DECLARE_GLOBAL_DATA_PTR;
139
140 ulong tbclk;
141
142 tbclk = (gd->bus_clk + 3L) / 4L;
143
144 return tbclk;
145}
146
147
148#if defined(CONFIG_WATCHDOG)
149void watchdog_reset (void)
150{
151 hang(); /* FIXME: implement watchdog_reset()? */
152}
153#endif /* CONFIG_WATCHDOG */