Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 2 | /* |
| 3 | * |
| 4 | * (C) Copyright 2000-2003 |
| 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 6 | * |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 7 | * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc. |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 8 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -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> |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -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> |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 19 | |
| 20 | #include <asm/immap.h> |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 21 | #include <asm/io.h> |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 22 | |
| 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[]) |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 26 | { |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 27 | ccm_t *ccm = (ccm_t *) MMAP_CCM; |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 28 | |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 29 | out_8(&ccm->rcr, CCM_RCR_SOFTRST); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 30 | /* we don't return! */ |
| 31 | return 0; |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 32 | } |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 33 | |
Angelo Dureghello | 3146b4d | 2017-08-20 00:01:55 +0200 | [diff] [blame] | 34 | #if defined(CONFIG_DISPLAY_CPUINFO) |
| 35 | int print_cpuinfo(void) |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 36 | { |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 37 | ccm_t *ccm = (ccm_t *) MMAP_CCM; |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 38 | u16 msk; |
| 39 | u16 id = 0; |
| 40 | u8 ver; |
| 41 | |
| 42 | puts("CPU: "); |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 43 | msk = (in_be16(&ccm->cir) >> 6); |
| 44 | ver = (in_be16(&ccm->cir) & 0x003f); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 45 | switch (msk) { |
| 46 | case 0x31: |
| 47 | id = 5235; |
| 48 | break; |
| 49 | } |
| 50 | |
| 51 | if (id) { |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 52 | char buf1[32], buf2[32]; |
| 53 | |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 54 | printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk, |
| 55 | ver); |
Wolfgang Denk | 2059104 | 2008-10-19 02:35:49 +0200 | [diff] [blame] | 56 | printf(" CPU CLK %s MHz BUS CLK %s MHz\n", |
TsiChung Liew | 10e9a6e | 2008-10-22 11:55:30 +0000 | [diff] [blame] | 57 | strmhz(buf1, gd->cpu_clk), |
| 58 | strmhz(buf2, gd->bus_clk)); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | return 0; |
| 62 | }; |
Angelo Dureghello | 3146b4d | 2017-08-20 00:01:55 +0200 | [diff] [blame] | 63 | #endif /* CONFIG_DISPLAY_CPUINFO */ |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 64 | |
| 65 | #if defined(CONFIG_WATCHDOG) |
| 66 | /* Called by macro WATCHDOG_RESET */ |
| 67 | void watchdog_reset(void) |
| 68 | { |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 69 | wdog_t *wdp = (wdog_t *) (MMAP_WDOG); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 70 | |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 71 | /* Count register */ |
| 72 | out_be16(&wdp->sr, 0x5555); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 73 | asm("nop"); |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 74 | out_be16(&wdp->sr, 0xaaaa); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | int watchdog_disable(void) |
| 78 | { |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 79 | wdog_t *wdp = (wdog_t *) (MMAP_WDOG); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 80 | |
| 81 | /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */ |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 82 | /* halted watchdog timer */ |
| 83 | setbits_be16(&wdp->cr, WTM_WCR_HALTED); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 84 | |
| 85 | puts("WATCHDOG:disabled\n"); |
| 86 | return (0); |
| 87 | } |
| 88 | |
| 89 | int watchdog_init(void) |
| 90 | { |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 91 | wdog_t *wdp = (wdog_t *) (MMAP_WDOG); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 92 | u32 wdog_module = 0; |
| 93 | |
| 94 | /* set timeout and enable watchdog */ |
Tom Rini | 9e7eeec | 2022-11-19 18:45:45 -0500 | [diff] [blame^] | 95 | wdog_module = ((CFG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT_MSECS); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 96 | wdog_module |= (wdog_module / 8192); |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 97 | out_be16(&wdp->mr, wdog_module); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 98 | |
Alison Wang | d132fe6 | 2012-03-26 21:49:06 +0000 | [diff] [blame] | 99 | out_be16(&wdp->cr, WTM_WCR_EN); |
TsiChungLiew | b859ef1 | 2007-08-16 19:23:50 -0500 | [diff] [blame] | 100 | puts("WATCHDOG:enabled\n"); |
| 101 | |
| 102 | return (0); |
| 103 | } |
| 104 | #endif /* CONFIG_WATCHDOG */ |
Ben Warren | 90c96db | 2008-08-26 22:16:25 -0700 | [diff] [blame] | 105 | |
| 106 | #if defined(CONFIG_MCFFEC) |
| 107 | /* Default initializations for MCFFEC controllers. To override, |
| 108 | * create a board-specific function called: |
Wolfgang Denk | 62fb2b4 | 2021-09-27 17:42:39 +0200 | [diff] [blame] | 109 | * int board_eth_init(struct bd_info *bis) |
Ben Warren | 90c96db | 2008-08-26 22:16:25 -0700 | [diff] [blame] | 110 | */ |
| 111 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 112 | int cpu_eth_init(struct bd_info *bis) |
Ben Warren | 90c96db | 2008-08-26 22:16:25 -0700 | [diff] [blame] | 113 | { |
| 114 | return mcffec_initialize(bis); |
| 115 | } |
| 116 | #endif |