lpc32xx: add Ethernet support
[oweals/u-boot.git] / arch / arm / cpu / arm926ejs / lpc32xx / cpu.c
1 /*
2  * Copyright (C) 2011 by Vladimir Zapolskiy <vz@mleia.com>
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <netdev.h>
9 #include <asm/arch/cpu.h>
10 #include <asm/arch/clk.h>
11 #include <asm/arch/wdt.h>
12 #include <asm/io.h>
13
14 static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
15 static struct wdt_regs  *wdt = (struct wdt_regs *)WDT_BASE;
16
17 void reset_cpu(ulong addr)
18 {
19         /* Enable watchdog clock */
20         setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
21
22         /* Reset pulse length is 13005 peripheral clock frames */
23         writel(13000, &wdt->pulse);
24
25         /* Force WDOG_RESET2 and RESOUT_N signal active */
26         writel(WDTIM_MCTRL_RESFRC2 | WDTIM_MCTRL_RESFRC1 | WDTIM_MCTRL_M_RES2,
27                &wdt->mctrl);
28
29         while (1)
30                 /* NOP */;
31 }
32
33 #if defined(CONFIG_ARCH_CPU_INIT)
34 int arch_cpu_init(void)
35 {
36         /*
37          * It might be necessary to flush data cache, if U-boot is loaded
38          * from kickstart bootloader, e.g. from S1L loader
39          */
40         flush_dcache_all();
41
42         return 0;
43 }
44 #else
45 #error "You have to select CONFIG_ARCH_CPU_INIT"
46 #endif
47
48 #if defined(CONFIG_DISPLAY_CPUINFO)
49 int print_cpuinfo(void)
50 {
51         printf("CPU:   NXP LPC32XX\n");
52         printf("CPU clock:        %uMHz\n", get_hclk_pll_rate() / 1000000);
53         printf("AHB bus clock:    %uMHz\n", get_hclk_clk_rate() / 1000000);
54         printf("Peripheral clock: %uMHz\n", get_periph_clk_rate() / 1000000);
55
56         return 0;
57 }
58 #endif
59
60 #ifdef CONFIG_LPC32XX_ETH
61 int cpu_eth_init(bd_t *bis)
62 {
63         lpc32xx_eth_initialize(bis);
64         return 0;
65 }
66 #endif