blob: 3fd34e3a435d232ea2248219a75f02b467be6eda [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Scott Woodf64c98c2015-03-20 19:28:12 -07002/*
Mingkai Hu0e58b512015-10-26 19:47:50 +08003 * Copyright 2014-2015 Freescale Semiconductor
Pankit Gargd6bd6782019-05-30 12:04:15 +00004 * Copyright 2019 NXP
Scott Woodf64c98c2015-03-20 19:28:12 -07005 */
6
7#include <common.h>
Simon Glass5e6201b2019-08-01 09:46:51 -06008#include <env.h>
Ashish Kumar11234062017-08-11 11:09:14 +05309#include <fsl_immap.h>
Scott Woodf64c98c2015-03-20 19:28:12 -070010#include <fsl_ifc.h>
Hou Zhiqiang4b23ca82016-08-02 19:03:27 +080011#include <asm/arch/fsl_serdes.h>
Mingkai Hu0e58b512015-10-26 19:47:50 +080012#include <asm/arch/soc.h>
Scott Woodae1df322015-03-20 19:28:13 -070013#include <asm/io.h>
Scott Wood8e728cd2015-03-24 13:25:02 -070014#include <asm/global_data.h>
Prabhakar Kushwaha22cfe962015-11-05 12:00:14 +053015#include <asm/arch-fsl-layerscape/config.h>
Ran Wang4e7cdcf2018-08-10 15:00:00 +080016#include <asm/arch-fsl-layerscape/ns_access.h>
Laurentiu Tudor512d13e2018-08-09 15:19:46 +030017#include <asm/arch-fsl-layerscape/fsl_icid.h>
Hou Zhiqiang4b23ca82016-08-02 19:03:27 +080018#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
Hou Zhiqiang5ac9a5c2016-08-02 19:03:23 +080019#include <fsl_csu.h>
Hou Zhiqiang4b23ca82016-08-02 19:03:27 +080020#endif
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053021#ifdef CONFIG_SYS_FSL_DDR
Shengzhou Liuddf060b2016-04-07 16:22:21 +080022#include <fsl_ddr_sdram.h>
23#include <fsl_ddr.h>
Prabhakar Kushwahad169ebe2016-06-03 18:41:31 +053024#endif
Aneesh Bansal39d5b3b2016-01-22 16:37:26 +053025#ifdef CONFIG_CHAIN_OF_TRUST
26#include <fsl_validate.h>
27#endif
Ashish Kumarb25faa22017-08-31 16:12:53 +053028#include <fsl_immap.h>
Pankit Gargbdbf84f2018-11-05 18:01:52 +000029#ifdef CONFIG_TFABOOT
Simon Glass9d1f6192019-08-02 09:44:25 -060030#include <env_internal.h>
Pankit Gargbdbf84f2018-11-05 18:01:52 +000031DECLARE_GLOBAL_DATA_PTR;
32#endif
Scott Wood8e728cd2015-03-24 13:25:02 -070033
York Suncbe8e1c2016-04-04 11:41:26 -070034bool soc_has_dp_ddr(void)
35{
36 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
37 u32 svr = gur_in32(&gur->svr);
38
Priyanka Jain4a6f1732016-11-17 12:29:55 +053039 /* LS2085A, LS2088A, LS2048A has DP_DDR */
40 if ((SVR_SOC_VER(svr) == SVR_LS2085A) ||
41 (SVR_SOC_VER(svr) == SVR_LS2088A) ||
42 (SVR_SOC_VER(svr) == SVR_LS2048A))
York Suncbe8e1c2016-04-04 11:41:26 -070043 return true;
44
45 return false;
46}
47
48bool soc_has_aiop(void)
49{
50 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
51 u32 svr = gur_in32(&gur->svr);
52
53 /* LS2085A has AIOP */
Prabhakar Kushwahaac7f2422016-06-24 13:48:13 +053054 if (SVR_SOC_VER(svr) == SVR_LS2085A)
York Suncbe8e1c2016-04-04 11:41:26 -070055 return true;
56
57 return false;
58}
59
Ran Wangb358b7b2017-09-04 18:46:48 +080060static inline void set_usb_txvreftune(u32 __iomem *scfg, u32 offset)
61{
62 scfg_clrsetbits32(scfg + offset / 4,
63 0xF << 6,
64 SCFG_USB_TXVREFTUNE << 6);
65}
66
67static void erratum_a009008(void)
68{
69#ifdef CONFIG_SYS_FSL_ERRATUM_A009008
70 u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
Ran Wang9e8fabc2017-09-04 18:46:49 +080071
Ran Wang02dc77b2017-11-13 16:14:48 +080072#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
73 defined(CONFIG_ARCH_LS1012A)
Ran Wangb358b7b2017-09-04 18:46:48 +080074 set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB1);
Ran Wang02dc77b2017-11-13 16:14:48 +080075#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
Ran Wangb358b7b2017-09-04 18:46:48 +080076 set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB2);
77 set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB3);
Ran Wang02dc77b2017-11-13 16:14:48 +080078#endif
Ran Wangb358b7b2017-09-04 18:46:48 +080079#elif defined(CONFIG_ARCH_LS2080A)
80 set_usb_txvreftune(scfg, SCFG_USB3PRM1CR);
81#endif
82#endif /* CONFIG_SYS_FSL_ERRATUM_A009008 */
83}
84
Ran Wang9e8fabc2017-09-04 18:46:49 +080085static inline void set_usb_sqrxtune(u32 __iomem *scfg, u32 offset)
86{
87 scfg_clrbits32(scfg + offset / 4,
88 SCFG_USB_SQRXTUNE_MASK << 23);
89}
90
91static void erratum_a009798(void)
92{
93#ifdef CONFIG_SYS_FSL_ERRATUM_A009798
94 u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
95
Ran Wang02dc77b2017-11-13 16:14:48 +080096#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
97 defined(CONFIG_ARCH_LS1012A)
Ran Wang9e8fabc2017-09-04 18:46:49 +080098 set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB1);
Ran Wang02dc77b2017-11-13 16:14:48 +080099#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
Ran Wang9e8fabc2017-09-04 18:46:49 +0800100 set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB2);
101 set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB3);
Ran Wang02dc77b2017-11-13 16:14:48 +0800102#endif
Ran Wang9e8fabc2017-09-04 18:46:49 +0800103#elif defined(CONFIG_ARCH_LS2080A)
104 set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR);
105#endif
106#endif /* CONFIG_SYS_FSL_ERRATUM_A009798 */
107}
108
Ran Wang02dc77b2017-11-13 16:14:48 +0800109#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
110 defined(CONFIG_ARCH_LS1012A)
Ran Wange64f7472017-09-04 18:46:50 +0800111static inline void set_usb_pcstxswingfull(u32 __iomem *scfg, u32 offset)
112{
113 scfg_clrsetbits32(scfg + offset / 4,
114 0x7F << 9,
115 SCFG_USB_PCSTXSWINGFULL << 9);
116}
117#endif
118
119static void erratum_a008997(void)
120{
121#ifdef CONFIG_SYS_FSL_ERRATUM_A008997
Ran Wang02dc77b2017-11-13 16:14:48 +0800122#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
123 defined(CONFIG_ARCH_LS1012A)
Ran Wange64f7472017-09-04 18:46:50 +0800124 u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
125
126 set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB1);
Ran Wang02dc77b2017-11-13 16:14:48 +0800127#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
Ran Wange64f7472017-09-04 18:46:50 +0800128 set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB2);
129 set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB3);
130#endif
Ran Wange118acb2019-05-14 17:34:56 +0800131#elif defined(CONFIG_ARCH_LS1028A)
132 clrsetbits_le32(DCSR_BASE + DCSR_USB_IOCR1,
133 0x7F << 11,
134 DCSR_USB_PCSTXSWINGFULL << 11);
Ran Wang02dc77b2017-11-13 16:14:48 +0800135#endif
Ran Wange64f7472017-09-04 18:46:50 +0800136#endif /* CONFIG_SYS_FSL_ERRATUM_A008997 */
137}
138
Ran Wang02dc77b2017-11-13 16:14:48 +0800139#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
140 defined(CONFIG_ARCH_LS1012A)
Ran Wang3ba69482017-09-04 18:46:51 +0800141
142#define PROGRAM_USB_PHY_RX_OVRD_IN_HI(phy) \
143 out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_1); \
144 out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_2); \
145 out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_3); \
146 out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_4)
147
Yinbo Zhu5c3767e2019-05-14 17:34:57 +0800148#elif defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LS1088A) || \
149 defined(CONFIG_ARCH_LS1028A)
Ran Wang3ba69482017-09-04 18:46:51 +0800150
151#define PROGRAM_USB_PHY_RX_OVRD_IN_HI(phy) \
152 out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_1); \
153 out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_2); \
154 out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_3); \
155 out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_4)
156
157#endif
158
159static void erratum_a009007(void)
160{
Ran Wang02dc77b2017-11-13 16:14:48 +0800161#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
162 defined(CONFIG_ARCH_LS1012A)
Ran Wang3ba69482017-09-04 18:46:51 +0800163 void __iomem *usb_phy = (void __iomem *)SCFG_USB_PHY1;
164
165 PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy);
Ran Wang02dc77b2017-11-13 16:14:48 +0800166#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
Ran Wang3ba69482017-09-04 18:46:51 +0800167 usb_phy = (void __iomem *)SCFG_USB_PHY2;
168 PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy);
169
170 usb_phy = (void __iomem *)SCFG_USB_PHY3;
171 PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy);
Ran Wang02dc77b2017-11-13 16:14:48 +0800172#endif
Yinbo Zhu5c3767e2019-05-14 17:34:57 +0800173#elif defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LS1088A) || \
174 defined(CONFIG_ARCH_LS1028A)
Ran Wang3ba69482017-09-04 18:46:51 +0800175 void __iomem *dcsr = (void __iomem *)DCSR_BASE;
176
177 PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY1);
178 PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY2);
179#endif /* CONFIG_SYS_FSL_ERRATUM_A009007 */
180}
181
Shengzhou Liua3117ee2016-11-11 18:11:05 +0800182#if defined(CONFIG_FSL_LSCH3)
Yao Yuanfae88052015-12-05 14:59:14 +0800183/*
184 * This erratum requires setting a value to eddrtqcr1 to
185 * optimal the DDR performance.
186 */
187static void erratum_a008336(void)
188{
Shengzhou Liua3117ee2016-11-11 18:11:05 +0800189#ifdef CONFIG_SYS_FSL_ERRATUM_A008336
Yao Yuanfae88052015-12-05 14:59:14 +0800190 u32 *eddrtqcr1;
191
Yao Yuanfae88052015-12-05 14:59:14 +0800192#ifdef CONFIG_SYS_FSL_DCSR_DDR_ADDR
193 eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR_ADDR + 0x800;
Shengzhou Liu7beb0c42016-08-26 18:30:38 +0800194 if (fsl_ddr_get_version(0) == 0x50200)
195 out_le32(eddrtqcr1, 0x63b30002);
Yao Yuanfae88052015-12-05 14:59:14 +0800196#endif
197#ifdef CONFIG_SYS_FSL_DCSR_DDR2_ADDR
198 eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR2_ADDR + 0x800;
Shengzhou Liu7beb0c42016-08-26 18:30:38 +0800199 if (fsl_ddr_get_version(0) == 0x50200)
200 out_le32(eddrtqcr1, 0x63b30002);
Yao Yuanfae88052015-12-05 14:59:14 +0800201#endif
202#endif
203}
204
205/*
206 * This erratum requires a register write before being Memory
207 * controller 3 being enabled.
208 */
209static void erratum_a008514(void)
210{
Shengzhou Liua3117ee2016-11-11 18:11:05 +0800211#ifdef CONFIG_SYS_FSL_ERRATUM_A008514
Yao Yuanfae88052015-12-05 14:59:14 +0800212 u32 *eddrtqcr1;
213
Yao Yuanfae88052015-12-05 14:59:14 +0800214#ifdef CONFIG_SYS_FSL_DCSR_DDR3_ADDR
215 eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR3_ADDR + 0x800;
216 out_le32(eddrtqcr1, 0x63b20002);
217#endif
218#endif
219}
Prabhakar Kushwaha22cfe962015-11-05 12:00:14 +0530220#ifdef CONFIG_SYS_FSL_ERRATUM_A009635
221#define PLATFORM_CYCLE_ENV_VAR "a009635_interval_val"
222
223static unsigned long get_internval_val_mhz(void)
224{
Simon Glass64b723f2017-08-03 12:22:12 -0600225 char *interval = env_get(PLATFORM_CYCLE_ENV_VAR);
Prabhakar Kushwaha22cfe962015-11-05 12:00:14 +0530226 /*
227 * interval is the number of platform cycles(MHz) between
228 * wake up events generated by EPU.
229 */
230 ulong interval_mhz = get_bus_freq(0) / (1000 * 1000);
231
232 if (interval)
233 interval_mhz = simple_strtoul(interval, NULL, 10);
234
235 return interval_mhz;
236}
237
238void erratum_a009635(void)
239{
240 u32 val;
241 unsigned long interval_mhz = get_internval_val_mhz();
242
243 if (!interval_mhz)
244 return;
245
246 val = in_le32(DCSR_CGACRE5);
247 writel(val | 0x00000200, DCSR_CGACRE5);
248
249 val = in_le32(EPU_EPCMPR5);
250 writel(interval_mhz, EPU_EPCMPR5);
251 val = in_le32(EPU_EPCCR5);
252 writel(val | 0x82820000, EPU_EPCCR5);
253 val = in_le32(EPU_EPSMCR5);
254 writel(val | 0x002f0000, EPU_EPSMCR5);
255 val = in_le32(EPU_EPECR5);
256 writel(val | 0x20000000, EPU_EPECR5);
257 val = in_le32(EPU_EPGCR);
258 writel(val | 0x80000000, EPU_EPGCR);
259}
260#endif /* CONFIG_SYS_FSL_ERRATUM_A009635 */
261
Scott Wood8e728cd2015-03-24 13:25:02 -0700262static void erratum_rcw_src(void)
263{
Santan Kumar99136482017-05-05 15:42:28 +0530264#if defined(CONFIG_SPL) && defined(CONFIG_NAND_BOOT)
Scott Wood8e728cd2015-03-24 13:25:02 -0700265 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
266 u32 __iomem *dcfg_dcsr = (u32 __iomem *)DCFG_DCSR_BASE;
267 u32 val;
268
269 val = in_le32(dcfg_ccsr + DCFG_PORSR1 / 4);
270 val &= ~DCFG_PORSR1_RCW_SRC;
271 val |= DCFG_PORSR1_RCW_SRC_NOR;
272 out_le32(dcfg_dcsr + DCFG_DCSR_PORCR1 / 4, val);
273#endif
274}
275
York Sun0404a392015-03-23 10:41:35 -0700276#define I2C_DEBUG_REG 0x6
277#define I2C_GLITCH_EN 0x8
278/*
279 * This erratum requires setting glitch_en bit to enable
280 * digital glitch filter to improve clock stability.
281 */
Ashish kumar3b52a232017-02-23 16:03:57 +0530282#ifdef CONFIG_SYS_FSL_ERRATUM_A009203
York Sun0404a392015-03-23 10:41:35 -0700283static void erratum_a009203(void)
284{
York Sun0404a392015-03-23 10:41:35 -0700285#ifdef CONFIG_SYS_I2C
Sriram Dashafa125b2017-09-04 15:45:02 +0530286 u8 __iomem *ptr;
York Sun0404a392015-03-23 10:41:35 -0700287#ifdef I2C1_BASE_ADDR
288 ptr = (u8 __iomem *)(I2C1_BASE_ADDR + I2C_DEBUG_REG);
289
290 writeb(I2C_GLITCH_EN, ptr);
291#endif
292#ifdef I2C2_BASE_ADDR
293 ptr = (u8 __iomem *)(I2C2_BASE_ADDR + I2C_DEBUG_REG);
294
295 writeb(I2C_GLITCH_EN, ptr);
296#endif
297#ifdef I2C3_BASE_ADDR
298 ptr = (u8 __iomem *)(I2C3_BASE_ADDR + I2C_DEBUG_REG);
299
300 writeb(I2C_GLITCH_EN, ptr);
301#endif
302#ifdef I2C4_BASE_ADDR
303 ptr = (u8 __iomem *)(I2C4_BASE_ADDR + I2C_DEBUG_REG);
304
305 writeb(I2C_GLITCH_EN, ptr);
306#endif
307#endif
308}
Ashish kumar3b52a232017-02-23 16:03:57 +0530309#endif
Shengzhou Liua3117ee2016-11-11 18:11:05 +0800310
Saksham Jain5d8ffe12016-03-23 16:24:40 +0530311void bypass_smmu(void)
312{
313 u32 val;
314 val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
315 out_le32(SMMU_SCR0, val);
316 val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
317 out_le32(SMMU_NSCR0, val);
318}
Scott Woodf64c98c2015-03-20 19:28:12 -0700319void fsl_lsch3_early_init_f(void)
320{
Scott Wood8e728cd2015-03-24 13:25:02 -0700321 erratum_rcw_src();
Sriram Dash36a4a342017-09-04 15:44:05 +0530322#ifdef CONFIG_FSL_IFC
Scott Woodf64c98c2015-03-20 19:28:12 -0700323 init_early_memctl_regs(); /* tighten IFC timing */
Sriram Dash36a4a342017-09-04 15:44:05 +0530324#endif
Ashish kumar3b52a232017-02-23 16:03:57 +0530325#ifdef CONFIG_SYS_FSL_ERRATUM_A009203
York Sun0404a392015-03-23 10:41:35 -0700326 erratum_a009203();
Ashish kumar3b52a232017-02-23 16:03:57 +0530327#endif
Yao Yuanfae88052015-12-05 14:59:14 +0800328 erratum_a008514();
329 erratum_a008336();
Ran Wangb358b7b2017-09-04 18:46:48 +0800330 erratum_a009008();
Ran Wang9e8fabc2017-09-04 18:46:49 +0800331 erratum_a009798();
Ran Wange64f7472017-09-04 18:46:50 +0800332 erratum_a008997();
Ran Wang3ba69482017-09-04 18:46:51 +0800333 erratum_a009007();
Saksham Jain5d8ffe12016-03-23 16:24:40 +0530334#ifdef CONFIG_CHAIN_OF_TRUST
335 /* In case of Secure Boot, the IBR configures the SMMU
336 * to allow only Secure transactions.
337 * SMMU must be reset in bypass mode.
338 * Set the ClientPD bit and Clear the USFCFG Bit
339 */
340 if (fsl_check_boot_mode_secure() == 1)
341 bypass_smmu();
342#endif
Laurentiu Tudor7690ea72019-07-30 17:29:58 +0300343
Laurentiu Tudor01dc5472019-07-30 17:29:59 +0300344#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS1028A)
Laurentiu Tudor7690ea72019-07-30 17:29:58 +0300345 set_icids();
346#endif
Scott Woodf64c98c2015-03-20 19:28:12 -0700347}
Mingkai Hue4e93ea2015-10-26 19:47:51 +0800348
Rajesh Bhagat814e0772018-01-17 16:13:00 +0530349/* Get VDD in the unit mV from voltage ID */
350int get_core_volt_from_fuse(void)
351{
352 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
353 int vdd;
354 u32 fusesr;
355 u8 vid;
356
357 /* get the voltage ID from fuse status register */
358 fusesr = in_le32(&gur->dcfg_fusesr);
359 debug("%s: fusesr = 0x%x\n", __func__, fusesr);
360 vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_ALTVID_SHIFT) &
361 FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK;
362 if ((vid == 0) || (vid == FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK)) {
363 vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_VID_SHIFT) &
364 FSL_CHASSIS3_DCFG_FUSESR_VID_MASK;
365 }
366 debug("%s: VID = 0x%x\n", __func__, vid);
367 switch (vid) {
368 case 0x00: /* VID isn't supported */
369 vdd = -EINVAL;
370 debug("%s: The VID feature is not supported\n", __func__);
371 break;
372 case 0x08: /* 0.9V silicon */
373 vdd = 900;
374 break;
375 case 0x10: /* 1.0V silicon */
376 vdd = 1000;
377 break;
378 default: /* Other core voltage */
379 vdd = -EINVAL;
380 debug("%s: The VID(%x) isn't supported\n", __func__, vid);
381 break;
382 }
383 debug("%s: The required minimum volt of CORE is %dmV\n", __func__, vdd);
384
385 return vdd;
386}
387
Prabhakar Kushwaha1966d012016-06-03 18:41:27 +0530388#elif defined(CONFIG_FSL_LSCH2)
Tang Yuantian57894be2015-12-09 15:32:18 +0800389
Mingkai Hu8beb0752015-12-07 16:58:54 +0800390static void erratum_a009929(void)
391{
392#ifdef CONFIG_SYS_FSL_ERRATUM_A009929
393 struct ccsr_gur *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
394 u32 __iomem *dcsr_cop_ccp = (void *)CONFIG_SYS_DCSR_COP_CCP_ADDR;
395 u32 rstrqmr1 = gur_in32(&gur->rstrqmr1);
396
397 rstrqmr1 |= 0x00000400;
398 gur_out32(&gur->rstrqmr1, rstrqmr1);
399 writel(0x01000000, dcsr_cop_ccp);
400#endif
401}
402
Mingkai Hu172081c2016-02-02 11:28:03 +0800403/*
404 * This erratum requires setting a value to eddrtqcr1 to optimal
405 * the DDR performance. The eddrtqcr1 register is in SCFG space
406 * of LS1043A and the offset is 0x157_020c.
407 */
408#if defined(CONFIG_SYS_FSL_ERRATUM_A009660) \
409 && defined(CONFIG_SYS_FSL_ERRATUM_A008514)
410#error A009660 and A008514 can not be both enabled.
411#endif
412
413static void erratum_a009660(void)
414{
415#ifdef CONFIG_SYS_FSL_ERRATUM_A009660
416 u32 *eddrtqcr1 = (void *)CONFIG_SYS_FSL_SCFG_ADDR + 0x20c;
417 out_be32(eddrtqcr1, 0x63b20042);
418#endif
419}
420
Shengzhou Liuddf060b2016-04-07 16:22:21 +0800421static void erratum_a008850_early(void)
422{
423#ifdef CONFIG_SYS_FSL_ERRATUM_A008850
424 /* part 1 of 2 */
Ashish Kumar11234062017-08-11 11:09:14 +0530425 struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR +
426 CONFIG_SYS_CCI400_OFFSET);
Shengzhou Liuddf060b2016-04-07 16:22:21 +0800427 struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
428
York Sune6b871e2017-05-15 08:51:59 -0700429 /* Skip if running at lower exception level */
430 if (current_el() < 3)
431 return;
432
Shengzhou Liuddf060b2016-04-07 16:22:21 +0800433 /* disables propagation of barrier transactions to DDRC from CCI400 */
434 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
435
436 /* disable the re-ordering in DDRC */
437 ddr_out32(&ddr->eor, DDR_EOR_RD_REOD_DIS | DDR_EOR_WD_REOD_DIS);
438#endif
439}
440
441void erratum_a008850_post(void)
442{
443#ifdef CONFIG_SYS_FSL_ERRATUM_A008850
444 /* part 2 of 2 */
Ashish Kumar11234062017-08-11 11:09:14 +0530445 struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR +
446 CONFIG_SYS_CCI400_OFFSET);
Shengzhou Liuddf060b2016-04-07 16:22:21 +0800447 struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
448 u32 tmp;
449
York Sune6b871e2017-05-15 08:51:59 -0700450 /* Skip if running at lower exception level */
451 if (current_el() < 3)
452 return;
453
Shengzhou Liuddf060b2016-04-07 16:22:21 +0800454 /* enable propagation of barrier transactions to DDRC from CCI400 */
455 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
456
457 /* enable the re-ordering in DDRC */
458 tmp = ddr_in32(&ddr->eor);
459 tmp &= ~(DDR_EOR_RD_REOD_DIS | DDR_EOR_WD_REOD_DIS);
460 ddr_out32(&ddr->eor, tmp);
461#endif
462}
Hou Zhiqiang4b23ca82016-08-02 19:03:27 +0800463
464#ifdef CONFIG_SYS_FSL_ERRATUM_A010315
465void erratum_a010315(void)
466{
467 int i;
468
469 for (i = PCIE1; i <= PCIE4; i++)
470 if (!is_serdes_configured(i)) {
471 debug("PCIe%d: disabled all R/W permission!\n", i);
472 set_pcie_ns_access(i, 0);
473 }
474}
475#endif
Shengzhou Liuddf060b2016-04-07 16:22:21 +0800476
Hou Zhiqiangc06b30a2016-09-29 12:42:44 +0800477static void erratum_a010539(void)
478{
479#if defined(CONFIG_SYS_FSL_ERRATUM_A010539) && defined(CONFIG_QSPI_BOOT)
480 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
481 u32 porsr1;
482
483 porsr1 = in_be32(&gur->porsr1);
484 porsr1 &= ~FSL_CHASSIS2_CCSR_PORSR1_RCW_MASK;
485 out_be32((void *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1),
486 porsr1);
Hou Zhiqiang653793a2018-04-25 14:25:42 +0800487 out_be32((void *)(CONFIG_SYS_FSL_SCFG_ADDR + 0x1a8), 0xffffffff);
Hou Zhiqiangc06b30a2016-09-29 12:42:44 +0800488#endif
489}
490
Hou Zhiqiang4ad59992016-12-09 16:09:00 +0800491/* Get VDD in the unit mV from voltage ID */
492int get_core_volt_from_fuse(void)
493{
494 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
495 int vdd;
496 u32 fusesr;
497 u8 vid;
498
499 fusesr = in_be32(&gur->dcfg_fusesr);
500 debug("%s: fusesr = 0x%x\n", __func__, fusesr);
501 vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_ALTVID_SHIFT) &
502 FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK;
503 if ((vid == 0) || (vid == FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK)) {
504 vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_VID_SHIFT) &
505 FSL_CHASSIS2_DCFG_FUSESR_VID_MASK;
506 }
507 debug("%s: VID = 0x%x\n", __func__, vid);
508 switch (vid) {
509 case 0x00: /* VID isn't supported */
510 vdd = -EINVAL;
511 debug("%s: The VID feature is not supported\n", __func__);
512 break;
513 case 0x08: /* 0.9V silicon */
514 vdd = 900;
515 break;
516 case 0x10: /* 1.0V silicon */
517 vdd = 1000;
518 break;
519 default: /* Other core voltage */
520 vdd = -EINVAL;
521 printf("%s: The VID(%x) isn't supported\n", __func__, vid);
522 break;
523 }
524 debug("%s: The required minimum volt of CORE is %dmV\n", __func__, vdd);
525
526 return vdd;
527}
528
529__weak int board_switch_core_volt(u32 vdd)
530{
531 return 0;
532}
533
534static int setup_core_volt(u32 vdd)
535{
536 return board_setup_core_volt(vdd);
537}
538
539#ifdef CONFIG_SYS_FSL_DDR
540static void ddr_enable_0v9_volt(bool en)
541{
542 struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
543 u32 tmp;
544
545 tmp = ddr_in32(&ddr->ddr_cdr1);
546
547 if (en)
548 tmp |= DDR_CDR1_V0PT9_EN;
549 else
550 tmp &= ~DDR_CDR1_V0PT9_EN;
551
552 ddr_out32(&ddr->ddr_cdr1, tmp);
553}
554#endif
555
556int setup_chip_volt(void)
557{
558 int vdd;
559
560 vdd = get_core_volt_from_fuse();
561 /* Nothing to do for silicons doesn't support VID */
562 if (vdd < 0)
563 return vdd;
564
565 if (setup_core_volt(vdd))
566 printf("%s: Switch core VDD to %dmV failed\n", __func__, vdd);
567#ifdef CONFIG_SYS_HAS_SERDES
568 if (setup_serdes_volt(vdd))
569 printf("%s: Switch SVDD to %dmV failed\n", __func__, vdd);
570#endif
571
572#ifdef CONFIG_SYS_FSL_DDR
573 if (vdd == 900)
574 ddr_enable_0v9_volt(true);
575#endif
576
577 return 0;
578}
579
Calvin Johnson6d6ef012018-03-08 15:30:33 +0530580#ifdef CONFIG_FSL_PFE
581void init_pfe_scfg_dcfg_regs(void)
582{
583 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
584 u32 ecccr2;
585
586 out_be32(&scfg->pfeasbcr,
587 in_be32(&scfg->pfeasbcr) | SCFG_PFEASBCR_AWCACHE0);
588 out_be32(&scfg->pfebsbcr,
589 in_be32(&scfg->pfebsbcr) | SCFG_PFEASBCR_AWCACHE0);
590
591 /* CCI-400 QoS settings for PFE */
592 out_be32(&scfg->wr_qos1, (unsigned int)(SCFG_WR_QOS1_PFE1_QOS
593 | SCFG_WR_QOS1_PFE2_QOS));
594 out_be32(&scfg->rd_qos1, (unsigned int)(SCFG_RD_QOS1_PFE1_QOS
595 | SCFG_RD_QOS1_PFE2_QOS));
596
597 ecccr2 = in_be32(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_ECCCR2);
598 out_be32((void *)CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_ECCCR2,
599 ecccr2 | (unsigned int)DISABLE_PFE_ECC);
600}
601#endif
602
Mingkai Hue4e93ea2015-10-26 19:47:51 +0800603void fsl_lsch2_early_init_f(void)
604{
Ashish Kumar11234062017-08-11 11:09:14 +0530605 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
606 CONFIG_SYS_CCI400_OFFSET);
Aneesh Bansal13d984d2015-12-08 13:54:27 +0530607 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
Pankit Garg41bde722019-05-29 12:12:36 +0000608#if defined(CONFIG_FSL_QSPI) && defined(CONFIG_TFABOOT)
609 enum boot_src src;
610#endif
Mingkai Hue4e93ea2015-10-26 19:47:51 +0800611
Hou Zhiqiang5ac9a5c2016-08-02 19:03:23 +0800612#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
613 enable_layerscape_ns_access();
614#endif
615
Mingkai Hue4e93ea2015-10-26 19:47:51 +0800616#ifdef CONFIG_FSL_IFC
617 init_early_memctl_regs(); /* tighten IFC timing */
618#endif
619
Pankit Garg41bde722019-05-29 12:12:36 +0000620#if defined(CONFIG_FSL_QSPI) && defined(CONFIG_TFABOOT)
621 src = get_boot_src();
622 if (src != BOOT_SOURCE_QSPI_NOR)
623 out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
624#else
Qianyu Gong5ab2d0a2016-03-16 18:01:52 +0800625#if defined(CONFIG_FSL_QSPI) && !defined(CONFIG_QSPI_BOOT)
Gong Qianyu760df892016-01-25 15:16:06 +0800626 out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
627#endif
Pankit Garg41bde722019-05-29 12:12:36 +0000628#endif
Aneesh Bansal13d984d2015-12-08 13:54:27 +0530629 /* Make SEC reads and writes snoopable */
630 setbits_be32(&scfg->snpcnfgcr, SCFG_SNPCNFGCR_SECRDSNP |
Tang Yuantian2945ae02016-08-08 15:07:20 +0800631 SCFG_SNPCNFGCR_SECWRSNP |
632 SCFG_SNPCNFGCR_SATARDSNP |
633 SCFG_SNPCNFGCR_SATAWRSNP);
Aneesh Bansal13d984d2015-12-08 13:54:27 +0530634
Mingkai Hue4e93ea2015-10-26 19:47:51 +0800635 /*
636 * Enable snoop requests and DVM message requests for
637 * Slave insterface S4 (A53 core cluster)
638 */
York Sune6b871e2017-05-15 08:51:59 -0700639 if (current_el() == 3) {
640 out_le32(&cci->slave[4].snoop_ctrl,
641 CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
642 }
Mingkai Hu8beb0752015-12-07 16:58:54 +0800643
Ran Wang4e7cdcf2018-08-10 15:00:00 +0800644 /*
645 * Program Central Security Unit (CSU) to grant access
646 * permission for USB 2.0 controller
647 */
648#if defined(CONFIG_ARCH_LS1012A) && defined(CONFIG_USB_EHCI_FSL)
649 if (current_el() == 3)
650 set_devices_ns_access(CSU_CSLX_USB_2, CSU_ALL_RW);
651#endif
Mingkai Hu8beb0752015-12-07 16:58:54 +0800652 /* Erratum */
Shengzhou Liuddf060b2016-04-07 16:22:21 +0800653 erratum_a008850_early(); /* part 1 of 2 */
Mingkai Hu8beb0752015-12-07 16:58:54 +0800654 erratum_a009929();
Mingkai Hu172081c2016-02-02 11:28:03 +0800655 erratum_a009660();
Hou Zhiqiangc06b30a2016-09-29 12:42:44 +0800656 erratum_a010539();
Ran Wangb358b7b2017-09-04 18:46:48 +0800657 erratum_a009008();
Ran Wang9e8fabc2017-09-04 18:46:49 +0800658 erratum_a009798();
Ran Wange64f7472017-09-04 18:46:50 +0800659 erratum_a008997();
Ran Wang3ba69482017-09-04 18:46:51 +0800660 erratum_a009007();
Laurentiu Tudor512d13e2018-08-09 15:19:46 +0300661
Laurentiu Tudor22012d52018-08-27 17:33:59 +0300662#if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
Laurentiu Tudor512d13e2018-08-09 15:19:46 +0300663 set_icids();
664#endif
Mingkai Hue4e93ea2015-10-26 19:47:51 +0800665}
Mingkai Hu0e58b512015-10-26 19:47:50 +0800666#endif
Scott Wood8e728cd2015-03-24 13:25:02 -0700667
Yuan Yao52ae4fd2016-12-01 10:13:52 +0800668#ifdef CONFIG_QSPI_AHB_INIT
669/* Enable 4bytes address support and fast read */
670int qspi_ahb_init(void)
671{
672 u32 *qspi_lut, lut_key, *qspi_key;
673
674 qspi_key = (void *)SYS_FSL_QSPI_ADDR + 0x300;
675 qspi_lut = (void *)SYS_FSL_QSPI_ADDR + 0x310;
676
677 lut_key = in_be32(qspi_key);
678
679 if (lut_key == 0x5af05af0) {
680 /* That means the register is BE */
681 out_be32(qspi_key, 0x5af05af0);
682 /* Unlock the lut table */
683 out_be32(qspi_key + 1, 0x00000002);
684 out_be32(qspi_lut, 0x0820040c);
685 out_be32(qspi_lut + 1, 0x1c080c08);
686 out_be32(qspi_lut + 2, 0x00002400);
687 /* Lock the lut table */
688 out_be32(qspi_key, 0x5af05af0);
689 out_be32(qspi_key + 1, 0x00000001);
690 } else {
691 /* That means the register is LE */
692 out_le32(qspi_key, 0x5af05af0);
693 /* Unlock the lut table */
694 out_le32(qspi_key + 1, 0x00000002);
695 out_le32(qspi_lut, 0x0820040c);
696 out_le32(qspi_lut + 1, 0x1c080c08);
697 out_le32(qspi_lut + 2, 0x00002400);
698 /* Lock the lut table */
699 out_le32(qspi_key, 0x5af05af0);
700 out_le32(qspi_key + 1, 0x00000001);
701 }
702
Pankit Gargbdbf84f2018-11-05 18:01:52 +0000703 return 0;
704}
705#endif
706
707#ifdef CONFIG_TFABOOT
Rajesh Bhagat5b73c902018-12-27 04:37:49 +0000708#define MAX_BOOTCMD_SIZE 512
Pankit Gargbdbf84f2018-11-05 18:01:52 +0000709
710int fsl_setenv_bootcmd(void)
711{
712 int ret;
713 enum boot_src src = get_boot_src();
714 char bootcmd_str[MAX_BOOTCMD_SIZE];
715
716 switch (src) {
717#ifdef IFC_NOR_BOOTCOMMAND
718 case BOOT_SOURCE_IFC_NOR:
719 sprintf(bootcmd_str, IFC_NOR_BOOTCOMMAND);
720 break;
721#endif
722#ifdef QSPI_NOR_BOOTCOMMAND
723 case BOOT_SOURCE_QSPI_NOR:
724 sprintf(bootcmd_str, QSPI_NOR_BOOTCOMMAND);
725 break;
726#endif
727#ifdef XSPI_NOR_BOOTCOMMAND
728 case BOOT_SOURCE_XSPI_NOR:
729 sprintf(bootcmd_str, XSPI_NOR_BOOTCOMMAND);
730 break;
731#endif
732#ifdef IFC_NAND_BOOTCOMMAND
733 case BOOT_SOURCE_IFC_NAND:
734 sprintf(bootcmd_str, IFC_NAND_BOOTCOMMAND);
735 break;
736#endif
737#ifdef QSPI_NAND_BOOTCOMMAND
738 case BOOT_SOURCE_QSPI_NAND:
739 sprintf(bootcmd_str, QSPI_NAND_BOOTCOMMAND);
740 break;
741#endif
742#ifdef XSPI_NAND_BOOTCOMMAND
743 case BOOT_SOURCE_XSPI_NAND:
744 sprintf(bootcmd_str, XSPI_NAND_BOOTCOMMAND);
745 break;
746#endif
747#ifdef SD_BOOTCOMMAND
748 case BOOT_SOURCE_SD_MMC:
749 sprintf(bootcmd_str, SD_BOOTCOMMAND);
750 break;
751#endif
752#ifdef SD2_BOOTCOMMAND
753 case BOOT_SOURCE_SD_MMC2:
754 sprintf(bootcmd_str, SD2_BOOTCOMMAND);
755 break;
756#endif
757 default:
758#ifdef QSPI_NOR_BOOTCOMMAND
759 sprintf(bootcmd_str, QSPI_NOR_BOOTCOMMAND);
760#endif
761 break;
762 }
763
764 ret = env_set("bootcmd", bootcmd_str);
765 if (ret) {
766 printf("Failed to set bootcmd: ret = %d\n", ret);
767 return ret;
768 }
Yuan Yao52ae4fd2016-12-01 10:13:52 +0800769 return 0;
770}
Pankit Garg82fcc462018-11-05 18:02:31 +0000771
772int fsl_setenv_mcinitcmd(void)
773{
774 int ret = 0;
775 enum boot_src src = get_boot_src();
776
777 switch (src) {
778#ifdef IFC_MC_INIT_CMD
779 case BOOT_SOURCE_IFC_NAND:
780 case BOOT_SOURCE_IFC_NOR:
781 ret = env_set("mcinitcmd", IFC_MC_INIT_CMD);
782 break;
783#endif
784#ifdef QSPI_MC_INIT_CMD
785 case BOOT_SOURCE_QSPI_NAND:
786 case BOOT_SOURCE_QSPI_NOR:
787 ret = env_set("mcinitcmd", QSPI_MC_INIT_CMD);
788 break;
789#endif
790#ifdef XSPI_MC_INIT_CMD
791 case BOOT_SOURCE_XSPI_NAND:
792 case BOOT_SOURCE_XSPI_NOR:
793 ret = env_set("mcinitcmd", XSPI_MC_INIT_CMD);
794 break;
795#endif
796#ifdef SD_MC_INIT_CMD
797 case BOOT_SOURCE_SD_MMC:
798 ret = env_set("mcinitcmd", SD_MC_INIT_CMD);
799 break;
800#endif
801#ifdef SD2_MC_INIT_CMD
802 case BOOT_SOURCE_SD_MMC2:
803 ret = env_set("mcinitcmd", SD2_MC_INIT_CMD);
804 break;
805#endif
806 default:
807#ifdef QSPI_MC_INIT_CMD
808 ret = env_set("mcinitcmd", QSPI_MC_INIT_CMD);
809#endif
810 break;
811 }
812
813 if (ret) {
814 printf("Failed to set mcinitcmd: ret = %d\n", ret);
815 return ret;
816 }
817 return 0;
818}
Yuan Yao52ae4fd2016-12-01 10:13:52 +0800819#endif
820
Mingkai Hu0e58b512015-10-26 19:47:50 +0800821#ifdef CONFIG_BOARD_LATE_INIT
822int board_late_init(void)
Scott Wood8e728cd2015-03-24 13:25:02 -0700823{
Aneesh Bansal39d5b3b2016-01-22 16:37:26 +0530824#ifdef CONFIG_CHAIN_OF_TRUST
825 fsl_setenv_chain_of_trust();
826#endif
Pankit Gargbdbf84f2018-11-05 18:01:52 +0000827#ifdef CONFIG_TFABOOT
828 /*
829 * check if gd->env_addr is default_environment; then setenv bootcmd
Pankit Garg82fcc462018-11-05 18:02:31 +0000830 * and mcinitcmd.
Pankit Gargbdbf84f2018-11-05 18:01:52 +0000831 */
Pankit Gargd6bd6782019-05-30 12:04:15 +0000832#if !defined(CONFIG_ENV_ADDR) || defined(ENV_IS_EMBEDDED)
833 if (gd->env_addr == (ulong)&default_environment[0]) {
834#else
Pankit Garg82fcc462018-11-05 18:02:31 +0000835 if (gd->env_addr + gd->reloc_off == (ulong)&default_environment[0]) {
Pankit Gargd6bd6782019-05-30 12:04:15 +0000836#endif
Pankit Gargbdbf84f2018-11-05 18:01:52 +0000837 fsl_setenv_bootcmd();
Pankit Garg82fcc462018-11-05 18:02:31 +0000838 fsl_setenv_mcinitcmd();
839 }
Rajesh Bhagat5b73c902018-12-27 04:37:49 +0000840
841 /*
842 * If the boot mode is secure, default environment is not present then
843 * setenv command needs to be run by default
844 */
845#ifdef CONFIG_CHAIN_OF_TRUST
846 if ((fsl_check_boot_mode_secure() == 1)) {
847 fsl_setenv_bootcmd();
848 fsl_setenv_mcinitcmd();
849 }
850#endif
Pankit Gargbdbf84f2018-11-05 18:01:52 +0000851#endif
Yuan Yao52ae4fd2016-12-01 10:13:52 +0800852#ifdef CONFIG_QSPI_AHB_INIT
853 qspi_ahb_init();
854#endif
Tang Yuantian57894be2015-12-09 15:32:18 +0800855
Mingkai Hu0e58b512015-10-26 19:47:50 +0800856 return 0;
Scott Wood8e728cd2015-03-24 13:25:02 -0700857}
858#endif