WS cleanup: remove SPACE(s) followed by TAB
[platform/kernel/u-boot.git] / arch / m68k / cpu / mcf523x / 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 <init.h>
13 #include <net.h>
14 #include <vsprintf.h>
15 #include <watchdog.h>
16 #include <command.h>
17 #include <netdev.h>
18 #include <asm/global_data.h>
19
20 #include <asm/immap.h>
21 #include <asm/io.h>
22
23 DECLARE_GLOBAL_DATA_PTR;
24
25 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
26 {
27         ccm_t *ccm = (ccm_t *) MMAP_CCM;
28
29         out_8(&ccm->rcr, CCM_RCR_SOFTRST);
30         /* we don't return! */
31         return 0;
32 }
33
34 #if defined(CONFIG_DISPLAY_CPUINFO)
35 int print_cpuinfo(void)
36 {
37         ccm_t *ccm = (ccm_t *) MMAP_CCM;
38         u16 msk;
39         u16 id = 0;
40         u8 ver;
41
42         puts("CPU:   ");
43         msk = (in_be16(&ccm->cir) >> 6);
44         ver = (in_be16(&ccm->cir) & 0x003f);
45         switch (msk) {
46         case 0x31:
47                 id = 5235;
48                 break;
49         }
50
51         if (id) {
52                 char buf1[32], buf2[32];
53
54                 printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
55                        ver);
56                 printf("       CPU CLK %s MHz BUS CLK %s MHz\n",
57                        strmhz(buf1, gd->cpu_clk),
58                        strmhz(buf2, gd->bus_clk));
59         }
60
61         return 0;
62 };
63 #endif /* CONFIG_DISPLAY_CPUINFO */
64
65 #if defined(CONFIG_WATCHDOG)
66 /* Called by macro WATCHDOG_RESET */
67 void watchdog_reset(void)
68 {
69         wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
70
71         /* Count register */
72         out_be16(&wdp->sr, 0x5555);
73         asm("nop");
74         out_be16(&wdp->sr, 0xaaaa);
75 }
76
77 int watchdog_disable(void)
78 {
79         wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
80
81         /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
82         /* halted watchdog timer */
83         setbits_be16(&wdp->cr, WTM_WCR_HALTED);
84
85         puts("WATCHDOG:disabled\n");
86         return (0);
87 }
88
89 int watchdog_init(void)
90 {
91         wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
92         u32 wdog_module = 0;
93
94         /* set timeout and enable watchdog */
95         wdog_module = ((CONFIG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT);
96         wdog_module |= (wdog_module / 8192);
97         out_be16(&wdp->mr, wdog_module);
98
99         out_be16(&wdp->cr, WTM_WCR_EN);
100         puts("WATCHDOG:enabled\n");
101
102         return (0);
103 }
104 #endif                          /* CONFIG_WATCHDOG */
105
106 #if defined(CONFIG_MCFFEC)
107 /* Default initializations for MCFFEC controllers.  To override,
108  * create a board-specific function called:
109  *      int board_eth_init(struct bd_info *bis)
110  */
111
112 int cpu_eth_init(struct bd_info *bis)
113 {
114         return mcffec_initialize(bis);
115 }
116 #endif