Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Vladimir Zapolskiy | 6b20ef8 | 2012-04-19 04:33:08 +0000 | [diff] [blame] | 2 | /* |
Sylvain Lemieux | eb48e2b | 2015-07-27 13:37:35 -0400 | [diff] [blame] | 3 | * Copyright (C) 2011-2015 by Vladimir Zapolskiy <vz@mleia.com> |
Vladimir Zapolskiy | 6b20ef8 | 2012-04-19 04:33:08 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 6 | #include <cpu_func.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 7 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 8 | #include <net.h> |
Albert ARIBAUD \(3ADEV\) | 391e163 | 2015-03-31 11:40:43 +0200 | [diff] [blame] | 9 | #include <netdev.h> |
Vladimir Zapolskiy | 6b20ef8 | 2012-04-19 04:33:08 +0000 | [diff] [blame] | 10 | #include <asm/arch/cpu.h> |
| 11 | #include <asm/arch/clk.h> |
| 12 | #include <asm/arch/wdt.h> |
Albert ARIBAUD \(3ADEV\) | ee69a39 | 2015-03-31 11:40:51 +0200 | [diff] [blame] | 13 | #include <asm/arch/sys_proto.h> |
Vladimir Zapolskiy | 6b20ef8 | 2012-04-19 04:33:08 +0000 | [diff] [blame] | 14 | #include <asm/io.h> |
| 15 | |
| 16 | static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE; |
| 17 | static struct wdt_regs *wdt = (struct wdt_regs *)WDT_BASE; |
| 18 | |
Harald Seiler | 6f14d5f | 2020-12-15 16:47:52 +0100 | [diff] [blame] | 19 | void reset_cpu(void) |
Vladimir Zapolskiy | 6b20ef8 | 2012-04-19 04:33:08 +0000 | [diff] [blame] | 20 | { |
| 21 | /* Enable watchdog clock */ |
| 22 | setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG); |
| 23 | |
Harald Seiler | 0f57627 | 2020-12-15 16:47:51 +0100 | [diff] [blame] | 24 | /* Reset pulse length is 13005 peripheral clock frames */ |
| 25 | writel(13000, &wdt->pulse); |
Vladimir Zapolskiy | 6b20ef8 | 2012-04-19 04:33:08 +0000 | [diff] [blame] | 26 | |
Harald Seiler | 0f57627 | 2020-12-15 16:47:51 +0100 | [diff] [blame] | 27 | /* Force WDOG_RESET2 and RESOUT_N signal active */ |
| 28 | writel(WDTIM_MCTRL_RESFRC2 | WDTIM_MCTRL_RESFRC1 | WDTIM_MCTRL_M_RES2, |
| 29 | &wdt->mctrl); |
Vladimir Zapolskiy | 6b20ef8 | 2012-04-19 04:33:08 +0000 | [diff] [blame] | 30 | |
| 31 | while (1) |
| 32 | /* NOP */; |
| 33 | } |
| 34 | |
| 35 | #if defined(CONFIG_ARCH_CPU_INIT) |
| 36 | int arch_cpu_init(void) |
| 37 | { |
| 38 | /* |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 39 | * It might be necessary to flush data cache, if U-Boot is loaded |
Vladimir Zapolskiy | 6b20ef8 | 2012-04-19 04:33:08 +0000 | [diff] [blame] | 40 | * 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) |
| 51 | int 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 |