blob: c2586d092956fcf26c6f0fa955cd563cf51403c6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +00002/*
Sylvain Lemieuxeb48e2b2015-07-27 13:37:35 -04003 * Copyright (C) 2011-2015 by Vladimir Zapolskiy <vz@mleia.com>
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +00004 */
5
6#include <common.h>
Simon Glass63334482019-11-14 12:57:39 -07007#include <cpu_func.h>
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -06009#include <net.h>
Albert ARIBAUD \(3ADEV\)391e1632015-03-31 11:40:43 +020010#include <netdev.h>
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000011#include <asm/arch/cpu.h>
12#include <asm/arch/clk.h>
13#include <asm/arch/wdt.h>
Albert ARIBAUD \(3ADEV\)ee69a392015-03-31 11:40:51 +020014#include <asm/arch/sys_proto.h>
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000015#include <asm/io.h>
16
17static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
18static struct wdt_regs *wdt = (struct wdt_regs *)WDT_BASE;
19
Harald Seiler6f14d5f2020-12-15 16:47:52 +010020void reset_cpu(void)
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000021{
22 /* Enable watchdog clock */
23 setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
24
Harald Seiler0f576272020-12-15 16:47:51 +010025 /* Reset pulse length is 13005 peripheral clock frames */
26 writel(13000, &wdt->pulse);
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000027
Harald Seiler0f576272020-12-15 16:47:51 +010028 /* Force WDOG_RESET2 and RESOUT_N signal active */
29 writel(WDTIM_MCTRL_RESFRC2 | WDTIM_MCTRL_RESFRC1 | WDTIM_MCTRL_M_RES2,
30 &wdt->mctrl);
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000031
32 while (1)
33 /* NOP */;
34}
35
36#if defined(CONFIG_ARCH_CPU_INIT)
37int arch_cpu_init(void)
38{
39 /*
Bin Meng75574052016-02-05 19:30:11 -080040 * It might be necessary to flush data cache, if U-Boot is loaded
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000041 * from kickstart bootloader, e.g. from S1L loader
42 */
43 flush_dcache_all();
44
45 return 0;
46}
47#else
48#error "You have to select CONFIG_ARCH_CPU_INIT"
49#endif
50
51#if defined(CONFIG_DISPLAY_CPUINFO)
52int print_cpuinfo(void)
53{
54 printf("CPU: NXP LPC32XX\n");
55 printf("CPU clock: %uMHz\n", get_hclk_pll_rate() / 1000000);
56 printf("AHB bus clock: %uMHz\n", get_hclk_clk_rate() / 1000000);
57 printf("Peripheral clock: %uMHz\n", get_periph_clk_rate() / 1000000);
58
59 return 0;
60}
61#endif
Albert ARIBAUD \(3ADEV\)391e1632015-03-31 11:40:43 +020062
63#ifdef CONFIG_LPC32XX_ETH
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090064int cpu_eth_init(struct bd_info *bis)
Albert ARIBAUD \(3ADEV\)391e1632015-03-31 11:40:43 +020065{
66 lpc32xx_eth_initialize(bis);
67 return 0;
68}
69#endif