aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-10-29 18:51:22 -0400
committerTom Rini <trini@konsulko.com>2022-10-29 18:51:22 -0400
commit6f02819cceb19c334f1dbd6eccefb4ccfae319f9 (patch)
treeada26fe279934fbb18d69324010b3ce1f55ffb63 /drivers
parentfb63362c63c7aeacb1dfde330ee8f692da7972f9 (diff)
parentf21954750aa8ed445ab83998bb099e366136c428 (diff)
downloadu-boot-WIP/29Oct2022.zip
u-boot-WIP/29Oct2022.tar.gz
u-boot-WIP/29Oct2022.tar.bz2
Merge tag 'dm-pull-29oct22' of https://source.denx.de/u-boot/custodians/u-boot-dmWIP/29Oct2022
Fix pylibfdt warnings and use setuptools to build Various minor changes to core dm and sandbox
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/Kconfig14
-rw-r--r--drivers/core/lists.c4
-rw-r--r--drivers/core/uclass.c30
-rw-r--r--drivers/dma/dma-uclass.c7
-rw-r--r--drivers/gpio/gpio-uclass.c18
-rw-r--r--drivers/pci/pci-uclass.c22
-rw-r--r--drivers/sysinfo/sysinfo-uclass.c10
-rw-r--r--drivers/w1/w1-uclass.c9
8 files changed, 62 insertions, 52 deletions
diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 0dc442b..b79e99b 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -350,6 +350,20 @@ config SPL_OF_TRANSLATE
used for the address translation. This function is faster and
smaller in size than fdt_translate_address().
+config TPL_OF_TRANSLATE
+ bool "Translate addresses using fdt_translate_address in TPL"
+ depends on TPL_DM && TPL_OF_CONTROL
+ help
+ If this option is enabled, the reg property will be translated
+ using the fdt_translate_address() function. This is necessary
+ on some platforms (e.g. MVEBU) using complex "ranges"
+ properties in many nodes. As this translation is not handled
+ correctly in the default simple_bus_translate() function.
+
+ If this option is not enabled, simple_bus_translate() will be
+ used for the address translation. This function is faster and
+ smaller in size than fdt_translate_address()
+
config VPL_OF_TRANSLATE
bool "Translate addresses using fdt_translate_address in SPL"
depends on SPL_DM && VPL_OF_CONTROL
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index c49695b..3878957 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -222,6 +222,7 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
log_debug(" - attempt to match compatible string '%s'\n",
compat);
+ id = NULL;
for (entry = driver; entry != driver + n_ents; entry++) {
if (drv) {
if (drv != entry)
@@ -250,7 +251,8 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp,
entry->name, entry->of_match->compatible,
id->compatible);
ret = device_bind_with_driver_data(parent, entry, name,
- id->data, node, &dev);
+ id ? id->data : 0, node,
+ &dev);
if (ret == -ENODEV) {
log_debug("Driver '%s' refuses to bind\n", entry->name);
continue;
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index b7d11bd..1762a07 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -574,28 +574,34 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent,
}
#endif
-int uclass_first_device(enum uclass_id id, struct udevice **devp)
+/*
+ * Starting from the given device @dev, return pointer to the first device in
+ * the uclass that probes successfully in @devp.
+ */
+static void _uclass_next_device(struct udevice *dev, struct udevice **devp)
+{
+ for (; dev; uclass_find_next_device(&dev)) {
+ if (!device_probe(dev))
+ break;
+ }
+ *devp = dev;
+}
+
+void uclass_first_device(enum uclass_id id, struct udevice **devp)
{
struct udevice *dev;
int ret;
- *devp = NULL;
ret = uclass_find_first_device(id, &dev);
- if (!dev)
- return 0;
- return uclass_get_device_tail(dev, ret, devp);
+ _uclass_next_device(dev, devp);
}
-int uclass_next_device(struct udevice **devp)
+void uclass_next_device(struct udevice **devp)
{
struct udevice *dev = *devp;
- int ret;
- *devp = NULL;
- ret = uclass_find_next_device(&dev);
- if (!dev)
- return 0;
- return uclass_get_device_tail(dev, ret, devp);
+ uclass_find_next_device(&dev);
+ _uclass_next_device(dev, devp);
}
int uclass_first_device_err(enum uclass_id id, struct udevice **devp)
diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c
index 81dbb4d..34f72fa 100644
--- a/drivers/dma/dma-uclass.c
+++ b/drivers/dma/dma-uclass.c
@@ -210,10 +210,9 @@ int dma_get_cfg(struct dma *dma, u32 cfg_id, void **cfg_data)
int dma_get_device(u32 transfer_type, struct udevice **devp)
{
struct udevice *dev;
- int ret;
- for (ret = uclass_first_device(UCLASS_DMA, &dev); dev && !ret;
- ret = uclass_next_device(&dev)) {
+ for (uclass_first_device(UCLASS_DMA, &dev); dev;
+ uclass_next_device(&dev)) {
struct dma_dev_priv *uc_priv;
uc_priv = dev_get_uclass_priv(dev);
@@ -229,7 +228,7 @@ int dma_get_device(u32 transfer_type, struct udevice **devp)
*devp = dev;
- return ret;
+ return 0;
}
int dma_memcpy(void *dst, void *src, size_t len)
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index a00880e..3a6ef3b 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -59,11 +59,10 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
{
struct gpio_dev_priv *uc_priv;
struct udevice *dev;
- int ret;
- for (ret = uclass_first_device(UCLASS_GPIO, &dev);
+ for (uclass_first_device(UCLASS_GPIO, &dev);
dev;
- ret = uclass_next_device(&dev)) {
+ uclass_next_device(&dev)) {
uc_priv = dev_get_uclass_priv(dev);
if (gpio >= uc_priv->gpio_base &&
gpio < uc_priv->gpio_base + uc_priv->gpio_count) {
@@ -73,7 +72,7 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
}
/* No such GPIO */
- return ret ? ret : -ENOENT;
+ return -ENOENT;
}
#if CONFIG_IS_ENABLED(DM_GPIO_LOOKUP_LABEL)
@@ -91,15 +90,13 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
static int dm_gpio_lookup_label(const char *name,
struct gpio_dev_priv *uc_priv, ulong *offset)
{
- int len;
int i;
*offset = -1;
- len = strlen(name);
for (i = 0; i < uc_priv->gpio_count; i++) {
if (!uc_priv->name[i])
continue;
- if (!strncmp(name, uc_priv->name[i], len)) {
+ if (!strcmp(name, uc_priv->name[i])) {
*offset = i;
return 0;
}
@@ -121,12 +118,11 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
struct udevice *dev;
ulong offset;
int numeric;
- int ret;
numeric = isdigit(*name) ? dectoul(name, NULL) : -1;
- for (ret = uclass_first_device(UCLASS_GPIO, &dev);
+ for (uclass_first_device(UCLASS_GPIO, &dev);
dev;
- ret = uclass_next_device(&dev)) {
+ uclass_next_device(&dev)) {
int len;
uc_priv = dev_get_uclass_priv(dev);
@@ -154,7 +150,7 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
}
if (!dev)
- return ret ? ret : -EINVAL;
+ return -EINVAL;
gpio_desc_init(desc, dev, offset);
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 5cff81a..9343cfc 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -1211,7 +1211,6 @@ static int pci_bridge_write_config(struct udevice *bus, pci_dev_t bdf,
static int skip_to_next_device(struct udevice *bus, struct udevice **devp)
{
struct udevice *dev;
- int ret = 0;
/*
* Scan through all the PCI controllers. On x86 there will only be one
@@ -1223,9 +1222,7 @@ static int skip_to_next_device(struct udevice *bus, struct udevice **devp)
*devp = dev;
return 0;
}
- ret = uclass_next_device(&bus);
- if (ret)
- return ret;
+ uclass_next_device(&bus);
}
return 0;
@@ -1235,7 +1232,6 @@ int pci_find_next_device(struct udevice **devp)
{
struct udevice *child = *devp;
struct udevice *bus = child->parent;
- int ret;
/* First try all the siblings */
*devp = NULL;
@@ -1248,9 +1244,7 @@ int pci_find_next_device(struct udevice **devp)
}
/* We ran out of siblings. Try the next bus */
- ret = uclass_next_device(&bus);
- if (ret)
- return ret;
+ uclass_next_device(&bus);
return bus ? skip_to_next_device(bus, devp) : 0;
}
@@ -1258,12 +1252,9 @@ int pci_find_next_device(struct udevice **devp)
int pci_find_first_device(struct udevice **devp)
{
struct udevice *bus;
- int ret;
*devp = NULL;
- ret = uclass_first_device(UCLASS_PCI, &bus);
- if (ret)
- return ret;
+ uclass_first_device(UCLASS_PCI, &bus);
return skip_to_next_device(bus, devp);
}
@@ -1777,10 +1768,9 @@ int pci_sriov_init(struct udevice *pdev, int vf_en)
bdf = dm_pci_get_bdf(pdev);
- pci_get_bus(PCI_BUS(bdf), &bus);
-
- if (!bus)
- return -ENODEV;
+ ret = pci_get_bus(PCI_BUS(bdf), &bus);
+ if (ret)
+ return ret;
bdf += PCI_BDF(0, 0, vf_offset);
diff --git a/drivers/sysinfo/sysinfo-uclass.c b/drivers/sysinfo/sysinfo-uclass.c
index c5cc3cb..10194d0 100644
--- a/drivers/sysinfo/sysinfo-uclass.c
+++ b/drivers/sysinfo/sysinfo-uclass.c
@@ -16,7 +16,15 @@ struct sysinfo_priv {
int sysinfo_get(struct udevice **devp)
{
- return uclass_first_device_err(UCLASS_SYSINFO, devp);
+ int ret = uclass_first_device_err(UCLASS_SYSINFO, devp);
+
+ /*
+ * There is some very dodgy error handling in gazerbeam,
+ * do not return a device on error.
+ */
+ if (ret)
+ *devp = NULL;
+ return ret;
}
int sysinfo_detect(struct udevice *dev)
diff --git a/drivers/w1/w1-uclass.c b/drivers/w1/w1-uclass.c
index de4f25b..a4247ec 100644
--- a/drivers/w1/w1-uclass.c
+++ b/drivers/w1/w1-uclass.c
@@ -36,15 +36,10 @@ int w1_bus_find_dev(const struct udevice *bus, u64 id, struct udevice
{
struct udevice *dev;
u8 family = id & 0xff;
- int ret;
- for (ret = uclass_first_device(UCLASS_W1_EEPROM, &dev);
- !ret && dev;
+ for (uclass_first_device(UCLASS_W1_EEPROM, &dev);
+ dev;
uclass_next_device(&dev)) {
- if (ret || !dev) {
- debug("cannot find w1 eeprom dev\n");
- return -ENODEV;
- }
if (dev_get_driver_data(dev) == family) {
*devp = dev;