cpu.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2010
  4. * Reinhard Meyer, reinhard.meyer@emk-elektronik.de
  5. * (C) Copyright 2009
  6. * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
  7. */
  8. #include <common.h>
  9. #include <asm/io.h>
  10. #include <asm/arch/hardware.h>
  11. #include <asm/arch/at91_pit.h>
  12. #include <asm/arch/at91_gpbr.h>
  13. #include <asm/arch/clk.h>
  14. #ifndef CONFIG_SYS_AT91_MAIN_CLOCK
  15. #define CONFIG_SYS_AT91_MAIN_CLOCK 0
  16. #endif
  17. int arch_cpu_init(void)
  18. {
  19. return at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);
  20. }
  21. void arch_preboot_os(void)
  22. {
  23. ulong cpiv;
  24. at91_pit_t *pit = (at91_pit_t *) ATMEL_BASE_PIT;
  25. cpiv = AT91_PIT_MR_PIV_MASK(readl(&pit->piir));
  26. /*
  27. * Disable PITC
  28. * Add 0x1000 to current counter to stop it faster
  29. * without waiting for wrapping back to 0
  30. */
  31. writel(cpiv + 0x1000, &pit->mr);
  32. }
  33. #if defined(CONFIG_DISPLAY_CPUINFO)
  34. int print_cpuinfo(void)
  35. {
  36. char __maybe_unused buf[32];
  37. printf("CPU: %s\n", ATMEL_CPU_NAME);
  38. printf("Crystal frequency: %8s MHz\n",
  39. strmhz(buf, get_main_clk_rate()));
  40. printf("CPU clock : %8s MHz\n",
  41. strmhz(buf, get_cpu_clk_rate()));
  42. printf("Master clock : %8s MHz\n",
  43. strmhz(buf, get_mck_clk_rate()));
  44. return 0;
  45. }
  46. #endif