speed.c 1009 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 <mpc8xx.h>
  8. #include <asm/processor.h>
  9. #include <asm/io.h>
  10. DECLARE_GLOBAL_DATA_PTR;
  11. /*
  12. * get_clocks() fills in gd->cpu_clock depending on CONFIG_8xx_GCLK_FREQ
  13. */
  14. int get_clocks(void)
  15. {
  16. immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
  17. uint sccr = in_be32(&immap->im_clkrst.car_sccr);
  18. uint divider = 1 << (((sccr & SCCR_DFBRG11) >> 11) * 2);
  19. /*
  20. * If for some reason measuring the gclk frequency won't
  21. * work, we return the hardwired value.
  22. * (For example, the cogent CMA286-60 CPU module has no
  23. * separate oscillator for PITRTCLK)
  24. */
  25. gd->cpu_clk = CONFIG_8xx_GCLK_FREQ;
  26. if ((sccr & SCCR_EBDF11) == 0) {
  27. /* No Bus Divider active */
  28. gd->bus_clk = gd->cpu_clk;
  29. } else {
  30. /* The MPC8xx has only one BDF: half clock speed */
  31. gd->bus_clk = gd->cpu_clk / 2;
  32. }
  33. gd->arch.brg_clk = gd->cpu_clk / divider;
  34. return 0;
  35. }