blob: 2bc3513abfa4e18c12e79e24e7ba23be5cb11678 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vladimir Zapolskiy52f69f82012-04-19 04:33:08 +00002/*
Sylvain Lemieux576007a2015-07-27 13:37:35 -04003 * Copyright (C) 2011-2015 by Vladimir Zapolskiy <vz@mleia.com>
Vladimir Zapolskiy52f69f82012-04-19 04:33:08 +00004 */
5
6#include <common.h>
Simon Glass1eb69ae2019-11-14 12:57:39 -07007#include <cpu_func.h>
Simon Glass90526e92020-05-10 11:39:56 -06008#include <net.h>
Albert ARIBAUD \(3ADEV\)ac2916a2015-03-31 11:40:43 +02009#include <netdev.h>
Vladimir Zapolskiy52f69f82012-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\)412ae532015-03-31 11:40:51 +020013#include <asm/arch/sys_proto.h>
Vladimir Zapolskiy52f69f82012-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
19void reset_cpu(ulong addr)
20{
21 /* Enable watchdog clock */
22 setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
23
Sylvain Lemieux576007a2015-07-27 13:37:35 -040024 /* To be compatible with the original U-Boot code:
25 * addr: - 0: perform hard reset.
26 * - !=0: perform a soft reset; i.e. "RESOUT_N" not asserted). */
27 if (addr == 0) {
28 /* Reset pulse length is 13005 peripheral clock frames */
29 writel(13000, &wdt->pulse);
Vladimir Zapolskiy52f69f82012-04-19 04:33:08 +000030
Sylvain Lemieux576007a2015-07-27 13:37:35 -040031 /* Force WDOG_RESET2 and RESOUT_N signal active */
32 writel(WDTIM_MCTRL_RESFRC2 | WDTIM_MCTRL_RESFRC1
33 | WDTIM_MCTRL_M_RES2, &wdt->mctrl);
34 } else {
35 /* Force match output active */
36 writel(0x01, &wdt->emr);
37
38 /* Internal reset on match output (no pulse on "RESOUT_N") */
39 writel(WDTIM_MCTRL_M_RES1, &wdt->mctrl);
40 }
Vladimir Zapolskiy52f69f82012-04-19 04:33:08 +000041
42 while (1)
43 /* NOP */;
44}
45
46#if defined(CONFIG_ARCH_CPU_INIT)
47int arch_cpu_init(void)
48{
49 /*
Bin Menga1875592016-02-05 19:30:11 -080050 * It might be necessary to flush data cache, if U-Boot is loaded
Vladimir Zapolskiy52f69f82012-04-19 04:33:08 +000051 * from kickstart bootloader, e.g. from S1L loader
52 */
53 flush_dcache_all();
54
55 return 0;
56}
57#else
58#error "You have to select CONFIG_ARCH_CPU_INIT"
59#endif
60
61#if defined(CONFIG_DISPLAY_CPUINFO)
62int print_cpuinfo(void)
63{
64 printf("CPU: NXP LPC32XX\n");
65 printf("CPU clock: %uMHz\n", get_hclk_pll_rate() / 1000000);
66 printf("AHB bus clock: %uMHz\n", get_hclk_clk_rate() / 1000000);
67 printf("Peripheral clock: %uMHz\n", get_periph_clk_rate() / 1000000);
68
69 return 0;
70}
71#endif
Albert ARIBAUD \(3ADEV\)ac2916a2015-03-31 11:40:43 +020072
73#ifdef CONFIG_LPC32XX_ETH
74int cpu_eth_init(bd_t *bis)
75{
76 lpc32xx_eth_initialize(bis);
77 return 0;
78}
79#endif