common: Drop net.h from common header
[oweals/u-boot.git] / arch / m68k / cpu / mcf547x_8x / cpu.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  *
4  * (C) Copyright 2000-2003
5  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6  *
7  * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
8  * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
9  */
10
11 #include <common.h>
12 #include <net.h>
13 #include <vsprintf.h>
14 #include <watchdog.h>
15 #include <command.h>
16 #include <netdev.h>
17
18 #include <asm/immap.h>
19 #include <asm/io.h>
20
21 DECLARE_GLOBAL_DATA_PTR;
22
23 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
24 {
25         gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
26
27         out_be16(&gptmr->pre, 10);
28         out_be16(&gptmr->cnt, 1);
29
30         /* enable watchdog, set timeout to 0 and wait */
31         out_8(&gptmr->mode, GPT_TMS_SGPIO);
32         out_8(&gptmr->ctrl, GPT_CTRL_WDEN | GPT_CTRL_CE);
33
34         /* we don't return! */
35         return 1;
36 };
37
38 #if defined(CONFIG_DISPLAY_CPUINFO)
39 int print_cpuinfo(void)
40 {
41         siu_t *siu = (siu_t *) MMAP_SIU;
42         u16 id = 0;
43
44         puts("CPU:   ");
45
46         switch ((in_be32(&siu->jtagid) & 0x000FF000) >> 12) {
47         case 0x0C:
48                 id = 5485;
49                 break;
50         case 0x0D:
51                 id = 5484;
52                 break;
53         case 0x0E:
54                 id = 5483;
55                 break;
56         case 0x0F:
57                 id = 5482;
58                 break;
59         case 0x10:
60                 id = 5481;
61                 break;
62         case 0x11:
63                 id = 5480;
64                 break;
65         case 0x12:
66                 id = 5475;
67                 break;
68         case 0x13:
69                 id = 5474;
70                 break;
71         case 0x14:
72                 id = 5473;
73                 break;
74         case 0x15:
75                 id = 5472;
76                 break;
77         case 0x16:
78                 id = 5471;
79                 break;
80         case 0x17:
81                 id = 5470;
82                 break;
83         }
84
85         if (id) {
86                 char buf1[32], buf2[32];
87
88                 printf("Freescale MCF%d\n", id);
89                 printf("       CPU CLK %s MHz BUS CLK %s MHz\n",
90                        strmhz(buf1, gd->cpu_clk),
91                        strmhz(buf2, gd->bus_clk));
92         }
93
94         return 0;
95 };
96 #endif /* CONFIG_DISPLAY_CPUINFO */
97
98 #if defined(CONFIG_HW_WATCHDOG)
99 /* Called by macro WATCHDOG_RESET */
100 void hw_watchdog_reset(void)
101 {
102         gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
103
104         out_8(&gptmr->ocpw, 0xa5);
105 }
106
107 int watchdog_disable(void)
108 {
109         gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
110
111         /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
112         out_8(&gptmr->mode, 0);
113         out_8(&gptmr->ctrl, 0);
114
115         puts("WATCHDOG:disabled\n");
116
117         return (0);
118 }
119
120 int watchdog_init(void)
121 {
122         gptmr_t *gptmr = (gptmr_t *) (MMAP_GPTMR);
123
124         out_be16(&gptmr->pre, CONFIG_WATCHDOG_TIMEOUT);
125         out_be16(&gptmr->cnt, CONFIG_SYS_TIMER_PRESCALER * 1000);
126
127         out_8(&gptmr->mode, GPT_TMS_SGPIO);
128         out_8(&gptmr->ctrl, GPT_CTRL_CE | GPT_CTRL_WDEN);
129         puts("WATCHDOG:enabled\n");
130
131         return (0);
132 }
133 #endif                          /* CONFIG_HW_WATCHDOG */
134
135 #if defined(CONFIG_FSLDMAFEC) || defined(CONFIG_MCFFEC)
136 /* Default initializations for MCFFEC controllers.  To override,
137  * create a board-specific function called:
138  *      int board_eth_init(bd_t *bis)
139  */
140
141 int cpu_eth_init(bd_t *bis)
142 {
143 #if defined(CONFIG_FSLDMAFEC)
144         mcdmafec_initialize(bis);
145 #endif
146 #if defined(CONFIG_MCFFEC)
147         mcffec_initialize(bis);
148 #endif
149         return 0;
150 }
151 #endif