blob: fae69be1c7a0d75c12719ac7223f4b9fefae5581 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peng Fanfcdbde72018-01-10 13:20:37 +08002/*
Ye Li70487ff2020-05-03 22:19:52 +08003 * Copyright 2017-2019 NXP
Peng Fanfcdbde72018-01-10 13:20:37 +08004 *
5 * Peng Fan <peng.fan@nxp.com>
Peng Fanfcdbde72018-01-10 13:20:37 +08006 */
7
8#include <common.h>
Simon Glass9edefc22019-11-14 12:57:37 -07009#include <cpu_func.h>
Simon Glass691d7192020-05-10 11:40:02 -060010#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060011#include <log.h>
Peng Fanfcdbde72018-01-10 13:20:37 +080012#include <asm/arch/imx-regs.h>
13#include <asm/io.h>
14#include <asm/arch/clock.h>
15#include <asm/arch/sys_proto.h>
16#include <asm/mach-imx/hab.h>
17#include <asm/mach-imx/boot_mode.h>
18#include <asm/mach-imx/syscounter.h>
19#include <asm/armv8/mmu.h>
Peng Fane663c702019-08-27 06:25:58 +000020#include <dm/uclass.h>
Peng Fanfcdbde72018-01-10 13:20:37 +080021#include <errno.h>
22#include <fdt_support.h>
23#include <fsl_wdog.h>
24#include <imx_sip.h>
Peng Fana2f143e2020-05-11 15:14:04 +080025#include <linux/arm-smccc.h>
Simon Glasscd93d622020-05-10 11:40:13 -060026#include <linux/bitops.h>
Peng Fanfcdbde72018-01-10 13:20:37 +080027
28DECLARE_GLOBAL_DATA_PTR;
29
Stefano Babicd714a752019-09-20 08:47:53 +020030#if defined(CONFIG_IMX_HAB)
Peng Fanfcdbde72018-01-10 13:20:37 +080031struct imx_sec_config_fuse_t const imx_sec_config_fuse = {
32 .bank = 1,
33 .word = 3,
34};
35#endif
36
37int timer_init(void)
38{
39#ifdef CONFIG_SPL_BUILD
40 struct sctr_regs *sctr = (struct sctr_regs *)SYSCNT_CTRL_BASE_ADDR;
41 unsigned long freq = readl(&sctr->cntfid0);
42
43 /* Update with accurate clock frequency */
44 asm volatile("msr cntfrq_el0, %0" : : "r" (freq) : "memory");
45
46 clrsetbits_le32(&sctr->cntcr, SC_CNTCR_FREQ0 | SC_CNTCR_FREQ1,
47 SC_CNTCR_FREQ0 | SC_CNTCR_ENABLE | SC_CNTCR_HDBG);
48#endif
49
50 gd->arch.tbl = 0;
51 gd->arch.tbu = 0;
52
53 return 0;
54}
55
56void enable_tzc380(void)
57{
58 struct iomuxc_gpr_base_regs *gpr =
59 (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
60
61 /* Enable TZASC and lock setting */
62 setbits_le32(&gpr->gpr[10], GPR_TZASC_EN);
63 setbits_le32(&gpr->gpr[10], GPR_TZASC_EN_LOCK);
Peng Fana07c7182019-12-27 10:19:42 +080064 if (is_imx8mm() || is_imx8mn() || is_imx8mp())
Peng Fandbb2b7e2019-08-27 06:25:30 +000065 setbits_le32(&gpr->gpr[10], BIT(1));
Ye Lib3cf0a82019-08-27 06:25:34 +000066 /*
67 * set Region 0 attribute to allow secure and non-secure
68 * read/write permission. Found some masters like usb dwc3
69 * controllers can't work with secure memory.
70 */
71 writel(0xf0000000, TZASC_BASE_ADDR + 0x108);
Peng Fanfcdbde72018-01-10 13:20:37 +080072}
73
74void set_wdog_reset(struct wdog_regs *wdog)
75{
76 /*
77 * Output WDOG_B signal to reset external pmic or POR_B decided by
78 * the board design. Without external reset, the peripherals/DDR/
79 * PMIC are not reset, that may cause system working abnormal.
80 * WDZST bit is write-once only bit. Align this bit in kernel,
81 * otherwise kernel code will have no chance to set this bit.
82 */
83 setbits_le16(&wdog->wcr, WDOG_WDT_MASK | WDOG_WDZST_MASK);
84}
85
86static struct mm_region imx8m_mem_map[] = {
87 {
88 /* ROM */
89 .virt = 0x0UL,
90 .phys = 0x0UL,
91 .size = 0x100000UL,
92 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
93 PTE_BLOCK_OUTER_SHARE
94 }, {
Gary Bissoncb158852018-11-14 17:55:28 +010095 /* CAAM */
96 .virt = 0x100000UL,
97 .phys = 0x100000UL,
98 .size = 0x8000UL,
99 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
100 PTE_BLOCK_NON_SHARE |
101 PTE_BLOCK_PXN | PTE_BLOCK_UXN
102 }, {
103 /* TCM */
104 .virt = 0x7C0000UL,
105 .phys = 0x7C0000UL,
106 .size = 0x80000UL,
107 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
108 PTE_BLOCK_NON_SHARE |
109 PTE_BLOCK_PXN | PTE_BLOCK_UXN
110 }, {
Peng Fanfcdbde72018-01-10 13:20:37 +0800111 /* OCRAM */
112 .virt = 0x900000UL,
113 .phys = 0x900000UL,
114 .size = 0x200000UL,
115 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
116 PTE_BLOCK_OUTER_SHARE
117 }, {
118 /* AIPS */
119 .virt = 0xB00000UL,
120 .phys = 0xB00000UL,
121 .size = 0x3f500000UL,
122 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
123 PTE_BLOCK_NON_SHARE |
124 PTE_BLOCK_PXN | PTE_BLOCK_UXN
125 }, {
126 /* DRAM1 */
127 .virt = 0x40000000UL,
128 .phys = 0x40000000UL,
Peng Fan59efa6b2019-08-27 06:25:27 +0000129 .size = PHYS_SDRAM_SIZE,
Peng Fanfcdbde72018-01-10 13:20:37 +0800130 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
131 PTE_BLOCK_OUTER_SHARE
Peng Fan59efa6b2019-08-27 06:25:27 +0000132#ifdef PHYS_SDRAM_2_SIZE
Peng Fanfcdbde72018-01-10 13:20:37 +0800133 }, {
134 /* DRAM2 */
135 .virt = 0x100000000UL,
136 .phys = 0x100000000UL,
Peng Fan59efa6b2019-08-27 06:25:27 +0000137 .size = PHYS_SDRAM_2_SIZE,
Peng Fanfcdbde72018-01-10 13:20:37 +0800138 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
139 PTE_BLOCK_OUTER_SHARE
Peng Fan59efa6b2019-08-27 06:25:27 +0000140#endif
Peng Fanfcdbde72018-01-10 13:20:37 +0800141 }, {
142 /* List terminator */
143 0,
144 }
145};
146
147struct mm_region *mem_map = imx8m_mem_map;
148
Peng Fan59efa6b2019-08-27 06:25:27 +0000149void enable_caches(void)
150{
151 /*
152 * If OPTEE runs, remove OPTEE memory from MMU table to
153 * avoid speculative prefetch. OPTEE runs at the top of
154 * the first memory bank
155 */
156 if (rom_pointer[1])
157 imx8m_mem_map[5].size -= rom_pointer[1];
158
159 icache_enable();
160 dcache_enable();
161}
162
Peng Fan78db9a52019-08-27 06:25:17 +0000163static u32 get_cpu_variant_type(u32 type)
164{
165 struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
166 struct fuse_bank *bank = &ocotp->bank[1];
167 struct fuse_bank1_regs *fuse =
168 (struct fuse_bank1_regs *)bank->fuse_regs;
169
170 u32 value = readl(&fuse->tester4);
171
Peng Fancb1a1de2020-02-05 17:34:54 +0800172 if (type == MXC_CPU_IMX8MQ) {
173 if ((value & 0x3) == 0x2)
174 return MXC_CPU_IMX8MD;
175 else if (value & 0x200000)
176 return MXC_CPU_IMX8MQL;
177
178 } else if (type == MXC_CPU_IMX8MM) {
Peng Fan78db9a52019-08-27 06:25:17 +0000179 switch (value & 0x3) {
180 case 2:
181 if (value & 0x1c0000)
182 return MXC_CPU_IMX8MMDL;
183 else
184 return MXC_CPU_IMX8MMD;
185 case 3:
186 if (value & 0x1c0000)
187 return MXC_CPU_IMX8MMSL;
188 else
189 return MXC_CPU_IMX8MMS;
190 default:
191 if (value & 0x1c0000)
192 return MXC_CPU_IMX8MML;
193 break;
194 }
Peng Fanc9154032020-02-05 17:39:27 +0800195 } else if (type == MXC_CPU_IMX8MN) {
196 switch (value & 0x3) {
197 case 2:
198 if (value & 0x1000000)
199 return MXC_CPU_IMX8MNDL;
200 else
201 return MXC_CPU_IMX8MND;
202 case 3:
203 if (value & 0x1000000)
204 return MXC_CPU_IMX8MNSL;
205 else
206 return MXC_CPU_IMX8MNS;
207 default:
208 if (value & 0x1000000)
209 return MXC_CPU_IMX8MNL;
210 break;
211 }
Peng Fan78db9a52019-08-27 06:25:17 +0000212 }
213
214 return type;
215}
216
Peng Fanfcdbde72018-01-10 13:20:37 +0800217u32 get_cpu_rev(void)
218{
219 struct anamix_pll *ana_pll = (struct anamix_pll *)ANATOP_BASE_ADDR;
220 u32 reg = readl(&ana_pll->digprog);
221 u32 type = (reg >> 16) & 0xff;
Peng Fan78db9a52019-08-27 06:25:17 +0000222 u32 major_low = (reg >> 8) & 0xff;
Peng Fanfcdbde72018-01-10 13:20:37 +0800223 u32 rom_version;
224
225 reg &= 0xff;
226
Peng Fan625b03d2019-12-27 10:14:02 +0800227 /* iMX8MP */
228 if (major_low == 0x43) {
229 return (MXC_CPU_IMX8MP << 12) | reg;
230 } else if (major_low == 0x42) {
231 /* iMX8MN */
Peng Fanc9154032020-02-05 17:39:27 +0800232 type = get_cpu_variant_type(MXC_CPU_IMX8MN);
Peng Fan24341312019-06-27 17:23:49 +0800233 } else if (major_low == 0x41) {
Peng Fan78db9a52019-08-27 06:25:17 +0000234 type = get_cpu_variant_type(MXC_CPU_IMX8MM);
235 } else {
236 if (reg == CHIP_REV_1_0) {
237 /*
Peng Fan9e094452019-10-16 10:24:17 +0000238 * For B0 chip, the DIGPROG is not updated,
239 * it is still TO1.0. we have to check ROM
240 * version or OCOTP_READ_FUSE_DATA.
241 * 0xff0055aa is magic number for B1.
Peng Fan78db9a52019-08-27 06:25:17 +0000242 */
Peng Fan9e094452019-10-16 10:24:17 +0000243 if (readl((void __iomem *)(OCOTP_BASE_ADDR + 0x40)) == 0xff0055aa) {
244 reg = CHIP_REV_2_1;
245 } else {
246 rom_version =
247 readl((void __iomem *)ROM_VERSION_A0);
248 if (rom_version != CHIP_REV_1_0) {
249 rom_version = readl((void __iomem *)ROM_VERSION_B0);
Patrick Wildt6a4b07e2019-11-19 09:42:06 +0100250 rom_version &= 0xff;
Peng Fan9e094452019-10-16 10:24:17 +0000251 if (rom_version == CHIP_REV_2_0)
252 reg = CHIP_REV_2_0;
253 }
Peng Fan78db9a52019-08-27 06:25:17 +0000254 }
Peng Fanfcdbde72018-01-10 13:20:37 +0800255 }
Peng Fancb1a1de2020-02-05 17:34:54 +0800256
257 type = get_cpu_variant_type(type);
Peng Fanfcdbde72018-01-10 13:20:37 +0800258 }
259
260 return (type << 12) | reg;
261}
262
263static void imx_set_wdog_powerdown(bool enable)
264{
265 struct wdog_regs *wdog1 = (struct wdog_regs *)WDOG1_BASE_ADDR;
266 struct wdog_regs *wdog2 = (struct wdog_regs *)WDOG2_BASE_ADDR;
267 struct wdog_regs *wdog3 = (struct wdog_regs *)WDOG3_BASE_ADDR;
268
269 /* Write to the PDE (Power Down Enable) bit */
270 writew(enable, &wdog1->wmcr);
271 writew(enable, &wdog2->wmcr);
272 writew(enable, &wdog3->wmcr);
273}
274
Peng Fane663c702019-08-27 06:25:58 +0000275int arch_cpu_init_dm(void)
276{
277 struct udevice *dev;
278 int ret;
279
Peng Fancd7c8062019-10-16 03:01:51 +0000280 if (CONFIG_IS_ENABLED(CLK)) {
281 ret = uclass_get_device_by_name(UCLASS_CLK,
282 "clock-controller@30380000",
283 &dev);
284 if (ret < 0) {
285 printf("Failed to find clock node. Check device tree\n");
286 return ret;
287 }
Peng Fane663c702019-08-27 06:25:58 +0000288 }
289
290 return 0;
291}
292
Peng Fanfcdbde72018-01-10 13:20:37 +0800293int arch_cpu_init(void)
294{
Peng Fan702339b2019-04-17 09:41:16 +0000295 struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
Peng Fanfcdbde72018-01-10 13:20:37 +0800296 /*
Peng Fan0528ba02019-08-27 06:25:37 +0000297 * ROM might disable clock for SCTR,
298 * enable the clock before timer_init.
299 */
300 if (IS_ENABLED(CONFIG_SPL_BUILD))
301 clock_enable(CCGR_SCTR, 1);
302 /*
Peng Fanfcdbde72018-01-10 13:20:37 +0800303 * Init timer at very early state, because sscg pll setting
304 * will use it
305 */
306 timer_init();
307
308 if (IS_ENABLED(CONFIG_SPL_BUILD)) {
309 clock_init();
310 imx_set_wdog_powerdown(false);
311 }
312
Peng Fan702339b2019-04-17 09:41:16 +0000313 if (is_imx8mq()) {
314 clock_enable(CCGR_OCOTP, 1);
315 if (readl(&ocotp->ctrl) & 0x200)
316 writel(0x200, &ocotp->ctrl_clr);
317 }
318
Peng Fanfcdbde72018-01-10 13:20:37 +0800319 return 0;
320}
321
Peng Fanb1821372019-09-16 03:09:36 +0000322#if defined(CONFIG_IMX8MN) || defined(CONFIG_IMX8MP)
323struct rom_api *g_rom_api = (struct rom_api *)0x980;
324
325enum boot_device get_boot_device(void)
326{
327 volatile gd_t *pgd = gd;
328 int ret;
329 u32 boot;
330 u16 boot_type;
331 u8 boot_instance;
332 enum boot_device boot_dev = SD1_BOOT;
333
334 ret = g_rom_api->query_boot_infor(QUERY_BT_DEV, &boot,
335 ((uintptr_t)&boot) ^ QUERY_BT_DEV);
336 gd = pgd;
337
338 if (ret != ROM_API_OKAY) {
339 puts("ROMAPI: failure at query_boot_info\n");
340 return -1;
341 }
342
343 boot_type = boot >> 16;
344 boot_instance = (boot >> 8) & 0xff;
345
346 switch (boot_type) {
347 case BT_DEV_TYPE_SD:
348 boot_dev = boot_instance + SD1_BOOT;
349 break;
350 case BT_DEV_TYPE_MMC:
351 boot_dev = boot_instance + MMC1_BOOT;
352 break;
353 case BT_DEV_TYPE_NAND:
354 boot_dev = NAND_BOOT;
355 break;
356 case BT_DEV_TYPE_FLEXSPINOR:
357 boot_dev = QSPI_BOOT;
358 break;
359 case BT_DEV_TYPE_USB:
360 boot_dev = USB_BOOT;
361 break;
362 default:
363 break;
364 }
365
366 return boot_dev;
367}
368#endif
369
Peng Fanfcdbde72018-01-10 13:20:37 +0800370bool is_usb_boot(void)
371{
372 return get_boot_device() == USB_BOOT;
373}
374
375#ifdef CONFIG_OF_SYSTEM_SETUP
376int ft_system_setup(void *blob, bd_t *bd)
377{
378 int i = 0;
379 int rc;
380 int nodeoff;
381
382 /* Disable the CPU idle for A0 chip since the HW does not support it */
383 if (is_soc_rev(CHIP_REV_1_0)) {
384 static const char * const nodes_path[] = {
385 "/cpus/cpu@0",
386 "/cpus/cpu@1",
387 "/cpus/cpu@2",
388 "/cpus/cpu@3",
389 };
390
391 for (i = 0; i < ARRAY_SIZE(nodes_path); i++) {
392 nodeoff = fdt_path_offset(blob, nodes_path[i]);
393 if (nodeoff < 0)
394 continue; /* Not found, skip it */
395
Marek Vasutdabaabd2020-04-24 21:37:33 +0200396 debug("Found %s node\n", nodes_path[i]);
Peng Fanfcdbde72018-01-10 13:20:37 +0800397
398 rc = fdt_delprop(blob, nodeoff, "cpu-idle-states");
Marek Vasutdabaabd2020-04-24 21:37:33 +0200399 if (rc == -FDT_ERR_NOTFOUND)
400 continue;
Peng Fanfcdbde72018-01-10 13:20:37 +0800401 if (rc) {
402 printf("Unable to update property %s:%s, err=%s\n",
403 nodes_path[i], "status", fdt_strerror(rc));
404 return rc;
405 }
406
Marek Vasutdabaabd2020-04-24 21:37:33 +0200407 debug("Remove %s:%s\n", nodes_path[i],
Peng Fanfcdbde72018-01-10 13:20:37 +0800408 "cpu-idle-states");
409 }
410 }
411
412 return 0;
413}
414#endif
415
Marek Vasutefa1a622020-04-29 15:04:21 +0200416#if !CONFIG_IS_ENABLED(SYSRESET)
Peng Fanfcdbde72018-01-10 13:20:37 +0800417void reset_cpu(ulong addr)
418{
Claudius Heinec5635a02020-04-29 15:04:23 +0200419 struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
Peng Fanfcdbde72018-01-10 13:20:37 +0800420
Ye Li72479742019-12-09 00:47:18 -0800421 /* Clear WDA to trigger WDOG_B immediately */
422 writew((SET_WCR_WT(1) | WCR_WDT | WCR_WDE | WCR_SRS), &wdog->wcr);
Peng Fand2041722019-08-27 06:25:41 +0000423
Ye Li72479742019-12-09 00:47:18 -0800424 while (1) {
425 /*
Harald Seiler568af922020-04-29 15:04:22 +0200426 * spin for .5 seconds before reset
Ye Li72479742019-12-09 00:47:18 -0800427 */
428 }
Peng Fanfcdbde72018-01-10 13:20:37 +0800429}
Peng Fand2041722019-08-27 06:25:41 +0000430#endif
Peng Fana07bcec2020-04-22 10:51:13 +0800431
432#if defined(CONFIG_ARCH_MISC_INIT)
433static void acquire_buildinfo(void)
434{
435 u64 atf_commit = 0;
Peng Fana2f143e2020-05-11 15:14:04 +0800436 struct arm_smccc_res res;
Peng Fana07bcec2020-04-22 10:51:13 +0800437
438 /* Get ARM Trusted Firmware commit id */
Peng Fana2f143e2020-05-11 15:14:04 +0800439 arm_smccc_smc(IMX_SIP_BUILDINFO, IMX_SIP_BUILDINFO_GET_COMMITHASH,
440 0, 0 , 0, 0, 0, 0, &res);
441 atf_commit = res.a0;
Peng Fana07bcec2020-04-22 10:51:13 +0800442 if (atf_commit == 0xffffffff) {
443 debug("ATF does not support build info\n");
444 atf_commit = 0x30; /* Display 0, 0 ascii is 0x30 */
445 }
446
447 printf("\n BuildInfo:\n - ATF %s\n\n", (char *)&atf_commit);
448}
449
450int arch_misc_init(void)
451{
452 acquire_buildinfo();
453
454 return 0;
455}
456#endif
Ye Li70487ff2020-05-03 22:19:52 +0800457
458void imx_tmu_arch_init(void *reg_base)
459{
Ye Li94c693d2020-05-03 22:19:53 +0800460 if (is_imx8mm() || is_imx8mn()) {
Ye Li70487ff2020-05-03 22:19:52 +0800461 /* Load TCALIV and TASR from fuses */
462 struct ocotp_regs *ocotp =
463 (struct ocotp_regs *)OCOTP_BASE_ADDR;
464 struct fuse_bank *bank = &ocotp->bank[3];
465 struct fuse_bank3_regs *fuse =
466 (struct fuse_bank3_regs *)bank->fuse_regs;
467
468 u32 tca_rt, tca_hr, tca_en;
469 u32 buf_vref, buf_slope;
470
471 tca_rt = fuse->ana0 & 0xFF;
472 tca_hr = (fuse->ana0 & 0xFF00) >> 8;
473 tca_en = (fuse->ana0 & 0x2000000) >> 25;
474
475 buf_vref = (fuse->ana0 & 0x1F00000) >> 20;
476 buf_slope = (fuse->ana0 & 0xF0000) >> 16;
477
478 writel(buf_vref | (buf_slope << 16), (ulong)reg_base + 0x28);
479 writel((tca_en << 31) | (tca_hr << 16) | tca_rt,
480 (ulong)reg_base + 0x30);
481 }
Ye Liebb9aab2020-05-03 22:19:54 +0800482#ifdef CONFIG_IMX8MP
483 /* Load TCALIV0/1/m40 and TRIM from fuses */
484 struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
485 struct fuse_bank *bank = &ocotp->bank[38];
486 struct fuse_bank38_regs *fuse =
487 (struct fuse_bank38_regs *)bank->fuse_regs;
488 struct fuse_bank *bank2 = &ocotp->bank[39];
489 struct fuse_bank39_regs *fuse2 =
490 (struct fuse_bank39_regs *)bank2->fuse_regs;
491 u32 buf_vref, buf_slope, bjt_cur, vlsb, bgr;
492 u32 reg;
493 u32 tca40[2], tca25[2], tca105[2];
494
495 /* For blank sample */
496 if (!fuse->ana_trim2 && !fuse->ana_trim3 &&
497 !fuse->ana_trim4 && !fuse2->ana_trim5) {
498 /* Use a default 25C binary codes */
499 tca25[0] = 1596;
Ye Li3462b552020-05-03 22:19:55 +0800500 tca25[1] = 1596;
Ye Liebb9aab2020-05-03 22:19:54 +0800501 writel(tca25[0], (ulong)reg_base + 0x30);
Ye Li3462b552020-05-03 22:19:55 +0800502 writel(tca25[1], (ulong)reg_base + 0x34);
Ye Liebb9aab2020-05-03 22:19:54 +0800503 return;
504 }
505
506 buf_vref = (fuse->ana_trim2 & 0xc0) >> 6;
507 buf_slope = (fuse->ana_trim2 & 0xF00) >> 8;
508 bjt_cur = (fuse->ana_trim2 & 0xF000) >> 12;
509 bgr = (fuse->ana_trim2 & 0xF0000) >> 16;
510 vlsb = (fuse->ana_trim2 & 0xF00000) >> 20;
511 writel(buf_vref | (buf_slope << 16), (ulong)reg_base + 0x28);
512
513 reg = (bgr << 28) | (bjt_cur << 20) | (vlsb << 12) | (1 << 7);
514 writel(reg, (ulong)reg_base + 0x3c);
515
516 tca40[0] = (fuse->ana_trim3 & 0xFFF0000) >> 16;
517 tca25[0] = (fuse->ana_trim3 & 0xF0000000) >> 28;
518 tca25[0] |= ((fuse->ana_trim4 & 0xFF) << 4);
519 tca105[0] = (fuse->ana_trim4 & 0xFFF00) >> 8;
520 tca40[1] = (fuse->ana_trim4 & 0xFFF00000) >> 20;
521 tca25[1] = fuse2->ana_trim5 & 0xFFF;
522 tca105[1] = (fuse2->ana_trim5 & 0xFFF000) >> 12;
523
524 /* use 25c for 1p calibration */
525 writel(tca25[0] | (tca105[0] << 16), (ulong)reg_base + 0x30);
526 writel(tca25[1] | (tca105[1] << 16), (ulong)reg_base + 0x34);
527 writel(tca40[0] | (tca40[1] << 16), (ulong)reg_base + 0x38);
528#endif
Ye Li70487ff2020-05-03 22:19:52 +0800529}