uboot/arch/powerpc/cpu/mpc5xxx/speed.c
<<
>>
Prefs
   1/*
   2 * (C) Copyright 2000-2002
   3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
   4 *
   5 * SPDX-License-Identifier:     GPL-2.0+
   6 */
   7
   8#include <common.h>
   9#include <mpc5xxx.h>
  10#include <asm/processor.h>
  11
  12DECLARE_GLOBAL_DATA_PTR;
  13
  14/* ------------------------------------------------------------------------- */
  15
  16/* Bus-to-Core Multipliers */
  17
  18static int bus2core[] = {
  19        3, 2, 2, 2, 4, 4, 5, 9,
  20        6, 11, 8, 10, 3, 12, 7, 0,
  21        6, 5, 13, 2, 14, 4, 15, 9,
  22        0, 11, 8, 10, 16, 12, 7, 0
  23};
  24/* ------------------------------------------------------------------------- */
  25
  26/*
  27 *
  28 */
  29
  30int get_clocks (void)
  31{
  32        ulong val, vco;
  33
  34#if !defined(CONFIG_SYS_MPC5XXX_CLKIN)
  35#error clock measuring not implemented yet - define CONFIG_SYS_MPC5XXX_CLKIN
  36#endif
  37
  38        val = *(vu_long *)MPC5XXX_CDM_PORCFG;
  39        if (val & (1 << 6)) {
  40                vco = CONFIG_SYS_MPC5XXX_CLKIN * 12;
  41        } else {
  42                vco = CONFIG_SYS_MPC5XXX_CLKIN * 16;
  43        }
  44        if (val & (1 << 5)) {
  45                gd->bus_clk = vco / 8;
  46        } else {
  47                gd->bus_clk = vco / 4;
  48        }
  49        gd->cpu_clk = gd->bus_clk * bus2core[val & 0x1f] / 2;
  50
  51        val = *(vu_long *)MPC5XXX_CDM_CFG;
  52        if (val & (1 << 8)) {
  53                gd->arch.ipb_clk = gd->bus_clk / 2;
  54        } else {
  55                gd->arch.ipb_clk = gd->bus_clk;
  56        }
  57        switch (val & 3) {
  58        case 0:
  59                gd->pci_clk = gd->arch.ipb_clk;
  60                break;
  61        case 1:
  62                gd->pci_clk = gd->arch.ipb_clk / 2;
  63                break;
  64        default:
  65                gd->pci_clk = gd->bus_clk / 4;
  66                break;
  67        }
  68
  69        return (0);
  70}
  71
  72int prt_mpc5xxx_clks (void)
  73{
  74        char buf1[32], buf2[32], buf3[32];
  75
  76        printf ("       Bus %s MHz, IPB %s MHz, PCI %s MHz\n",
  77                strmhz(buf1, gd->bus_clk),
  78                strmhz(buf2, gd->arch.ipb_clk),
  79                strmhz(buf3, gd->pci_clk)
  80        );
  81        return (0);
  82}
  83
  84/* ------------------------------------------------------------------------- */
  85