Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 2 | /* |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 3 | * Copyright 2014-2015 Freescale Semiconductor |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Ashish Kumar | 1123406 | 2017-08-11 11:09:14 +0530 | [diff] [blame] | 7 | #include <fsl_immap.h> |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 8 | #include <fsl_ifc.h> |
Hou Zhiqiang | 4b23ca8 | 2016-08-02 19:03:27 +0800 | [diff] [blame] | 9 | #include <asm/arch/fsl_serdes.h> |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 10 | #include <asm/arch/soc.h> |
Scott Wood | ae1df32 | 2015-03-20 19:28:13 -0700 | [diff] [blame] | 11 | #include <asm/io.h> |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 12 | #include <asm/global_data.h> |
Prabhakar Kushwaha | 22cfe96 | 2015-11-05 12:00:14 +0530 | [diff] [blame] | 13 | #include <asm/arch-fsl-layerscape/config.h> |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame^] | 14 | #include <asm/arch-fsl-layerscape/fsl_icid.h> |
Hou Zhiqiang | 4b23ca8 | 2016-08-02 19:03:27 +0800 | [diff] [blame] | 15 | #ifdef CONFIG_LAYERSCAPE_NS_ACCESS |
Hou Zhiqiang | 5ac9a5c | 2016-08-02 19:03:23 +0800 | [diff] [blame] | 16 | #include <fsl_csu.h> |
Hou Zhiqiang | 4b23ca8 | 2016-08-02 19:03:27 +0800 | [diff] [blame] | 17 | #endif |
Prabhakar Kushwaha | d169ebe | 2016-06-03 18:41:31 +0530 | [diff] [blame] | 18 | #ifdef CONFIG_SYS_FSL_DDR |
Shengzhou Liu | ddf060b | 2016-04-07 16:22:21 +0800 | [diff] [blame] | 19 | #include <fsl_ddr_sdram.h> |
| 20 | #include <fsl_ddr.h> |
Prabhakar Kushwaha | d169ebe | 2016-06-03 18:41:31 +0530 | [diff] [blame] | 21 | #endif |
Aneesh Bansal | 39d5b3b | 2016-01-22 16:37:26 +0530 | [diff] [blame] | 22 | #ifdef CONFIG_CHAIN_OF_TRUST |
| 23 | #include <fsl_validate.h> |
| 24 | #endif |
Ashish Kumar | b25faa2 | 2017-08-31 16:12:53 +0530 | [diff] [blame] | 25 | #include <fsl_immap.h> |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 26 | |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 27 | bool soc_has_dp_ddr(void) |
| 28 | { |
| 29 | struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 30 | u32 svr = gur_in32(&gur->svr); |
| 31 | |
Priyanka Jain | 4a6f173 | 2016-11-17 12:29:55 +0530 | [diff] [blame] | 32 | /* LS2085A, LS2088A, LS2048A has DP_DDR */ |
| 33 | if ((SVR_SOC_VER(svr) == SVR_LS2085A) || |
| 34 | (SVR_SOC_VER(svr) == SVR_LS2088A) || |
| 35 | (SVR_SOC_VER(svr) == SVR_LS2048A)) |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 36 | return true; |
| 37 | |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | bool soc_has_aiop(void) |
| 42 | { |
| 43 | struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 44 | u32 svr = gur_in32(&gur->svr); |
| 45 | |
| 46 | /* LS2085A has AIOP */ |
Prabhakar Kushwaha | ac7f242 | 2016-06-24 13:48:13 +0530 | [diff] [blame] | 47 | if (SVR_SOC_VER(svr) == SVR_LS2085A) |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 48 | return true; |
| 49 | |
| 50 | return false; |
| 51 | } |
| 52 | |
Ran Wang | b358b7b | 2017-09-04 18:46:48 +0800 | [diff] [blame] | 53 | static inline void set_usb_txvreftune(u32 __iomem *scfg, u32 offset) |
| 54 | { |
| 55 | scfg_clrsetbits32(scfg + offset / 4, |
| 56 | 0xF << 6, |
| 57 | SCFG_USB_TXVREFTUNE << 6); |
| 58 | } |
| 59 | |
| 60 | static void erratum_a009008(void) |
| 61 | { |
| 62 | #ifdef CONFIG_SYS_FSL_ERRATUM_A009008 |
| 63 | u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE; |
Ran Wang | 9e8fabc | 2017-09-04 18:46:49 +0800 | [diff] [blame] | 64 | |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 65 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \ |
| 66 | defined(CONFIG_ARCH_LS1012A) |
Ran Wang | b358b7b | 2017-09-04 18:46:48 +0800 | [diff] [blame] | 67 | set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB1); |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 68 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) |
Ran Wang | b358b7b | 2017-09-04 18:46:48 +0800 | [diff] [blame] | 69 | set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB2); |
| 70 | set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB3); |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 71 | #endif |
Ran Wang | b358b7b | 2017-09-04 18:46:48 +0800 | [diff] [blame] | 72 | #elif defined(CONFIG_ARCH_LS2080A) |
| 73 | set_usb_txvreftune(scfg, SCFG_USB3PRM1CR); |
| 74 | #endif |
| 75 | #endif /* CONFIG_SYS_FSL_ERRATUM_A009008 */ |
| 76 | } |
| 77 | |
Ran Wang | 9e8fabc | 2017-09-04 18:46:49 +0800 | [diff] [blame] | 78 | static inline void set_usb_sqrxtune(u32 __iomem *scfg, u32 offset) |
| 79 | { |
| 80 | scfg_clrbits32(scfg + offset / 4, |
| 81 | SCFG_USB_SQRXTUNE_MASK << 23); |
| 82 | } |
| 83 | |
| 84 | static void erratum_a009798(void) |
| 85 | { |
| 86 | #ifdef CONFIG_SYS_FSL_ERRATUM_A009798 |
| 87 | u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE; |
| 88 | |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 89 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \ |
| 90 | defined(CONFIG_ARCH_LS1012A) |
Ran Wang | 9e8fabc | 2017-09-04 18:46:49 +0800 | [diff] [blame] | 91 | set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB1); |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 92 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) |
Ran Wang | 9e8fabc | 2017-09-04 18:46:49 +0800 | [diff] [blame] | 93 | set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB2); |
| 94 | set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB3); |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 95 | #endif |
Ran Wang | 9e8fabc | 2017-09-04 18:46:49 +0800 | [diff] [blame] | 96 | #elif defined(CONFIG_ARCH_LS2080A) |
| 97 | set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR); |
| 98 | #endif |
| 99 | #endif /* CONFIG_SYS_FSL_ERRATUM_A009798 */ |
| 100 | } |
| 101 | |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 102 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \ |
| 103 | defined(CONFIG_ARCH_LS1012A) |
Ran Wang | e64f747 | 2017-09-04 18:46:50 +0800 | [diff] [blame] | 104 | static inline void set_usb_pcstxswingfull(u32 __iomem *scfg, u32 offset) |
| 105 | { |
| 106 | scfg_clrsetbits32(scfg + offset / 4, |
| 107 | 0x7F << 9, |
| 108 | SCFG_USB_PCSTXSWINGFULL << 9); |
| 109 | } |
| 110 | #endif |
| 111 | |
| 112 | static void erratum_a008997(void) |
| 113 | { |
| 114 | #ifdef CONFIG_SYS_FSL_ERRATUM_A008997 |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 115 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \ |
| 116 | defined(CONFIG_ARCH_LS1012A) |
Ran Wang | e64f747 | 2017-09-04 18:46:50 +0800 | [diff] [blame] | 117 | u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE; |
| 118 | |
| 119 | set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB1); |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 120 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) |
Ran Wang | e64f747 | 2017-09-04 18:46:50 +0800 | [diff] [blame] | 121 | set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB2); |
| 122 | set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB3); |
| 123 | #endif |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 124 | #endif |
Ran Wang | e64f747 | 2017-09-04 18:46:50 +0800 | [diff] [blame] | 125 | #endif /* CONFIG_SYS_FSL_ERRATUM_A008997 */ |
| 126 | } |
| 127 | |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 128 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \ |
| 129 | defined(CONFIG_ARCH_LS1012A) |
Ran Wang | 3ba6948 | 2017-09-04 18:46:51 +0800 | [diff] [blame] | 130 | |
| 131 | #define PROGRAM_USB_PHY_RX_OVRD_IN_HI(phy) \ |
| 132 | out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_1); \ |
| 133 | out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_2); \ |
| 134 | out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_3); \ |
| 135 | out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_4) |
| 136 | |
Ran Wang | ef27707 | 2017-09-22 15:21:34 +0800 | [diff] [blame] | 137 | #elif defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LS1088A) |
Ran Wang | 3ba6948 | 2017-09-04 18:46:51 +0800 | [diff] [blame] | 138 | |
| 139 | #define PROGRAM_USB_PHY_RX_OVRD_IN_HI(phy) \ |
| 140 | out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_1); \ |
| 141 | out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_2); \ |
| 142 | out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_3); \ |
| 143 | out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_4) |
| 144 | |
| 145 | #endif |
| 146 | |
| 147 | static void erratum_a009007(void) |
| 148 | { |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 149 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \ |
| 150 | defined(CONFIG_ARCH_LS1012A) |
Ran Wang | 3ba6948 | 2017-09-04 18:46:51 +0800 | [diff] [blame] | 151 | void __iomem *usb_phy = (void __iomem *)SCFG_USB_PHY1; |
| 152 | |
| 153 | PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy); |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 154 | #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) |
Ran Wang | 3ba6948 | 2017-09-04 18:46:51 +0800 | [diff] [blame] | 155 | usb_phy = (void __iomem *)SCFG_USB_PHY2; |
| 156 | PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy); |
| 157 | |
| 158 | usb_phy = (void __iomem *)SCFG_USB_PHY3; |
| 159 | PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy); |
Ran Wang | 02dc77b | 2017-11-13 16:14:48 +0800 | [diff] [blame] | 160 | #endif |
Ran Wang | ef27707 | 2017-09-22 15:21:34 +0800 | [diff] [blame] | 161 | #elif defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LS1088A) |
Ran Wang | 3ba6948 | 2017-09-04 18:46:51 +0800 | [diff] [blame] | 162 | void __iomem *dcsr = (void __iomem *)DCSR_BASE; |
| 163 | |
| 164 | PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY1); |
| 165 | PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY2); |
| 166 | #endif /* CONFIG_SYS_FSL_ERRATUM_A009007 */ |
| 167 | } |
| 168 | |
Shengzhou Liu | a3117ee | 2016-11-11 18:11:05 +0800 | [diff] [blame] | 169 | #if defined(CONFIG_FSL_LSCH3) |
Yao Yuan | fae8805 | 2015-12-05 14:59:14 +0800 | [diff] [blame] | 170 | /* |
| 171 | * This erratum requires setting a value to eddrtqcr1 to |
| 172 | * optimal the DDR performance. |
| 173 | */ |
| 174 | static void erratum_a008336(void) |
| 175 | { |
Shengzhou Liu | a3117ee | 2016-11-11 18:11:05 +0800 | [diff] [blame] | 176 | #ifdef CONFIG_SYS_FSL_ERRATUM_A008336 |
Yao Yuan | fae8805 | 2015-12-05 14:59:14 +0800 | [diff] [blame] | 177 | u32 *eddrtqcr1; |
| 178 | |
Yao Yuan | fae8805 | 2015-12-05 14:59:14 +0800 | [diff] [blame] | 179 | #ifdef CONFIG_SYS_FSL_DCSR_DDR_ADDR |
| 180 | eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR_ADDR + 0x800; |
Shengzhou Liu | 7beb0c4 | 2016-08-26 18:30:38 +0800 | [diff] [blame] | 181 | if (fsl_ddr_get_version(0) == 0x50200) |
| 182 | out_le32(eddrtqcr1, 0x63b30002); |
Yao Yuan | fae8805 | 2015-12-05 14:59:14 +0800 | [diff] [blame] | 183 | #endif |
| 184 | #ifdef CONFIG_SYS_FSL_DCSR_DDR2_ADDR |
| 185 | eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR2_ADDR + 0x800; |
Shengzhou Liu | 7beb0c4 | 2016-08-26 18:30:38 +0800 | [diff] [blame] | 186 | if (fsl_ddr_get_version(0) == 0x50200) |
| 187 | out_le32(eddrtqcr1, 0x63b30002); |
Yao Yuan | fae8805 | 2015-12-05 14:59:14 +0800 | [diff] [blame] | 188 | #endif |
| 189 | #endif |
| 190 | } |
| 191 | |
| 192 | /* |
| 193 | * This erratum requires a register write before being Memory |
| 194 | * controller 3 being enabled. |
| 195 | */ |
| 196 | static void erratum_a008514(void) |
| 197 | { |
Shengzhou Liu | a3117ee | 2016-11-11 18:11:05 +0800 | [diff] [blame] | 198 | #ifdef CONFIG_SYS_FSL_ERRATUM_A008514 |
Yao Yuan | fae8805 | 2015-12-05 14:59:14 +0800 | [diff] [blame] | 199 | u32 *eddrtqcr1; |
| 200 | |
Yao Yuan | fae8805 | 2015-12-05 14:59:14 +0800 | [diff] [blame] | 201 | #ifdef CONFIG_SYS_FSL_DCSR_DDR3_ADDR |
| 202 | eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR3_ADDR + 0x800; |
| 203 | out_le32(eddrtqcr1, 0x63b20002); |
| 204 | #endif |
| 205 | #endif |
| 206 | } |
Prabhakar Kushwaha | 22cfe96 | 2015-11-05 12:00:14 +0530 | [diff] [blame] | 207 | #ifdef CONFIG_SYS_FSL_ERRATUM_A009635 |
| 208 | #define PLATFORM_CYCLE_ENV_VAR "a009635_interval_val" |
| 209 | |
| 210 | static unsigned long get_internval_val_mhz(void) |
| 211 | { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 212 | char *interval = env_get(PLATFORM_CYCLE_ENV_VAR); |
Prabhakar Kushwaha | 22cfe96 | 2015-11-05 12:00:14 +0530 | [diff] [blame] | 213 | /* |
| 214 | * interval is the number of platform cycles(MHz) between |
| 215 | * wake up events generated by EPU. |
| 216 | */ |
| 217 | ulong interval_mhz = get_bus_freq(0) / (1000 * 1000); |
| 218 | |
| 219 | if (interval) |
| 220 | interval_mhz = simple_strtoul(interval, NULL, 10); |
| 221 | |
| 222 | return interval_mhz; |
| 223 | } |
| 224 | |
| 225 | void erratum_a009635(void) |
| 226 | { |
| 227 | u32 val; |
| 228 | unsigned long interval_mhz = get_internval_val_mhz(); |
| 229 | |
| 230 | if (!interval_mhz) |
| 231 | return; |
| 232 | |
| 233 | val = in_le32(DCSR_CGACRE5); |
| 234 | writel(val | 0x00000200, DCSR_CGACRE5); |
| 235 | |
| 236 | val = in_le32(EPU_EPCMPR5); |
| 237 | writel(interval_mhz, EPU_EPCMPR5); |
| 238 | val = in_le32(EPU_EPCCR5); |
| 239 | writel(val | 0x82820000, EPU_EPCCR5); |
| 240 | val = in_le32(EPU_EPSMCR5); |
| 241 | writel(val | 0x002f0000, EPU_EPSMCR5); |
| 242 | val = in_le32(EPU_EPECR5); |
| 243 | writel(val | 0x20000000, EPU_EPECR5); |
| 244 | val = in_le32(EPU_EPGCR); |
| 245 | writel(val | 0x80000000, EPU_EPGCR); |
| 246 | } |
| 247 | #endif /* CONFIG_SYS_FSL_ERRATUM_A009635 */ |
| 248 | |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 249 | static void erratum_rcw_src(void) |
| 250 | { |
Santan Kumar | 9913648 | 2017-05-05 15:42:28 +0530 | [diff] [blame] | 251 | #if defined(CONFIG_SPL) && defined(CONFIG_NAND_BOOT) |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 252 | u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE; |
| 253 | u32 __iomem *dcfg_dcsr = (u32 __iomem *)DCFG_DCSR_BASE; |
| 254 | u32 val; |
| 255 | |
| 256 | val = in_le32(dcfg_ccsr + DCFG_PORSR1 / 4); |
| 257 | val &= ~DCFG_PORSR1_RCW_SRC; |
| 258 | val |= DCFG_PORSR1_RCW_SRC_NOR; |
| 259 | out_le32(dcfg_dcsr + DCFG_DCSR_PORCR1 / 4, val); |
| 260 | #endif |
| 261 | } |
| 262 | |
York Sun | 0404a39 | 2015-03-23 10:41:35 -0700 | [diff] [blame] | 263 | #define I2C_DEBUG_REG 0x6 |
| 264 | #define I2C_GLITCH_EN 0x8 |
| 265 | /* |
| 266 | * This erratum requires setting glitch_en bit to enable |
| 267 | * digital glitch filter to improve clock stability. |
| 268 | */ |
Ashish kumar | 3b52a23 | 2017-02-23 16:03:57 +0530 | [diff] [blame] | 269 | #ifdef CONFIG_SYS_FSL_ERRATUM_A009203 |
York Sun | 0404a39 | 2015-03-23 10:41:35 -0700 | [diff] [blame] | 270 | static void erratum_a009203(void) |
| 271 | { |
York Sun | 0404a39 | 2015-03-23 10:41:35 -0700 | [diff] [blame] | 272 | #ifdef CONFIG_SYS_I2C |
Sriram Dash | afa125b | 2017-09-04 15:45:02 +0530 | [diff] [blame] | 273 | u8 __iomem *ptr; |
York Sun | 0404a39 | 2015-03-23 10:41:35 -0700 | [diff] [blame] | 274 | #ifdef I2C1_BASE_ADDR |
| 275 | ptr = (u8 __iomem *)(I2C1_BASE_ADDR + I2C_DEBUG_REG); |
| 276 | |
| 277 | writeb(I2C_GLITCH_EN, ptr); |
| 278 | #endif |
| 279 | #ifdef I2C2_BASE_ADDR |
| 280 | ptr = (u8 __iomem *)(I2C2_BASE_ADDR + I2C_DEBUG_REG); |
| 281 | |
| 282 | writeb(I2C_GLITCH_EN, ptr); |
| 283 | #endif |
| 284 | #ifdef I2C3_BASE_ADDR |
| 285 | ptr = (u8 __iomem *)(I2C3_BASE_ADDR + I2C_DEBUG_REG); |
| 286 | |
| 287 | writeb(I2C_GLITCH_EN, ptr); |
| 288 | #endif |
| 289 | #ifdef I2C4_BASE_ADDR |
| 290 | ptr = (u8 __iomem *)(I2C4_BASE_ADDR + I2C_DEBUG_REG); |
| 291 | |
| 292 | writeb(I2C_GLITCH_EN, ptr); |
| 293 | #endif |
| 294 | #endif |
| 295 | } |
Ashish kumar | 3b52a23 | 2017-02-23 16:03:57 +0530 | [diff] [blame] | 296 | #endif |
Shengzhou Liu | a3117ee | 2016-11-11 18:11:05 +0800 | [diff] [blame] | 297 | |
Saksham Jain | 5d8ffe1 | 2016-03-23 16:24:40 +0530 | [diff] [blame] | 298 | void bypass_smmu(void) |
| 299 | { |
| 300 | u32 val; |
| 301 | val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK); |
| 302 | out_le32(SMMU_SCR0, val); |
| 303 | val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK); |
| 304 | out_le32(SMMU_NSCR0, val); |
| 305 | } |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 306 | void fsl_lsch3_early_init_f(void) |
| 307 | { |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 308 | erratum_rcw_src(); |
Sriram Dash | 36a4a34 | 2017-09-04 15:44:05 +0530 | [diff] [blame] | 309 | #ifdef CONFIG_FSL_IFC |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 310 | init_early_memctl_regs(); /* tighten IFC timing */ |
Sriram Dash | 36a4a34 | 2017-09-04 15:44:05 +0530 | [diff] [blame] | 311 | #endif |
Ashish kumar | 3b52a23 | 2017-02-23 16:03:57 +0530 | [diff] [blame] | 312 | #ifdef CONFIG_SYS_FSL_ERRATUM_A009203 |
York Sun | 0404a39 | 2015-03-23 10:41:35 -0700 | [diff] [blame] | 313 | erratum_a009203(); |
Ashish kumar | 3b52a23 | 2017-02-23 16:03:57 +0530 | [diff] [blame] | 314 | #endif |
Yao Yuan | fae8805 | 2015-12-05 14:59:14 +0800 | [diff] [blame] | 315 | erratum_a008514(); |
| 316 | erratum_a008336(); |
Ran Wang | b358b7b | 2017-09-04 18:46:48 +0800 | [diff] [blame] | 317 | erratum_a009008(); |
Ran Wang | 9e8fabc | 2017-09-04 18:46:49 +0800 | [diff] [blame] | 318 | erratum_a009798(); |
Ran Wang | e64f747 | 2017-09-04 18:46:50 +0800 | [diff] [blame] | 319 | erratum_a008997(); |
Ran Wang | 3ba6948 | 2017-09-04 18:46:51 +0800 | [diff] [blame] | 320 | erratum_a009007(); |
Saksham Jain | 5d8ffe1 | 2016-03-23 16:24:40 +0530 | [diff] [blame] | 321 | #ifdef CONFIG_CHAIN_OF_TRUST |
| 322 | /* In case of Secure Boot, the IBR configures the SMMU |
| 323 | * to allow only Secure transactions. |
| 324 | * SMMU must be reset in bypass mode. |
| 325 | * Set the ClientPD bit and Clear the USFCFG Bit |
| 326 | */ |
| 327 | if (fsl_check_boot_mode_secure() == 1) |
| 328 | bypass_smmu(); |
| 329 | #endif |
Scott Wood | f64c98c | 2015-03-20 19:28:12 -0700 | [diff] [blame] | 330 | } |
Mingkai Hu | e4e93ea | 2015-10-26 19:47:51 +0800 | [diff] [blame] | 331 | |
Rajesh Bhagat | 814e077 | 2018-01-17 16:13:00 +0530 | [diff] [blame] | 332 | /* Get VDD in the unit mV from voltage ID */ |
| 333 | int get_core_volt_from_fuse(void) |
| 334 | { |
| 335 | struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 336 | int vdd; |
| 337 | u32 fusesr; |
| 338 | u8 vid; |
| 339 | |
| 340 | /* get the voltage ID from fuse status register */ |
| 341 | fusesr = in_le32(&gur->dcfg_fusesr); |
| 342 | debug("%s: fusesr = 0x%x\n", __func__, fusesr); |
| 343 | vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_ALTVID_SHIFT) & |
| 344 | FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK; |
| 345 | if ((vid == 0) || (vid == FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK)) { |
| 346 | vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_VID_SHIFT) & |
| 347 | FSL_CHASSIS3_DCFG_FUSESR_VID_MASK; |
| 348 | } |
| 349 | debug("%s: VID = 0x%x\n", __func__, vid); |
| 350 | switch (vid) { |
| 351 | case 0x00: /* VID isn't supported */ |
| 352 | vdd = -EINVAL; |
| 353 | debug("%s: The VID feature is not supported\n", __func__); |
| 354 | break; |
| 355 | case 0x08: /* 0.9V silicon */ |
| 356 | vdd = 900; |
| 357 | break; |
| 358 | case 0x10: /* 1.0V silicon */ |
| 359 | vdd = 1000; |
| 360 | break; |
| 361 | default: /* Other core voltage */ |
| 362 | vdd = -EINVAL; |
| 363 | debug("%s: The VID(%x) isn't supported\n", __func__, vid); |
| 364 | break; |
| 365 | } |
| 366 | debug("%s: The required minimum volt of CORE is %dmV\n", __func__, vdd); |
| 367 | |
| 368 | return vdd; |
| 369 | } |
| 370 | |
Prabhakar Kushwaha | 1966d01 | 2016-06-03 18:41:27 +0530 | [diff] [blame] | 371 | #elif defined(CONFIG_FSL_LSCH2) |
Tang Yuantian | 57894be | 2015-12-09 15:32:18 +0800 | [diff] [blame] | 372 | |
Mingkai Hu | 8beb075 | 2015-12-07 16:58:54 +0800 | [diff] [blame] | 373 | static void erratum_a009929(void) |
| 374 | { |
| 375 | #ifdef CONFIG_SYS_FSL_ERRATUM_A009929 |
| 376 | struct ccsr_gur *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR; |
| 377 | u32 __iomem *dcsr_cop_ccp = (void *)CONFIG_SYS_DCSR_COP_CCP_ADDR; |
| 378 | u32 rstrqmr1 = gur_in32(&gur->rstrqmr1); |
| 379 | |
| 380 | rstrqmr1 |= 0x00000400; |
| 381 | gur_out32(&gur->rstrqmr1, rstrqmr1); |
| 382 | writel(0x01000000, dcsr_cop_ccp); |
| 383 | #endif |
| 384 | } |
| 385 | |
Mingkai Hu | 172081c | 2016-02-02 11:28:03 +0800 | [diff] [blame] | 386 | /* |
| 387 | * This erratum requires setting a value to eddrtqcr1 to optimal |
| 388 | * the DDR performance. The eddrtqcr1 register is in SCFG space |
| 389 | * of LS1043A and the offset is 0x157_020c. |
| 390 | */ |
| 391 | #if defined(CONFIG_SYS_FSL_ERRATUM_A009660) \ |
| 392 | && defined(CONFIG_SYS_FSL_ERRATUM_A008514) |
| 393 | #error A009660 and A008514 can not be both enabled. |
| 394 | #endif |
| 395 | |
| 396 | static void erratum_a009660(void) |
| 397 | { |
| 398 | #ifdef CONFIG_SYS_FSL_ERRATUM_A009660 |
| 399 | u32 *eddrtqcr1 = (void *)CONFIG_SYS_FSL_SCFG_ADDR + 0x20c; |
| 400 | out_be32(eddrtqcr1, 0x63b20042); |
| 401 | #endif |
| 402 | } |
| 403 | |
Shengzhou Liu | ddf060b | 2016-04-07 16:22:21 +0800 | [diff] [blame] | 404 | static void erratum_a008850_early(void) |
| 405 | { |
| 406 | #ifdef CONFIG_SYS_FSL_ERRATUM_A008850 |
| 407 | /* part 1 of 2 */ |
Ashish Kumar | 1123406 | 2017-08-11 11:09:14 +0530 | [diff] [blame] | 408 | struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR + |
| 409 | CONFIG_SYS_CCI400_OFFSET); |
Shengzhou Liu | ddf060b | 2016-04-07 16:22:21 +0800 | [diff] [blame] | 410 | struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR; |
| 411 | |
York Sun | e6b871e | 2017-05-15 08:51:59 -0700 | [diff] [blame] | 412 | /* Skip if running at lower exception level */ |
| 413 | if (current_el() < 3) |
| 414 | return; |
| 415 | |
Shengzhou Liu | ddf060b | 2016-04-07 16:22:21 +0800 | [diff] [blame] | 416 | /* disables propagation of barrier transactions to DDRC from CCI400 */ |
| 417 | out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER); |
| 418 | |
| 419 | /* disable the re-ordering in DDRC */ |
| 420 | ddr_out32(&ddr->eor, DDR_EOR_RD_REOD_DIS | DDR_EOR_WD_REOD_DIS); |
| 421 | #endif |
| 422 | } |
| 423 | |
| 424 | void erratum_a008850_post(void) |
| 425 | { |
| 426 | #ifdef CONFIG_SYS_FSL_ERRATUM_A008850 |
| 427 | /* part 2 of 2 */ |
Ashish Kumar | 1123406 | 2017-08-11 11:09:14 +0530 | [diff] [blame] | 428 | struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR + |
| 429 | CONFIG_SYS_CCI400_OFFSET); |
Shengzhou Liu | ddf060b | 2016-04-07 16:22:21 +0800 | [diff] [blame] | 430 | struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR; |
| 431 | u32 tmp; |
| 432 | |
York Sun | e6b871e | 2017-05-15 08:51:59 -0700 | [diff] [blame] | 433 | /* Skip if running at lower exception level */ |
| 434 | if (current_el() < 3) |
| 435 | return; |
| 436 | |
Shengzhou Liu | ddf060b | 2016-04-07 16:22:21 +0800 | [diff] [blame] | 437 | /* enable propagation of barrier transactions to DDRC from CCI400 */ |
| 438 | out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER); |
| 439 | |
| 440 | /* enable the re-ordering in DDRC */ |
| 441 | tmp = ddr_in32(&ddr->eor); |
| 442 | tmp &= ~(DDR_EOR_RD_REOD_DIS | DDR_EOR_WD_REOD_DIS); |
| 443 | ddr_out32(&ddr->eor, tmp); |
| 444 | #endif |
| 445 | } |
Hou Zhiqiang | 4b23ca8 | 2016-08-02 19:03:27 +0800 | [diff] [blame] | 446 | |
| 447 | #ifdef CONFIG_SYS_FSL_ERRATUM_A010315 |
| 448 | void erratum_a010315(void) |
| 449 | { |
| 450 | int i; |
| 451 | |
| 452 | for (i = PCIE1; i <= PCIE4; i++) |
| 453 | if (!is_serdes_configured(i)) { |
| 454 | debug("PCIe%d: disabled all R/W permission!\n", i); |
| 455 | set_pcie_ns_access(i, 0); |
| 456 | } |
| 457 | } |
| 458 | #endif |
Shengzhou Liu | ddf060b | 2016-04-07 16:22:21 +0800 | [diff] [blame] | 459 | |
Hou Zhiqiang | c06b30a | 2016-09-29 12:42:44 +0800 | [diff] [blame] | 460 | static void erratum_a010539(void) |
| 461 | { |
| 462 | #if defined(CONFIG_SYS_FSL_ERRATUM_A010539) && defined(CONFIG_QSPI_BOOT) |
| 463 | struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 464 | u32 porsr1; |
| 465 | |
| 466 | porsr1 = in_be32(&gur->porsr1); |
| 467 | porsr1 &= ~FSL_CHASSIS2_CCSR_PORSR1_RCW_MASK; |
| 468 | out_be32((void *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1), |
| 469 | porsr1); |
Hou Zhiqiang | 653793a | 2018-04-25 14:25:42 +0800 | [diff] [blame] | 470 | out_be32((void *)(CONFIG_SYS_FSL_SCFG_ADDR + 0x1a8), 0xffffffff); |
Hou Zhiqiang | c06b30a | 2016-09-29 12:42:44 +0800 | [diff] [blame] | 471 | #endif |
| 472 | } |
| 473 | |
Hou Zhiqiang | 4ad5999 | 2016-12-09 16:09:00 +0800 | [diff] [blame] | 474 | /* Get VDD in the unit mV from voltage ID */ |
| 475 | int get_core_volt_from_fuse(void) |
| 476 | { |
| 477 | struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 478 | int vdd; |
| 479 | u32 fusesr; |
| 480 | u8 vid; |
| 481 | |
| 482 | fusesr = in_be32(&gur->dcfg_fusesr); |
| 483 | debug("%s: fusesr = 0x%x\n", __func__, fusesr); |
| 484 | vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_ALTVID_SHIFT) & |
| 485 | FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK; |
| 486 | if ((vid == 0) || (vid == FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK)) { |
| 487 | vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_VID_SHIFT) & |
| 488 | FSL_CHASSIS2_DCFG_FUSESR_VID_MASK; |
| 489 | } |
| 490 | debug("%s: VID = 0x%x\n", __func__, vid); |
| 491 | switch (vid) { |
| 492 | case 0x00: /* VID isn't supported */ |
| 493 | vdd = -EINVAL; |
| 494 | debug("%s: The VID feature is not supported\n", __func__); |
| 495 | break; |
| 496 | case 0x08: /* 0.9V silicon */ |
| 497 | vdd = 900; |
| 498 | break; |
| 499 | case 0x10: /* 1.0V silicon */ |
| 500 | vdd = 1000; |
| 501 | break; |
| 502 | default: /* Other core voltage */ |
| 503 | vdd = -EINVAL; |
| 504 | printf("%s: The VID(%x) isn't supported\n", __func__, vid); |
| 505 | break; |
| 506 | } |
| 507 | debug("%s: The required minimum volt of CORE is %dmV\n", __func__, vdd); |
| 508 | |
| 509 | return vdd; |
| 510 | } |
| 511 | |
| 512 | __weak int board_switch_core_volt(u32 vdd) |
| 513 | { |
| 514 | return 0; |
| 515 | } |
| 516 | |
| 517 | static int setup_core_volt(u32 vdd) |
| 518 | { |
| 519 | return board_setup_core_volt(vdd); |
| 520 | } |
| 521 | |
| 522 | #ifdef CONFIG_SYS_FSL_DDR |
| 523 | static void ddr_enable_0v9_volt(bool en) |
| 524 | { |
| 525 | struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR; |
| 526 | u32 tmp; |
| 527 | |
| 528 | tmp = ddr_in32(&ddr->ddr_cdr1); |
| 529 | |
| 530 | if (en) |
| 531 | tmp |= DDR_CDR1_V0PT9_EN; |
| 532 | else |
| 533 | tmp &= ~DDR_CDR1_V0PT9_EN; |
| 534 | |
| 535 | ddr_out32(&ddr->ddr_cdr1, tmp); |
| 536 | } |
| 537 | #endif |
| 538 | |
| 539 | int setup_chip_volt(void) |
| 540 | { |
| 541 | int vdd; |
| 542 | |
| 543 | vdd = get_core_volt_from_fuse(); |
| 544 | /* Nothing to do for silicons doesn't support VID */ |
| 545 | if (vdd < 0) |
| 546 | return vdd; |
| 547 | |
| 548 | if (setup_core_volt(vdd)) |
| 549 | printf("%s: Switch core VDD to %dmV failed\n", __func__, vdd); |
| 550 | #ifdef CONFIG_SYS_HAS_SERDES |
| 551 | if (setup_serdes_volt(vdd)) |
| 552 | printf("%s: Switch SVDD to %dmV failed\n", __func__, vdd); |
| 553 | #endif |
| 554 | |
| 555 | #ifdef CONFIG_SYS_FSL_DDR |
| 556 | if (vdd == 900) |
| 557 | ddr_enable_0v9_volt(true); |
| 558 | #endif |
| 559 | |
| 560 | return 0; |
| 561 | } |
| 562 | |
Calvin Johnson | 6d6ef01 | 2018-03-08 15:30:33 +0530 | [diff] [blame] | 563 | #ifdef CONFIG_FSL_PFE |
| 564 | void init_pfe_scfg_dcfg_regs(void) |
| 565 | { |
| 566 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR; |
| 567 | u32 ecccr2; |
| 568 | |
| 569 | out_be32(&scfg->pfeasbcr, |
| 570 | in_be32(&scfg->pfeasbcr) | SCFG_PFEASBCR_AWCACHE0); |
| 571 | out_be32(&scfg->pfebsbcr, |
| 572 | in_be32(&scfg->pfebsbcr) | SCFG_PFEASBCR_AWCACHE0); |
| 573 | |
| 574 | /* CCI-400 QoS settings for PFE */ |
| 575 | out_be32(&scfg->wr_qos1, (unsigned int)(SCFG_WR_QOS1_PFE1_QOS |
| 576 | | SCFG_WR_QOS1_PFE2_QOS)); |
| 577 | out_be32(&scfg->rd_qos1, (unsigned int)(SCFG_RD_QOS1_PFE1_QOS |
| 578 | | SCFG_RD_QOS1_PFE2_QOS)); |
| 579 | |
| 580 | ecccr2 = in_be32(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_ECCCR2); |
| 581 | out_be32((void *)CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_ECCCR2, |
| 582 | ecccr2 | (unsigned int)DISABLE_PFE_ECC); |
| 583 | } |
| 584 | #endif |
| 585 | |
Mingkai Hu | e4e93ea | 2015-10-26 19:47:51 +0800 | [diff] [blame] | 586 | void fsl_lsch2_early_init_f(void) |
| 587 | { |
Ashish Kumar | 1123406 | 2017-08-11 11:09:14 +0530 | [diff] [blame] | 588 | struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR + |
| 589 | CONFIG_SYS_CCI400_OFFSET); |
Aneesh Bansal | 13d984d | 2015-12-08 13:54:27 +0530 | [diff] [blame] | 590 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR; |
Mingkai Hu | e4e93ea | 2015-10-26 19:47:51 +0800 | [diff] [blame] | 591 | |
Hou Zhiqiang | 5ac9a5c | 2016-08-02 19:03:23 +0800 | [diff] [blame] | 592 | #ifdef CONFIG_LAYERSCAPE_NS_ACCESS |
| 593 | enable_layerscape_ns_access(); |
| 594 | #endif |
| 595 | |
Mingkai Hu | e4e93ea | 2015-10-26 19:47:51 +0800 | [diff] [blame] | 596 | #ifdef CONFIG_FSL_IFC |
| 597 | init_early_memctl_regs(); /* tighten IFC timing */ |
| 598 | #endif |
| 599 | |
Qianyu Gong | 5ab2d0a | 2016-03-16 18:01:52 +0800 | [diff] [blame] | 600 | #if defined(CONFIG_FSL_QSPI) && !defined(CONFIG_QSPI_BOOT) |
Gong Qianyu | 760df89 | 2016-01-25 15:16:06 +0800 | [diff] [blame] | 601 | out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL); |
| 602 | #endif |
Aneesh Bansal | 13d984d | 2015-12-08 13:54:27 +0530 | [diff] [blame] | 603 | /* Make SEC reads and writes snoopable */ |
| 604 | setbits_be32(&scfg->snpcnfgcr, SCFG_SNPCNFGCR_SECRDSNP | |
Tang Yuantian | 2945ae0 | 2016-08-08 15:07:20 +0800 | [diff] [blame] | 605 | SCFG_SNPCNFGCR_SECWRSNP | |
| 606 | SCFG_SNPCNFGCR_SATARDSNP | |
| 607 | SCFG_SNPCNFGCR_SATAWRSNP); |
Aneesh Bansal | 13d984d | 2015-12-08 13:54:27 +0530 | [diff] [blame] | 608 | |
Mingkai Hu | e4e93ea | 2015-10-26 19:47:51 +0800 | [diff] [blame] | 609 | /* |
| 610 | * Enable snoop requests and DVM message requests for |
| 611 | * Slave insterface S4 (A53 core cluster) |
| 612 | */ |
York Sun | e6b871e | 2017-05-15 08:51:59 -0700 | [diff] [blame] | 613 | if (current_el() == 3) { |
| 614 | out_le32(&cci->slave[4].snoop_ctrl, |
| 615 | CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN); |
| 616 | } |
Mingkai Hu | 8beb075 | 2015-12-07 16:58:54 +0800 | [diff] [blame] | 617 | |
| 618 | /* Erratum */ |
Shengzhou Liu | ddf060b | 2016-04-07 16:22:21 +0800 | [diff] [blame] | 619 | erratum_a008850_early(); /* part 1 of 2 */ |
Mingkai Hu | 8beb075 | 2015-12-07 16:58:54 +0800 | [diff] [blame] | 620 | erratum_a009929(); |
Mingkai Hu | 172081c | 2016-02-02 11:28:03 +0800 | [diff] [blame] | 621 | erratum_a009660(); |
Hou Zhiqiang | c06b30a | 2016-09-29 12:42:44 +0800 | [diff] [blame] | 622 | erratum_a010539(); |
Ran Wang | b358b7b | 2017-09-04 18:46:48 +0800 | [diff] [blame] | 623 | erratum_a009008(); |
Ran Wang | 9e8fabc | 2017-09-04 18:46:49 +0800 | [diff] [blame] | 624 | erratum_a009798(); |
Ran Wang | e64f747 | 2017-09-04 18:46:50 +0800 | [diff] [blame] | 625 | erratum_a008997(); |
Ran Wang | 3ba6948 | 2017-09-04 18:46:51 +0800 | [diff] [blame] | 626 | erratum_a009007(); |
Laurentiu Tudor | 512d13e | 2018-08-09 15:19:46 +0300 | [diff] [blame^] | 627 | |
| 628 | #ifdef CONFIG_ARCH_LS1046A |
| 629 | set_icids(); |
| 630 | #endif |
Mingkai Hu | e4e93ea | 2015-10-26 19:47:51 +0800 | [diff] [blame] | 631 | } |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 632 | #endif |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 633 | |
Yuan Yao | 52ae4fd | 2016-12-01 10:13:52 +0800 | [diff] [blame] | 634 | #ifdef CONFIG_QSPI_AHB_INIT |
| 635 | /* Enable 4bytes address support and fast read */ |
| 636 | int qspi_ahb_init(void) |
| 637 | { |
| 638 | u32 *qspi_lut, lut_key, *qspi_key; |
| 639 | |
| 640 | qspi_key = (void *)SYS_FSL_QSPI_ADDR + 0x300; |
| 641 | qspi_lut = (void *)SYS_FSL_QSPI_ADDR + 0x310; |
| 642 | |
| 643 | lut_key = in_be32(qspi_key); |
| 644 | |
| 645 | if (lut_key == 0x5af05af0) { |
| 646 | /* That means the register is BE */ |
| 647 | out_be32(qspi_key, 0x5af05af0); |
| 648 | /* Unlock the lut table */ |
| 649 | out_be32(qspi_key + 1, 0x00000002); |
| 650 | out_be32(qspi_lut, 0x0820040c); |
| 651 | out_be32(qspi_lut + 1, 0x1c080c08); |
| 652 | out_be32(qspi_lut + 2, 0x00002400); |
| 653 | /* Lock the lut table */ |
| 654 | out_be32(qspi_key, 0x5af05af0); |
| 655 | out_be32(qspi_key + 1, 0x00000001); |
| 656 | } else { |
| 657 | /* That means the register is LE */ |
| 658 | out_le32(qspi_key, 0x5af05af0); |
| 659 | /* Unlock the lut table */ |
| 660 | out_le32(qspi_key + 1, 0x00000002); |
| 661 | out_le32(qspi_lut, 0x0820040c); |
| 662 | out_le32(qspi_lut + 1, 0x1c080c08); |
| 663 | out_le32(qspi_lut + 2, 0x00002400); |
| 664 | /* Lock the lut table */ |
| 665 | out_le32(qspi_key, 0x5af05af0); |
| 666 | out_le32(qspi_key + 1, 0x00000001); |
| 667 | } |
| 668 | |
| 669 | return 0; |
| 670 | } |
| 671 | #endif |
| 672 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 673 | #ifdef CONFIG_BOARD_LATE_INIT |
| 674 | int board_late_init(void) |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 675 | { |
Aneesh Bansal | 39d5b3b | 2016-01-22 16:37:26 +0530 | [diff] [blame] | 676 | #ifdef CONFIG_CHAIN_OF_TRUST |
| 677 | fsl_setenv_chain_of_trust(); |
| 678 | #endif |
Yuan Yao | 52ae4fd | 2016-12-01 10:13:52 +0800 | [diff] [blame] | 679 | #ifdef CONFIG_QSPI_AHB_INIT |
| 680 | qspi_ahb_init(); |
| 681 | #endif |
Tang Yuantian | 57894be | 2015-12-09 15:32:18 +0800 | [diff] [blame] | 682 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 683 | return 0; |
Scott Wood | 8e728cd | 2015-03-24 13:25:02 -0700 | [diff] [blame] | 684 | } |
| 685 | #endif |