blob: 4cd3ff0051b765e5cb8407739cafe1684c396c3f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Fabio Estevam6cfa7122016-02-29 09:33:22 -03002/*
3 * Copyright (C) 2016 NXP Semiconductors
4 * Author: Fabio Estevam <fabio.estevam@nxp.com>
Fabio Estevam6cfa7122016-02-29 09:33:22 -03005 */
6
Simon Glassa7b51302019-11-14 12:57:46 -07007#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -06008#include <net.h>
Fabio Estevam6cfa7122016-02-29 09:33:22 -03009#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>
Simon Glass3ba929a2020-10-30 21:38:53 -060013#include <asm/global_data.h>
Fabio Estevam6cfa7122016-02-29 09:33:22 -030014#include <asm/gpio.h>
Bryan O'Donoghue1b60ee62018-04-24 18:46:33 +010015#include <asm/mach-imx/hab.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020016#include <asm/mach-imx/iomux-v3.h>
Fabio Estevam6cfa7122016-02-29 09:33:22 -030017#include <asm/io.h>
Simon Glass07dc93c2019-08-01 09:46:47 -060018#include <env.h>
Fabio Estevam6cfa7122016-02-29 09:33:22 -030019#include <asm/arch/crm_regs.h>
Kevin Hilman46fdd842016-12-16 13:08:10 -080020#include <netdev.h>
Vanessa Maegima4abedc82016-08-19 10:21:36 -030021#include <power/pmic.h>
22#include <power/pfuze3000_pmic.h>
23#include "../freescale/common/pfuze.h"
Bryan O'Donoghue1936c412018-03-26 15:27:34 +010024#include <asm/setup.h>
25#include <asm/bootm.h>
Fabio Estevam6cfa7122016-02-29 09:33:22 -030026
27DECLARE_GLOBAL_DATA_PTR;
28
Fabio Estevam6cfa7122016-02-29 09:33:22 -030029int dram_init(void)
30{
31 gd->ram_size = PHYS_SDRAM_SIZE;
32
Bryan O'Donoghue2adfdff2018-04-24 18:46:35 +010033 /* Subtract the defined OPTEE runtime firmware length */
34#ifdef CONFIG_OPTEE_TZDRAM_SIZE
35 gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE;
36#endif
37
Fabio Estevam6cfa7122016-02-29 09:33:22 -030038 return 0;
39}
40
Marco Franchi3d73f522016-06-10 14:45:28 -030041static iomux_v3_cfg_t const wdog_pads[] = {
42 MX7D_PAD_GPIO1_IO00__WDOG1_WDOG_B | MUX_PAD_CTRL(NO_PAD_CTRL),
43};
44
Bryan O'Donoghue6f1eee62019-01-18 17:40:14 +000045#ifdef CONFIG_DM_PMIC
Vanessa Maegima4abedc82016-08-19 10:21:36 -030046int power_init_board(void)
47{
Bryan O'Donoghue6f1eee62019-01-18 17:40:14 +000048 struct udevice *dev;
49 int ret, dev_id, rev_id;
Vanessa Maegima4abedc82016-08-19 10:21:36 -030050
Joris Offougae19e7cc2020-01-29 22:05:58 +010051 ret = pmic_get("pfuze3000@8", &dev);
Bryan O'Donoghue6f1eee62019-01-18 17:40:14 +000052 if (ret == -ENODEV)
53 return 0;
54 if (ret != 0)
Vanessa Maegima4abedc82016-08-19 10:21:36 -030055 return ret;
56
Bryan O'Donoghue6f1eee62019-01-18 17:40:14 +000057 dev_id = pmic_reg_read(dev, PFUZE3000_DEVICEID);
58 rev_id = pmic_reg_read(dev, PFUZE3000_REVID);
59 printf("PMIC: PFUZE3000 DEV_ID=0x%x REV_ID=0x%x\n", dev_id, rev_id);
Vanessa Maegima4abedc82016-08-19 10:21:36 -030060
61 /* disable Low Power Mode during standby mode */
Fabio Estevam7ac7b962019-02-14 11:37:51 -020062 pmic_reg_write(dev, PFUZE3000_LDOGCTL, 1);
Vanessa Maegima4abedc82016-08-19 10:21:36 -030063
64 return 0;
65}
66#endif
67
Fabio Estevam6cfa7122016-02-29 09:33:22 -030068int board_init(void)
69{
70 /* address of boot parameters */
71 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
72
73 return 0;
74}
75
76int checkboard(void)
77{
Fabio Estevamf8f21942016-08-25 21:07:20 -030078 char *mode;
79
80 if (IS_ENABLED(CONFIG_ARMV7_BOOT_SEC_DEFAULT))
81 mode = "secure";
82 else
83 mode = "non-secure";
84
Bryan O'Donoghue446dddd2018-04-24 18:46:36 +010085#ifdef CONFIG_OPTEE_TZDRAM_SIZE
86 unsigned long optee_start, optee_end;
87
88 optee_end = PHYS_SDRAM + PHYS_SDRAM_SIZE;
89 optee_start = optee_end - CONFIG_OPTEE_TZDRAM_SIZE;
90
91 printf("Board: WARP7 in %s mode OPTEE DRAM 0x%08lx-0x%08lx\n",
92 mode, optee_start, optee_end);
93#else
Fabio Estevamf8f21942016-08-25 21:07:20 -030094 printf("Board: WARP7 in %s mode\n", mode);
Bryan O'Donoghue446dddd2018-04-24 18:46:36 +010095#endif
Fabio Estevam6cfa7122016-02-29 09:33:22 -030096
97 return 0;
98}
99
Marco Franchi3d73f522016-06-10 14:45:28 -0300100int board_late_init(void)
101{
102 struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
Tom Riniae21e7f2021-08-30 09:16:29 -0400103#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
Bryan O'Donoghue1936c412018-03-26 15:27:34 +0100104 struct tag_serialnr serialnr;
105 char serial_string[0x20];
106#endif
Marco Franchi3d73f522016-06-10 14:45:28 -0300107
108 imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
109
110 set_wdog_reset(wdog);
111
112 /*
113 * Do not assert internal WDOG_RESET_B_DEB(controlled by bit 4),
114 * since we use PMIC_PWRON to reset the board.
115 */
116 clrsetbits_le16(&wdog->wcr, 0, 0x10);
117
Stefano Babicf8b509b2019-09-20 08:47:53 +0200118#ifdef CONFIG_IMX_HAB
Bryan O'Donoghue1b60ee62018-04-24 18:46:33 +0100119 /* Determine HAB state */
120 env_set_ulong(HAB_ENABLED_ENVNAME, imx_hab_is_enabled());
121#else
122 env_set_ulong(HAB_ENABLED_ENVNAME, 0);
123#endif
124
Tom Riniae21e7f2021-08-30 09:16:29 -0400125#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
Bryan O'Donoghue1936c412018-03-26 15:27:34 +0100126 /* Set serial# standard environment variable based on OTP settings */
127 get_board_serial(&serialnr);
128 snprintf(serial_string, sizeof(serial_string), "WaRP7-0x%08x%08x",
129 serialnr.low, serialnr.high);
130 env_set("serial#", serial_string);
131#endif
132
Marco Franchi3d73f522016-06-10 14:45:28 -0300133 return 0;
134}