From 674afa6b3588dafe02b99406278ed81216fbefcb Mon Sep 17 00:00:00 2001 From: John Keeping Date: Wed, 19 May 2021 15:05:53 +0100 Subject: [PATCH 01/13] spl: use CONFIG_IS_ENABLED(LOAD_FIT_FULL) It's possible that LOAD_FIT_FULL will have different values for TPL and SPL, in which case just checking CONFIG_SPL_LOAD_FIT_FULL causes this to be compiled in to the TPL even though functions and struct members it depends on are not. Use CONFIG_IS_ENABLED() to ensure the correct TPL/SPL variant is checked. Signed-off-by: John Keeping Reviewed-by: Bin Meng Reviewed-by: Simon Glass --- common/spl/spl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 3b96f2fc310..3ec16d0de65 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -200,7 +200,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image) spl_image->name = "U-Boot"; } -#ifdef CONFIG_SPL_LOAD_FIT_FULL +#if CONFIG_IS_ENABLED(LOAD_FIT_FULL) /* Parse and load full fitImage in SPL */ static int spl_load_fit_image(struct spl_image_info *spl_image, const struct image_header *header) @@ -307,7 +307,7 @@ __weak int spl_parse_legacy_header(struct spl_image_info *spl_image, int spl_parse_image_header(struct spl_image_info *spl_image, const struct image_header *header) { -#ifdef CONFIG_SPL_LOAD_FIT_FULL +#if CONFIG_IS_ENABLED(LOAD_FIT_FULL) int ret = spl_load_fit_image(spl_image, header); if (!ret) From 9e6da34c72274578be6f86ba7b7aa7849a624315 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Wed, 19 May 2021 16:27:41 +0200 Subject: [PATCH 02/13] tee: optee: sync cache on pre-reloc OP-TEE invocation This change ensures both U-Boot and OP-TEE see the same content from shared memory when OP-TEE is invoked prior U-Boot relocation. This change is required since U-Boot may execute with data cache off while OP-TEE always enables cache on memory shared with U-Boot. Signed-off-by: Etienne Carriere Reviewed-by: Jens Wiklander Acked-by: Ilias Apalodimas --- drivers/tee/optee/core.c | 21 ++++++++++++++++++++- drivers/tee/tee-uclass.c | 19 ++++++++++++++++++- include/tee.h | 6 ++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index 73dbb22ba09..dad46aa388a 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -1,9 +1,10 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (c) 2018 Linaro Limited + * Copyright (c) 2018-2020 Linaro Limited */ #include +#include #include #include #include @@ -295,6 +296,16 @@ static u32 call_err_to_res(u32 call_err) } } +static void flush_shm_dcache(struct udevice *dev, struct optee_msg_arg *arg) +{ + size_t sz = OPTEE_MSG_GET_ARG_SIZE(arg->num_params); + + flush_dcache_range(rounddown((ulong)arg, CONFIG_SYS_CACHELINE_SIZE), + roundup((ulong)arg + sz, CONFIG_SYS_CACHELINE_SIZE)); + + tee_flush_all_shm_dcache(dev); +} + static u32 do_call_with_arg(struct udevice *dev, struct optee_msg_arg *arg) { struct optee_pdata *pdata = dev_get_plat(dev); @@ -305,9 +316,17 @@ static u32 do_call_with_arg(struct udevice *dev, struct optee_msg_arg *arg) while (true) { struct arm_smccc_res res; + /* If cache are off from U-Boot, sync the cache shared with OP-TEE */ + if (!dcache_status()) + flush_shm_dcache(dev, arg); + pdata->invoke_fn(param.a0, param.a1, param.a2, param.a3, param.a4, param.a5, param.a6, param.a7, &res); + /* If cache are off from U-Boot, sync the cache shared with OP-TEE */ + if (!dcache_status()) + flush_shm_dcache(dev, arg); + free(page_list); page_list = NULL; diff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c index cb1b28e2f83..52412a4098e 100644 --- a/drivers/tee/tee-uclass.c +++ b/drivers/tee/tee-uclass.c @@ -1,15 +1,17 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (c) 2018 Linaro Limited + * Copyright (c) 2018-2020 Linaro Limited */ #define LOG_CATEGORY UCLASS_TEE #include +#include #include #include #include #include +#include #include #include @@ -235,3 +237,18 @@ void tee_optee_ta_uuid_to_octets(u8 d[TEE_UUID_LEN], d[7] = s->time_hi_and_version; memcpy(d + 8, s->clock_seq_and_node, sizeof(s->clock_seq_and_node)); } + +void tee_flush_all_shm_dcache(struct udevice *dev) +{ + struct tee_uclass_priv *priv = dev_get_uclass_priv(dev); + struct tee_shm *s; + + list_for_each_entry(s, &priv->list_shm, link) { + ulong start = rounddown((ulong)s->addr, + CONFIG_SYS_CACHELINE_SIZE); + ulong end = roundup((ulong)s->addr + s->size, + CONFIG_SYS_CACHELINE_SIZE); + + flush_dcache_range(start, end); + } +} diff --git a/include/tee.h b/include/tee.h index 99367b258e2..2ef29bfc8fa 100644 --- a/include/tee.h +++ b/include/tee.h @@ -377,4 +377,10 @@ void tee_optee_ta_uuid_from_octets(struct tee_optee_ta_uuid *d, void tee_optee_ta_uuid_to_octets(u8 d[TEE_UUID_LEN], const struct tee_optee_ta_uuid *s); +/** + * tee_flush_all_shm_dcache() - Flush data cache for all shared memories + * @dev: The TEE device + */ +void tee_flush_all_shm_dcache(struct udevice *dev); + #endif /* __TEE_H */ From 4c60fd993a21a285c645c6d46762d8c2992b7dd7 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 21 May 2021 09:47:31 +0200 Subject: [PATCH 03/13] cmd: pinmux: update result of do_status Update the result of do_status and always returns a CMD_RET_ value (-ENOSYS was a possible result of show_pinmux). This patch also adds pincontrol name in error messages (dev->name) and treats correctly the status sub command when pin-controller device is not selected. Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- cmd/pinmux.c | 31 +++++++++++++++++-------------- include/dm/pinctrl.h | 2 +- test/py/tests/test_pinmux.py | 4 ++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/cmd/pinmux.c b/cmd/pinmux.c index 9942b154196..0df78c71da7 100644 --- a/cmd/pinmux.c +++ b/cmd/pinmux.c @@ -52,20 +52,21 @@ static int show_pinmux(struct udevice *dev) pins_count = pinctrl_get_pins_count(dev); if (pins_count == -ENOSYS) { - printf("Ops get_pins_count not supported\n"); + printf("Ops get_pins_count not supported by %s\n", dev->name); return pins_count; } for (i = 0; i < pins_count; i++) { ret = pinctrl_get_pin_name(dev, i, pin_name, PINNAME_SIZE); - if (ret == -ENOSYS) { - printf("Ops get_pin_name not supported\n"); + if (ret) { + printf("Ops get_pin_name error (%d) by %s\n", ret, dev->name); return ret; } ret = pinctrl_get_pin_muxing(dev, i, pin_mux, PINMUX_SIZE); if (ret) { - printf("Ops get_pin_muxing error (%d)\n", ret); + printf("Ops get_pin_muxing error (%d) by %s in %s\n", + ret, pin_name, dev->name); return ret; } @@ -80,25 +81,27 @@ static int do_status(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; - int ret = CMD_RET_USAGE; - if (currdev && (argc < 2 || strcmp(argv[1], "-a"))) - return show_pinmux(currdev); + if (argc < 2) { + if (!currdev) { + printf("pin-controller device not selected\n"); + return CMD_RET_FAILURE; + } + show_pinmux(currdev); + return CMD_RET_SUCCESS; + } - if (argc < 2 || strcmp(argv[1], "-a")) - return ret; + if (strcmp(argv[1], "-a")) + return CMD_RET_USAGE; uclass_foreach_dev_probe(UCLASS_PINCTRL, dev) { /* insert a separator between each pin-controller display */ printf("--------------------------\n"); printf("%s:\n", dev->name); - ret = show_pinmux(dev); - if (ret < 0) - printf("Can't display pin muxing for %s\n", - dev->name); + show_pinmux(dev); } - return ret; + return CMD_RET_SUCCESS; } static int do_list(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/include/dm/pinctrl.h b/include/dm/pinctrl.h index 1bdc8d3cbd7..695e78ad0de 100644 --- a/include/dm/pinctrl.h +++ b/include/dm/pinctrl.h @@ -587,7 +587,7 @@ int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf, * * This allows to know the number of pins owned by a given pin-controller * - * Return: Number of pins if OK, or negative error code on failure + * Return: Number of pins if OK, or -ENOSYS when not supported */ int pinctrl_get_pins_count(struct udevice *dev); diff --git a/test/py/tests/test_pinmux.py b/test/py/tests/test_pinmux.py index 0cbbae000c8..b3ae2ab0240 100644 --- a/test/py/tests/test_pinmux.py +++ b/test/py/tests/test_pinmux.py @@ -13,9 +13,9 @@ def test_pinmux_usage_1(u_boot_console): @pytest.mark.buildconfigspec('cmd_pinmux') def test_pinmux_usage_2(u_boot_console): """Test that 'pinmux status' executed without previous "pinmux dev" - command displays pinmux usage.""" + command displays error message.""" output = u_boot_console.run_command('pinmux status') - assert 'Usage:' in output + assert 'pin-controller device not selected' in output @pytest.mark.buildconfigspec('cmd_pinmux') @pytest.mark.boardspec('sandbox') From fea0345992fac2a2b2bd20d72b666ce948c9c99b Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 21 May 2021 09:47:32 +0200 Subject: [PATCH 04/13] cmd: pinmux: support pin name in status command Allow pin name parameter for pimux staus command, as gpio command to get status of one pin. The possible usage of the command is: > pinmux dev pinctrl > pinmux status > pinmux status -a > pinmux status Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- cmd/pinmux.c | 46 +++++++++++++++++++++++++++++++++++++--------- test/cmd/Makefile | 1 + test/cmd/pinmux.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 test/cmd/pinmux.c diff --git a/cmd/pinmux.c b/cmd/pinmux.c index 0df78c71da7..2d233575266 100644 --- a/cmd/pinmux.c +++ b/cmd/pinmux.c @@ -41,13 +41,22 @@ static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_SUCCESS; } -static int show_pinmux(struct udevice *dev) +/** + * Print the muxing information for one or all pins of one pinctrl device + * + * @param dev pinctrl device + * @param name NULL to display all the pins + * or name of the pin to display + * @return 0 on success, non-0 on error + */ +static int show_pinmux(struct udevice *dev, char *name) { char pin_name[PINNAME_SIZE]; char pin_mux[PINMUX_SIZE]; int pins_count; int i; int ret; + bool found = false; pins_count = pinctrl_get_pins_count(dev); @@ -62,7 +71,9 @@ static int show_pinmux(struct udevice *dev) printf("Ops get_pin_name error (%d) by %s\n", ret, dev->name); return ret; } - + if (name && strcmp(name, pin_name)) + continue; + found = true; ret = pinctrl_get_pin_muxing(dev, i, pin_mux, PINMUX_SIZE); if (ret) { printf("Ops get_pin_muxing error (%d) by %s in %s\n", @@ -74,6 +85,9 @@ static int show_pinmux(struct udevice *dev) PINMUX_SIZE, pin_mux); } + if (!found) + return -ENOENT; + return 0; } @@ -81,24 +95,38 @@ static int do_status(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; + char *name; + int ret; if (argc < 2) { if (!currdev) { printf("pin-controller device not selected\n"); return CMD_RET_FAILURE; } - show_pinmux(currdev); + show_pinmux(currdev, NULL); return CMD_RET_SUCCESS; } if (strcmp(argv[1], "-a")) - return CMD_RET_USAGE; + name = argv[1]; + else + name = NULL; uclass_foreach_dev_probe(UCLASS_PINCTRL, dev) { - /* insert a separator between each pin-controller display */ - printf("--------------------------\n"); - printf("%s:\n", dev->name); - show_pinmux(dev); + if (!name) { + /* insert a separator between each pin-controller display */ + printf("--------------------------\n"); + printf("%s:\n", dev->name); + } + ret = show_pinmux(dev, name); + /* stop when the status of requested pin is displayed */ + if (name && !ret) + return CMD_RET_SUCCESS; + } + + if (name) { + printf("%s not found\n", name); + return CMD_RET_FAILURE; } return CMD_RET_SUCCESS; @@ -149,5 +177,5 @@ U_BOOT_CMD(pinmux, CONFIG_SYS_MAXARGS, 1, do_pinmux, "show pin-controller muxing", "list - list UCLASS_PINCTRL devices\n" "pinmux dev [pincontroller-name] - select pin-controller device\n" - "pinmux status [-a] - print pin-controller muxing [for all]\n" + "pinmux status [-a | pin-name] - print pin-controller muxing [for all | for pin-name]\n" ) diff --git a/test/cmd/Makefile b/test/cmd/Makefile index 2cfe43a6bd3..a59adb1e6d6 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -8,5 +8,6 @@ endif obj-y += mem.o obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o +obj-$(CONFIG_CMD_PINMUX) += pinmux.o obj-$(CONFIG_CMD_PWM) += pwm.o obj-$(CONFIG_CMD_SETEXPR) += setexpr.o diff --git a/test/cmd/pinmux.c b/test/cmd/pinmux.c new file mode 100644 index 00000000000..8ae807b5377 --- /dev/null +++ b/test/cmd/pinmux.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Executes tests for pinmux command + * + * Copyright (C) 2021, STMicroelectronics - All Rights Reserved + */ + +#include +#include +#include +#include +#include + +static int dm_test_cmd_pinmux_status_pinname(struct unit_test_state *uts) +{ + /* Test that 'pinmux status ' displays the selected pin. */ + console_record_reset(); + run_command("pinmux status a5", 0); + ut_assert_nextline("a5 : gpio input . "); + ut_assert_console_end(); + + console_record_reset(); + run_command("pinmux status P7", 0); + ut_assert_nextline("P7 : GPIO2 bias-pull-down input-enable. "); + ut_assert_console_end(); + + console_record_reset(); + run_command("pinmux status P9", 0); + ut_assert_nextline("single-pinctrl pinctrl-single-no-width: missing register width"); + ut_assert_nextline("P9 not found"); + ut_assert_console_end(); + + return 0; +} + +DM_TEST(dm_test_cmd_pinmux_status_pinname, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); From 0119c910521cd6b089e5c3ec623902caf75b4915 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Mon, 7 Jun 2021 14:26:33 +0200 Subject: [PATCH 05/13] i2c: pcf8575: Remove not used members of pcf8575_chip structure Those members are not used anymore as ones from gpio_dev_priv structure (when DM_GPIO support is enabled) are used instead. Signed-off-by: Lukasz Majewski Reviewed-by: Heiko Schocher --- drivers/gpio/pcf8575_gpio.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpio/pcf8575_gpio.c b/drivers/gpio/pcf8575_gpio.c index 359646266c9..bae9695f28b 100644 --- a/drivers/gpio/pcf8575_gpio.c +++ b/drivers/gpio/pcf8575_gpio.c @@ -34,8 +34,6 @@ DECLARE_GLOBAL_DATA_PTR; struct pcf8575_chip { - int gpio_count; /* No. GPIOs supported by the chip */ - /* NOTE: these chips have strange "quasi-bidirectional" I/O pins. * We can't actually know whether a pin is configured (a) as output * and driving the signal low, or (b) as input and reporting a low @@ -49,7 +47,6 @@ struct pcf8575_chip { * reset state. Otherwise it flags pins to be driven low. */ unsigned int out; /* software latch */ - const char *bank_name; /* Name of the expander bank */ }; /* Read/Write to 16-bit I/O expander */ From 2132fce7e1a56d81d5e5bdbd39b8f6500655c815 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Mon, 7 Jun 2021 14:26:34 +0200 Subject: [PATCH 06/13] i2c: pcf8575: Add support for 8 bit I2C IO expanders (like pca8574) This patch add support for using NXP's pca8574 I2C IO expander, which has only 8 IO lines. After this change the .data member's information from struct udevice_id are used to either sent one or two bytes. Moreover, the '_le16' suffix from pcf8575_i2c_{write|read}_le16() functions have been removed as now we also sent 8 bit data. Signed-off-by: Lukasz Majewski Reviewed-by: Heiko Schocher --- drivers/gpio/pcf8575_gpio.c | 40 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/gpio/pcf8575_gpio.c b/drivers/gpio/pcf8575_gpio.c index bae9695f28b..d5930d941fc 100644 --- a/drivers/gpio/pcf8575_gpio.c +++ b/drivers/gpio/pcf8575_gpio.c @@ -12,15 +12,9 @@ * * Copyright (C) 2007 David Brownell * - */ - -/* - * NOTE: The driver and devicetree bindings are borrowed from Linux - * Kernel, but driver does not support all PCF857x devices. It currently - * supports PCF8575 16-bit expander by TI and NXP. + * Add support for 8 bit expanders - like pca8574 + * Copyright (C) 2021 Lukasz Majewski - DENX Software Engineering * - * TODO(vigneshr@ti.com): - * Support 8 bit PCF857x compatible expanders. */ #include @@ -49,15 +43,15 @@ struct pcf8575_chip { unsigned int out; /* software latch */ }; -/* Read/Write to 16-bit I/O expander */ +/* Read/Write to I/O expander */ -static int pcf8575_i2c_write_le16(struct udevice *dev, unsigned int word) +static int pcf8575_i2c_write(struct udevice *dev, unsigned int word) { struct dm_i2c_chip *chip = dev_get_parent_plat(dev); u8 buf[2] = { word & 0xff, word >> 8, }; int ret; - ret = dm_i2c_write(dev, 0, buf, 2); + ret = dm_i2c_write(dev, 0, buf, dev_get_driver_data(dev)); if (ret) printf("%s i2c write failed to addr %x\n", __func__, chip->chip_addr); @@ -65,13 +59,13 @@ static int pcf8575_i2c_write_le16(struct udevice *dev, unsigned int word) return ret; } -static int pcf8575_i2c_read_le16(struct udevice *dev) +static int pcf8575_i2c_read(struct udevice *dev) { struct dm_i2c_chip *chip = dev_get_parent_plat(dev); - u8 buf[2]; + u8 buf[2] = {0x00, 0x00}; int ret; - ret = dm_i2c_read(dev, 0, buf, 2); + ret = dm_i2c_read(dev, 0, buf, dev_get_driver_data(dev)); if (ret) { printf("%s i2c read failed from addr %x\n", __func__, chip->chip_addr); @@ -87,7 +81,7 @@ static int pcf8575_direction_input(struct udevice *dev, unsigned offset) int status; plat->out |= BIT(offset); - status = pcf8575_i2c_write_le16(dev, plat->out); + status = pcf8575_i2c_write(dev, plat->out); return status; } @@ -103,7 +97,7 @@ static int pcf8575_direction_output(struct udevice *dev, else plat->out &= ~BIT(offset); - ret = pcf8575_i2c_write_le16(dev, plat->out); + ret = pcf8575_i2c_write(dev, plat->out); return ret; } @@ -112,7 +106,7 @@ static int pcf8575_get_value(struct udevice *dev, unsigned int offset) { int value; - value = pcf8575_i2c_read_le16(dev); + value = pcf8575_i2c_read(dev); return (value < 0) ? value : ((value & BIT(offset)) >> offset); } @@ -130,8 +124,11 @@ static int pcf8575_ofdata_plat(struct udevice *dev) int n_latch; - uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "gpio-count", 16); + /* + * Number of pins depends on the expander device and is specified + * in the struct udevice_id (as in the Linue kernel). + */ + uc_priv->gpio_count = dev_get_driver_data(dev) * 8; uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "gpio-bank-name", NULL); if (!uc_priv->bank_name) @@ -163,8 +160,9 @@ static const struct dm_gpio_ops pcf8575_gpio_ops = { }; static const struct udevice_id pcf8575_gpio_ids[] = { - { .compatible = "nxp,pcf8575" }, - { .compatible = "ti,pcf8575" }, + { .compatible = "nxp,pcf8575", .data = 2 }, + { .compatible = "ti,pcf8575", .data = 2 }, + { .compatible = "nxp,pca8574", .data = 1 }, { } }; From 7cb31e399e46a74d1d46e8b64598d86018fa4e0b Mon Sep 17 00:00:00 2001 From: Anders Dellien Date: Tue, 22 Jun 2021 10:40:01 +0100 Subject: [PATCH 07/13] cmd: part: Correct error handling As 'part_get_info_by_name' now returns more status codes than just -1 to indicate failure, we need to update the return value check. Signed-off-by: Anders Dellien Reviewed-by: Sean Anderson --- cmd/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/part.c b/cmd/part.c index 3395c17b892..e0463b5a541 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -140,7 +140,7 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param) return 1; } else { part = part_get_info_by_name(desc, argv[2], &info); - if (part == -1) + if (part < 0) return 1; } From 650bf008e57a98cd6fa89839d48561dfdc5c51e7 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Fri, 25 Jun 2021 17:58:04 +0100 Subject: [PATCH 08/13] fit: Allow external data for FDTs Switch to fit_image_get_data_and_size() for consistency with all other data loaded from FIT. Signed-off-by: John Keeping Reviewed-by: Simon Glass --- common/image-fit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/image-fit.c b/common/image-fit.c index 28bd8e78c75..d6b2c3c7eca 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1777,7 +1777,8 @@ int fit_conf_find_compat(const void *fit, const void *fdt) } /* search in this config's kernel FDT */ - if (fit_image_get_data(fit, kfdt_noffset, &fdt, &sz)) { + if (fit_image_get_data_and_size(fit, kfdt_noffset, + &fdt, &sz)) { debug("Failed to get fdt \"%s\".\n", kfdt_name); continue; } From 55adabbbfc18dbb217f4d9820f0faf00ad8a31c0 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 9 Jul 2021 10:39:21 -0400 Subject: [PATCH 09/13] Kconfig.boot: Make 0x0 the default SYS_TEXT_BASE for POSITION_INDEPENDENT When we build U-Boot with POSITION_INDEPENDENT we must have SYS_TEXT_BASE be set to zero. Make this the default in that case. Signed-off-by: Tom Rini Reviewed-by: Mark Kettenis --- common/Kconfig.boot | 1 + 1 file changed, 1 insertion(+) diff --git a/common/Kconfig.boot b/common/Kconfig.boot index ae3f2b6f62b..b4dc49e0195 100644 --- a/common/Kconfig.boot +++ b/common/Kconfig.boot @@ -358,6 +358,7 @@ config HAVE_SYS_TEXT_BASE config SYS_TEXT_BASE depends on HAVE_SYS_TEXT_BASE + default 0x0 if POSITION_INDEPENDENT default 0x80800000 if ARCH_OMAP2PLUS || ARCH_K3 default 0x4a000000 if ARCH_SUNXI && !MACH_SUN9I && !MACH_SUN8I_V3S default 0x2a000000 if ARCH_SUNXI && MACH_SUN9I From ccadfca251aa83982e01fc6278405a316831c933 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Mon, 12 Jul 2021 00:07:09 +0100 Subject: [PATCH 10/13] distro_boot: Fix block device after DHCP boot sequence The generic distro boot sequence iterates over several types of devices, trying one after another. In doing do, it starts with setting the "devtype" variable, then uses this later in more generic commands. Now most (block) device types use a local variable for that, but DHCP puts the type into the environment, where it shadows any local variables. As a consequence any boot attempt after bootcmd_dhcp has been run fails: =========================== VExpress64# run bootcmd_dhcp ... VExpress64# run bootcmd_sata0 SATA#0: (3.0 Gbps) SATA#1: (No RDY) Device 0: Model: 16GB SATA Flash Drive .... ... is now current device Couldn't find partition dhcp 0:1 =========================== This problem typically doesn't show, because DHCP is mostly the last command to try, but is a problem when this order is different, or when distro_bootcmd or bootcmd_xxx are run separately or multiple times. Let bootcmd_dhcp use a local variable, as the other kids do, to make the order of boot commands irrelevant, and allow repeated calls. Signed-off-by: Andre Przywara Reviewed-by: Simon Glass --- include/config_distro_bootcmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 2627c2a6a54..e70423f25dd 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -375,7 +375,7 @@ #endif #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \ "bootcmd_dhcp=" \ - "setenv devtype " #devtypel "; " \ + "devtype=" #devtypel "; " \ BOOTENV_RUN_NET_USB_START \ BOOTENV_RUN_PCI_ENUM \ "if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \ From d3c1b514dc4774d14150cba9a19de22cc2a37e7a Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Mon, 12 Jul 2021 00:25:15 +0100 Subject: [PATCH 11/13] arm: vexpress64: juno: Enable distro_bootcmd functionality The ARM Juno boards can be used as somewhat decent machines to run off-the-shelf distributions, with USB, SATA, GBit Ethernet and 8GB of DRAM. With stable DTs in the board's NOR flash this would work really nicely, however the default boot command is to fetch a kernel and an initrd from the on-board NOR flash, which sounds somewhat embedded. Include the config_distro_bootcmd.h header and define the available devices (starting with USB, to catch USB installer sticks) to make distributions and UEFI work out of the box. The NOR flash kernel functionality is still preserved as the last resort, should all other methods fail. Signed-off-by: Andre Przywara Reviewed-by: Simon Glass Reviewed-by: Linus Walleij --- include/configs/vexpress_aemv8a.h | 58 ++++++++++++++++++------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h index 7318fb6c585..54b5967a89d 100644 --- a/include/configs/vexpress_aemv8a.h +++ b/include/configs/vexpress_aemv8a.h @@ -126,6 +126,39 @@ /* Initial environment variables */ #ifdef CONFIG_TARGET_VEXPRESS64_JUNO +/* Copy the kernel and FDT to DRAM memory and boot */ +#define BOOTENV_DEV_AFS(devtypeu, devtypel, instance) \ + "bootcmd_afs=" \ + "afs load ${kernel_name} ${kernel_addr_r} ;"\ + "if test $? -eq 1; then "\ + " echo Loading ${kernel_alt_name} instead of ${kernel_name}; "\ + " afs load ${kernel_alt_name} ${kernel_addr_r};"\ + "fi ; "\ + "afs load ${fdtfile} ${fdt_addr_r} ;"\ + "if test $? -eq 1; then "\ + " echo Loading ${fdt_alt_name} instead of ${fdtfile}; "\ + " afs load ${fdt_alt_name} ${fdt_addr_r}; "\ + "fi ; "\ + "fdt addr ${fdt_addr_r}; fdt resize; " \ + "if afs load ${ramdisk_name} ${ramdisk_addr_r} ; "\ + "then "\ + " setenv ramdisk_param ${ramdisk_addr_r}; "\ + "else "\ + " setenv ramdisk_param -; "\ + "fi ; " \ + "booti ${kernel_addr_r} ${ramdisk_param} ${fdt_addr_r}\0" +#define BOOTENV_DEV_NAME_AFS(devtypeu, devtypel, instance) "afs " + +#define BOOT_TARGET_DEVICES(func) \ + func(USB, usb, 0) \ + func(SATA, sata, 0) \ + func(SATA, sata, 1) \ + func(PXE, pxe, na) \ + func(DHCP, dhcp, na) \ + func(AFS, afs, na) + +#include + /* * Defines where the kernel and FDT exist in NOR flash and where it will * be copied into DRAM @@ -139,30 +172,7 @@ "fdtfile=board.dtb\0" \ "fdt_alt_name=juno\0" \ "fdt_addr_r=0x80000000\0" \ - -#ifndef CONFIG_BOOTCOMMAND -/* Copy the kernel and FDT to DRAM memory and boot */ -#define CONFIG_BOOTCOMMAND "afs load ${kernel_name} ${kernel_addr_r} ;"\ - "if test $? -eq 1; then "\ - " echo Loading ${kernel_alt_name} instead of "\ - "${kernel_name}; "\ - " afs load ${kernel_alt_name} ${kernel_addr_r};"\ - "fi ; "\ - "afs load ${fdtfile} ${fdt_addr_r} ;"\ - "if test $? -eq 1; then "\ - " echo Loading ${fdt_alt_name} instead of "\ - "${fdtfile}; "\ - " afs load ${fdt_alt_name} ${fdt_addr_r}; "\ - "fi ; "\ - "fdt addr ${fdt_addr_r}; fdt resize; " \ - "if afs load ${ramdisk_name} ${ramdisk_addr_r} ; "\ - "then "\ - " setenv ramdisk_param ${ramdisk_addr_r}; "\ - " else setenv ramdisk_param -; "\ - "fi ; " \ - "booti ${kernel_addr_r} ${ramdisk_param} ${fdt_addr_r}" -#endif - + BOOTENV #elif CONFIG_TARGET_VEXPRESS64_BASE_FVP #define CONFIG_EXTRA_ENV_SETTINGS \ From 0523326af4e505d837968a5694c99c0ee1d0041c Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Tue, 13 Jul 2021 23:02:18 +0200 Subject: [PATCH 12/13] mux: correct prototype for mux_control_try_select() The macro should be passed a state, which should be passed to the actual function. Otherwise using that macro would yield a build error. Signed-off-by: Patrick Wildt Reviewed-by: Pratyush Yadav --- include/mux.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mux.h b/include/mux.h index 23844f480ac..9f809912742 100644 --- a/include/mux.h +++ b/include/mux.h @@ -51,7 +51,7 @@ unsigned int mux_control_states(struct mux_control *mux); */ int __must_check mux_control_select(struct mux_control *mux, unsigned int state); -#define mux_control_try_select(mux) mux_control_select(mux) +#define mux_control_try_select(mux, state) mux_control_select(mux, state) /** * mux_control_deselect() - Deselect the previously selected multiplexer state. @@ -128,7 +128,7 @@ int __must_check mux_control_select(struct mux_control *mux, return -ENOSYS; } -#define mux_control_try_select(mux) mux_control_select(mux) +#define mux_control_try_select(mux, state) mux_control_select(mux, state) int mux_control_deselect(struct mux_control *mux) { From 988002dcd931e7236422e4d158c397d964ba1360 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 14 Jul 2021 09:12:41 +0200 Subject: [PATCH 13/13] net: remove CONFIG_NET_MULTI (again) CONFIG_NET_MULTI has been removed long time ago by commit 795428fc679f ("net: remove CONFIG_NET_MULTI") but 4 boards were added later which wasn't found. The patch is removing this reference from 4 boards. Signed-off-by: Michal Simek Reviewed-by: Chris Packham --- include/configs/SBx81LIFKW.h | 1 - include/configs/SBx81LIFXCAT.h | 1 - include/configs/ebisu.h | 1 - include/configs/xilinx_versal.h | 1 - 4 files changed, 4 deletions(-) diff --git a/include/configs/SBx81LIFKW.h b/include/configs/SBx81LIFKW.h index eaa6b9246c9..ded494cfa9b 100644 --- a/include/configs/SBx81LIFKW.h +++ b/include/configs/SBx81LIFKW.h @@ -84,7 +84,6 @@ * Ethernet Driver configuration */ #ifdef CONFIG_CMD_NET -#define CONFIG_NET_MULTI /* specify more that one ports available */ #define CONFIG_MVGBE /* Enable kirkwood Gbe Controller Driver */ #define CONFIG_MVGBE_PORTS {1, 0} /* enable a single port */ #define CONFIG_PHY_BASE_ADR 0x01 diff --git a/include/configs/SBx81LIFXCAT.h b/include/configs/SBx81LIFXCAT.h index c0dc3d38c12..06bbd8642e3 100644 --- a/include/configs/SBx81LIFXCAT.h +++ b/include/configs/SBx81LIFXCAT.h @@ -84,7 +84,6 @@ * Ethernet Driver configuration */ #ifdef CONFIG_CMD_NET -#define CONFIG_NET_MULTI /* specify more that one ports available */ #define CONFIG_MVGBE /* Enable kirkwood Gbe Controller Driver */ #define CONFIG_MVGBE_PORTS {1, 0} /* enable a single port */ #define CONFIG_PHY_BASE_ADR 0x01 diff --git a/include/configs/ebisu.h b/include/configs/ebisu.h index 19ec74fb588..48d4c8a9480 100644 --- a/include/configs/ebisu.h +++ b/include/configs/ebisu.h @@ -14,7 +14,6 @@ #include "rcar-gen3-common.h" /* Ethernet RAVB */ -#define CONFIG_NET_MULTI #define CONFIG_BITBANGMII_MULTI /* Generic Timer Definitions (use in assembler source) */ diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h index ebe81968d13..aae128f5ed0 100644 --- a/include/configs/xilinx_versal.h +++ b/include/configs/xilinx_versal.h @@ -53,7 +53,6 @@ /* Ethernet driver */ #if defined(CONFIG_ZYNQ_GEM) -# define CONFIG_NET_MULTI # define CONFIG_SYS_FAULT_ECHO_LINK_DOWN # define PHY_ANEG_TIMEOUT 20000 #endif