uboot/arch/sparc/cpu/leon3/cpu.c
<<
>>
Prefs
   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
   9#include <common.h>
  10#include <watchdog.h>
  11#include <command.h>
  12#include <netdev.h>
  13
  14#include <asm/io.h>
  15#include <asm/processor.h>
  16#include <ambapp.h>
  17
  18DECLARE_GLOBAL_DATA_PTR;
  19
  20extern void _reset_reloc(void);
  21
  22int leon_cpu_cnt = 1;
  23int leon_ver = 3;
  24unsigned int leon_cpu_freq = CONFIG_SYS_CLK_FREQ;
  25
  26int cpu_freq(void)
  27{
  28        ambapp_ahbdev dev;
  29
  30        if (leon_ver == 3) {
  31                ambapp_ahbmst_find(&ambapp_plb, VENDOR_GAISLER,
  32                        GAISLER_LEON3, 0, &dev);
  33        } else {
  34                ambapp_ahbmst_find(&ambapp_plb, VENDOR_GAISLER,
  35                        GAISLER_LEON4, 0, &dev);
  36        }
  37
  38        leon_cpu_freq = ambapp_bus_freq(&ambapp_plb, dev.ahb_bus_index);
  39
  40        return 0;
  41}
  42
  43int checkcpu(void)
  44{
  45        int cnt;
  46        char str[4];
  47
  48        /* check LEON version here */
  49        cnt = ambapp_ahbmst_count(&ambapp_plb, VENDOR_GAISLER, GAISLER_LEON3);
  50        if (cnt <= 0) {
  51                cnt = ambapp_ahbmst_count(&ambapp_plb, VENDOR_GAISLER,
  52                        GAISLER_LEON4);
  53                if (cnt > 0)
  54                        leon_ver = 4;
  55        }
  56
  57        cpu_freq();
  58
  59        str[0] = '\0';
  60        if (cnt > 1) {
  61                leon_cpu_cnt = cnt;
  62                str[0] = '0' + cnt;
  63                str[1] = 'x';
  64                str[2] = '\0';
  65        }
  66        printf("CPU: %sLEON%d @ %dMHz\n", str, leon_ver,
  67                leon_cpu_freq / 1000000);
  68
  69        return 0;
  70}
  71
  72#ifdef CONFIG_DISPLAY_CPUINFO
  73
  74int print_cpuinfo(void)
  75{
  76        printf("CPU:   LEON3\n");
  77        return 0;
  78}
  79
  80#endif
  81
  82/* ------------------------------------------------------------------------- */
  83
  84void cpu_reset(void)
  85{
  86        /* Interrupts off */
  87        disable_interrupts();
  88
  89        /* jump to restart in flash */
  90        _reset_reloc();
  91}
  92
  93int do_reset(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
  94{
  95        cpu_reset();
  96
  97        return 1;
  98
  99}
 100
 101u64 flash_read64(void *addr)
 102{
 103        return __raw_readq(addr);
 104}
 105
 106/* ------------------------------------------------------------------------- */
 107
 108#ifdef CONFIG_GRETH
 109int cpu_eth_init(bd_t *bis)
 110{
 111        return greth_initialize(bis);
 112}
 113#endif
 114