blob: 149e5c69e631a7bf998d2ae381c4b651496d82d4 [file] [log] [blame]
Daniel Hellstromb552dbe2008-03-26 22:51:29 +01001/* CPU specific code for the LEON3 CPU
2 *
Francois Retiefe3051d92015-10-28 14:29:32 +02003 * (C) Copyright 2007, 2015
4 * Daniel Hellstrom, Cobham Gaisler, daniel@gaisler.com
Daniel Hellstromb552dbe2008-03-26 22:51:29 +01005 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Daniel Hellstromb552dbe2008-03-26 22:51:29 +01007 */
8
9#include <common.h>
10#include <watchdog.h>
11#include <command.h>
Ben Warren2f2b6b62008-08-31 22:22:04 -070012#include <netdev.h>
Daniel Hellstromb552dbe2008-03-26 22:51:29 +010013
14#include <asm/io.h>
15#include <asm/processor.h>
Daniel Hellstromcbb7de62010-01-22 13:25:03 +010016#include <ambapp.h>
Daniel Hellstromb552dbe2008-03-26 22:51:29 +010017
18DECLARE_GLOBAL_DATA_PTR;
19
20extern void _reset_reloc(void);
21
Daniel Hellstromcbb7de62010-01-22 13:25:03 +010022int 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
Daniel Hellstromb552dbe2008-03-26 22:51:29 +010043int checkcpu(void)
44{
Daniel Hellstromcbb7de62010-01-22 13:25:03 +010045 int cnt;
46 char str[4];
47
Daniel Hellstromb552dbe2008-03-26 22:51:29 +010048 /* check LEON version here */
Daniel Hellstromcbb7de62010-01-22 13:25:03 +010049 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
Daniel Hellstromb552dbe2008-03-26 22:51:29 +010069 return 0;
70}
71
Francois Retief703d0242015-10-28 16:49:02 +020072#ifdef CONFIG_DISPLAY_CPUINFO
73
74int print_cpuinfo(void)
75{
76 printf("CPU: LEON3\n");
77 return 0;
78}
79
80#endif
81
Daniel Hellstromb552dbe2008-03-26 22:51:29 +010082/* ------------------------------------------------------------------------- */
83
84void cpu_reset(void)
85{
86 /* Interrupts off */
87 disable_interrupts();
88
89 /* jump to restart in flash */
90 _reset_reloc();
91}
92
Wolfgang Denk6262d0212010-06-28 22:00:46 +020093int do_reset(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Daniel Hellstromb552dbe2008-03-26 22:51:29 +010094{
95 cpu_reset();
96
97 return 1;
98
99}
100
101u64 flash_read64(void *addr)
102{
103 return __raw_readq(addr);
104}
105
106/* ------------------------------------------------------------------------- */
Ben Warren8c042b62008-07-09 01:04:19 -0700107
108#ifdef CONFIG_GRETH
109int cpu_eth_init(bd_t *bis)
110{
111 return greth_initialize(bis);
112}
113#endif