Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 1 | /* |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame^] | 2 | * Copyright 2014-2015 Freescale Semiconductor |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <fsl_ifc.h> |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame^] | 9 | #include <asm/arch/soc.h> |
Scott Wood | ae1df32 | 2015-03-20 19:28:13 -0700 | [diff] [blame] | 10 | #include <asm/io.h> |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 11 | #include <asm/global_data.h> |
| 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
Scott Wood | ae1df32 | 2015-03-20 19:28:13 -0700 | [diff] [blame] | 14 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame^] | 15 | #ifdef CONFIG_LS2085A |
Scott Wood | ae1df32 | 2015-03-20 19:28:13 -0700 | [diff] [blame] | 16 | static void erratum_a008751(void) |
| 17 | { |
| 18 | #ifdef CONFIG_SYS_FSL_ERRATUM_A008751 |
| 19 | u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE; |
| 20 | |
| 21 | writel(0x27672b2a, scfg + SCFG_USB3PRM1CR / 4); |
| 22 | #endif |
| 23 | } |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 24 | |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 25 | static void erratum_rcw_src(void) |
| 26 | { |
| 27 | #if defined(CONFIG_SPL) |
| 28 | u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE; |
| 29 | u32 __iomem *dcfg_dcsr = (u32 __iomem *)DCFG_DCSR_BASE; |
| 30 | u32 val; |
| 31 | |
| 32 | val = in_le32(dcfg_ccsr + DCFG_PORSR1 / 4); |
| 33 | val &= ~DCFG_PORSR1_RCW_SRC; |
| 34 | val |= DCFG_PORSR1_RCW_SRC_NOR; |
| 35 | out_le32(dcfg_dcsr + DCFG_DCSR_PORCR1 / 4, val); |
| 36 | #endif |
| 37 | } |
| 38 | |
York Sun | 0404a39 | 2015-03-23 10:41:35 -0700 | [diff] [blame] | 39 | #define I2C_DEBUG_REG 0x6 |
| 40 | #define I2C_GLITCH_EN 0x8 |
| 41 | /* |
| 42 | * This erratum requires setting glitch_en bit to enable |
| 43 | * digital glitch filter to improve clock stability. |
| 44 | */ |
| 45 | static void erratum_a009203(void) |
| 46 | { |
| 47 | u8 __iomem *ptr; |
| 48 | #ifdef CONFIG_SYS_I2C |
| 49 | #ifdef I2C1_BASE_ADDR |
| 50 | ptr = (u8 __iomem *)(I2C1_BASE_ADDR + I2C_DEBUG_REG); |
| 51 | |
| 52 | writeb(I2C_GLITCH_EN, ptr); |
| 53 | #endif |
| 54 | #ifdef I2C2_BASE_ADDR |
| 55 | ptr = (u8 __iomem *)(I2C2_BASE_ADDR + I2C_DEBUG_REG); |
| 56 | |
| 57 | writeb(I2C_GLITCH_EN, ptr); |
| 58 | #endif |
| 59 | #ifdef I2C3_BASE_ADDR |
| 60 | ptr = (u8 __iomem *)(I2C3_BASE_ADDR + I2C_DEBUG_REG); |
| 61 | |
| 62 | writeb(I2C_GLITCH_EN, ptr); |
| 63 | #endif |
| 64 | #ifdef I2C4_BASE_ADDR |
| 65 | ptr = (u8 __iomem *)(I2C4_BASE_ADDR + I2C_DEBUG_REG); |
| 66 | |
| 67 | writeb(I2C_GLITCH_EN, ptr); |
| 68 | #endif |
| 69 | #endif |
| 70 | } |
| 71 | |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 72 | void fsl_lsch3_early_init_f(void) |
| 73 | { |
Scott Wood | ae1df32 | 2015-03-20 19:28:13 -0700 | [diff] [blame] | 74 | erratum_a008751(); |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 75 | erratum_rcw_src(); |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 76 | init_early_memctl_regs(); /* tighten IFC timing */ |
York Sun | 0404a39 | 2015-03-23 10:41:35 -0700 | [diff] [blame] | 77 | erratum_a009203(); |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 78 | } |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame^] | 79 | #endif |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 80 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame^] | 81 | #ifdef CONFIG_BOARD_LATE_INIT |
| 82 | int board_late_init(void) |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 83 | { |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame^] | 84 | return 0; |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 85 | } |
| 86 | #endif |