1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 NXP Semiconductors
4 * Author: Fabio Estevam <fabio.estevam@nxp.com>
9 #include <asm/arch/clock.h>
10 #include <asm/arch/imx-regs.h>
11 #include <asm/arch/mx7-pins.h>
12 #include <asm/arch/sys_proto.h>
13 #include <asm/global_data.h>
15 #include <asm/mach-imx/hab.h>
16 #include <asm/mach-imx/iomux-v3.h>
20 #include <asm/arch/crm_regs.h>
22 #include <power/pmic.h>
23 #include <power/pfuze3000_pmic.h>
24 #include "../freescale/common/pfuze.h"
25 #include <asm/setup.h>
26 #include <asm/bootm.h>
28 DECLARE_GLOBAL_DATA_PTR;
32 gd->ram_size = PHYS_SDRAM_SIZE;
34 /* Subtract the defined OPTEE runtime firmware length */
35 #ifdef CONFIG_OPTEE_TZDRAM_SIZE
36 gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE;
42 static iomux_v3_cfg_t const wdog_pads[] = {
43 MX7D_PAD_GPIO1_IO00__WDOG1_WDOG_B | MUX_PAD_CTRL(NO_PAD_CTRL),
47 int power_init_board(void)
50 int ret, dev_id, rev_id;
52 ret = pmic_get("pfuze3000@8", &dev);
58 dev_id = pmic_reg_read(dev, PFUZE3000_DEVICEID);
59 rev_id = pmic_reg_read(dev, PFUZE3000_REVID);
60 printf("PMIC: PFUZE3000 DEV_ID=0x%x REV_ID=0x%x\n", dev_id, rev_id);
62 /* disable Low Power Mode during standby mode */
63 pmic_reg_write(dev, PFUZE3000_LDOGCTL, 1);
71 /* address of boot parameters */
72 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
81 if (IS_ENABLED(CONFIG_ARMV7_BOOT_SEC_DEFAULT))
86 #ifdef CONFIG_OPTEE_TZDRAM_SIZE
87 unsigned long optee_start, optee_end;
89 optee_end = PHYS_SDRAM + PHYS_SDRAM_SIZE;
90 optee_start = optee_end - CONFIG_OPTEE_TZDRAM_SIZE;
92 printf("Board: WARP7 in %s mode OPTEE DRAM 0x%08lx-0x%08lx\n",
93 mode, optee_start, optee_end);
95 printf("Board: WARP7 in %s mode\n", mode);
101 int board_late_init(void)
103 struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
104 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
105 struct tag_serialnr serialnr;
106 char serial_string[0x20];
109 imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
111 set_wdog_reset(wdog);
114 * Do not assert internal WDOG_RESET_B_DEB(controlled by bit 4),
115 * since we use PMIC_PWRON to reset the board.
117 clrsetbits_le16(&wdog->wcr, 0, 0x10);
119 #ifdef CONFIG_IMX_HAB
120 /* Determine HAB state */
121 env_set_ulong(HAB_ENABLED_ENVNAME, imx_hab_is_enabled());
123 env_set_ulong(HAB_ENABLED_ENVNAME, 0);
126 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
127 /* Set serial# standard environment variable based on OTP settings */
128 get_board_serial(&serialnr);
129 snprintf(serial_string, sizeof(serial_string), "WaRP7-0x%08x%08x",
130 serialnr.low, serialnr.high);
131 env_set("serial#", serial_string);