Minor fixes for sandbox and handling of dm-ranges

-----BEGIN PGP SIGNATURE-----
 
 iQFFBAABCgAvFiEEslwAIq+Gp8wWVbYnfxc6PpAIreYFAmC8+C8RHHNqZ0BjaHJv
 bWl1bS5vcmcACgkQfxc6PpAIreb4RwgAutcNAhPFOePWW4y/Uey2m9N0W9IlZ6Kl
 6FGXgdbruqEArO8JVMkMJZMF/yRGUZbTR5Um6IEs/X0e9851m5nFv1716ITzD2nK
 bBCjbU6/4sNfCKmuFbwXvcKHSbd+0NsMk1ElqgNLaeINOKW8a07p4QL0vM8+MENC
 G1TpHHAtEMbj3l1+uO+UCEk3XQn7pxb/5+SJJVM2/8GpOfViqZfH6JF4Id3a8naC
 WzB/Lq4m+JJNjagcXcfZbRAd4wlVmWKPEAlcTZRjx/AuZo+zHrGEx68UeUT+dYh5
 jHcHBvaAnAnd1h0aMUXB2QiwdiqeEoogUtIt6oUPEBR4qkMJEqyESw==
 =+LM7
 -----END PGP SIGNATURE-----

Merge tag 'dm-pull-6jun21' of https://source.denx.de/u-boot/custodians/u-boot-dm

Minor fixes for sandbox and handling of dm-ranges
This commit is contained in:
Tom Rini 2021-06-06 13:00:23 -04:00
commit 281e95c40f
5 changed files with 44 additions and 13 deletions

View file

@ -436,10 +436,13 @@ void sandbox_reset(void)
int main(int argc, char *argv[])
{
struct sandbox_state *state;
void * text_base;
gd_t data;
int size;
int ret;
text_base = os_find_text_base();
/*
* Copy argv[] so that we can pass the arguments in the original
* sequence when resetting the sandbox.
@ -452,7 +455,7 @@ int main(int argc, char *argv[])
memset(&data, '\0', sizeof(data));
gd = &data;
gd->arch.text_base = os_find_text_base();
gd->arch.text_base = text_base;
ret = state_init();
if (ret)

View file

@ -118,11 +118,6 @@ static struct of_bus *of_match_bus(struct device_node *np)
return NULL;
}
static void dev_count_cells(const struct device_node *np, int *nap, int *nsp)
{
of_bus_default_count_cells(np, nap, nsp);
}
const __be32 *of_get_address(const struct device_node *dev, int index,
u64 *size, unsigned int *flags)
{
@ -136,7 +131,6 @@ const __be32 *of_get_address(const struct device_node *dev, int index,
parent = of_get_parent(dev);
if (parent == NULL)
return NULL;
dev_count_cells(dev, &na, &ns);
bus = of_match_bus(parent);
bus->count_cells(dev, &na, &ns);
of_node_put(parent);
@ -192,9 +186,13 @@ static int of_translate_one(const struct device_node *parent,
*
* As far as we know, this damage only exists on Apple machines, so
* This code is only enabled on powerpc. --gcl
*
* This quirk also applies for 'dma-ranges' which frequently exist in
* child nodes without 'dma-ranges' in the parent nodes. --RobH
*/
ranges = of_get_property(parent, rprop, &rlen);
if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
if (ranges == NULL && !of_empty_ranges_quirk(parent) &&
strcmp(rprop, "dma-ranges")) {
debug("no ranges; cannot translate\n");
return 1;
}

View file

@ -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 */

View file

@ -80,5 +80,5 @@ U_BOOT_DRIVER(cros_ec_pwm) = {
.id = UCLASS_PWM,
.of_match = cros_ec_pwm_ids,
.ops = &cros_ec_pwm_ops,
.priv_auto_alloc_size = sizeof(struct cros_ec_pwm_priv),
.priv_auto = sizeof(struct cros_ec_pwm_priv),
};

View file

@ -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);