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