cpu.c 1.5 KB

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