Merge branch 'master' of git://git.denx.de/u-boot-fdt
[platform/kernel/u-boot.git] / board / work-microwave / work_92105 / work_92105.c
1 /*
2  * WORK Microwave work_92105 board support
3  *
4  * (C) Copyright 2014  DENX Software Engineering GmbH
5  * Written-by: Albert ARIBAUD <albert.aribaud@3adev.fr>
6  *
7  * SPDX-License-Identifier:     GPL-2.0+
8  */
9
10 #include <common.h>
11 #include <asm/io.h>
12 #include <asm/arch/sys_proto.h>
13 #include <asm/arch/cpu.h>
14 #include <asm/arch/clk.h>
15 #include <asm/arch/emc.h>
16 #include <asm/arch/wdt.h>
17 #include <asm/gpio.h>
18 #include <spl.h>
19 #include "work_92105_display.h"
20
21 DECLARE_GLOBAL_DATA_PTR;
22
23 static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
24 static struct wdt_regs  *wdt = (struct wdt_regs *)WDT_BASE;
25
26 void reset_periph(void)
27 {
28         setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
29         writel(WDTIM_MCTRL_RESFRC1, &wdt->mctrl);
30         udelay(150);
31         writel(0, &wdt->mctrl);
32         clrbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
33 }
34
35 int board_early_init_f(void)
36 {
37         /* initialize serial port for console */
38         lpc32xx_uart_init(CONFIG_SYS_LPC32XX_UART);
39         /* enable I2C, SSP, MAC, NAND */
40         lpc32xx_i2c_init(1); /* only I2C1 has devices, I2C2 has none */
41         lpc32xx_ssp_init();
42         lpc32xx_mac_init();
43         lpc32xx_mlc_nand_init();
44         /* Display must wait until after relocation and devices init */
45         return 0;
46 }
47
48 #define GPO_19 115
49
50 int board_early_init_r(void)
51 {
52         /* Set NAND !WP to 1 through GPO_19 */
53         gpio_request(GPO_19, "NAND_nWP");
54         gpio_direction_output(GPO_19, 1);
55
56         /* initialize display */
57         work_92105_display_init();
58
59         return 0;
60 }
61
62 int board_init(void)
63 {
64         reset_periph();
65         /* adress of boot parameters */
66         gd->bd->bi_boot_params  = CONFIG_SYS_SDRAM_BASE + 0x100;
67
68         return 0;
69 }
70
71 int dram_init(void)
72 {
73         gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
74                                     CONFIG_SYS_SDRAM_SIZE);
75
76         return 0;
77 }