cpu.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. #include <asm/io.h>
  29. #include <asm/arch/hardware.h>
  30. #include <asm/arch/at91_dbu.h>
  31. #include <asm/arch/at91_pmc.h>
  32. #include <asm/arch/at91_pit.h>
  33. #include <asm/arch/at91_gpbr.h>
  34. #include <asm/arch/clk.h>
  35. #ifndef CONFIG_SYS_AT91_MAIN_CLOCK
  36. #define CONFIG_SYS_AT91_MAIN_CLOCK 0
  37. #endif
  38. int arch_cpu_init(void)
  39. {
  40. return at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);
  41. }
  42. void arch_preboot_os(void)
  43. {
  44. ulong cpiv;
  45. at91_pit_t *pit = (at91_pit_t *)ATMEL_BASE_PIT;
  46. cpiv = AT91_PIT_MR_PIV_MASK(readl(&pit->piir));
  47. /*
  48. * Disable PITC
  49. * Add 0x1000 to current counter to stop it faster
  50. * without waiting for wrapping back to 0
  51. */
  52. writel(cpiv + 0x1000, &pit->mr);
  53. }
  54. #if defined(CONFIG_DISPLAY_CPUINFO)
  55. int print_cpuinfo(void)
  56. {
  57. char buf[32];
  58. printf("CPU: %s\n", get_cpu_name());
  59. printf("Crystal frequency: %8s MHz\n",
  60. strmhz(buf, get_main_clk_rate()));
  61. printf("CPU clock : %8s MHz\n",
  62. strmhz(buf, get_cpu_clk_rate()));
  63. printf("Master clock : %8s MHz\n",
  64. strmhz(buf, get_mck_clk_rate()));
  65. return 0;
  66. }
  67. #endif
  68. void enable_caches(void)
  69. {
  70. }
  71. unsigned int get_chip_id(void)
  72. {
  73. return readl(ATMEL_BASE_DBGU + AT91_DBU_CIDR) & ~AT91_DBU_CIDR_MASK;
  74. }
  75. unsigned int get_extension_chip_id(void)
  76. {
  77. return readl(ATMEL_BASE_DBGU + AT91_DBU_EXID);
  78. }