Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 1 | /* |
| 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 Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 9 | #include <nand.h> |
| 10 | #include <spl.h> |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 11 | #include <asm/arch-fsl-lsch3/soc.h> |
Scott Wood | ae1df32 | 2015-03-20 19:28:13 -0700 | [diff] [blame] | 12 | #include <asm/io.h> |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 13 | #include <asm/global_data.h> |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
Scott Wood | ae1df32 | 2015-03-20 19:28:13 -0700 | [diff] [blame] | 16 | |
| 17 | static 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 Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 25 | |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 26 | static 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 Sun | 0404a39 | 2015-03-23 10:41:35 -0700 | [diff] [blame^] | 40 | #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 | */ |
| 46 | static 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 Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 73 | void fsl_lsch3_early_init_f(void) |
| 74 | { |
Scott Wood | ae1df32 | 2015-03-20 19:28:13 -0700 | [diff] [blame] | 75 | erratum_a008751(); |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 76 | erratum_rcw_src(); |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 77 | init_early_memctl_regs(); /* tighten IFC timing */ |
York Sun | 0404a39 | 2015-03-23 10:41:35 -0700 | [diff] [blame^] | 78 | erratum_a009203(); |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 79 | } |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 80 | |
| 81 | #ifdef CONFIG_SPL_BUILD |
| 82 | void 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 | |
| 103 | u32 spl_boot_device(void) |
| 104 | { |
| 105 | return BOOT_DEVICE_NAND; |
| 106 | } |
| 107 | #endif |