blob: f4eaf15970bb84bd26ff61f6bc9cb67f59f3cf4d [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Vladimir Zapolskiy3ed0fcf2012-04-19 04:33:10 +00002/*
3 * Embest/Timll DevKit3250 board support
4 *
Vladimir Zapolskiy3704e432015-07-18 01:47:10 +03005 * Copyright (C) 2011-2015 Vladimir Zapolskiy <vz@mleia.com>
Vladimir Zapolskiy3ed0fcf2012-04-19 04:33:10 +00006 */
7
8#include <common.h>
Simon Glass8e16b1e2019-12-28 10:45:05 -07009#include <init.h>
Vladimir Zapolskiy3ed0fcf2012-04-19 04:33:10 +000010#include <asm/arch/sys_proto.h>
Vladimir Zapolskiy3704e432015-07-18 01:47:10 +030011#include <asm/arch/clk.h>
Vladimir Zapolskiy3ed0fcf2012-04-19 04:33:10 +000012#include <asm/arch/cpu.h>
13#include <asm/arch/emc.h>
Vladimir Zapolskiy3704e432015-07-18 01:47:10 +030014#include <asm/arch/wdt.h>
15#include <asm/io.h>
Simon Glassdbd79542020-05-10 11:40:11 -060016#include <linux/delay.h>
Vladimir Zapolskiy3ed0fcf2012-04-19 04:33:10 +000017
18DECLARE_GLOBAL_DATA_PTR;
19
20static struct emc_regs *emc = (struct emc_regs *)EMC_BASE;
Vladimir Zapolskiy3704e432015-07-18 01:47:10 +030021static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
22static struct wdt_regs *wdt = (struct wdt_regs *)WDT_BASE;
23
24void reset_periph(void)
25{
26 /* This function resets peripherals by triggering RESOUT_N */
27 setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
28 writel(WDTIM_MCTRL_RESFRC1, &wdt->mctrl);
29 udelay(300);
30
31 writel(0, &wdt->mctrl);
32 clrbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
33
34 /* Such a long delay is needed to initialize SMSC phy */
35 udelay(10000);
36}
Vladimir Zapolskiy3ed0fcf2012-04-19 04:33:10 +000037
38int board_early_init_f(void)
39{
40 lpc32xx_uart_init(CONFIG_SYS_LPC32XX_UART);
Vladimir Zapolskiy3704e432015-07-18 01:47:10 +030041 lpc32xx_i2c_init(1);
42 lpc32xx_i2c_init(2);
43 lpc32xx_ssp_init();
44 lpc32xx_mac_init();
45
46 /*
47 * nWP may be controlled by GPO19, but unpopulated by default R23
48 * makes no sense to configure this GPIO level, nWP is always high
49 */
50 lpc32xx_slc_nand_init();
Vladimir Zapolskiy3ed0fcf2012-04-19 04:33:10 +000051
52 return 0;
53}
54
55int board_init(void)
56{
57 /* adress of boot parameters */
58 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
59
60#ifdef CONFIG_SYS_FLASH_CFI
61 /* Use 16-bit memory interface for NOR Flash */
62 emc->stat[0].config = EMC_STAT_CONFIG_PB | EMC_STAT_CONFIG_16BIT;
63
64 /* Change the NOR timings to optimum value to get maximum bandwidth */
65 emc->stat[0].waitwen = EMC_STAT_WAITWEN(1);
Vladimir Zapolskiy902d7962015-10-04 23:18:24 +010066 emc->stat[0].waitoen = EMC_STAT_WAITOEN(0);
Vladimir Zapolskiy3ed0fcf2012-04-19 04:33:10 +000067 emc->stat[0].waitrd = EMC_STAT_WAITRD(12);
68 emc->stat[0].waitpage = EMC_STAT_WAITPAGE(12);
69 emc->stat[0].waitwr = EMC_STAT_WAITWR(5);
70 emc->stat[0].waitturn = EMC_STAT_WAITTURN(2);
71#endif
72
73 return 0;
74}
75
76int dram_init(void)
77{
78 gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
79 CONFIG_SYS_SDRAM_SIZE);
80
81 return 0;
82}