blob: 663510987d373b993de74f390d10d3b216712364 [file] [log] [blame]
Eran Libertyf046ccd2005-07-28 10:08:46 -05001/*
Dave Liu03051c32007-09-18 12:36:11 +08002 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
Eran Libertyf046ccd2005-07-28 10:08:46 -05003 *
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
Eran Libertyf046ccd2005-07-28 10:08:46 -050021 */
22
23/*
24 * CPU specific code for the MPC83xx family.
25 *
26 * Derived from the MPC8260 and MPC85xx.
27 */
28
29#include <common.h>
30#include <watchdog.h>
31#include <command.h>
32#include <mpc83xx.h>
33#include <asm/processor.h>
Gerald Van Baren213bf8c2007-03-31 12:23:51 -040034#include <libfdt.h>
Andy Fleming75b9d4a2008-08-31 16:33:26 -050035#include <tsec.h>
Ben Warren0e8454e2008-10-22 23:32:48 -070036#include <netdev.h>
Andy Fleminge1ac3872008-10-30 16:50:14 -050037#include <fsl_esdhc.h>
Heiko Schocherf70fd132009-02-24 11:30:51 +010038#ifdef CONFIG_BOOTCOUNT_LIMIT
39#include <asm/immap_qe.h>
40#include <asm/io.h>
41#endif
Eran Libertyf046ccd2005-07-28 10:08:46 -050042
Wolfgang Denkd87080b2006-03-31 18:32:53 +020043DECLARE_GLOBAL_DATA_PTR;
44
Eran Libertyf046ccd2005-07-28 10:08:46 -050045int checkcpu(void)
46{
Dave Liu5f820432006-11-03 19:33:44 -060047 volatile immap_t *immr;
Eran Libertyf046ccd2005-07-28 10:08:46 -050048 ulong clock = gd->cpu_clk;
49 u32 pvr = get_pvr();
Dave Liu5f820432006-11-03 19:33:44 -060050 u32 spridr;
Eran Libertyf046ccd2005-07-28 10:08:46 -050051 char buf[32];
Kim Phillipse5c4ade2008-03-28 10:19:07 -050052 int i;
53
Kim Phillipse5c4ade2008-03-28 10:19:07 -050054 const struct cpu_type {
55 char name[15];
56 u32 partid;
57 } cpu_type_list [] = {
Ilya Yanok7c619dd2010-06-28 16:44:33 +040058 CPU_TYPE_ENTRY(8308),
Kim Phillipse5c4ade2008-03-28 10:19:07 -050059 CPU_TYPE_ENTRY(8311),
60 CPU_TYPE_ENTRY(8313),
61 CPU_TYPE_ENTRY(8314),
62 CPU_TYPE_ENTRY(8315),
63 CPU_TYPE_ENTRY(8321),
64 CPU_TYPE_ENTRY(8323),
65 CPU_TYPE_ENTRY(8343),
66 CPU_TYPE_ENTRY(8347_TBGA_),
67 CPU_TYPE_ENTRY(8347_PBGA_),
68 CPU_TYPE_ENTRY(8349),
69 CPU_TYPE_ENTRY(8358_TBGA_),
70 CPU_TYPE_ENTRY(8358_PBGA_),
71 CPU_TYPE_ENTRY(8360),
72 CPU_TYPE_ENTRY(8377),
73 CPU_TYPE_ENTRY(8378),
74 CPU_TYPE_ENTRY(8379),
75 };
Eran Libertyf046ccd2005-07-28 10:08:46 -050076
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020077 immr = (immap_t *)CONFIG_SYS_IMMR;
Dave Liu5f820432006-11-03 19:33:44 -060078
Kim Phillips54b2d432007-04-30 15:26:21 -050079 puts("CPU: ");
Scott Wood95e7ef82007-04-16 14:34:16 -050080
81 switch (pvr & 0xffff0000) {
82 case PVR_E300C1:
83 printf("e300c1, ");
84 break;
85
86 case PVR_E300C2:
87 printf("e300c2, ");
88 break;
89
90 case PVR_E300C3:
91 printf("e300c3, ");
92 break;
93
Dave Liu03051c32007-09-18 12:36:11 +080094 case PVR_E300C4:
95 printf("e300c4, ");
96 break;
97
Scott Wood95e7ef82007-04-16 14:34:16 -050098 default:
99 printf("Unknown core, ");
Eran Libertyf046ccd2005-07-28 10:08:46 -0500100 }
101
Dave Liu5f820432006-11-03 19:33:44 -0600102 spridr = immr->sysconf.spridr;
Rafal Jaworowski6902df52005-10-17 02:39:53 +0200103
Kim Phillipse5c4ade2008-03-28 10:19:07 -0500104 for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++)
105 if (cpu_type_list[i].partid == PARTID_NO_E(spridr)) {
106 puts("MPC");
107 puts(cpu_type_list[i].name);
108 if (IS_E_PROCESSOR(spridr))
109 puts("E");
Kim Phillipsdfe812c2010-04-15 17:36:02 -0500110 if ((SPR_FAMILY(spridr) == SPR_834X_FAMILY ||
111 SPR_FAMILY(spridr) == SPR_836X_FAMILY) &&
112 REVID_MAJOR(spridr) >= 2)
Kim Phillipse5c4ade2008-03-28 10:19:07 -0500113 puts("A");
114 printf(", Rev: %d.%d", REVID_MAJOR(spridr),
115 REVID_MINOR(spridr));
116 break;
117 }
118
119 if (i == ARRAY_SIZE(cpu_type_list))
120 printf("(SPRIDR %08x unknown), ", spridr);
121
122 printf(" at %s MHz, ", strmhz(buf, clock));
123
124 printf("CSB: %s MHz\n", strmhz(buf, gd->csb_clk));
Kim Phillips54b2d432007-04-30 15:26:21 -0500125
Eran Libertyf046ccd2005-07-28 10:08:46 -0500126 return 0;
127}
128
Eran Libertyf046ccd2005-07-28 10:08:46 -0500129int
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200130do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Eran Libertyf046ccd2005-07-28 10:08:46 -0500131{
Wolfgang Denk07a25052005-08-05 19:49:35 +0200132 ulong msr;
133#ifndef MPC83xx_RESET
134 ulong addr;
135#endif
Eran Libertyf046ccd2005-07-28 10:08:46 -0500136
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200137 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Eran Libertyf046ccd2005-07-28 10:08:46 -0500138
Michael Zaidman4c006dd2010-02-15 10:02:32 +0200139 puts("Resetting the board.\n");
140
Eran Libertyf046ccd2005-07-28 10:08:46 -0500141#ifdef MPC83xx_RESET
Michael Zaidman4c006dd2010-02-15 10:02:32 +0200142
Eran Libertyf046ccd2005-07-28 10:08:46 -0500143 /* Interrupts and MMU off */
144 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
145
146 msr &= ~( MSR_EE | MSR_IR | MSR_DR);
147 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
148
149 /* enable Reset Control Reg */
150 immap->reset.rpr = 0x52535445;
Marian Balakowicz6d8ae5a2006-03-14 16:12:48 +0100151 __asm__ __volatile__ ("sync");
152 __asm__ __volatile__ ("isync");
Eran Libertyf046ccd2005-07-28 10:08:46 -0500153
154 /* confirm Reset Control Reg is enabled */
155 while(!((immap->reset.rcer) & RCER_CRE));
156
Eran Libertyf046ccd2005-07-28 10:08:46 -0500157 udelay(200);
158
159 /* perform reset, only one bit */
Wolfgang Denk07a25052005-08-05 19:49:35 +0200160 immap->reset.rcr = RCR_SWHR;
Eran Libertyf046ccd2005-07-28 10:08:46 -0500161
Wolfgang Denk07a25052005-08-05 19:49:35 +0200162#else /* ! MPC83xx_RESET */
163
164 immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
165
166 /* Interrupts and MMU off */
167 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
Eran Libertyf046ccd2005-07-28 10:08:46 -0500168
169 msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
170 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
171
172 /*
173 * Trying to execute the next instruction at a non-existing address
174 * should cause a machine check, resulting in reset
175 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200176 addr = CONFIG_SYS_RESET_ADDRESS;
Eran Libertyf046ccd2005-07-28 10:08:46 -0500177
Eran Libertyf046ccd2005-07-28 10:08:46 -0500178 ((void (*)(void)) addr) ();
Wolfgang Denk07a25052005-08-05 19:49:35 +0200179#endif /* MPC83xx_RESET */
180
Eran Libertyf046ccd2005-07-28 10:08:46 -0500181 return 1;
182}
183
184
185/*
186 * Get timebase clock frequency (like cpu_clk in Hz)
187 */
188
189unsigned long get_tbclk(void)
190{
Eran Libertyf046ccd2005-07-28 10:08:46 -0500191 ulong tbclk;
192
193 tbclk = (gd->bus_clk + 3L) / 4L;
194
195 return tbclk;
196}
197
198
199#if defined(CONFIG_WATCHDOG)
200void watchdog_reset (void)
201{
Timur Tabi2ad6b512006-10-31 18:44:42 -0600202 int re_enable = disable_interrupts();
203
204 /* Reset the 83xx watchdog */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200205 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
Timur Tabi2ad6b512006-10-31 18:44:42 -0600206 immr->wdt.swsrr = 0x556c;
207 immr->wdt.swsrr = 0xaa39;
208
209 if (re_enable)
210 enable_interrupts ();
Eran Libertyf046ccd2005-07-28 10:08:46 -0500211}
Timur Tabi2ad6b512006-10-31 18:44:42 -0600212#endif
Kumar Gala62ec6412006-01-11 16:48:10 -0600213
Andy Fleming75b9d4a2008-08-31 16:33:26 -0500214/*
215 * Initializes on-chip ethernet controllers.
216 * to override, implement board_eth_init()
Ben Warrendd354792008-06-23 22:57:27 -0700217 */
Ben Warrendd354792008-06-23 22:57:27 -0700218int cpu_eth_init(bd_t *bis)
219{
Haiying Wang8e552582009-06-04 16:12:41 -0400220#if defined(CONFIG_UEC_ETH)
221 uec_standard_init(bis);
Ben Warren0e8454e2008-10-22 23:32:48 -0700222#endif
Haiying Wang8e552582009-06-04 16:12:41 -0400223
Andy Fleming75b9d4a2008-08-31 16:33:26 -0500224#if defined(CONFIG_TSEC_ENET)
225 tsec_standard_init(bis);
Ben Warrendd354792008-06-23 22:57:27 -0700226#endif
Ben Warrendd354792008-06-23 22:57:27 -0700227 return 0;
228}
Andy Fleminge1ac3872008-10-30 16:50:14 -0500229
230/*
231 * Initializes on-chip MMC controllers.
232 * to override, implement board_mmc_init()
233 */
234int cpu_mmc_init(bd_t *bis)
235{
236#ifdef CONFIG_FSL_ESDHC
237 return fsl_esdhc_mmc_init(bis);
238#else
239 return 0;
240#endif
241}