cpu.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* CPU specific code for the LEON3 CPU
  2. *
  3. * (C) Copyright 2007, 2015
  4. * Daniel Hellstrom, Cobham Gaisler, daniel@gaisler.com
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <watchdog.h>
  10. #include <command.h>
  11. #include <netdev.h>
  12. #include <asm/io.h>
  13. #include <asm/processor.h>
  14. #include <ambapp.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. extern void _reset_reloc(void);
  17. int leon_cpu_cnt = 1;
  18. int leon_ver = 3;
  19. unsigned int leon_cpu_freq = CONFIG_SYS_CLK_FREQ;
  20. int cpu_freq(void)
  21. {
  22. ambapp_ahbdev dev;
  23. if (leon_ver == 3) {
  24. ambapp_ahbmst_find(&ambapp_plb, VENDOR_GAISLER,
  25. GAISLER_LEON3, 0, &dev);
  26. } else {
  27. ambapp_ahbmst_find(&ambapp_plb, VENDOR_GAISLER,
  28. GAISLER_LEON4, 0, &dev);
  29. }
  30. leon_cpu_freq = ambapp_bus_freq(&ambapp_plb, dev.ahb_bus_index);
  31. return 0;
  32. }
  33. int checkcpu(void)
  34. {
  35. int cnt;
  36. char str[4];
  37. /* check LEON version here */
  38. cnt = ambapp_ahbmst_count(&ambapp_plb, VENDOR_GAISLER, GAISLER_LEON3);
  39. if (cnt <= 0) {
  40. cnt = ambapp_ahbmst_count(&ambapp_plb, VENDOR_GAISLER,
  41. GAISLER_LEON4);
  42. if (cnt > 0)
  43. leon_ver = 4;
  44. }
  45. cpu_freq();
  46. str[0] = '\0';
  47. if (cnt > 1) {
  48. leon_cpu_cnt = cnt;
  49. str[0] = '0' + cnt;
  50. str[1] = 'x';
  51. str[2] = '\0';
  52. }
  53. printf("CPU: %sLEON%d @ %dMHz\n", str, leon_ver,
  54. leon_cpu_freq / 1000000);
  55. return 0;
  56. }
  57. #ifdef CONFIG_DISPLAY_CPUINFO
  58. int print_cpuinfo(void)
  59. {
  60. printf("CPU: LEON3\n");
  61. return 0;
  62. }
  63. #endif
  64. /* ------------------------------------------------------------------------- */
  65. void cpu_reset(void)
  66. {
  67. /* Interrupts off */
  68. disable_interrupts();
  69. /* jump to restart in flash */
  70. _reset_reloc();
  71. }
  72. int do_reset(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  73. {
  74. cpu_reset();
  75. return 1;
  76. }
  77. u64 flash_read64(void *addr)
  78. {
  79. return __raw_readq(addr);
  80. }
  81. /* ------------------------------------------------------------------------- */
  82. #ifdef CONFIG_GRETH
  83. int cpu_eth_init(bd_t *bis)
  84. {
  85. return greth_initialize(bis);
  86. }
  87. #endif