speed.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * (C) Copyright 2000-2004
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.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. uint immr = get_immr(0); /* Return full IMMR contents */
  18. immap_t __iomem *immap = (immap_t __iomem *)(immr & 0xFFFF0000);
  19. uint sccr = in_be32(&immap->im_clkrst.car_sccr);
  20. uint divider = 1 << (((sccr & SCCR_DFBRG11) >> 11) * 2);
  21. /*
  22. * If for some reason measuring the gclk frequency won't
  23. * work, we return the hardwired value.
  24. * (For example, the cogent CMA286-60 CPU module has no
  25. * separate oscillator for PITRTCLK)
  26. */
  27. gd->cpu_clk = CONFIG_8xx_GCLK_FREQ;
  28. if ((sccr & SCCR_EBDF11) == 0) {
  29. /* No Bus Divider active */
  30. gd->bus_clk = gd->cpu_clk;
  31. } else {
  32. /* The MPC8xx has only one BDF: half clock speed */
  33. gd->bus_clk = gd->cpu_clk / 2;
  34. }
  35. gd->arch.brg_clk = gd->cpu_clk / divider;
  36. return 0;
  37. }