speed.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000-2004
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #include <common.h>
  7. #include <clock_legacy.h>
  8. #include <mpc8xx.h>
  9. #include <asm/processor.h>
  10. #include <asm/io.h>
  11. DECLARE_GLOBAL_DATA_PTR;
  12. /*
  13. * get_clocks() fills in gd->cpu_clock depending on CONFIG_8xx_GCLK_FREQ
  14. */
  15. int get_clocks(void)
  16. {
  17. immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
  18. uint sccr = in_be32(&immap->im_clkrst.car_sccr);
  19. uint divider = 1 << (((sccr & SCCR_DFBRG11) >> 11) * 2);
  20. /*
  21. * If for some reason measuring the gclk frequency won't
  22. * work, we return the hardwired value.
  23. * (For example, the cogent CMA286-60 CPU module has no
  24. * separate oscillator for PITRTCLK)
  25. */
  26. gd->cpu_clk = CONFIG_8xx_GCLK_FREQ;
  27. if ((sccr & SCCR_EBDF11) == 0) {
  28. /* No Bus Divider active */
  29. gd->bus_clk = gd->cpu_clk;
  30. } else {
  31. /* The MPC8xx has only one BDF: half clock speed */
  32. gd->bus_clk = gd->cpu_clk / 2;
  33. }
  34. gd->arch.brg_clk = gd->cpu_clk / divider;
  35. return 0;
  36. }