[PATCH v2 0/2] dm: core: Add address translation in fdt_get_resource - fixes

Hi,
This serie push again 2 modifications proposed in previous serie V3 [1] but missing in master branch as only patchset V1 [2] is merged.
The first patch solves a issue see by horatiu.vultur@microchip.com in V1 [2].
Regards, Patrick
[1] [v3] dm: core: Add address translation in fdt_get_resource http://patchwork.ozlabs.org/project/uboot/list/?series=242010&state=*
[2] dm: core: Add address translation in fdt_get_resource http://patchwork.ozlabs.org/project/uboot/list/?series=237557&state=*
Changes in v2: - Add reviewed-by - Add reviewed-by - use lower-case hex
Patrick Delaunay (2): net: luton: remove address translation after ofnode_read_resource test: add dm_test_read_resource
drivers/net/mscc_eswitch/luton_switch.c | 5 +--- test/dm/test-fdt.c | 33 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-)

Removed call of ofnode_translate_address() after ofnode_read_resource in luton_switch.c:luton_probe(); it is unnecessary since the commit feb7ac457c20 ("dm: core: Add address translation in fdt_get_resource").
Fixes: feb7ac457c20 ("dm: core: Add address translation in fdt_get_resource") Reviewed-by: Ramon Fried rfried.dev@gmail.com Reported-by: Horatiu Vultur horatiu.vultur@microchip.com Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
Changes in v2: - Add reviewed-by
drivers/net/mscc_eswitch/luton_switch.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/mscc_eswitch/luton_switch.c b/drivers/net/mscc_eswitch/luton_switch.c index 54afa14c9d..73c950d118 100644 --- a/drivers/net/mscc_eswitch/luton_switch.c +++ b/drivers/net/mscc_eswitch/luton_switch.c @@ -588,7 +588,6 @@ static int luton_probe(struct udevice *dev) struct luton_private *priv = dev_get_priv(dev); int i, ret; struct resource res; - fdt32_t faddr; phys_addr_t addr_base; unsigned long addr_size; ofnode eth_node, node, mdio_node; @@ -658,9 +657,7 @@ static int luton_probe(struct udevice *dev)
if (ofnode_read_resource(mdio_node, 0, &res)) return -ENOMEM; - faddr = cpu_to_fdt32(res.start); - - addr_base = ofnode_translate_address(mdio_node, &faddr); + addr_base = res.start; addr_size = res.end - res.start;
/* If the bus is new then create a new bus */

Removed call of ofnode_translate_address() after ofnode_read_resource in luton_switch.c:luton_probe(); it is unnecessary since the commit feb7ac457c20 ("dm: core: Add address translation in fdt_get_resource").
Fixes: feb7ac457c20 ("dm: core: Add address translation in fdt_get_resource") Reviewed-by: Ramon Fried rfried.dev@gmail.com Reported-by: Horatiu Vultur horatiu.vultur@microchip.com Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
Changes in v2: - Add reviewed-by
drivers/net/mscc_eswitch/luton_switch.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Applied to u-boot-dm, thanks!

Add a test of dev_read_resource with translation or without translation
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add reviewed-by - use lower-case hex
test/dm/test-fdt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 9b771fdf19..d273e21853 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -19,6 +19,7 @@ #include <dm/util.h> #include <dm/lists.h> #include <dm/of_access.h> +#include <linux/ioport.h> #include <test/test.h> #include <test/ut.h>
@@ -1165,3 +1166,35 @@ static int dm_test_decode_display_timing(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_decode_display_timing, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +/* Test read_resourcee() */ +static int dm_test_read_resource(struct unit_test_state *uts) +{ + struct udevice *dev; + struct resource res; + + /* test resource without translation */ + ut_assertok(uclass_find_device_by_name(UCLASS_SIMPLE_BUS, "syscon@2", &dev)); + ut_assertok(dev_read_resource(dev, 0, &res)); + ut_asserteq(0x40, res.start); + ut_asserteq(0x44, res.end); + ut_assertok(dev_read_resource(dev, 1, &res)); + ut_asserteq(0x48, res.start); + ut_asserteq(0x4d, res.end); + + /* test resource with translation */ + ut_assertok(uclass_find_device_by_name(UCLASS_TEST_DUMMY, "dev@1,100", &dev)); + ut_assertok(dev_read_resource(dev, 0, &res)); + ut_asserteq(0x9000, res.start); + ut_asserteq(0x9fff, res.end); + + /* test named resource */ + ut_assertok(uclass_find_device_by_name(UCLASS_TEST_DUMMY, "dev@0,0", &dev)); + ut_assertok(dev_read_resource_byname(dev, "sandbox-dummy-0", &res)); + ut_asserteq(0x8000, res.start); + ut_asserteq(0x8fff, res.end); + + return 0; +} + +DM_TEST(dm_test_read_resource, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);

Add a test of dev_read_resource with translation or without translation
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add reviewed-by - use lower-case hex
test/dm/test-fdt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
Applied to u-boot-dm, thanks!
participants (2)
-
Patrick Delaunay
-
Simon Glass