cpu.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. * (C) Copyright 2013
  8. * Bo Shen <voice.shen@atmel.com>
  9. */
  10. #include <common.h>
  11. #include <cpu_func.h>
  12. #include <init.h>
  13. #include <vsprintf.h>
  14. #include <asm/io.h>
  15. #include <asm/arch/hardware.h>
  16. #include <asm/arch/at91_pit.h>
  17. #include <asm/arch/at91_gpbr.h>
  18. #include <asm/arch/clk.h>
  19. #ifndef CONFIG_SYS_AT91_MAIN_CLOCK
  20. #define CONFIG_SYS_AT91_MAIN_CLOCK 0
  21. #endif
  22. int arch_cpu_init(void)
  23. {
  24. return at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);
  25. }
  26. void arch_preboot_os(void)
  27. {
  28. ulong cpiv;
  29. at91_pit_t *pit = (at91_pit_t *)ATMEL_BASE_PIT;
  30. cpiv = AT91_PIT_MR_PIV_MASK(readl(&pit->piir));
  31. /*
  32. * Disable PITC
  33. * Add 0x1000 to current counter to stop it faster
  34. * without waiting for wrapping back to 0
  35. */
  36. writel(cpiv + 0x1000, &pit->mr);
  37. }
  38. #if defined(CONFIG_DISPLAY_CPUINFO)
  39. int print_cpuinfo(void)
  40. {
  41. char buf[32];
  42. printf("CPU: %s\n", get_cpu_name());
  43. printf("Crystal frequency: %8s MHz\n",
  44. strmhz(buf, get_main_clk_rate()));
  45. printf("CPU clock : %8s MHz\n",
  46. strmhz(buf, get_cpu_clk_rate()));
  47. printf("Master clock : %8s MHz\n",
  48. strmhz(buf, get_mck_clk_rate()));
  49. return 0;
  50. }
  51. #endif
  52. void enable_caches(void)
  53. {
  54. icache_enable();
  55. dcache_enable();
  56. }
  57. #define ATMEL_CHIPID_CIDR_VERSION 0x1f
  58. unsigned int get_chip_id(void)
  59. {
  60. return readl(ATMEL_CHIPID_CIDR) & ~ATMEL_CHIPID_CIDR_VERSION;
  61. }
  62. unsigned int get_extension_chip_id(void)
  63. {
  64. return readl(ATMEL_CHIPID_EXID);
  65. }