2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2007-08-17 00:23:50 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (C) Copyright 2000-2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2012-03-26 21:49:06 +00:00
|
|
|
* Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
|
2007-08-17 00:23:50 +00:00
|
|
|
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <net.h>
|
2019-11-14 19:57:20 +00:00
|
|
|
#include <vsprintf.h>
|
2007-08-17 00:23:50 +00:00
|
|
|
#include <watchdog.h>
|
|
|
|
#include <command.h>
|
2008-09-01 05:22:04 +00:00
|
|
|
#include <netdev.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2007-08-17 00:23:50 +00:00
|
|
|
|
|
|
|
#include <asm/immap.h>
|
2012-03-26 21:49:06 +00:00
|
|
|
#include <asm/io.h>
|
2007-08-17 00:23:50 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
2007-08-17 00:23:50 +00:00
|
|
|
{
|
2012-03-26 21:49:06 +00:00
|
|
|
ccm_t *ccm = (ccm_t *) MMAP_CCM;
|
2007-08-17 00:23:50 +00:00
|
|
|
|
2012-03-26 21:49:06 +00:00
|
|
|
out_8(&ccm->rcr, CCM_RCR_SOFTRST);
|
2007-08-17 00:23:50 +00:00
|
|
|
/* we don't return! */
|
|
|
|
return 0;
|
2012-03-26 21:49:06 +00:00
|
|
|
}
|
2007-08-17 00:23:50 +00:00
|
|
|
|
2017-08-19 22:01:55 +00:00
|
|
|
#if defined(CONFIG_DISPLAY_CPUINFO)
|
|
|
|
int print_cpuinfo(void)
|
2007-08-17 00:23:50 +00:00
|
|
|
{
|
2012-03-26 21:49:06 +00:00
|
|
|
ccm_t *ccm = (ccm_t *) MMAP_CCM;
|
2007-08-17 00:23:50 +00:00
|
|
|
u16 msk;
|
|
|
|
u16 id = 0;
|
|
|
|
u8 ver;
|
|
|
|
|
|
|
|
puts("CPU: ");
|
2012-03-26 21:49:06 +00:00
|
|
|
msk = (in_be16(&ccm->cir) >> 6);
|
|
|
|
ver = (in_be16(&ccm->cir) & 0x003f);
|
2007-08-17 00:23:50 +00:00
|
|
|
switch (msk) {
|
|
|
|
case 0x31:
|
|
|
|
id = 5235;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id) {
|
2008-10-19 00:35:49 +00:00
|
|
|
char buf1[32], buf2[32];
|
|
|
|
|
2007-08-17 00:23:50 +00:00
|
|
|
printf("Freescale MCF%d (Mask:%01x Version:%x)\n", id, msk,
|
|
|
|
ver);
|
2008-10-19 00:35:49 +00:00
|
|
|
printf(" CPU CLK %s MHz BUS CLK %s MHz\n",
|
2008-10-22 11:55:30 +00:00
|
|
|
strmhz(buf1, gd->cpu_clk),
|
|
|
|
strmhz(buf2, gd->bus_clk));
|
2007-08-17 00:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
};
|
2017-08-19 22:01:55 +00:00
|
|
|
#endif /* CONFIG_DISPLAY_CPUINFO */
|
2007-08-17 00:23:50 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_WATCHDOG)
|
|
|
|
/* Called by macro WATCHDOG_RESET */
|
|
|
|
void watchdog_reset(void)
|
|
|
|
{
|
2012-03-26 21:49:06 +00:00
|
|
|
wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
|
2007-08-17 00:23:50 +00:00
|
|
|
|
2012-03-26 21:49:06 +00:00
|
|
|
/* Count register */
|
|
|
|
out_be16(&wdp->sr, 0x5555);
|
2007-08-17 00:23:50 +00:00
|
|
|
asm("nop");
|
2012-03-26 21:49:06 +00:00
|
|
|
out_be16(&wdp->sr, 0xaaaa);
|
2007-08-17 00:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int watchdog_disable(void)
|
|
|
|
{
|
2012-03-26 21:49:06 +00:00
|
|
|
wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
|
2007-08-17 00:23:50 +00:00
|
|
|
|
|
|
|
/* UserManual, once the wdog is disabled, wdog cannot be re-enabled */
|
2012-03-26 21:49:06 +00:00
|
|
|
/* halted watchdog timer */
|
|
|
|
setbits_be16(&wdp->cr, WTM_WCR_HALTED);
|
2007-08-17 00:23:50 +00:00
|
|
|
|
|
|
|
puts("WATCHDOG:disabled\n");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int watchdog_init(void)
|
|
|
|
{
|
2012-03-26 21:49:06 +00:00
|
|
|
wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
|
2007-08-17 00:23:50 +00:00
|
|
|
u32 wdog_module = 0;
|
|
|
|
|
|
|
|
/* set timeout and enable watchdog */
|
2008-10-16 13:01:15 +00:00
|
|
|
wdog_module = ((CONFIG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT);
|
2007-08-17 00:23:50 +00:00
|
|
|
wdog_module |= (wdog_module / 8192);
|
2012-03-26 21:49:06 +00:00
|
|
|
out_be16(&wdp->mr, wdog_module);
|
2007-08-17 00:23:50 +00:00
|
|
|
|
2012-03-26 21:49:06 +00:00
|
|
|
out_be16(&wdp->cr, WTM_WCR_EN);
|
2007-08-17 00:23:50 +00:00
|
|
|
puts("WATCHDOG:enabled\n");
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_WATCHDOG */
|
2008-08-27 05:16:25 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_MCFFEC)
|
|
|
|
/* Default initializations for MCFFEC controllers. To override,
|
|
|
|
* create a board-specific function called:
|
2021-09-27 15:42:39 +00:00
|
|
|
* int board_eth_init(struct bd_info *bis)
|
2008-08-27 05:16:25 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
int cpu_eth_init(struct bd_info *bis)
|
2008-08-27 05:16:25 +00:00
|
|
|
{
|
|
|
|
return mcffec_initialize(bis);
|
|
|
|
}
|
|
|
|
#endif
|