blob: e275fcea41e8ed519de09d90ba56bc32c050ac32 [file] [log] [blame]
Eran Liberty9095d4a2005-07-28 10:08:46 -05001/*
Dave Liu5245ff52007-09-18 12:36:11 +08002 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
Eran Liberty9095d4a2005-07-28 10:08:46 -05003 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Eran Liberty9095d4a2005-07-28 10:08:46 -05005 */
6
7/*
8 * CPU specific code for the MPC83xx family.
9 *
10 * Derived from the MPC8260 and MPC85xx.
11 */
12
13#include <common.h>
14#include <watchdog.h>
15#include <command.h>
16#include <mpc83xx.h>
17#include <asm/processor.h>
Gerald Van Barend6abef42007-03-31 12:23:51 -040018#include <libfdt.h>
Andy Flemingfecff2b2008-08-31 16:33:26 -050019#include <tsec.h>
Ben Warren67731692008-10-22 23:32:48 -070020#include <netdev.h>
Andy Fleming1463b4b2008-10-30 16:50:14 -050021#include <fsl_esdhc.h>
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +010022#ifdef CONFIG_BOOTCOUNT_LIMIT
23#include <asm/immap_qe.h>
24#include <asm/io.h>
25#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -050026
Wolfgang Denk6405a152006-03-31 18:32:53 +020027DECLARE_GLOBAL_DATA_PTR;
28
Eran Liberty9095d4a2005-07-28 10:08:46 -050029int checkcpu(void)
30{
Dave Liua46daea2006-11-03 19:33:44 -060031 volatile immap_t *immr;
Eran Liberty9095d4a2005-07-28 10:08:46 -050032 ulong clock = gd->cpu_clk;
33 u32 pvr = get_pvr();
Dave Liua46daea2006-11-03 19:33:44 -060034 u32 spridr;
Eran Liberty9095d4a2005-07-28 10:08:46 -050035 char buf[32];
Kim Phillipsecb2d6f2008-03-28 10:19:07 -050036 int i;
37
Kim Phillipsecb2d6f2008-03-28 10:19:07 -050038 const struct cpu_type {
39 char name[15];
40 u32 partid;
41 } cpu_type_list [] = {
Ilya Yanoka3e5fd52010-06-28 16:44:33 +040042 CPU_TYPE_ENTRY(8308),
Gerlando Falautofe201cb2012-10-10 22:13:08 +000043 CPU_TYPE_ENTRY(8309),
Kim Phillipsecb2d6f2008-03-28 10:19:07 -050044 CPU_TYPE_ENTRY(8311),
45 CPU_TYPE_ENTRY(8313),
46 CPU_TYPE_ENTRY(8314),
47 CPU_TYPE_ENTRY(8315),
48 CPU_TYPE_ENTRY(8321),
49 CPU_TYPE_ENTRY(8323),
50 CPU_TYPE_ENTRY(8343),
51 CPU_TYPE_ENTRY(8347_TBGA_),
52 CPU_TYPE_ENTRY(8347_PBGA_),
53 CPU_TYPE_ENTRY(8349),
54 CPU_TYPE_ENTRY(8358_TBGA_),
55 CPU_TYPE_ENTRY(8358_PBGA_),
56 CPU_TYPE_ENTRY(8360),
57 CPU_TYPE_ENTRY(8377),
58 CPU_TYPE_ENTRY(8378),
59 CPU_TYPE_ENTRY(8379),
60 };
Eran Liberty9095d4a2005-07-28 10:08:46 -050061
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020062 immr = (immap_t *)CONFIG_SYS_IMMR;
Dave Liua46daea2006-11-03 19:33:44 -060063
Kim Phillipsd82b0772007-04-30 15:26:21 -050064 puts("CPU: ");
Scott Wood7206a992007-04-16 14:34:16 -050065
66 switch (pvr & 0xffff0000) {
67 case PVR_E300C1:
68 printf("e300c1, ");
69 break;
70
71 case PVR_E300C2:
72 printf("e300c2, ");
73 break;
74
75 case PVR_E300C3:
76 printf("e300c3, ");
77 break;
78
Dave Liu5245ff52007-09-18 12:36:11 +080079 case PVR_E300C4:
80 printf("e300c4, ");
81 break;
82
Scott Wood7206a992007-04-16 14:34:16 -050083 default:
84 printf("Unknown core, ");
Eran Liberty9095d4a2005-07-28 10:08:46 -050085 }
86
Dave Liua46daea2006-11-03 19:33:44 -060087 spridr = immr->sysconf.spridr;
Kim Phillipsecb2d6f2008-03-28 10:19:07 -050088
89 for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++)
90 if (cpu_type_list[i].partid == PARTID_NO_E(spridr)) {
91 puts("MPC");
92 puts(cpu_type_list[i].name);
93 if (IS_E_PROCESSOR(spridr))
94 puts("E");
Kim Phillips39b48162010-04-15 17:36:02 -050095 if ((SPR_FAMILY(spridr) == SPR_834X_FAMILY ||
96 SPR_FAMILY(spridr) == SPR_836X_FAMILY) &&
97 REVID_MAJOR(spridr) >= 2)
Kim Phillipsecb2d6f2008-03-28 10:19:07 -050098 puts("A");
99 printf(", Rev: %d.%d", REVID_MAJOR(spridr),
100 REVID_MINOR(spridr));
101 break;
102 }
103
104 if (i == ARRAY_SIZE(cpu_type_list))
105 printf("(SPRIDR %08x unknown), ", spridr);
106
107 printf(" at %s MHz, ", strmhz(buf, clock));
Rafal Jaworowski384da5e2005-10-17 02:39:53 +0200108
Simon Glasscc76e9e2012-12-13 20:48:47 +0000109 printf("CSB: %s MHz\n", strmhz(buf, gd->arch.csb_clk));
Kim Phillipsd82b0772007-04-30 15:26:21 -0500110
Eran Liberty9095d4a2005-07-28 10:08:46 -0500111 return 0;
112}
113
Eran Liberty9095d4a2005-07-28 10:08:46 -0500114int
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200115do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Eran Liberty9095d4a2005-07-28 10:08:46 -0500116{
Wolfgang Denk301d0962005-08-05 19:49:35 +0200117 ulong msr;
118#ifndef MPC83xx_RESET
119 ulong addr;
120#endif
Eran Liberty9095d4a2005-07-28 10:08:46 -0500121
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200122 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500123
Michael Zaidman184154b2010-02-15 10:02:32 +0200124 puts("Resetting the board.\n");
125
Eran Liberty9095d4a2005-07-28 10:08:46 -0500126#ifdef MPC83xx_RESET
Michael Zaidman184154b2010-02-15 10:02:32 +0200127
Eran Liberty9095d4a2005-07-28 10:08:46 -0500128 /* Interrupts and MMU off */
129 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
130
131 msr &= ~( MSR_EE | MSR_IR | MSR_DR);
132 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
133
134 /* enable Reset Control Reg */
135 immap->reset.rpr = 0x52535445;
Marian Balakowicz919b1872006-03-14 16:12:48 +0100136 __asm__ __volatile__ ("sync");
137 __asm__ __volatile__ ("isync");
Eran Liberty9095d4a2005-07-28 10:08:46 -0500138
139 /* confirm Reset Control Reg is enabled */
140 while(!((immap->reset.rcer) & RCER_CRE));
141
Eran Liberty9095d4a2005-07-28 10:08:46 -0500142 udelay(200);
143
144 /* perform reset, only one bit */
Wolfgang Denk301d0962005-08-05 19:49:35 +0200145 immap->reset.rcr = RCR_SWHR;
146
147#else /* ! MPC83xx_RESET */
Eran Liberty9095d4a2005-07-28 10:08:46 -0500148
Wolfgang Denk301d0962005-08-05 19:49:35 +0200149 immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
150
151 /* Interrupts and MMU off */
152 __asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
Eran Liberty9095d4a2005-07-28 10:08:46 -0500153
154 msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
155 __asm__ __volatile__ ("mtmsr %0"::"r" (msr));
156
157 /*
158 * Trying to execute the next instruction at a non-existing address
159 * should cause a machine check, resulting in reset
160 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200161 addr = CONFIG_SYS_RESET_ADDRESS;
Eran Liberty9095d4a2005-07-28 10:08:46 -0500162
Eran Liberty9095d4a2005-07-28 10:08:46 -0500163 ((void (*)(void)) addr) ();
Wolfgang Denk301d0962005-08-05 19:49:35 +0200164#endif /* MPC83xx_RESET */
165
Eran Liberty9095d4a2005-07-28 10:08:46 -0500166 return 1;
167}
168
169
170/*
171 * Get timebase clock frequency (like cpu_clk in Hz)
172 */
173
174unsigned long get_tbclk(void)
175{
Eran Liberty9095d4a2005-07-28 10:08:46 -0500176 ulong tbclk;
177
178 tbclk = (gd->bus_clk + 3L) / 4L;
179
180 return tbclk;
181}
182
183
184#if defined(CONFIG_WATCHDOG)
185void watchdog_reset (void)
186{
Timur Tabi054838e2006-10-31 18:44:42 -0600187 int re_enable = disable_interrupts();
188
189 /* Reset the 83xx watchdog */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200190 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
Timur Tabi054838e2006-10-31 18:44:42 -0600191 immr->wdt.swsrr = 0x556c;
192 immr->wdt.swsrr = 0xaa39;
193
194 if (re_enable)
195 enable_interrupts ();
Eran Liberty9095d4a2005-07-28 10:08:46 -0500196}
Timur Tabi054838e2006-10-31 18:44:42 -0600197#endif
Kumar Gala5bbb0452006-01-11 16:48:10 -0600198
Andy Flemingfecff2b2008-08-31 16:33:26 -0500199/*
200 * Initializes on-chip ethernet controllers.
201 * to override, implement board_eth_init()
Ben Warrend448a492008-06-23 22:57:27 -0700202 */
Ben Warrend448a492008-06-23 22:57:27 -0700203int cpu_eth_init(bd_t *bis)
204{
Haiying Wang511d8282009-06-04 16:12:41 -0400205#if defined(CONFIG_UEC_ETH)
206 uec_standard_init(bis);
Ben Warren67731692008-10-22 23:32:48 -0700207#endif
Haiying Wang511d8282009-06-04 16:12:41 -0400208
Andy Flemingfecff2b2008-08-31 16:33:26 -0500209#if defined(CONFIG_TSEC_ENET)
210 tsec_standard_init(bis);
Ben Warrend448a492008-06-23 22:57:27 -0700211#endif
Ben Warrend448a492008-06-23 22:57:27 -0700212 return 0;
213}
Andy Fleming1463b4b2008-10-30 16:50:14 -0500214
215/*
216 * Initializes on-chip MMC controllers.
217 * to override, implement board_mmc_init()
218 */
219int cpu_mmc_init(bd_t *bis)
220{
221#ifdef CONFIG_FSL_ESDHC
222 return fsl_esdhc_mmc_init(bis);
223#else
224 return 0;
225#endif
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +0100226}