Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Vladimir Zapolskiy | 3ed0fcf | 2012-04-19 04:33:10 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Embest/Timll DevKit3250 board support |
| 4 | * |
Vladimir Zapolskiy | 3704e43 | 2015-07-18 01:47:10 +0300 | [diff] [blame] | 5 | * Copyright (C) 2011-2015 Vladimir Zapolskiy <vz@mleia.com> |
Vladimir Zapolskiy | 3ed0fcf | 2012-04-19 04:33:10 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | 8e16b1e | 2019-12-28 10:45:05 -0700 | [diff] [blame] | 9 | #include <init.h> |
Vladimir Zapolskiy | 3ed0fcf | 2012-04-19 04:33:10 +0000 | [diff] [blame] | 10 | #include <asm/arch/sys_proto.h> |
Vladimir Zapolskiy | 3704e43 | 2015-07-18 01:47:10 +0300 | [diff] [blame] | 11 | #include <asm/arch/clk.h> |
Vladimir Zapolskiy | 3ed0fcf | 2012-04-19 04:33:10 +0000 | [diff] [blame] | 12 | #include <asm/arch/cpu.h> |
| 13 | #include <asm/arch/emc.h> |
Vladimir Zapolskiy | 3704e43 | 2015-07-18 01:47:10 +0300 | [diff] [blame] | 14 | #include <asm/arch/wdt.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 15 | #include <asm/global_data.h> |
Vladimir Zapolskiy | 3704e43 | 2015-07-18 01:47:10 +0300 | [diff] [blame] | 16 | #include <asm/io.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 17 | #include <linux/delay.h> |
Vladimir Zapolskiy | 3ed0fcf | 2012-04-19 04:33:10 +0000 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
| 21 | static struct emc_regs *emc = (struct emc_regs *)EMC_BASE; |
Vladimir Zapolskiy | 3704e43 | 2015-07-18 01:47:10 +0300 | [diff] [blame] | 22 | static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE; |
| 23 | static struct wdt_regs *wdt = (struct wdt_regs *)WDT_BASE; |
| 24 | |
| 25 | void reset_periph(void) |
| 26 | { |
| 27 | /* This function resets peripherals by triggering RESOUT_N */ |
| 28 | setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG); |
| 29 | writel(WDTIM_MCTRL_RESFRC1, &wdt->mctrl); |
| 30 | udelay(300); |
| 31 | |
| 32 | writel(0, &wdt->mctrl); |
| 33 | clrbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG); |
| 34 | |
| 35 | /* Such a long delay is needed to initialize SMSC phy */ |
| 36 | udelay(10000); |
| 37 | } |
Vladimir Zapolskiy | 3ed0fcf | 2012-04-19 04:33:10 +0000 | [diff] [blame] | 38 | |
| 39 | int board_early_init_f(void) |
| 40 | { |
Trevor Woerner | 0b881ac | 2021-06-10 22:37:02 -0400 | [diff] [blame] | 41 | lpc32xx_uart_init(CONFIG_CONS_INDEX); |
Vladimir Zapolskiy | 3704e43 | 2015-07-18 01:47:10 +0300 | [diff] [blame] | 42 | lpc32xx_i2c_init(1); |
| 43 | lpc32xx_i2c_init(2); |
| 44 | lpc32xx_ssp_init(); |
| 45 | lpc32xx_mac_init(); |
| 46 | |
| 47 | /* |
| 48 | * nWP may be controlled by GPO19, but unpopulated by default R23 |
| 49 | * makes no sense to configure this GPIO level, nWP is always high |
| 50 | */ |
| 51 | lpc32xx_slc_nand_init(); |
Vladimir Zapolskiy | 3ed0fcf | 2012-04-19 04:33:10 +0000 | [diff] [blame] | 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | int board_init(void) |
| 57 | { |
| 58 | /* adress of boot parameters */ |
| 59 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
| 60 | |
| 61 | #ifdef CONFIG_SYS_FLASH_CFI |
| 62 | /* Use 16-bit memory interface for NOR Flash */ |
| 63 | emc->stat[0].config = EMC_STAT_CONFIG_PB | EMC_STAT_CONFIG_16BIT; |
| 64 | |
| 65 | /* Change the NOR timings to optimum value to get maximum bandwidth */ |
| 66 | emc->stat[0].waitwen = EMC_STAT_WAITWEN(1); |
Vladimir Zapolskiy | 902d796 | 2015-10-04 23:18:24 +0100 | [diff] [blame] | 67 | emc->stat[0].waitoen = EMC_STAT_WAITOEN(0); |
Vladimir Zapolskiy | 3ed0fcf | 2012-04-19 04:33:10 +0000 | [diff] [blame] | 68 | emc->stat[0].waitrd = EMC_STAT_WAITRD(12); |
| 69 | emc->stat[0].waitpage = EMC_STAT_WAITPAGE(12); |
| 70 | emc->stat[0].waitwr = EMC_STAT_WAITWR(5); |
| 71 | emc->stat[0].waitturn = EMC_STAT_WAITTURN(2); |
| 72 | #endif |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | int dram_init(void) |
| 78 | { |
| 79 | gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, |
| 80 | CONFIG_SYS_SDRAM_SIZE); |
| 81 | |
| 82 | return 0; |
| 83 | } |