blob: 2538001bca593fcb0ffc0de862463b2bbfc27ae3 [file] [log] [blame]
Scott Woodf64c98c2015-03-20 19:28:12 -07001/*
2 * Copyright 2015 Freescale Semiconductor
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <fsl_ifc.h>
Scott Wood8e728cd2015-03-24 13:25:02 -07009#include <nand.h>
10#include <spl.h>
Scott Woodf64c98c2015-03-20 19:28:12 -070011#include <asm/arch-fsl-lsch3/soc.h>
Scott Woodae1df322015-03-20 19:28:13 -070012#include <asm/io.h>
Scott Wood8e728cd2015-03-24 13:25:02 -070013#include <asm/global_data.h>
14
15DECLARE_GLOBAL_DATA_PTR;
Scott Woodae1df322015-03-20 19:28:13 -070016
17static void erratum_a008751(void)
18{
19#ifdef CONFIG_SYS_FSL_ERRATUM_A008751
20 u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
21
22 writel(0x27672b2a, scfg + SCFG_USB3PRM1CR / 4);
23#endif
24}
Scott Woodf64c98c2015-03-20 19:28:12 -070025
Scott Wood8e728cd2015-03-24 13:25:02 -070026static void erratum_rcw_src(void)
27{
28#if defined(CONFIG_SPL)
29 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
30 u32 __iomem *dcfg_dcsr = (u32 __iomem *)DCFG_DCSR_BASE;
31 u32 val;
32
33 val = in_le32(dcfg_ccsr + DCFG_PORSR1 / 4);
34 val &= ~DCFG_PORSR1_RCW_SRC;
35 val |= DCFG_PORSR1_RCW_SRC_NOR;
36 out_le32(dcfg_dcsr + DCFG_DCSR_PORCR1 / 4, val);
37#endif
38}
39
York Sun0404a392015-03-23 10:41:35 -070040#define I2C_DEBUG_REG 0x6
41#define I2C_GLITCH_EN 0x8
42/*
43 * This erratum requires setting glitch_en bit to enable
44 * digital glitch filter to improve clock stability.
45 */
46static void erratum_a009203(void)
47{
48 u8 __iomem *ptr;
49#ifdef CONFIG_SYS_I2C
50#ifdef I2C1_BASE_ADDR
51 ptr = (u8 __iomem *)(I2C1_BASE_ADDR + I2C_DEBUG_REG);
52
53 writeb(I2C_GLITCH_EN, ptr);
54#endif
55#ifdef I2C2_BASE_ADDR
56 ptr = (u8 __iomem *)(I2C2_BASE_ADDR + I2C_DEBUG_REG);
57
58 writeb(I2C_GLITCH_EN, ptr);
59#endif
60#ifdef I2C3_BASE_ADDR
61 ptr = (u8 __iomem *)(I2C3_BASE_ADDR + I2C_DEBUG_REG);
62
63 writeb(I2C_GLITCH_EN, ptr);
64#endif
65#ifdef I2C4_BASE_ADDR
66 ptr = (u8 __iomem *)(I2C4_BASE_ADDR + I2C_DEBUG_REG);
67
68 writeb(I2C_GLITCH_EN, ptr);
69#endif
70#endif
71}
72
Scott Woodf64c98c2015-03-20 19:28:12 -070073void fsl_lsch3_early_init_f(void)
74{
Scott Woodae1df322015-03-20 19:28:13 -070075 erratum_a008751();
Scott Wood8e728cd2015-03-24 13:25:02 -070076 erratum_rcw_src();
Scott Woodf64c98c2015-03-20 19:28:12 -070077 init_early_memctl_regs(); /* tighten IFC timing */
York Sun0404a392015-03-23 10:41:35 -070078 erratum_a009203();
Scott Woodf64c98c2015-03-20 19:28:12 -070079}
Scott Wood8e728cd2015-03-24 13:25:02 -070080
81#ifdef CONFIG_SPL_BUILD
82void board_init_f(ulong dummy)
83{
84 /* Clear global data */
85 memset((void *)gd, 0, sizeof(gd_t));
86
87 arch_cpu_init();
88 board_early_init_f();
89 timer_init();
90 env_init();
91 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
92
93 serial_init();
94 console_init_f();
95 dram_init();
96
97 /* Clear the BSS. */
98 memset(__bss_start, 0, __bss_end - __bss_start);
99
100 board_init_r(NULL, 0);
101}
102
103u32 spl_boot_device(void)
104{
105 return BOOT_DEVICE_NAND;
106}
107#endif