📄 cpu.c.svn-base
字号:
break; case 0x21020068: printf ("XPC850xxZTC"); m = 1; break; default: printf ("unknown MPC850 (0x%08x)", k); } printf (" at %s MHz:", strmhz (buf, clock)); printf (" %u kB I-Cache", checkicache () >> 10); printf (" %u kB D-Cache", checkdcache () >> 10); /* lets check and see if we're running on a 850T (or P?) */ immap->im_cpm.cp_fec.fec_addr_low = 0x12345678; if (immap->im_cpm.cp_fec.fec_addr_low == 0x12345678) { printf (" FEC present"); } if (!m) { puts (cpu_warning); } putc ('\n'); return 0;}#else#error CPU undefined#endif/* ------------------------------------------------------------------------- */int checkcpu (void){ ulong clock = gd->cpu_clk; uint immr = get_immr (0); /* Return full IMMR contents */ uint pvr = get_pvr (); puts ("CPU: "); /* 850 has PARTNUM 20 */ /* 801 has PARTNUM 10 */ return check_CPU (clock, pvr, immr);}/* ------------------------------------------------------------------------- *//* L1 i-cache *//* the standard 860 has 128 sets of 16 bytes in 2 ways (= 4 kB) *//* the 860 P (plus) has 256 sets of 16 bytes in 4 ways (= 16 kB) */int checkicache (void){ volatile immap_t *immap = (immap_t *) CFG_IMMR; volatile memctl8xx_t *memctl = &immap->im_memctl; u32 cacheon = rd_ic_cst () & IDC_ENABLED;#ifdef CONFIG_IP86x u32 k = memctl->memc_br1 & ~0x00007fff; /* probe in flash memoryarea */#else u32 k = memctl->memc_br0 & ~0x00007fff; /* probe in flash memoryarea */#endif u32 m; u32 lines = -1; wr_ic_cst (IDC_UNALL); wr_ic_cst (IDC_INVALL); wr_ic_cst (IDC_DISABLE); __asm__ volatile ("isync"); while (!((m = rd_ic_cst ()) & IDC_CERR2)) { wr_ic_adr (k); wr_ic_cst (IDC_LDLCK); __asm__ volatile ("isync"); lines++; k += 0x10; /* the number of bytes in a cacheline */ } wr_ic_cst (IDC_UNALL); wr_ic_cst (IDC_INVALL); if (cacheon) wr_ic_cst (IDC_ENABLE); else wr_ic_cst (IDC_DISABLE); __asm__ volatile ("isync"); return lines << 4;};/* ------------------------------------------------------------------------- *//* L1 d-cache *//* the standard 860 has 128 sets of 16 bytes in 2 ways (= 4 kB) *//* the 860 P (plus) has 256 sets of 16 bytes in 2 ways (= 8 kB) *//* call with cache disabled */int checkdcache (void){ volatile immap_t *immap = (immap_t *) CFG_IMMR; volatile memctl8xx_t *memctl = &immap->im_memctl; u32 cacheon = rd_dc_cst () & IDC_ENABLED;#ifdef CONFIG_IP86x u32 k = memctl->memc_br1 & ~0x00007fff; /* probe in flash memoryarea */#else u32 k = memctl->memc_br0 & ~0x00007fff; /* probe in flash memoryarea */#endif u32 m; u32 lines = -1; wr_dc_cst (IDC_UNALL); wr_dc_cst (IDC_INVALL); wr_dc_cst (IDC_DISABLE); while (!((m = rd_dc_cst ()) & IDC_CERR2)) { wr_dc_adr (k); wr_dc_cst (IDC_LDLCK); lines++; k += 0x10; /* the number of bytes in a cacheline */ } wr_dc_cst (IDC_UNALL); wr_dc_cst (IDC_INVALL); if (cacheon) wr_dc_cst (IDC_ENABLE); else wr_dc_cst (IDC_DISABLE); return lines << 4;};/* ------------------------------------------------------------------------- */void upmconfig (uint upm, uint * table, uint size){ uint i; uint addr = 0; volatile immap_t *immap = (immap_t *) CFG_IMMR; volatile memctl8xx_t *memctl = &immap->im_memctl; for (i = 0; i < size; i++) { memctl->memc_mdr = table[i]; /* (16-15) */ memctl->memc_mcr = addr | upm; /* (16-16) */ addr++; }}/* ------------------------------------------------------------------------- */#ifndef CONFIG_LWMONint do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ ulong msr, addr; volatile immap_t *immap = (immap_t *) CFG_IMMR; immap->im_clkrst.car_plprcr |= PLPRCR_CSR; /* Checkstop Reset enable */ /* Interrupts and MMU off */ __asm__ volatile ("mtspr 81, 0"); __asm__ volatile ("mfmsr %0":"=r" (msr)); msr &= ~0x1030; __asm__ volatile ("mtmsr %0"::"r" (msr)); /* * Trying to execute the next instruction at a non-existing address * should cause a machine check, resulting in reset */#ifdef CFG_RESET_ADDRESS addr = CFG_RESET_ADDRESS;#else /* * note: when CFG_MONITOR_BASE points to a RAM address, CFG_MONITOR_BASE * - sizeof (ulong) is usually a valid address. Better pick an address * known to be invalid on your system and assign it to CFG_RESET_ADDRESS. * "(ulong)-1" used to be a good choice for many systems... */ addr = CFG_MONITOR_BASE - sizeof (ulong);#endif ((void (*)(void)) addr) (); return 1;}#else /* CONFIG_LWMON *//* * On the LWMON board, the MCLR reset input of the PIC's on the board * uses a 47K/1n RC combination which has a 47us time constant. The * low signal on the HRESET pin of the CPU is only 512 clocks = 8 us * and thus too short to reset the external hardware. So we use the * watchdog to reset the board. */int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ /* prevent triggering the watchdog */ disable_interrupts (); /* make sure the watchdog is running */ reset_8xx_watchdog ((immap_t *) CFG_IMMR); /* wait for watchdog reset */ while (1) {}; /* NOTREACHED */ return 1;}#endif /* CONFIG_LWMON *//* ------------------------------------------------------------------------- *//* * Get timebase clock frequency (like cpu_clk in Hz) * * See sections 14.2 and 14.6 of the User's Manual */unsigned long get_tbclk (void){ uint immr = get_immr (0); /* Return full IMMR contents */ volatile immap_t *immap = (volatile immap_t *)(immr & 0xFFFF0000); ulong oscclk, factor, pll; if (immap->im_clkrst.car_sccr & SCCR_TBS) { return (gd->cpu_clk / 16); } pll = immap->im_clkrst.car_plprcr;#define PLPRCR_val(a) ((pll & PLPRCR_ ## a ## _MSK) >> PLPRCR_ ## a ## _SHIFT) /* * For newer PQ1 chips (MPC866/87x/88x families), PLL multiplication * factor is calculated as follows: * * MFN * MFI + ------- * MFD + 1 * factor = ----------------- * (PDF + 1) * 2^S * * For older chips, it's just MF field of PLPRCR plus one. */ if ((immr & 0x0FFF) >= MPC8xx_NEW_CLK) { /* MPC866/87x/88x series */ factor = (PLPRCR_val(MFI) + PLPRCR_val(MFN)/(PLPRCR_val(MFD)+1))/ (PLPRCR_val(PDF)+1) / (1<<PLPRCR_val(S)); } else { factor = PLPRCR_val(MF)+1; } oscclk = gd->cpu_clk / factor; if ((immap->im_clkrst.car_sccr & SCCR_RTSEL) == 0 || factor > 2) { return (oscclk / 4); } return (oscclk / 16);}/* ------------------------------------------------------------------------- */#if defined(CONFIG_WATCHDOG)void watchdog_reset (void){ int re_enable = disable_interrupts (); reset_8xx_watchdog ((immap_t *) CFG_IMMR); if (re_enable) enable_interrupts ();}#endif /* CONFIG_WATCHDOG */#if defined(CONFIG_WATCHDOG) || defined(CONFIG_LWMON)void reset_8xx_watchdog (volatile immap_t * immr){# if defined(CONFIG_LWMON) /* * The LWMON board uses a MAX6301 Watchdog * with the trigger pin connected to port PA.7 * * (The old board version used a MAX706TESA Watchdog, which * had to be handled exactly the same.) */# define WATCHDOG_BIT 0x0100 immr->im_ioport.iop_papar &= ~(WATCHDOG_BIT); /* GPIO */ immr->im_ioport.iop_padir |= WATCHDOG_BIT; /* Output */ immr->im_ioport.iop_paodr &= ~(WATCHDOG_BIT); /* active output */ immr->im_ioport.iop_padat ^= WATCHDOG_BIT; /* Toggle WDI */# elif defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X) /* * The KUP4 boards uses a TPS3705 Watchdog * with the trigger pin connected to port PA.5 */# define WATCHDOG_BIT 0x0400 immr->im_ioport.iop_papar &= ~(WATCHDOG_BIT); /* GPIO */ immr->im_ioport.iop_padir |= WATCHDOG_BIT; /* Output */ immr->im_ioport.iop_paodr &= ~(WATCHDOG_BIT); /* active output */ immr->im_ioport.iop_padat ^= WATCHDOG_BIT; /* Toggle WDI */# else /* * All other boards use the MPC8xx Internal Watchdog */ immr->im_siu_conf.sc_swsr = 0x556c; /* write magic1 */ immr->im_siu_conf.sc_swsr = 0xaa39; /* write magic2 */# endif /* CONFIG_LWMON */}#endif /* CONFIG_WATCHDOG *//* ------------------------------------------------------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -