Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * (C) Copyright 2000-2003 |
| 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 6 | * |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 7 | * Copyright (C) 2004-2008, 2012 Freescale Semiconductor, Inc. |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 8 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 12 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 13 | #include <net.h> |
Simon Glass | f5c208d | 2019-11-14 12:57:20 -0700 | [diff] [blame] | 14 | #include <vsprintf.h> |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 15 | #include <watchdog.h> |
| 16 | #include <command.h> |
Ben Warren | 2f2b6b6 | 2008-08-31 22:22:04 -0700 | [diff] [blame] | 17 | #include <netdev.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 18 | #include <linux/delay.h> |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 19 | |
TsiChungLiew | fb66174 | 2007-07-05 23:01:22 -0500 | [diff] [blame] | 20 | #include <asm/immap.h> |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 21 | #include <asm/io.h> |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 22 | |
Wolfgang Denk | d112a2c | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 25 | int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 26 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 27 | rcm_t *rcm = (rcm_t *) (MMAP_RCM); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 28 | |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 29 | udelay(1000); |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 30 | setbits_8(&rcm->rcr, RCM_RCR_SOFTRST); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 31 | |
| 32 | /* we don't return! */ |
| 33 | return 0; |
| 34 | }; |
| 35 | |
Angelo Dureghello | 3146b4d | 2017-08-20 00:01:55 +0200 | [diff] [blame] | 36 | #if defined(CONFIG_DISPLAY_CPUINFO) |
| 37 | int print_cpuinfo(void) |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 38 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 39 | ccm_t *ccm = (ccm_t *) MMAP_CCM; |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 40 | u16 msk; |
| 41 | u16 id = 0; |
| 42 | u8 ver; |
| 43 | |
| 44 | puts("CPU: "); |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 45 | msk = (in_be16(&ccm->cir) >> 6); |
| 46 | ver = (in_be16(&ccm->cir) & 0x003f); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 47 | switch (msk) { |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 48 | #ifdef CONFIG_MCF5301x |
| 49 | case 0x78: |
| 50 | id = 53010; |
| 51 | break; |
| 52 | case 0x77: |
| 53 | id = 53012; |
| 54 | break; |
| 55 | case 0x76: |
| 56 | id = 53015; |
| 57 | break; |
| 58 | case 0x74: |
| 59 | id = 53011; |
| 60 | break; |
| 61 | case 0x73: |
| 62 | id = 53013; |
| 63 | break; |
| 64 | #endif |
| 65 | #ifdef CONFIG_MCF532x |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 66 | case 0x54: |
| 67 | id = 5329; |
| 68 | break; |
| 69 | case 0x59: |
| 70 | id = 5328; |
| 71 | break; |
| 72 | case 0x61: |
| 73 | id = 5327; |
| 74 | break; |
TsiChungLiew | 6f8a0a3 | 2008-01-14 17:23:08 -0600 | [diff] [blame] | 75 | case 0x65: |
| 76 | id = 5373; |
| 77 | break; |
| 78 | case 0x68: |
| 79 | id = 53721; |
| 80 | break; |
| 81 | case 0x69: |
| 82 | id = 5372; |
| 83 | break; |
| 84 | case 0x6B: |
| 85 | id = 5372; |
| 86 | break; |
TsiChung Liew | e7e4fc8 | 2008-10-22 11:38:21 +0000 | [diff] [blame] | 87 | #endif |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | if (id) { |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 91 | char buf1[32], buf2[32]; |
| 92 | |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 93 | printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk, |
| 94 | ver); |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 95 | printf(" CPU CLK %s MHz BUS CLK %s MHz\n", |
TsiChung Liew | 10e9a6e | 2008-10-22 11:55:30 +0000 | [diff] [blame] | 96 | strmhz(buf1, gd->cpu_clk), |
| 97 | strmhz(buf2, gd->bus_clk)); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | return 0; |
| 101 | }; |
Angelo Dureghello | 3146b4d | 2017-08-20 00:01:55 +0200 | [diff] [blame] | 102 | #endif /* CONFIG_DISPLAY_CPUINFO */ |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 103 | |
| 104 | #if defined(CONFIG_WATCHDOG) |
| 105 | /* Called by macro WATCHDOG_RESET */ |
| 106 | void watchdog_reset(void) |
| 107 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 108 | wdog_t *wdp = (wdog_t *) (MMAP_WDOG); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 109 | |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 110 | /* Count register */ |
| 111 | out_be16(&wdp->sr, 0x5555); |
| 112 | out_be16(&wdp->sr, 0xaaaa); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | int watchdog_disable(void) |
| 116 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 117 | wdog_t *wdp = (wdog_t *) (MMAP_WDOG); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 118 | |
| 119 | /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */ |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 120 | /* halted watchdog timer */ |
| 121 | setbits_be16(&wdp->cr, WTM_WCR_HALTED); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 122 | |
| 123 | puts("WATCHDOG:disabled\n"); |
| 124 | return (0); |
| 125 | } |
| 126 | |
| 127 | int watchdog_init(void) |
| 128 | { |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 129 | wdog_t *wdp = (wdog_t *) (MMAP_WDOG); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 130 | u32 wdog_module = 0; |
| 131 | |
| 132 | /* set timeout and enable watchdog */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 133 | wdog_module = ((CONFIG_SYS_CLK / 1000) * CONFIG_WATCHDOG_TIMEOUT); |
TsiChungLiew | 6f8a0a3 | 2008-01-14 17:23:08 -0600 | [diff] [blame] | 134 | #ifdef CONFIG_M5329 |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 135 | out_be16(&wdp->mr, wdog_module / 8192); |
TsiChungLiew | 6f8a0a3 | 2008-01-14 17:23:08 -0600 | [diff] [blame] | 136 | #else |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 137 | out_be16(&wdp->mr, wdog_module / 4096); |
TsiChungLiew | 6f8a0a3 | 2008-01-14 17:23:08 -0600 | [diff] [blame] | 138 | #endif |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 139 | |
Alison Wang | 35d23df | 2012-03-26 21:49:05 +0000 | [diff] [blame] | 140 | out_be16(&wdp->cr, WTM_WCR_EN); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 141 | puts("WATCHDOG:enabled\n"); |
| 142 | |
| 143 | return (0); |
| 144 | } |
TsiChungLiew | fb66174 | 2007-07-05 23:01:22 -0500 | [diff] [blame] | 145 | #endif /* CONFIG_WATCHDOG */ |
Ben Warren | 90c96db | 2008-08-26 22:16:25 -0700 | [diff] [blame] | 146 | |
| 147 | #if defined(CONFIG_MCFFEC) |
| 148 | /* Default initializations for MCFFEC controllers. To override, |
| 149 | * create a board-specific function called: |
| 150 | * int board_eth_init(bd_t *bis) |
| 151 | */ |
Ben Warren | 90c96db | 2008-08-26 22:16:25 -0700 | [diff] [blame] | 152 | int cpu_eth_init(bd_t *bis) |
| 153 | { |
| 154 | return mcffec_initialize(bis); |
| 155 | } |
| 156 | #endif |