blob: 80f5e7c88eb47dd3c05a5df50d312ff701eac0ec [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
Simon Glass63334482019-11-14 12:57:39 -07006#include <cpu_func.h>
Simon Glass97589732020-05-10 11:40:02 -06007#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -06008#include <net.h>
Albert ARIBAUD \(3ADEV\)391e1632015-03-31 11:40:43 +02009#include <netdev.h>
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000010#include <asm/arch/cpu.h>
11#include <asm/arch/clk.h>
12#include <asm/arch/wdt.h>
Albert ARIBAUD \(3ADEV\)ee69a392015-03-31 11:40:51 +020013#include <asm/arch/sys_proto.h>
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000014#include <asm/io.h>
15
16static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
17static struct wdt_regs *wdt = (struct wdt_regs *)WDT_BASE;
18
Harald Seiler6f14d5f2020-12-15 16:47:52 +010019void reset_cpu(void)
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000020{
21 /* Enable watchdog clock */
22 setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
23
Harald Seiler0f576272020-12-15 16:47:51 +010024 /* Reset pulse length is 13005 peripheral clock frames */
25 writel(13000, &wdt->pulse);
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000026
Harald Seiler0f576272020-12-15 16:47:51 +010027 /* Force WDOG_RESET2 and RESOUT_N signal active */
28 writel(WDTIM_MCTRL_RESFRC2 | WDTIM_MCTRL_RESFRC1 | WDTIM_MCTRL_M_RES2,
29 &wdt->mctrl);
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000030
31 while (1)
32 /* NOP */;
33}
34
35#if defined(CONFIG_ARCH_CPU_INIT)
36int arch_cpu_init(void)
37{
38 /*
Bin Meng75574052016-02-05 19:30:11 -080039 * It might be necessary to flush data cache, if U-Boot is loaded
Vladimir Zapolskiy6b20ef82012-04-19 04:33:08 +000040 * from kickstart bootloader, e.g. from S1L loader
41 */
42 flush_dcache_all();
43
44 return 0;
45}
46#else
47#error "You have to select CONFIG_ARCH_CPU_INIT"
48#endif
49
50#if defined(CONFIG_DISPLAY_CPUINFO)
51int print_cpuinfo(void)
52{
53 printf("CPU: NXP LPC32XX\n");
54 printf("CPU clock: %uMHz\n", get_hclk_pll_rate() / 1000000);
55 printf("AHB bus clock: %uMHz\n", get_hclk_clk_rate() / 1000000);
56 printf("Peripheral clock: %uMHz\n", get_periph_clk_rate() / 1000000);
57
58 return 0;
59}
60#endif