command: Remove the cmd_tbl_t typedef
[oweals/u-boot.git] / arch / m68k / cpu / mcf532x / 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-2008, 2012 Freescale Semiconductor, Inc.
8  * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
9  */
10
11 #include <common.h>
12 #include <init.h>
13 #include <net.h>
14 #include <vsprintf.h>
15 #include <watchdog.h>
16 #include <command.h>
17 #include <netdev.h>
18
19 #include <asm/immap.h>
20 #include <asm/io.h>
21
22 DECLARE_GLOBAL_DATA_PTR;
23
24 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
25 {
26         rcm_t *rcm = (rcm_t *) (MMAP_RCM);
27
28         udelay(1000);
29         setbits_8(&rcm->rcr, RCM_RCR_SOFTRST);
30
31         /* we don't return! */
32         return 0;
33 };
34
35 #if defined(CONFIG_DISPLAY_CPUINFO)
36 int print_cpuinfo(void)
37 {
38         ccm_t *ccm = (ccm_t *) MMAP_CCM;
39         u16 msk;
40         u16 id = 0;
41         u8 ver;
42
43         puts("CPU:   ");
44         msk = (in_be16(&ccm->cir) >> 6);
45         ver = (in_be16(&ccm->cir) & 0x003f);
46         switch (msk) {
47 #ifdef CONFIG_MCF5301x
48         case 0x78:
49                 id = 53010;
50                 break;
51         case 0x77:
52                 id = 53012;
53                 break;
54         case 0x76:
55                 id = 53015;
56                 break;
57         case 0x74:
58                 id = 53011;
59                 break;
60         case 0x73:
61                 id = 53013;
62                 break;
63 #endif
64 #ifdef CONFIG_MCF532x
65         case 0x54:
66                 id = 5329;
67                 break;
68         case 0x59:
69                 id = 5328;
70                 break;
71         case 0x61:
72                 id = 5327;
73                 break;
74         case 0x65:
75                 id = 5373;
76                 break;
77         case 0x68:
78                 id = 53721;
79                 break;
80         case 0x69:
81                 id = 5372;
82                 break;
83         case 0x6B:
84                 id = 5372;
85                 break;
86 #endif
87         }
88
89         if (id) {
90                 char buf1[32], buf2[32];
91
92                 printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
93                        ver);
94                 printf("       CPU CLK %s MHz BUS CLK %s MHz\n",
95                        strmhz(buf1, gd->cpu_clk),
96                        strmhz(buf2, gd->bus_clk));
97         }
98
99         return 0;
100 };
101 #endif /* CONFIG_DISPLAY_CPUINFO */
102
103 #if defined(CONFIG_WATCHDOG)
104 /* Called by macro WATCHDOG_RESET */
105 void watchdog_reset(void)
106 {
107         wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
108
109         /* Count register */
110         out_be16(&wdp->sr, 0x5555);
111         out_be16(&wdp->sr, 0xaaaa);
112 }
113
114 int watchdog_disable(void)
115 {
116         wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
117
118         /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
119         /* halted watchdog timer */
120         setbits_be16(&wdp->cr, WTM_WCR_HALTED);
121
122         puts("WATCHDOG:disabled\n");
123         return (0);
124 }
125
126 int watchdog_init(void)
127 {
128         wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
129         u32 wdog_module = 0;
130
131         /* set timeout and enable watchdog */
132         wdog_module = ((CONFIG_SYS_CLK / 1000) * CONFIG_WATCHDOG_TIMEOUT);
133 #ifdef CONFIG_M5329
134         out_be16(&wdp->mr, wdog_module / 8192);
135 #else
136         out_be16(&wdp->mr, wdog_module / 4096);
137 #endif
138
139         out_be16(&wdp->cr, WTM_WCR_EN);
140         puts("WATCHDOG:enabled\n");
141
142         return (0);
143 }
144 #endif                          /* CONFIG_WATCHDOG */
145
146 #if defined(CONFIG_MCFFEC)
147 /* Default initializations for MCFFEC controllers.  To override,
148  * create a board-specific function called:
149  *      int board_eth_init(bd_t *bis)
150  */
151 int cpu_eth_init(bd_t *bis)
152 {
153         return mcffec_initialize(bis);
154 }
155 #endif