1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc.
7 * CPU specific code for the MPC83xx family.
9 * Derived from the MPC8260 and MPC85xx.
18 #include <asm/processor.h>
19 #include <linux/libfdt.h>
22 #include <fsl_esdhc.h>
23 #if defined(CONFIG_BOOTCOUNT_LIMIT) && !defined(CONFIG_ARCH_MPC831X)
24 #include <linux/immap_qe.h>
28 DECLARE_GLOBAL_DATA_PTR;
30 #ifndef CONFIG_CPU_MPC83XX
33 volatile immap_t *immr;
34 ulong clock = gd->cpu_clk;
41 const struct cpu_type {
44 } cpu_type_list [] = {
54 CPU_TYPE_ENTRY(8347_TBGA_),
55 CPU_TYPE_ENTRY(8347_PBGA_),
57 CPU_TYPE_ENTRY(8358_TBGA_),
58 CPU_TYPE_ENTRY(8358_PBGA_),
65 immr = (immap_t *)CONFIG_SYS_IMMR;
73 switch (pvr & 0xffff0000) {
91 printf("Unknown core, ");
94 spridr = immr->sysconf.spridr;
96 for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++)
97 if (cpu_type_list[i].partid == PARTID_NO_E(spridr)) {
99 puts(cpu_type_list[i].name);
100 if (IS_E_PROCESSOR(spridr))
102 if ((SPR_FAMILY(spridr) == SPR_834X_FAMILY ||
103 SPR_FAMILY(spridr) == SPR_836X_FAMILY) &&
104 REVID_MAJOR(spridr) >= 2)
106 printf(", Rev: %d.%d", REVID_MAJOR(spridr),
107 REVID_MINOR(spridr));
111 if (i == ARRAY_SIZE(cpu_type_list))
112 printf("(SPRIDR %08x unknown), ", spridr);
114 printf(" at %s MHz, ", strmhz(buf, clock));
116 printf("CSB: %s MHz\n", strmhz(buf, gd->arch.csb_clk));
122 #ifndef CONFIG_SYSRESET
124 do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
127 #ifndef MPC83xx_RESET
131 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
133 puts("Resetting the board.\n");
137 /* Interrupts and MMU off */
139 msr &= ~(MSR_EE | MSR_IR | MSR_DR);
142 /* enable Reset Control Reg */
143 immap->reset.rpr = 0x52535445;
147 /* confirm Reset Control Reg is enabled */
148 while(!((immap->reset.rcer) & RCER_CRE))
153 /* perform reset, only one bit */
154 immap->reset.rcr = RCR_SWHR;
156 #else /* ! MPC83xx_RESET */
158 immap->reset.rmr = RMR_CSRE; /* Checkstop Reset enable */
160 /* Interrupts and MMU off */
162 msr &= ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR);
166 * Trying to execute the next instruction at a non-existing address
167 * should cause a machine check, resulting in reset
169 addr = CONFIG_SYS_RESET_ADDRESS;
171 ((void (*)(void)) addr) ();
172 #endif /* MPC83xx_RESET */
179 * Get timebase clock frequency (like cpu_clk in Hz)
182 unsigned long get_tbclk(void)
184 return (gd->bus_clk + 3L) / 4L;
188 #if defined(CONFIG_WATCHDOG)
189 void watchdog_reset (void)
191 int re_enable = disable_interrupts();
193 /* Reset the 83xx watchdog */
194 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
195 immr->wdt.swsrr = 0x556c;
196 immr->wdt.swsrr = 0xaa39;
203 #ifndef CONFIG_DM_ETH
205 * Initializes on-chip ethernet controllers.
206 * to override, implement board_eth_init()
208 int cpu_eth_init(bd_t *bis)
210 #if defined(CONFIG_UEC_ETH)
211 uec_standard_init(bis);
214 #if defined(CONFIG_TSEC_ENET)
215 tsec_standard_init(bis);
219 #endif /* !CONFIG_DM_ETH */
222 * Initializes on-chip MMC controllers.
223 * to override, implement board_mmc_init()
225 int cpu_mmc_init(bd_t *bis)
227 #ifdef CONFIG_FSL_ESDHC
228 return fsl_esdhc_mmc_init(bis);
234 void ppcDWstore(unsigned int *addr, unsigned int *value)
236 asm("lfd 1, 0(%1)\n\t"
239 : "r" (addr), "r" (value)
243 void ppcDWload(unsigned int *addr, unsigned int *ret)
245 asm("lfd 1, 0(%0)\n\t"
248 : "r" (addr), "r" (ret)