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