From ae6b33dcc342e8539f4f69aba238748e9e89280a Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 25 Jul 2020 21:38:49 +0200 Subject: [PATCH 01/17] dm: fix ofnode_read_addr/size_cells() In the case of the live tree ofnode_read_addr_cells() and ofnode_read_size_cells() return the #address-cells and #size-cells defined in the parent node. With the patch the same is done for a non-live tree. The only consumer of these functions is currently the CFI flash driver. This patch fixes the incorrect parsing of the device tree leading to 'saveenv' failing on qemu_arm64_defconfig. For testing qemu-system-aarch64 has to be called with -drive if=pflash,format=raw,index=1,file=envstore.img to provide the flash memory. envstore.img must be 64 MiB large. Signed-off-by: Heinrich Schuchardt Reviewed-by: Stefan Roese --- drivers/core/ofnode.c | 20 ++++++++++++++------ include/dm/read.h | 10 ++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index c37afa1fe6f..d02d8d33fef 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -776,18 +776,26 @@ int ofnode_read_pci_vendev(ofnode node, u16 *vendor, u16 *device) int ofnode_read_addr_cells(ofnode node) { - if (ofnode_is_np(node)) + if (ofnode_is_np(node)) { return of_n_addr_cells(ofnode_to_np(node)); - else /* NOTE: this call should walk up the parent stack */ - return fdt_address_cells(gd->fdt_blob, ofnode_to_offset(node)); + } else { + int parent = fdt_parent_offset(gd->fdt_blob, + ofnode_to_offset(node)); + + return fdt_address_cells(gd->fdt_blob, parent); + } } int ofnode_read_size_cells(ofnode node) { - if (ofnode_is_np(node)) + if (ofnode_is_np(node)) { return of_n_size_cells(ofnode_to_np(node)); - else /* NOTE: this call should walk up the parent stack */ - return fdt_size_cells(gd->fdt_blob, ofnode_to_offset(node)); + } else { + int parent = fdt_parent_offset(gd->fdt_blob, + ofnode_to_offset(node)); + + return fdt_size_cells(gd->fdt_blob, parent); + } } int ofnode_read_simple_addr_cells(ofnode node) diff --git a/include/dm/read.h b/include/dm/read.h index 487ec9e9c93..cac7dd5f187 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -878,14 +878,16 @@ static inline int dev_count_phandle_with_args(const struct udevice *dev, static inline int dev_read_addr_cells(const struct udevice *dev) { - /* NOTE: this call should walk up the parent stack */ - return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev)); + int parent = fdt_parent_offset(gd->fdt_blob, dev_of_offset(dev)); + + return fdt_address_cells(gd->fdt_blob, parent); } static inline int dev_read_size_cells(const struct udevice *dev) { - /* NOTE: this call should walk up the parent stack */ - return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev)); + int parent = fdt_parent_offset(gd->fdt_blob, dev_of_offset(dev)); + + return fdt_size_cells(gd->fdt_blob, parent); } static inline int dev_read_simple_addr_cells(const struct udevice *dev) From 84f8e36f03fafa7e2e2ff822db90fefa6bd5f350 Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Tue, 28 Jul 2020 09:13:31 +0200 Subject: [PATCH 02/17] cmd: bind: allow to bind driver with driver data Initial implementation invokes device_bind_with_driver_data() with driver_data parameter equal to 0. For driver with driver data, the bind command can't bind correctly this driver or even worse causes data abort as shown below: As example, for debug purpose on STM32MP1 platform, ethernet (dwc_eth_qos.c) driver needed to be unbinded/binded. This driver is using driver data: static const struct udevice_id eqos_ids[] = { { .compatible = "nvidia,tegra186-eqos", .data = (ulong)&eqos_tegra186_config }, { .compatible = "snps,dwmac-4.20a", .data = (ulong)&eqos_stm32_config }, { } }; After unbinding/binding this driver and probing it (with the dhcp command), we got a prefetch abort as below: STM32MP> unbind eth ethernet@5800a000 STM32MP> bind /soc/ethernet@5800a000 eth_eqos STM32MP> dhcp prefetch abort pc : [<4310801c>] lr : [] reloc pc : [<035ba01c>] lr : [] sp : fdaf19b0 ip : ffcea83c fp : 00000001 r10: ffcfd4a0 r9 : fdaffed0 r8 : 00000000 r7 : ffcff304 r6 : fdc63220 r5 : 00000000 r4 : fdc5b108 r3 : 43108020 r2 : 00003d39 r1 : ffcea544 r0 : fdc63220 Flags: nZCv IRQs off FIQs off Mode SVC_32 Code: data abort pc : [] lr : [] reloc pc : [] lr : [] sp : fdaf18b8 ip : 00000000 fp : 00000001 r10: ffcd69b2 r9 : fdaffed0 r8 : ffcd69aa r7 : 00000000 r6 : 00000008 r5 : 4310801c r4 : fffffffc r3 : 00000001 r2 : 00000028 r1 : 00000000 r0 : 00000006 Flags: NzCv IRQs on FIQs on Mode SVC_32 (T) Code: 2f00 d1e9 2c00 dce9 (f855) 2024 Resetting CPU ... Signed-off-by: Patrice Chotard Cc: Jean-Jacques Hiblot Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- cmd/bind.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/bind.c b/cmd/bind.c index 068b1399ab1..af2f22cc4c3 100644 --- a/cmd/bind.c +++ b/cmd/bind.c @@ -8,6 +8,7 @@ #include #include #include +#include #include static int bind_by_class_index(const char *uclass, int index, @@ -151,8 +152,8 @@ static int bind_by_node_path(const char *path, const char *drv_name) } ofnode = ofnode_path(path); - ret = device_bind_with_driver_data(parent, drv, ofnode_get_name(ofnode), - 0, ofnode, &dev); + ret = lists_bind_fdt(parent, ofnode, &dev, false); + if (!dev || ret) { printf("Unable to bind. err:%d\n", ret); return ret; From cfa3ed4390c158b527bdb2ceceacf7eabae1b01e Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Tue, 28 Jul 2020 09:13:32 +0200 Subject: [PATCH 03/17] sandbox: phy: add driver_data for bind test cmd Add driver data to existing compatible string "sandbox,phy". Add an additional compatible string without driver_data This will verify that bind command parses, finds and passes the correct driver data to device_bind_with_driver_data() by using driver_data in the second sandbox_phy_ids table entry. In sandbox_phy_bind() a check is added to validate driver_data content. Signed-off-by: Patrice Chotard Reviewed-by: Simon Glass --- drivers/phy/sandbox-phy.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/phy/sandbox-phy.c b/drivers/phy/sandbox-phy.c index 84ff5c6275b..5f36da7692b 100644 --- a/drivers/phy/sandbox-phy.c +++ b/drivers/phy/sandbox-phy.c @@ -8,6 +8,8 @@ #include #include +#define DRIVER_DATA 0x12345678 + struct sandbox_phy_priv { bool initialized; bool on; @@ -71,6 +73,14 @@ static int sandbox_phy_exit(struct phy *phy) return 0; } +static int sandbox_phy_bind(struct udevice *dev) +{ + if (dev_get_driver_data(dev) != DRIVER_DATA) + return -ENODATA; + + return 0; +} + static int sandbox_phy_probe(struct udevice *dev) { struct sandbox_phy_priv *priv = dev_get_priv(dev); @@ -90,13 +100,19 @@ static struct phy_ops sandbox_phy_ops = { }; static const struct udevice_id sandbox_phy_ids[] = { - { .compatible = "sandbox,phy" }, + { .compatible = "sandbox,phy_no_driver_data", + }, + + { .compatible = "sandbox,phy", + .data = DRIVER_DATA + }, { } }; U_BOOT_DRIVER(phy_sandbox) = { .name = "phy_sandbox", .id = UCLASS_PHY, + .bind = sandbox_phy_bind, .of_match = sandbox_phy_ids, .ops = &sandbox_phy_ops, .probe = sandbox_phy_probe, From 1f0d5885dbbd669400e5d8cfdb3998c7945e0a7a Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Tue, 28 Jul 2020 09:13:33 +0200 Subject: [PATCH 04/17] sandbox: dts: Add compatible string for bind-test node Usage of lists_bind_fdt() in bind command imposes to add a compatible string for bind-test node. Others impacts are: - bind-test node is binded at sandbox start, so no need to bind it in test_bind_unbind_with_node() test. - As explained just above, after sandbox start, now a phy exist. In test/dm/phy.c, it was verified that a third phy didn't exist, now we must verified that a fourth phy doesn't exist. Signed-off-by: Patrice Chotard Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 1 + test/dm/phy.c | 2 +- test/py/tests/test_bind.py | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 692c3775dde..1d8956abbeb 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -149,6 +149,7 @@ }; bind-test { + compatible = "simple-bus"; bind-test-child1 { compatible = "sandbox,phy"; #phy-cells = <1>; diff --git a/test/dm/phy.c b/test/dm/phy.c index 75d05a14c03..ecbd47bf12f 100644 --- a/test/dm/phy.c +++ b/test/dm/phy.c @@ -47,7 +47,7 @@ static int dm_test_phy_base(struct unit_test_state *uts) ut_assert(phy2.dev != phy3.dev); /* Try to get a non-existing phy */ - ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PHY, 3, &dev)); + ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PHY, 4, &dev)); ut_asserteq(-ENODATA, generic_phy_get_by_name(parent, "phy_not_existing", &phy1_method1)); diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py index e9681c69c54..1de125ce459 100644 --- a/test/py/tests/test_bind.py +++ b/test/py/tests/test_bind.py @@ -25,9 +25,6 @@ def in_tree(response, name, uclass, drv, depth, last_child): @pytest.mark.buildconfigspec('cmd_bind') def test_bind_unbind_with_node(u_boot_console): - #bind /bind-test. Device should come up as well as its children - response = u_boot_console.run_command('bind /bind-test simple_bus') - assert response == '' tree = u_boot_console.run_command('dm tree') assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True) assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, False) From e37d4c4fd2c8b3db43faa4e36641b72a2c0ea69f Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Tue, 28 Jul 2020 09:13:34 +0200 Subject: [PATCH 05/17] test/py: Update test_bind As bind-test is now binded at sandbox startup and no more by test_bind.py, bind-test nodes are not located at the end of "dm tree" output, but can be located everywhere in the tree, so bind-test output could either be: simple_bus 0 [ ] generic_simple_bus |-- bind-test phy 0 [ ] phy_sandbox | |-- bind-test-child1 simple_bus 1 [ ] generic_simple_bus | `-- bind-test-child2 or: simple_bus 5 [ ] generic_simple_bus `-- bind-test phy 2 [ ] phy_sandbox |-- bind-test-child1 simple_bus 6 [ ] generic_simple_bus `-- bind-test-child2 in_tree() function need to be updated to take care of that change. Signed-off-by: Patrice Chotard Reviewed-by: Simon Glass --- test/py/tests/test_bind.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py index 1de125ce459..5e73d403618 100644 --- a/test/py/tests/test_bind.py +++ b/test/py/tests/test_bind.py @@ -7,13 +7,16 @@ import re def in_tree(response, name, uclass, drv, depth, last_child): lines = [x.strip() for x in response.splitlines()] - leaf = ' ' * 4 * depth; - if not last_child: - leaf = leaf + r'\|' - else: - leaf = leaf + '`' + leaf = '' + if depth != 0: + leaf = ' ' + ' ' * (depth - 1) ; + if not last_child: + leaf = leaf + r'\|' + else: + leaf = leaf + '`' + leaf = leaf + '-- ' + name - line = (r' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$' + line = (r' *{:10.10} [0-9]* \[ [ +] \] {:20.20} [` |]{}$' .format(uclass, drv, leaf)) prog = re.compile(line) for l in lines: From 02291d83fdaaf30e355eb7cef05581ec086962bd Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Tue, 28 Jul 2020 09:13:35 +0200 Subject: [PATCH 06/17] doc: add bind/unbind command documentation Add documentation in doc/drivel-model for the bind/unbind command. Part of this documentation is extracted from original patch commit message: commit 49c752c93a78 ("cmd: Add bind/unbind commands to bind a device to a driver from the command line") Signed-off-by: Patrice Chotard Reviewed-by: Simon Glass --- doc/driver-model/bind.rst | 49 ++++++++++++++++++++++++++++++++++++++ doc/driver-model/index.rst | 1 + 2 files changed, 50 insertions(+) create mode 100644 doc/driver-model/bind.rst diff --git a/doc/driver-model/bind.rst b/doc/driver-model/bind.rst new file mode 100644 index 00000000000..e3e9cb4d3c5 --- /dev/null +++ b/doc/driver-model/bind.rst @@ -0,0 +1,49 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. sectionauthor:: Patrice Chotard + +Binding/unbinding a driver +========================== + +This document aims to describe the bind and unbind commands. + +For debugging purpose, it should be useful to bind or unbind a driver from +the U-boot command line. + +The unbind command calls the remove device driver callback and unbind the +device from its driver. + +The bind command binds a device to its driver. + +In some cases it can be useful to be able to bind a device to a driver from +the command line. +The obvious example is for versatile devices such as USB gadget. +Another use case is when the devices are not yet ready at startup and +require some setup before the drivers are bound (ex: FPGA which bitsream is +fetched from a mass storage or ethernet) + +usage: + +bind +bind + +unbind +unbind +unbind + +Where: + - is the node's device tree path + - is one of the class available in the list given by the "dm uclass" + command or first column of "dm tree" command. + - is the index of the parent's node (second column of "dm tree" output). + - is the driver name to bind given by the "dm drivers" command or the by + the fourth column of "dm tree" output. + +example: + +bind usb_dev_generic 0 usb_ether +unbind usb_dev_generic 0 usb_ether +or +unbind eth 1 + +bind /ocp/omap_dwc3@48380000/usb@48390000 usb_ether +unbind /ocp/omap_dwc3@48380000/usb@48390000 diff --git a/doc/driver-model/index.rst b/doc/driver-model/index.rst index f17c72ce69d..c9faf0a5910 100644 --- a/doc/driver-model/index.rst +++ b/doc/driver-model/index.rst @@ -6,6 +6,7 @@ Driver Model .. toctree:: :maxdepth: 2 + bind debugging design ethernet From 3fe69d3764c3ca6f304c51faa6aae7a84f1fa56c Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Mon, 3 Aug 2020 22:17:35 +0300 Subject: [PATCH 07/17] dm: core: Fix devfdt_get_addr_ptr return value According to the description of devfdt_get_addr_ptr, this function should return NULL on failure, but currently it returns (void *)FDT_ADDR_T_NONE. Fix this by making devfdt_get_addr_ptr return NULL on failure, as described in the function comments. Also, update the drivers currently checking (void *)FDT_ADDR_T_NONE to check for NULL. Signed-off-by: Ovidiu Panait Reviewed-by: Simon Glass --- drivers/clk/aspeed/clk_ast2500.c | 4 ++-- drivers/core/fdtaddr.c | 4 +++- drivers/i2c/ast_i2c.c | 4 ++-- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 2 +- drivers/timer/ast_timer.c | 4 ++-- drivers/watchdog/ast_wdt.c | 4 ++-- include/dm/read.h | 4 +--- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c index ccfeded30c5..284f5f58d6e 100644 --- a/drivers/clk/aspeed/clk_ast2500.c +++ b/drivers/clk/aspeed/clk_ast2500.c @@ -498,8 +498,8 @@ static int ast2500_clk_ofdata_to_platdata(struct udevice *dev) struct ast2500_clk_priv *priv = dev_get_priv(dev); priv->scu = devfdt_get_addr_ptr(dev); - if (IS_ERR(priv->scu)) - return PTR_ERR(priv->scu); + if (!priv->scu) + return -EINVAL; return 0; } diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c index dfcb868f650..8b48aa5bc5b 100644 --- a/drivers/core/fdtaddr.c +++ b/drivers/core/fdtaddr.c @@ -154,7 +154,9 @@ fdt_addr_t devfdt_get_addr(const struct udevice *dev) void *devfdt_get_addr_ptr(const struct udevice *dev) { - return (void *)(uintptr_t)devfdt_get_addr_index(dev, 0); + fdt_addr_t addr = devfdt_get_addr_index(dev, 0); + + return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)(uintptr_t)addr; } void *devfdt_remap_addr_index(const struct udevice *dev, int index) diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c index 214362d04bb..253e653666a 100644 --- a/drivers/i2c/ast_i2c.c +++ b/drivers/i2c/ast_i2c.c @@ -93,8 +93,8 @@ static int ast_i2c_ofdata_to_platdata(struct udevice *dev) int ret; priv->regs = devfdt_get_addr_ptr(dev); - if (IS_ERR(priv->regs)) - return PTR_ERR(priv->regs); + if (!priv->regs) + return -EINVAL; ret = clk_get_by_index(dev, 0, &priv->clk); if (ret < 0) { diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index 2206e958ec7..ac0377e7968 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c @@ -194,7 +194,7 @@ int mvebu_pinctl_probe(struct udevice *dev) } priv->base_reg = devfdt_get_addr_ptr(dev); - if (priv->base_reg == (void *)FDT_ADDR_T_NONE) { + if (!priv->base_reg) { debug("%s: Failed to get base address\n", __func__); return -EINVAL; } diff --git a/drivers/timer/ast_timer.c b/drivers/timer/ast_timer.c index 3838601f54d..9f28cbfcf9a 100644 --- a/drivers/timer/ast_timer.c +++ b/drivers/timer/ast_timer.c @@ -65,8 +65,8 @@ static int ast_timer_ofdata_to_platdata(struct udevice *dev) struct ast_timer_priv *priv = dev_get_priv(dev); priv->regs = devfdt_get_addr_ptr(dev); - if (IS_ERR(priv->regs)) - return PTR_ERR(priv->regs); + if (!priv->regs) + return -EINVAL; priv->tmc = ast_get_timer_counter(priv->regs, AST_TICK_TIMER); diff --git a/drivers/watchdog/ast_wdt.c b/drivers/watchdog/ast_wdt.c index 7e11465a570..a21f9a4d140 100644 --- a/drivers/watchdog/ast_wdt.c +++ b/drivers/watchdog/ast_wdt.c @@ -91,8 +91,8 @@ static int ast_wdt_ofdata_to_platdata(struct udevice *dev) struct ast_wdt_priv *priv = dev_get_priv(dev); priv->regs = devfdt_get_addr_ptr(dev); - if (IS_ERR(priv->regs)) - return PTR_ERR(priv->regs); + if (!priv->regs) + return -EINVAL; return 0; } diff --git a/include/dm/read.h b/include/dm/read.h index cac7dd5f187..0a7aacd2d04 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -802,9 +802,7 @@ static inline fdt_addr_t dev_read_addr(const struct udevice *dev) static inline void *dev_read_addr_ptr(const struct udevice *dev) { - void *addr = devfdt_get_addr_ptr(dev); - - return ((fdt_addr_t)(uintptr_t)addr == FDT_ADDR_T_NONE) ? NULL : addr; + return devfdt_get_addr_ptr(dev); } static inline fdt_addr_t dev_read_addr_pci(const struct udevice *dev) From 6e64830f0bca623180d5d1667df02c288616ea5c Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Mon, 3 Aug 2020 22:17:36 +0300 Subject: [PATCH 08/17] test: dm: Add test case for devfdt_get_addr_ptr Add flat tree test case to cover devfdt_get_addr_ptr function. Signed-off-by: Ovidiu Panait Reviewed-by: Simon Glass --- test/dm/test-fdt.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index ac8ce99f512..04802deb7fc 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -619,6 +619,24 @@ static int dm_test_fdt_translation(struct unit_test_state *uts) } DM_TEST(dm_test_fdt_translation, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +static int dm_test_fdt_get_addr_ptr_flat(struct unit_test_state *uts) +{ + struct udevice *gpio, *dev; + void *ptr; + + /* Test for missing reg property */ + ut_assertok(uclass_first_device_err(UCLASS_GPIO, &gpio)); + ut_assertnull(devfdt_get_addr_ptr(gpio)); + + ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev)); + ptr = devfdt_get_addr_ptr(dev); + ut_asserteq_ptr((void *)0x8000, ptr); + + return 0; +} +DM_TEST(dm_test_fdt_get_addr_ptr_flat, + UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE); + static int dm_test_fdt_remap_addr_flat(struct unit_test_state *uts) { struct udevice *dev; From 0cbf3e08fc735b54e7918138e73b34870a213333 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Aug 2020 14:14:41 +0900 Subject: [PATCH 09/17] gpio: at91: use dev_read_addr() to get base address It is strange to use devfdt_get_addr_ptr(), then cast the pointer back to uint32 because you could use devfdt_get_addr() without casting. Convert it to dev_read_addr(), which is capable to CONFIG_OF_LIVE. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- drivers/gpio/at91_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c index 4a8b2e6ff61..ef7984374b1 100644 --- a/drivers/gpio/at91_gpio.c +++ b/drivers/gpio/at91_gpio.c @@ -606,7 +606,7 @@ static int at91_gpio_probe(struct udevice *dev) clk_free(&clk); #if CONFIG_IS_ENABLED(OF_CONTROL) - plat->base_addr = (uint32_t)devfdt_get_addr_ptr(dev); + plat->base_addr = dev_read_addr(dev); #endif plat->bank_name = at91_get_bank_name(plat->base_addr); port->regs = (struct at91_port *)plat->base_addr; From 1450bff3e4719d1b34189bf62ad19d0e3c10a548 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Aug 2020 14:14:42 +0900 Subject: [PATCH 10/17] ata: mvebu: use dev_read_addr() to get base address It is strange to use devfdt_get_addr_ptr(), then cast the pointer back to ulong because you could use devfdt_get_addr() without casting. Convert it to dev_read_addr(), which is capable to CONFIG_OF_LIVE. Signed-off-by: Masahiro Yamada Reviewed-by: Stefan Roese --- drivers/ata/ahci_mvebu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/ahci_mvebu.c b/drivers/ata/ahci_mvebu.c index 8be1826d405..7d82d2ea3ff 100644 --- a/drivers/ata/ahci_mvebu.c +++ b/drivers/ata/ahci_mvebu.c @@ -39,7 +39,7 @@ static int mvebu_ahci_probe(struct udevice *dev) */ board_ahci_enable(); - ahci_probe_scsi(dev, (ulong)devfdt_get_addr_ptr(dev)); + ahci_probe_scsi(dev, dev_read_addr(dev)); return 0; } From 702e57e113d85fef60ebe9e5c87194414666cfac Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Aug 2020 14:14:43 +0900 Subject: [PATCH 11/17] treewide: convert devfdt_get_addr_ptr() to dev_read_addr_ptr() When you enable CONFIG_OF_LIVE, you will end up with a lot of conversions. To help this tedious work, this commit converts devfdt_get_addr_ptr() to dev_read_addr_ptr() by coccinelle. I also removed redundant casts because dev_read_addr_ptr() returns an opaque pointer. To generate this commit, I ran the following semantic patch excluding include/dm/. @@ type T; expression dev; @@ -(T *)devfdt_get_addr_ptr(dev) +dev_read_addr_ptr(dev) @@ expression dev; @@ -devfdt_get_addr_ptr(dev) +dev_read_addr_ptr(dev) Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- drivers/clk/aspeed/clk_ast2500.c | 2 +- drivers/clk/at91/pmc.c | 4 ++-- drivers/gpio/hsdk-creg-gpio.c | 2 +- drivers/i2c/ast_i2c.c | 2 +- drivers/i2c/designware_i2c.c | 2 +- drivers/i2c/mv_i2c.c | 2 +- drivers/i2c/mvtwsi.c | 4 ++-- drivers/mmc/gen_atmel_mci.c | 2 +- drivers/mmc/snps_dw_mmc.c | 2 +- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 2 +- drivers/reset/reset-socfpga.c | 2 +- drivers/serial/serial_mvebu_a3700.c | 2 +- drivers/spi/uniphier_spi.c | 2 +- drivers/sysreset/sysreset_socfpga.c | 2 +- drivers/timer/ast_timer.c | 2 +- drivers/timer/atmel_pit_timer.c | 2 +- drivers/usb/host/ehci-zynq.c | 2 +- drivers/watchdog/ast_wdt.c | 2 +- 18 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c index 284f5f58d6e..d1940f18849 100644 --- a/drivers/clk/aspeed/clk_ast2500.c +++ b/drivers/clk/aspeed/clk_ast2500.c @@ -497,7 +497,7 @@ static int ast2500_clk_ofdata_to_platdata(struct udevice *dev) { struct ast2500_clk_priv *priv = dev_get_priv(dev); - priv->scu = devfdt_get_addr_ptr(dev); + priv->scu = dev_read_addr_ptr(dev); if (!priv->scu) return -EINVAL; diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 54ae0d281d0..ca90abef2d5 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -41,7 +41,7 @@ int at91_pmc_core_probe(struct udevice *dev) dev = dev_get_parent(dev); - plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev); + plat->reg_base = dev_read_addr_ptr(dev); return 0; } @@ -116,7 +116,7 @@ int at91_clk_probe(struct udevice *dev) dev_periph_container = dev_get_parent(dev); dev_pmc = dev_get_parent(dev_periph_container); - plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev_pmc); + plat->reg_base = dev_read_addr_ptr(dev_pmc); return 0; } diff --git a/drivers/gpio/hsdk-creg-gpio.c b/drivers/gpio/hsdk-creg-gpio.c index d9df804f639..35b114904d5 100644 --- a/drivers/gpio/hsdk-creg-gpio.c +++ b/drivers/gpio/hsdk-creg-gpio.c @@ -83,7 +83,7 @@ static int hsdk_creg_gpio_probe(struct udevice *dev) u32 shift, bit_per_gpio, activate, deactivate, gpio_count; const u8 *defaults; - hcg->regs = (u32 *)devfdt_get_addr_ptr(dev); + hcg->regs = dev_read_addr_ptr(dev); gpio_count = dev_read_u32_default(dev, "gpio-count", 1); shift = dev_read_u32_default(dev, "gpio-first-shift", 0); bit_per_gpio = dev_read_u32_default(dev, "gpio-bit-per-line", 1); diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c index 253e653666a..2cdfb5561b7 100644 --- a/drivers/i2c/ast_i2c.c +++ b/drivers/i2c/ast_i2c.c @@ -92,7 +92,7 @@ static int ast_i2c_ofdata_to_platdata(struct udevice *dev) struct ast_i2c_priv *priv = dev_get_priv(dev); int ret; - priv->regs = devfdt_get_addr_ptr(dev); + priv->regs = dev_read_addr_ptr(dev); if (!priv->regs) return -EINVAL; diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index cf892c69d9f..569a5d39b49 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -768,7 +768,7 @@ int designware_i2c_ofdata_to_platdata(struct udevice *bus) int ret; if (!priv->regs) - priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus); + priv->regs = dev_read_addr_ptr(bus); dev_read_u32(bus, "i2c-scl-rising-time-ns", &priv->scl_rise_time_ns); dev_read_u32(bus, "i2c-scl-falling-time-ns", &priv->scl_fall_time_ns); dev_read_u32(bus, "i2c-sda-hold-time-ns", &priv->sda_hold_time_ns); diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c index 59675d8d574..82e8fdac413 100644 --- a/drivers/i2c/mv_i2c.c +++ b/drivers/i2c/mv_i2c.c @@ -580,7 +580,7 @@ static int mv_i2c_probe(struct udevice *bus) { struct mv_i2c_priv *priv = dev_get_priv(bus); - priv->base = (void *)devfdt_get_addr_ptr(bus); + priv->base = dev_read_addr_ptr(bus); return 0; } diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index d3cc9b9d838..fdb8fd42e5c 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -798,7 +798,7 @@ static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus) { struct mvtwsi_i2c_dev *dev = dev_get_priv(bus); - dev->base = devfdt_get_addr_ptr(bus); + dev->base = dev_read_addr_ptr(bus); if (!dev->base) return -ENOMEM; @@ -820,7 +820,7 @@ static void twsi_disable_i2c_slave(struct mvtwsi_registers *twsi) static int mvtwsi_i2c_bind(struct udevice *bus) { - struct mvtwsi_registers *twsi = devfdt_get_addr_ptr(bus); + struct mvtwsi_registers *twsi = dev_read_addr_ptr(bus); /* Disable the hidden slave in i2c0 of these platforms */ if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARCH_KIRKWOOD)) diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c index 9d20e283839..0a347b2fb20 100644 --- a/drivers/mmc/gen_atmel_mci.c +++ b/drivers/mmc/gen_atmel_mci.c @@ -592,7 +592,7 @@ static int atmel_mci_probe(struct udevice *dev) if (ret) return ret; - plat->mci = (struct atmel_mci *)devfdt_get_addr_ptr(dev); + plat->mci = dev_read_addr_ptr(dev); atmel_mci_setup_cfg(dev); diff --git a/drivers/mmc/snps_dw_mmc.c b/drivers/mmc/snps_dw_mmc.c index c606ef011bf..4b468a1f3db 100644 --- a/drivers/mmc/snps_dw_mmc.c +++ b/drivers/mmc/snps_dw_mmc.c @@ -83,7 +83,7 @@ static int snps_dwmmc_ofdata_to_platdata(struct udevice *dev) u32 fifo_depth; int ret; - host->ioaddr = devfdt_get_addr_ptr(dev); + host->ioaddr = dev_read_addr_ptr(dev); /* * If fifo-depth is unset don't set fifoth_val - we will try to diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index ac0377e7968..146f5c6e426 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c @@ -193,7 +193,7 @@ int mvebu_pinctl_probe(struct udevice *dev) return -EINVAL; } - priv->base_reg = devfdt_get_addr_ptr(dev); + priv->base_reg = dev_read_addr_ptr(dev); if (!priv->base_reg) { debug("%s: Failed to get base address\n", __func__); return -EINVAL; diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c index 830eda9430e..1849db4da9b 100644 --- a/drivers/reset/reset-socfpga.c +++ b/drivers/reset/reset-socfpga.c @@ -118,7 +118,7 @@ static int socfpga_reset_probe(struct udevice *dev) u32 modrst_offset; void __iomem *membase; - membase = devfdt_get_addr_ptr(dev); + membase = dev_read_addr_ptr(dev); modrst_offset = dev_read_u32_default(dev, "altr,modrst-offset", 0x10); data->modrst_base = membase + modrst_offset; diff --git a/drivers/serial/serial_mvebu_a3700.c b/drivers/serial/serial_mvebu_a3700.c index 7e4cd6c4b49..fb43f88eaf6 100644 --- a/drivers/serial/serial_mvebu_a3700.c +++ b/drivers/serial/serial_mvebu_a3700.c @@ -104,7 +104,7 @@ static int mvebu_serial_ofdata_to_platdata(struct udevice *dev) { struct mvebu_platdata *plat = dev_get_platdata(dev); - plat->base = devfdt_get_addr_ptr(dev); + plat->base = dev_read_addr_ptr(dev); return 0; } diff --git a/drivers/spi/uniphier_spi.c b/drivers/spi/uniphier_spi.c index 114bd8abd7a..b6456685f8d 100644 --- a/drivers/spi/uniphier_spi.c +++ b/drivers/spi/uniphier_spi.c @@ -368,7 +368,7 @@ static int uniphier_spi_ofdata_to_platdata(struct udevice *bus) const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); - plat->base = devfdt_get_addr_ptr(bus); + plat->base = dev_read_addr_ptr(bus); plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency", 12500000); diff --git a/drivers/sysreset/sysreset_socfpga.c b/drivers/sysreset/sysreset_socfpga.c index 178bcb227ff..67cec6563a2 100644 --- a/drivers/sysreset/sysreset_socfpga.c +++ b/drivers/sysreset/sysreset_socfpga.c @@ -40,7 +40,7 @@ static int socfpga_sysreset_probe(struct udevice *dev) { struct socfpga_sysreset_data *data = dev_get_priv(dev); - data->rstmgr_base = devfdt_get_addr_ptr(dev); + data->rstmgr_base = dev_read_addr_ptr(dev); return 0; } diff --git a/drivers/timer/ast_timer.c b/drivers/timer/ast_timer.c index 9f28cbfcf9a..e3132497404 100644 --- a/drivers/timer/ast_timer.c +++ b/drivers/timer/ast_timer.c @@ -64,7 +64,7 @@ static int ast_timer_ofdata_to_platdata(struct udevice *dev) { struct ast_timer_priv *priv = dev_get_priv(dev); - priv->regs = devfdt_get_addr_ptr(dev); + priv->regs = dev_read_addr_ptr(dev); if (!priv->regs) return -EINVAL; diff --git a/drivers/timer/atmel_pit_timer.c b/drivers/timer/atmel_pit_timer.c index 70511697fef..843d670b5e2 100644 --- a/drivers/timer/atmel_pit_timer.c +++ b/drivers/timer/atmel_pit_timer.c @@ -64,7 +64,7 @@ static int atmel_pit_ofdata_to_platdata(struct udevice *dev) { struct atmel_pit_platdata *plat = dev_get_platdata(dev); - plat->regs = (struct atmel_pit_regs *)devfdt_get_addr_ptr(dev); + plat->regs = dev_read_addr_ptr(dev); return 0; } diff --git a/drivers/usb/host/ehci-zynq.c b/drivers/usb/host/ehci-zynq.c index 939c30999ee..80f1d6fd97c 100644 --- a/drivers/usb/host/ehci-zynq.c +++ b/drivers/usb/host/ehci-zynq.c @@ -25,7 +25,7 @@ static int ehci_zynq_ofdata_to_platdata(struct udevice *dev) { struct zynq_ehci_priv *priv = dev_get_priv(dev); - priv->ehci = (struct usb_ehci *)devfdt_get_addr_ptr(dev); + priv->ehci = dev_read_addr_ptr(dev); if (!priv->ehci) return -EINVAL; diff --git a/drivers/watchdog/ast_wdt.c b/drivers/watchdog/ast_wdt.c index a21f9a4d140..9b83d2ad442 100644 --- a/drivers/watchdog/ast_wdt.c +++ b/drivers/watchdog/ast_wdt.c @@ -90,7 +90,7 @@ static int ast_wdt_ofdata_to_platdata(struct udevice *dev) { struct ast_wdt_priv *priv = dev_get_priv(dev); - priv->regs = devfdt_get_addr_ptr(dev); + priv->regs = dev_read_addr_ptr(dev); if (!priv->regs) return -EINVAL; From 87d43329ef7698eab5b090a91228269c39643122 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 5 Aug 2020 13:27:46 -0600 Subject: [PATCH 12/17] binman: Move GetEntryModules() to control When binman is installed its main program is in a different directory to its modules. This means that __file__ is different and we cannot use it to obtain the path to etype/ from main.py To fix this, move the function to the 'control' module, since it is installed with all the other modules, including the etype/ directory. Signed-off-by: Simon Glass --- tools/binman/control.py | 13 +++++++++++++ tools/binman/ftest.py | 5 ++--- tools/binman/main.py | 16 ++-------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/binman/control.py b/tools/binman/control.py index 343b0a0c35b..69c36ed6582 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -6,6 +6,7 @@ # from collections import OrderedDict +import glob import os import sys from patman import tools @@ -51,6 +52,18 @@ def _FindBinmanNode(dtb): return node return None +def GetEntryModules(include_testing=True): + """Get a set of entry class implementations + + Returns: + Set of paths to entry class filenames + """ + our_path = os.path.dirname(os.path.realpath(__file__)) + glob_list = glob.glob(os.path.join(our_path, 'etype/*.py')) + return set([os.path.splitext(os.path.basename(item))[0] + for item in glob_list + if include_testing or '_testing' not in item]) + def WriteEntryDocs(modules, test_missing=None): """Write out documentation for all entries diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index bf7f59fb841..fedcc1ada1b 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -24,7 +24,6 @@ from binman import control from binman import elf from binman import elf_test from binman import fmap_util -from binman import main from binman import state from dtoc import fdt from dtoc import fdt_util @@ -1440,14 +1439,14 @@ class TestFunctional(unittest.TestCase): def testEntryDocs(self): """Test for creation of entry documentation""" with test_util.capture_sys_output() as (stdout, stderr): - control.WriteEntryDocs(main.GetEntryModules()) + control.WriteEntryDocs(control.GetEntryModules()) self.assertTrue(len(stdout.getvalue()) > 0) def testEntryDocsMissing(self): """Test handling of missing entry documentation""" with self.assertRaises(ValueError) as e: with test_util.capture_sys_output() as (stdout, stderr): - control.WriteEntryDocs(main.GetEntryModules(), 'u_boot') + control.WriteEntryDocs(control.GetEntryModules(), 'u_boot') self.assertIn('Documentation is missing for modules: u_boot', str(e.exception)) diff --git a/tools/binman/main.py b/tools/binman/main.py index e543a7d06a7..3e463b0119b 100755 --- a/tools/binman/main.py +++ b/tools/binman/main.py @@ -10,7 +10,6 @@ """See README for more information""" from distutils.sysconfig import get_python_lib -import glob import os import site import sys @@ -78,20 +77,9 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): return test_util.ReportResult('binman', test_name, result) -def GetEntryModules(include_testing=True): - """Get a set of entry class implementations - - Returns: - Set of paths to entry class filenames - """ - glob_list = glob.glob(os.path.join(our_path, 'etype/*.py')) - return set([os.path.splitext(os.path.basename(item))[0] - for item in glob_list - if include_testing or '_testing' not in item]) - def RunTestCoverage(toolpath): """Run the tests and check that we get 100% coverage""" - glob_list = GetEntryModules(False) + glob_list = control.GetEntryModules(False) all_set = set([os.path.splitext(os.path.basename(item))[0] for item in glob_list if '_testing' not in item]) extra_args = '' @@ -127,7 +115,7 @@ def RunBinman(args): args.toolpath) elif args.cmd == 'entry-docs': - control.WriteEntryDocs(GetEntryModules()) + control.WriteEntryDocs(control.GetEntryModules()) else: try: From 07237988dcf88366ce4182eceac698cf1e97afc5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 5 Aug 2020 13:27:47 -0600 Subject: [PATCH 13/17] binman: Correct some import statements Some of these were not converted when binman moved to use absolute paths. Fix them. Also drop the import of 'test' which is a directory, not a module. Signed-off-by: Simon Glass --- tools/binman/control.py | 4 ++-- tools/binman/ftest.py | 2 +- tools/binman/image_test.py | 2 +- tools/binman/main.py | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/binman/control.py b/tools/binman/control.py index 69c36ed6582..60e89d3776b 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -123,7 +123,7 @@ def ReadEntry(image_fname, entry_path, decomp=True): data extracted from the entry """ global Image - from image import Image + from binman.image import Image image = Image.FromFile(image_fname) entry = image.FindEntryPath(entry_path) @@ -496,7 +496,7 @@ def Binman(args): return 0 # Put these here so that we can import this module without libfdt - from image import Image + from binman.image import Image from binman import state if args.cmd in ['ls', 'extract', 'replace']: diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index fedcc1ada1b..5f650b5f94c 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -29,7 +29,7 @@ from dtoc import fdt from dtoc import fdt_util from binman.etype import fdtmap from binman.etype import image_header -from image import Image +from binman.image import Image from patman import command from patman import test_util from patman import tools diff --git a/tools/binman/image_test.py b/tools/binman/image_test.py index f85c3c51c0f..e351fa84ab3 100644 --- a/tools/binman/image_test.py +++ b/tools/binman/image_test.py @@ -6,7 +6,7 @@ import unittest -from image import Image +from binman.image import Image from patman.test_util import capture_sys_output class TestImage(unittest.TestCase): diff --git a/tools/binman/main.py b/tools/binman/main.py index 3e463b0119b..8c1e478d54c 100755 --- a/tools/binman/main.py +++ b/tools/binman/main.py @@ -61,7 +61,6 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): from binman import fdt_test from binman import ftest from binman import image_test - from binman import test import doctest result = unittest.TestResult() From 946ec8503737e4d9b2e9474939312c393ca092c0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 5 Aug 2020 13:27:48 -0600 Subject: [PATCH 14/17] dtoc: Add a setup script for Python Allow dtoc to be installed by adding a suitable setup.py script. Signed-off-by: Simon Glass --- tools/dtoc/setup.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tools/dtoc/setup.py diff --git a/tools/dtoc/setup.py b/tools/dtoc/setup.py new file mode 100644 index 00000000000..5e092fe0872 --- /dev/null +++ b/tools/dtoc/setup.py @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0+ + +from distutils.core import setup +setup(name='dtoc', + version='1.0', + license='GPL-2.0+', + scripts=['dtoc'], + packages=['dtoc'], + package_dir={'dtoc': ''}, + package_data={'dtoc': ['README']}, + classifiers=['Environment :: Console', + 'Topic :: Software Development :: Embedded Systems']) From 02c102074ddc0721db881118db6ffdc2fbb05ebb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 5 Aug 2020 13:27:49 -0600 Subject: [PATCH 15/17] binman: Add a setup script for Python Allow binman to be installed by adding a suitable setup.py script. Signed-off-by: Simon Glass --- tools/binman/setup.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tools/binman/setup.py diff --git a/tools/binman/setup.py b/tools/binman/setup.py new file mode 100644 index 00000000000..fe408ed6911 --- /dev/null +++ b/tools/binman/setup.py @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0+ + +from distutils.core import setup +setup(name='binman', + version='1.0', + license='GPL-2.0+', + scripts=['binman'], + packages=['binman', 'binman.etype'], + package_dir={'binman': ''}, + package_data={'binman': ['README', 'README.entries']}, + classifiers=['Environment :: Console', + 'Topic :: Software Development :: Embedded Systems']) From 78237828a3b20d993670e1beeacb5089d40c5e53 Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Mon, 17 Aug 2020 21:27:50 +0300 Subject: [PATCH 16/17] board_f: Remove dead code from init_func_i2c Since commit 69153988a6f4 ("i2c: Finish dropping use of CONFIG_I2C_HARD") init_func_i2c is wrapped only by "#if defined(CONFIG_SYS_I2C)". Because of this, the second ifdef within becomes pointless: #if defined(CONFIG_SYS_I2C) static int init_func_i2c(void) #ifdef CONFIG_SYS_I2C ... #else ... #endif } #endif Remove the dead #else preprocessor code. Fixes: 69153988a6f ("i2c: Finish dropping use of CONFIG_I2C_HARD") Signed-off-by: Ovidiu Panait --- common/board_f.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index 3932e0c69dd..d3444c7edc9 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -254,11 +254,7 @@ __weak int dram_init_banksize(void) static int init_func_i2c(void) { puts("I2C: "); -#ifdef CONFIG_SYS_I2C i2c_init_all(); -#else - i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); -#endif puts("ready\n"); return 0; } From a4020350289c520e896fd6180e510be557ed3bf9 Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Mon, 17 Aug 2020 21:27:51 +0300 Subject: [PATCH 17/17] sandbox: u-boot.lds: Remove bogus __bss_start symbol The sections described in the sandbox linker script are inserted before data section via "INSERT BEFORE .data;". Running readelf -S on sandbox u-boot binary shows that the bss section is located after the data section: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align ... [25] .u_boot_list PROGBITS 000000000041d1c8 0021d1c8 000000000000dd90 0000000000000000 WA 0 0 8 [26] _u_boot_sandbox_g PROGBITS 000000000042af58 0022af58 00000000000000a0 0000000000000000 WA 0 0 8 [27] .data PROGBITS 000000000042b000 0022b000 000000000000f708 0000000000000000 WA 0 0 32 [28] .bss NOBITS 000000000043a720 0023a708 0000000000018930 0000000000000000 WA 0 0 32 This means that the __bss_start assignment in the linker script is bogus, as the actual bss section start is located elsewhere. Remove this assignment, as the __bss_start symbol is not used on sandbox anyway. Signed-off-by: Ovidiu Panait --- arch/sandbox/cpu/u-boot-spl.lds | 2 -- arch/sandbox/cpu/u-boot.lds | 2 -- 2 files changed, 4 deletions(-) diff --git a/arch/sandbox/cpu/u-boot-spl.lds b/arch/sandbox/cpu/u-boot-spl.lds index c60eb109b15..649abeb5ee7 100644 --- a/arch/sandbox/cpu/u-boot-spl.lds +++ b/arch/sandbox/cpu/u-boot-spl.lds @@ -16,8 +16,6 @@ SECTIONS __u_boot_sandbox_option_start = .; _u_boot_sandbox_getopt : { KEEP(*(.u_boot_sandbox_getopt)) } __u_boot_sandbox_option_end = .; - - __bss_start = .; } INSERT AFTER .data; diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds index 6a26c27e8e2..936da5e1402 100644 --- a/arch/sandbox/cpu/u-boot.lds +++ b/arch/sandbox/cpu/u-boot.lds @@ -44,8 +44,6 @@ SECTIONS { *(.__efi_runtime_rel_stop) } - - __bss_start = .; } INSERT BEFORE .data;