blob: 04124d8014ddc4f73a67802c69551d8f54a24a96 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roese6edf27e2016-05-17 15:04:16 +02002/*
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
Stefan Roese6edf27e2016-05-17 15:04:16 +02004 */
5
6#include <common.h>
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +02007#include <dm.h>
Pali Rohárf1000632020-12-21 11:09:10 +01008#include <dm/device-internal.h>
Andre Heiderac81fa02020-09-11 06:35:10 +02009#include <env.h>
Pali Roháre8928992020-12-23 12:21:29 +010010#include <env_internal.h>
Simon Glass1cedca12023-08-21 21:17:01 -060011#include <event.h>
Stefan Roese6edf27e2016-05-17 15:04:16 +020012#include <i2c.h>
Simon Glass97589732020-05-10 11:40:02 -060013#include <init.h>
Pali Rohár71388ee2020-11-25 19:20:10 +010014#include <mmc.h>
Marek Behún56a776e2022-04-27 12:41:48 +020015#include <miiphy.h>
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +020016#include <phy.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060017#include <asm/global_data.h>
Stefan Roese6edf27e2016-05-17 15:04:16 +020018#include <asm/io.h>
19#include <asm/arch/cpu.h>
20#include <asm/arch/soc.h>
Simon Glassdbd79542020-05-10 11:40:11 -060021#include <linux/delay.h>
Stefan Roese6edf27e2016-05-17 15:04:16 +020022
23DECLARE_GLOBAL_DATA_PTR;
24
25/* IO expander I2C device */
26#define I2C_IO_EXP_ADDR 0x22
27#define I2C_IO_CFG_REG_0 0x6
28#define I2C_IO_DATA_OUT_REG_0 0x2
29#define I2C_IO_REG_0_SATA_OFF 2
30#define I2C_IO_REG_0_USB_H_OFF 1
31
Konstantin Porotchkinb65ffc42017-02-16 13:52:32 +020032/* The pin control values are the same for DB and Espressobin */
Konstantin Porotchkincfa88a32017-02-16 13:52:26 +020033#define PINCTRL_NB_REG_VALUE 0x000173fa
34#define PINCTRL_SB_REG_VALUE 0x00007a23
35
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +020036/* Ethernet switch registers */
37/* SMI addresses for multi-chip mode */
38#define MVEBU_PORT_CTRL_SMI_ADDR(p) (16 + (p))
39#define MVEBU_SW_G2_SMI_ADDR (28)
40
41/* Multi-chip mode */
42#define MVEBU_SW_SMI_DATA_REG (1)
43#define MVEBU_SW_SMI_CMD_REG (0)
44 #define SW_SMI_CMD_REG_ADDR_OFF 0
45 #define SW_SMI_CMD_DEV_ADDR_OFF 5
46 #define SW_SMI_CMD_SMI_OP_OFF 10
47 #define SW_SMI_CMD_SMI_MODE_OFF 12
48 #define SW_SMI_CMD_SMI_BUSY_OFF 15
49
50/* Single-chip mode */
51/* Switch Port Registers */
52#define MVEBU_SW_LINK_CTRL_REG (1)
53#define MVEBU_SW_PORT_CTRL_REG (4)
Pali Rohár7325a812020-08-17 16:36:38 +020054#define MVEBU_SW_PORT_BASE_VLAN (6)
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +020055
56/* Global 2 Registers */
57#define MVEBU_G2_SMI_PHY_CMD_REG (24)
58#define MVEBU_G2_SMI_PHY_DATA_REG (25)
59
Andre Heiderac81fa02020-09-11 06:35:10 +020060/*
61 * Memory Controller Registers
62 *
63 * Assembled based on public information:
Pali Rohár5f852242022-01-21 12:01:15 +010064 * https://gitlab.nic.cz/turris/mox-boot-builder/-/blob/v2020.11.26/wtmi/main.c#L332-336
Andre Heiderac81fa02020-09-11 06:35:10 +020065 * https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell/blob/mv_ddr-armada-18.12/drivers/mv_ddr_mc6.h#L309-L332
66 *
67 * And checked against the written register values for the various topologies:
Pali Rohár5f852242022-01-21 12:01:15 +010068 * https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell/blob/master/a3700/mv_ddr_tim.h
Andre Heiderac81fa02020-09-11 06:35:10 +020069 */
70#define A3700_CH0_MC_CTRL2_REG MVEBU_REGISTER(0x002c4)
71#define A3700_MC_CTRL2_SDRAM_TYPE_MASK 0xf
72#define A3700_MC_CTRL2_SDRAM_TYPE_OFFS 4
73#define A3700_MC_CTRL2_SDRAM_TYPE_DDR3 2
74#define A3700_MC_CTRL2_SDRAM_TYPE_DDR4 3
75
Stefan Roese6edf27e2016-05-17 15:04:16 +020076int board_early_init_f(void)
77{
Stefan Roese6edf27e2016-05-17 15:04:16 +020078 return 0;
79}
80
81int board_init(void)
82{
83 /* adress of boot parameters */
Tom Rinibb4dd962022-11-16 13:10:37 -050084 gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
Stefan Roese6edf27e2016-05-17 15:04:16 +020085
86 return 0;
87}
Andre Heiderac81fa02020-09-11 06:35:10 +020088
89#ifdef CONFIG_BOARD_LATE_INIT
90int board_late_init(void)
91{
Marek Behún73d25342021-10-22 15:47:24 +020092 char *ptr = &default_environment[0];
Pali Rohárf1000632020-12-21 11:09:10 +010093 struct udevice *dev;
Pali Rohár71388ee2020-11-25 19:20:10 +010094 struct mmc *mmc_dev;
Andre Heiderac81fa02020-09-11 06:35:10 +020095 bool ddr4, emmc;
Pali Rohár88d349a2020-12-23 12:21:30 +010096 const char *mac;
97 char eth[10];
98 int i;
Andre Heiderac81fa02020-09-11 06:35:10 +020099
Andre Heider3d33c1d2020-10-02 07:51:12 +0200100 if (!of_machine_is_compatible("globalscale,espressobin"))
Andre Heiderac81fa02020-09-11 06:35:10 +0200101 return 0;
102
Derek LaHousse0bf72a92022-12-12 07:34:17 +0100103 /*
104 * Find free space for new variables in default_environment[] array.
105 * Free space is after the last variable, each variable is termined
106 * by nul byte and after the last variable is additional nul byte.
107 * Move ptr to the position where new variable can be filled.
108 */
109 while (*ptr != '\0') {
110 do { ptr++; } while (*ptr != '\0');
111 ptr++;
112 }
Pali Roháre8928992020-12-23 12:21:29 +0100113
Pali Rohár88d349a2020-12-23 12:21:30 +0100114 /*
115 * Ensure that 'env default -a' does not erase permanent MAC addresses
116 * stored in env variables: $ethaddr, $eth1addr, $eth2addr and $eth3addr
117 */
118
119 mac = env_get("ethaddr");
120 if (mac && strlen(mac) <= 17)
121 ptr += sprintf(ptr, "ethaddr=%s", mac) + 1;
122
123 for (i = 1; i <= 3; i++) {
124 sprintf(eth, "eth%daddr", i);
125 mac = env_get(eth);
126 if (mac && strlen(mac) <= 17)
127 ptr += sprintf(ptr, "%s=%s", eth, mac) + 1;
128 }
129
Andre Heiderac81fa02020-09-11 06:35:10 +0200130 /* If the memory controller has been configured for DDR4, we're running on v7 */
131 ddr4 = ((readl(A3700_CH0_MC_CTRL2_REG) >> A3700_MC_CTRL2_SDRAM_TYPE_OFFS)
132 & A3700_MC_CTRL2_SDRAM_TYPE_MASK) == A3700_MC_CTRL2_SDRAM_TYPE_DDR4;
133
Pali Rohár71388ee2020-11-25 19:20:10 +0100134 /* eMMC is mmc dev num 1 */
135 mmc_dev = find_mmc_device(1);
Pali Rohár7c639622021-07-14 16:37:29 +0200136 emmc = (mmc_dev && mmc_get_op_cond(mmc_dev, true) == 0);
Andre Heiderac81fa02020-09-11 06:35:10 +0200137
Pali Rohárf1000632020-12-21 11:09:10 +0100138 /* if eMMC is not present then remove it from DM */
139 if (!emmc && mmc_dev) {
140 dev = mmc_dev->dev;
141 device_remove(dev, DM_REMOVE_NORMAL);
142 device_unbind(dev);
Pali Rohárf71edd42022-08-27 14:00:51 +0200143 if (of_live_active())
144 ofnode_set_enabled(dev_ofnode(dev), false);
Pali Rohárf1000632020-12-21 11:09:10 +0100145 }
146
Pali Roháre8928992020-12-23 12:21:29 +0100147 /* Ensure that 'env default -a' set correct value to $fdtfile */
Andre Heiderac81fa02020-09-11 06:35:10 +0200148 if (ddr4 && emmc)
Pali Roháre8928992020-12-23 12:21:29 +0100149 strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin-v7-emmc.dtb");
Andre Heiderac81fa02020-09-11 06:35:10 +0200150 else if (ddr4)
Pali Roháre8928992020-12-23 12:21:29 +0100151 strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin-v7.dtb");
Andre Heiderac81fa02020-09-11 06:35:10 +0200152 else if (emmc)
Pali Roháre8928992020-12-23 12:21:29 +0100153 strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin-emmc.dtb");
Andre Heiderac81fa02020-09-11 06:35:10 +0200154 else
Pali Roháre8928992020-12-23 12:21:29 +0100155 strcpy(ptr, "fdtfile=marvell/armada-3720-espressobin.dtb");
Derek LaHousse0bf72a92022-12-12 07:34:17 +0100156 ptr += strlen(ptr) + 1;
157
158 /*
159 * After the last variable (which is nul term string) append another nul
160 * byte which terminates the list. So everything after ptr is ignored.
161 */
162 *ptr = '\0';
Pali Roháre8928992020-12-23 12:21:29 +0100163
Andre Heiderac81fa02020-09-11 06:35:10 +0200164 return 0;
165}
166#endif
Stefan Roese6edf27e2016-05-17 15:04:16 +0200167
168/* Board specific AHCI / SATA enable code */
169int board_ahci_enable(void)
170{
171 struct udevice *dev;
172 int ret;
173 u8 buf[8];
174
Konstantin Porotchkinb65ffc42017-02-16 13:52:32 +0200175 /* Only DB requres this configuration */
176 if (!of_machine_is_compatible("marvell,armada-3720-db"))
177 return 0;
178
Stefan Roese6edf27e2016-05-17 15:04:16 +0200179 /* Configure IO exander PCA9555: 7bit address 0x22 */
180 ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
181 if (ret) {
182 printf("Cannot find PCA9555: %d\n", ret);
183 return 0;
184 }
185
186 ret = dm_i2c_read(dev, I2C_IO_CFG_REG_0, buf, 1);
187 if (ret) {
188 printf("Failed to read IO expander value via I2C\n");
189 return -EIO;
190 }
191
192 /*
193 * Enable SATA power via IO expander connected via I2C by setting
194 * the corresponding bit to output mode to enable power for SATA
195 */
196 buf[0] &= ~(1 << I2C_IO_REG_0_SATA_OFF);
197 ret = dm_i2c_write(dev, I2C_IO_CFG_REG_0, buf, 1);
198 if (ret) {
199 printf("Failed to set IO expander via I2C\n");
200 return -EIO;
201 }
202
203 return 0;
204}
205
206/* Board specific xHCI enable code */
Jon Nettletona81f47c2017-11-06 10:33:19 +0200207int board_xhci_enable(fdt_addr_t base)
Stefan Roese6edf27e2016-05-17 15:04:16 +0200208{
209 struct udevice *dev;
210 int ret;
211 u8 buf[8];
212
Konstantin Porotchkinb65ffc42017-02-16 13:52:32 +0200213 /* Only DB requres this configuration */
214 if (!of_machine_is_compatible("marvell,armada-3720-db"))
215 return 0;
216
Stefan Roese6edf27e2016-05-17 15:04:16 +0200217 /* Configure IO exander PCA9555: 7bit address 0x22 */
218 ret = i2c_get_chip_for_busnum(0, I2C_IO_EXP_ADDR, 1, &dev);
219 if (ret) {
220 printf("Cannot find PCA9555: %d\n", ret);
221 return 0;
222 }
223
224 printf("Enable USB VBUS\n");
225
226 /*
227 * Read configuration (direction) and set VBUS pin as output
228 * (reset pin = output)
229 */
230 ret = dm_i2c_read(dev, I2C_IO_CFG_REG_0, buf, 1);
231 if (ret) {
232 printf("Failed to read IO expander value via I2C\n");
233 return -EIO;
234 }
235 buf[0] &= ~(1 << I2C_IO_REG_0_USB_H_OFF);
236 ret = dm_i2c_write(dev, I2C_IO_CFG_REG_0, buf, 1);
237 if (ret) {
238 printf("Failed to set IO expander via I2C\n");
239 return -EIO;
240 }
241
242 /* Read VBUS output value and disable it */
243 ret = dm_i2c_read(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
244 if (ret) {
245 printf("Failed to read IO expander value via I2C\n");
246 return -EIO;
247 }
248 buf[0] &= ~(1 << I2C_IO_REG_0_USB_H_OFF);
249 ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
250 if (ret) {
251 printf("Failed to set IO expander via I2C\n");
252 return -EIO;
253 }
254
255 /*
256 * Required delay for configuration to settle - must wait for
257 * power on port is disabled in case VBUS signal was high,
258 * required 3 seconds delay to let VBUS signal fully settle down
259 */
260 mdelay(3000);
261
262 /* Enable VBUS power: Set output value of VBUS pin as enabled */
263 buf[0] |= (1 << I2C_IO_REG_0_USB_H_OFF);
264 ret = dm_i2c_write(dev, I2C_IO_DATA_OUT_REG_0, buf, 1);
265 if (ret) {
266 printf("Failed to set IO expander via I2C\n");
267 return -EIO;
268 }
269
270 mdelay(500); /* required delay to let output value settle */
271
272 return 0;
273}
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200274
Marek Behún56a776e2022-04-27 12:41:48 +0200275#ifdef CONFIG_LAST_STAGE_INIT
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200276/* Helper function for accessing switch devices in multi-chip connection mode */
Marek Behún56a776e2022-04-27 12:41:48 +0200277static int mii_multi_chip_mode_write(struct udevice *bus, int dev_smi_addr,
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200278 int smi_addr, int reg, u16 value)
279{
280 u16 smi_cmd = 0;
281
Marek Behún56a776e2022-04-27 12:41:48 +0200282 if (dm_mdio_write(bus, dev_smi_addr, MDIO_DEVAD_NONE,
283 MVEBU_SW_SMI_DATA_REG, value) != 0) {
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200284 printf("Error writing to the PHY addr=%02x reg=%02x\n",
285 smi_addr, reg);
286 return -EFAULT;
287 }
288
289 smi_cmd = (1 << SW_SMI_CMD_SMI_BUSY_OFF) |
290 (1 << SW_SMI_CMD_SMI_MODE_OFF) |
291 (1 << SW_SMI_CMD_SMI_OP_OFF) |
292 (smi_addr << SW_SMI_CMD_DEV_ADDR_OFF) |
293 (reg << SW_SMI_CMD_REG_ADDR_OFF);
Marek Behún56a776e2022-04-27 12:41:48 +0200294 if (dm_mdio_write(bus, dev_smi_addr, MDIO_DEVAD_NONE,
295 MVEBU_SW_SMI_CMD_REG, smi_cmd) != 0) {
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200296 printf("Error writing to the PHY addr=%02x reg=%02x\n",
297 smi_addr, reg);
298 return -EFAULT;
299 }
300
301 return 0;
302}
303
304/* Bring-up board-specific network stuff */
Simon Glass1cedca12023-08-21 21:17:01 -0600305static int last_stage_init(void)
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200306{
Marek Behún56a776e2022-04-27 12:41:48 +0200307 struct udevice *bus;
308 ofnode node;
309
Simon Glassaadec122023-09-20 07:29:51 -0600310 if (!CONFIG_IS_ENABLED(DM_MDIO) ||
311 !of_machine_is_compatible("globalscale,espressobin"))
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200312 return 0;
313
Marek Behún56a776e2022-04-27 12:41:48 +0200314 node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
315 if (!ofnode_valid(node) ||
316 uclass_get_device_by_ofnode(UCLASS_MDIO, node, &bus) ||
317 device_probe(bus)) {
318 printf("Cannot find MDIO bus\n");
319 return 0;
320 }
321
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200322 /*
323 * FIXME: remove this code once Topaz driver gets available
324 * A3720 Community Board Only
325 * Configure Topaz switch (88E6341)
Pali Rohár7325a812020-08-17 16:36:38 +0200326 * Restrict output to ports 1,2,3 only from port 0 (CPU)
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200327 * Set port 0,1,2,3 to forwarding Mode (through Switch Port registers)
328 */
Pali Rohár7325a812020-08-17 16:36:38 +0200329 mii_multi_chip_mode_write(bus, 1, MVEBU_PORT_CTRL_SMI_ADDR(1),
330 MVEBU_SW_PORT_BASE_VLAN, BIT(0));
331 mii_multi_chip_mode_write(bus, 1, MVEBU_PORT_CTRL_SMI_ADDR(2),
332 MVEBU_SW_PORT_BASE_VLAN, BIT(0));
333 mii_multi_chip_mode_write(bus, 1, MVEBU_PORT_CTRL_SMI_ADDR(3),
334 MVEBU_SW_PORT_BASE_VLAN, BIT(0));
335
Konstantin Porotchkinf4d32b42017-02-16 13:52:29 +0200336 mii_multi_chip_mode_write(bus, 1, MVEBU_PORT_CTRL_SMI_ADDR(0),
337 MVEBU_SW_PORT_CTRL_REG, 0x7f);
338 mii_multi_chip_mode_write(bus, 1, MVEBU_PORT_CTRL_SMI_ADDR(1),
339 MVEBU_SW_PORT_CTRL_REG, 0x7f);
340 mii_multi_chip_mode_write(bus, 1, MVEBU_PORT_CTRL_SMI_ADDR(2),
341 MVEBU_SW_PORT_CTRL_REG, 0x7f);
342 mii_multi_chip_mode_write(bus, 1, MVEBU_PORT_CTRL_SMI_ADDR(3),
343 MVEBU_SW_PORT_CTRL_REG, 0x7f);
344
345 /* RGMII Delay on Port 0 (CPU port), force link to 1000Mbps */
346 mii_multi_chip_mode_write(bus, 1, MVEBU_PORT_CTRL_SMI_ADDR(0),
347 MVEBU_SW_LINK_CTRL_REG, 0xe002);
348
349 /* Power up PHY 1, 2, 3 (through Global 2 registers) */
350 mii_multi_chip_mode_write(bus, 1, MVEBU_SW_G2_SMI_ADDR,
351 MVEBU_G2_SMI_PHY_DATA_REG, 0x1140);
352 mii_multi_chip_mode_write(bus, 1, MVEBU_SW_G2_SMI_ADDR,
353 MVEBU_G2_SMI_PHY_CMD_REG, 0x9620);
354 mii_multi_chip_mode_write(bus, 1, MVEBU_SW_G2_SMI_ADDR,
355 MVEBU_G2_SMI_PHY_CMD_REG, 0x9640);
356 mii_multi_chip_mode_write(bus, 1, MVEBU_SW_G2_SMI_ADDR,
357 MVEBU_G2_SMI_PHY_CMD_REG, 0x9660);
358
359 return 0;
360}
Simon Glass1cedca12023-08-21 21:17:01 -0600361EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
362
Marek Behún56a776e2022-04-27 12:41:48 +0200363#endif
Pali Rohárcb00c182020-08-19 16:24:17 +0200364
Rogier Stame0e10d42022-02-09 00:27:00 +0100365#ifdef CONFIG_OF_BOARD_SETUP
Pali Rohárcb00c182020-08-19 16:24:17 +0200366int ft_board_setup(void *blob, struct bd_info *bd)
367{
Rogier Stame0e10d42022-02-09 00:27:00 +0100368#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
Pali Rohárcb00c182020-08-19 16:24:17 +0200369 int ret;
370 int spi_off;
371 int parts_off;
372 int part_off;
373
374 /* Fill SPI MTD partitions for Linux kernel on Espressobin */
Andre Heider3d33c1d2020-10-02 07:51:12 +0200375 if (!of_machine_is_compatible("globalscale,espressobin"))
Pali Rohárcb00c182020-08-19 16:24:17 +0200376 return 0;
377
378 spi_off = fdt_node_offset_by_compatible(blob, -1, "jedec,spi-nor");
379 if (spi_off < 0)
380 return 0;
381
382 /* Do not touch partitions if they are already defined */
383 if (fdt_subnode_offset(blob, spi_off, "partitions") >= 0)
384 return 0;
385
386 parts_off = fdt_add_subnode(blob, spi_off, "partitions");
387 if (parts_off < 0) {
388 printf("Can't add partitions node: %s\n", fdt_strerror(parts_off));
389 return 0;
390 }
391
392 ret = fdt_setprop_string(blob, parts_off, "compatible", "fixed-partitions");
393 if (ret < 0) {
394 printf("Can't set compatible property: %s\n", fdt_strerror(ret));
395 return 0;
396 }
397
398 ret = fdt_setprop_u32(blob, parts_off, "#address-cells", 1);
399 if (ret < 0) {
400 printf("Can't set #address-cells property: %s\n", fdt_strerror(ret));
401 return 0;
402 }
403
404 ret = fdt_setprop_u32(blob, parts_off, "#size-cells", 1);
405 if (ret < 0) {
406 printf("Can't set #size-cells property: %s\n", fdt_strerror(ret));
407 return 0;
408 }
409
410 /* Add u-boot-env partition */
411
412 part_off = fdt_add_subnode(blob, parts_off, "partition@u-boot-env");
413 if (part_off < 0) {
414 printf("Can't add partition@u-boot-env node: %s\n", fdt_strerror(part_off));
415 return 0;
416 }
417
418 ret = fdt_setprop_u32(blob, part_off, "reg", CONFIG_ENV_OFFSET);
419 if (ret < 0) {
420 printf("Can't set partition@u-boot-env reg property: %s\n", fdt_strerror(ret));
421 return 0;
422 }
423
424 ret = fdt_appendprop_u32(blob, part_off, "reg", CONFIG_ENV_SIZE);
425 if (ret < 0) {
426 printf("Can't set partition@u-boot-env reg property: %s\n", fdt_strerror(ret));
427 return 0;
428 }
429
430 ret = fdt_setprop_string(blob, part_off, "label", "u-boot-env");
431 if (ret < 0) {
432 printf("Can't set partition@u-boot-env label property: %s\n", fdt_strerror(ret));
433 return 0;
434 }
435
436 /* Add firmware partition */
437
438 part_off = fdt_add_subnode(blob, parts_off, "partition@firmware");
439 if (part_off < 0) {
440 printf("Can't add partition@firmware node: %s\n", fdt_strerror(part_off));
441 return 0;
442 }
443
444 ret = fdt_setprop_u32(blob, part_off, "reg", 0);
445 if (ret < 0) {
446 printf("Can't set partition@firmware reg property: %s\n", fdt_strerror(ret));
447 return 0;
448 }
449
450 ret = fdt_appendprop_u32(blob, part_off, "reg", CONFIG_ENV_OFFSET);
451 if (ret < 0) {
452 printf("Can't set partition@firmware reg property: %s\n", fdt_strerror(ret));
453 return 0;
454 }
455
456 ret = fdt_setprop_string(blob, part_off, "label", "firmware");
457 if (ret < 0) {
458 printf("Can't set partition@firmware label property: %s\n", fdt_strerror(ret));
459 return 0;
460 }
461
Rogier Stame0e10d42022-02-09 00:27:00 +0100462#endif
Pali Rohárcb00c182020-08-19 16:24:17 +0200463 return 0;
464}
465#endif