diff options
author | Tom Rini <trini@konsulko.com> | 2020-02-11 10:58:41 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-02-11 10:58:41 -0500 |
commit | 9a8942b53d57149754e0dfc975e0d92d1afd4087 (patch) | |
tree | de55e5352f3a8a79c413c0b8cb533428e5476841 /drivers/core | |
parent | ae347120eed8204b1fdf018ddf79131964e57016 (diff) | |
parent | 21d651fb29cf268b1a5f64d080e3d352ee32c87f (diff) | |
download | u-boot-9a8942b53d57149754e0dfc975e0d92d1afd4087.tar.gz |
Merge tag 'dm-pull-6feb20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
sandbox conversion to SDL2
TPM TEE driver
Various minor sandbox video enhancements
New driver model core utility functions
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/device.c | 85 | ||||
-rw-r--r-- | drivers/core/devres.c | 2 | ||||
-rw-r--r-- | drivers/core/dump.c | 19 | ||||
-rw-r--r-- | drivers/core/fdtaddr.c | 26 | ||||
-rw-r--r-- | drivers/core/of_access.c | 1 | ||||
-rw-r--r-- | drivers/core/ofnode.c | 72 | ||||
-rw-r--r-- | drivers/core/read.c | 97 | ||||
-rw-r--r-- | drivers/core/syscon-uclass.c | 1 | ||||
-rw-r--r-- | drivers/core/uclass.c | 4 |
9 files changed, 202 insertions, 105 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c index 9f39218423..89ea820d48 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -591,7 +591,8 @@ static int device_find_by_ofnode(ofnode node, struct udevice **devp) } #endif -int device_get_child(struct udevice *parent, int index, struct udevice **devp) +int device_get_child(const struct udevice *parent, int index, + struct udevice **devp) { struct udevice *dev; @@ -603,7 +604,7 @@ int device_get_child(struct udevice *parent, int index, struct udevice **devp) return -ENODEV; } -int device_get_child_count(struct udevice *parent) +int device_get_child_count(const struct udevice *parent) { struct udevice *dev; int count = 0; @@ -614,7 +615,7 @@ int device_get_child_count(struct udevice *parent) return count; } -int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq, +int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq, bool find_req_seq, struct udevice **devp) { struct udevice *dev; @@ -634,7 +635,7 @@ int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq, return -ENODEV; } -int device_get_child_by_seq(struct udevice *parent, int seq, +int device_get_child_by_seq(const struct udevice *parent, int seq, struct udevice **devp) { struct udevice *dev; @@ -652,7 +653,7 @@ int device_get_child_by_seq(struct udevice *parent, int seq, return device_get_device_tail(dev, ret, devp); } -int device_find_child_by_of_offset(struct udevice *parent, int of_offset, +int device_find_child_by_of_offset(const struct udevice *parent, int of_offset, struct udevice **devp) { struct udevice *dev; @@ -669,7 +670,7 @@ int device_find_child_by_of_offset(struct udevice *parent, int of_offset, return -ENODEV; } -int device_get_child_by_of_offset(struct udevice *parent, int node, +int device_get_child_by_of_offset(const struct udevice *parent, int node, struct udevice **devp) { struct udevice *dev; @@ -712,7 +713,7 @@ int device_get_global_by_ofnode(ofnode ofnode, struct udevice **devp) return device_get_device_tail(dev, dev ? 0 : -ENOENT, devp); } -int device_find_first_child(struct udevice *parent, struct udevice **devp) +int device_find_first_child(const struct udevice *parent, struct udevice **devp) { if (list_empty(&parent->child_head)) { *devp = NULL; @@ -739,7 +740,7 @@ int device_find_next_child(struct udevice **devp) return 0; } -int device_find_first_inactive_child(struct udevice *parent, +int device_find_first_inactive_child(const struct udevice *parent, enum uclass_id uclass_id, struct udevice **devp) { @@ -757,7 +758,7 @@ int device_find_first_inactive_child(struct udevice *parent, return -ENODEV; } -int device_find_first_child_by_uclass(struct udevice *parent, +int device_find_first_child_by_uclass(const struct udevice *parent, enum uclass_id uclass_id, struct udevice **devp) { @@ -774,7 +775,7 @@ int device_find_first_child_by_uclass(struct udevice *parent, return -ENODEV; } -int device_find_child_by_name(struct udevice *parent, const char *name, +int device_find_child_by_name(const struct udevice *parent, const char *name, struct udevice **devp) { struct udevice *dev; @@ -791,6 +792,64 @@ int device_find_child_by_name(struct udevice *parent, const char *name, return -ENODEV; } +int device_first_child_err(struct udevice *parent, struct udevice **devp) +{ + struct udevice *dev; + + device_find_first_child(parent, &dev); + if (!dev) + return -ENODEV; + + return device_get_device_tail(dev, 0, devp); +} + +int device_next_child_err(struct udevice **devp) +{ + struct udevice *dev = *devp; + + device_find_next_child(&dev); + if (!dev) + return -ENODEV; + + return device_get_device_tail(dev, 0, devp); +} + +int device_first_child_ofdata_err(struct udevice *parent, struct udevice **devp) +{ + struct udevice *dev; + int ret; + + device_find_first_child(parent, &dev); + if (!dev) + return -ENODEV; + + ret = device_ofdata_to_platdata(dev); + if (ret) + return ret; + + *devp = dev; + + return 0; +} + +int device_next_child_ofdata_err(struct udevice **devp) +{ + struct udevice *dev = *devp; + int ret; + + device_find_next_child(&dev); + if (!dev) + return -ENODEV; + + ret = device_ofdata_to_platdata(dev); + if (ret) + return ret; + + *devp = dev; + + return 0; +} + struct udevice *dev_get_parent(const struct udevice *child) { return child->parent; @@ -827,7 +886,7 @@ bool device_has_children(const struct udevice *dev) return !list_empty(&dev->child_head); } -bool device_has_active_children(struct udevice *dev) +bool device_has_active_children(const struct udevice *dev) { struct udevice *child; @@ -841,7 +900,7 @@ bool device_has_active_children(struct udevice *dev) return false; } -bool device_is_last_sibling(struct udevice *dev) +bool device_is_last_sibling(const struct udevice *dev) { struct udevice *parent = dev->parent; @@ -867,7 +926,7 @@ int device_set_name(struct udevice *dev, const char *name) } #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) -bool device_is_compatible(struct udevice *dev, const char *compat) +bool device_is_compatible(const struct udevice *dev, const char *compat) { return ofnode_device_is_compatible(dev_ofnode(dev), compat); } diff --git a/drivers/core/devres.c b/drivers/core/devres.c index 237b42653c..457e1309c5 100644 --- a/drivers/core/devres.c +++ b/drivers/core/devres.c @@ -10,10 +10,12 @@ #define LOG_CATEGORY LOGC_DEVRES #include <common.h> +#include <malloc.h> #include <linux/compat.h> #include <linux/kernel.h> #include <linux/list.h> #include <dm/device.h> +#include <dm/devres.h> #include <dm/root.h> #include <dm/util.h> diff --git a/drivers/core/dump.c b/drivers/core/dump.c index 4704049aee..e73ebeabcc 100644 --- a/drivers/core/dump.c +++ b/drivers/core/dump.c @@ -96,3 +96,22 @@ void dm_dump_uclass(void) puts("\n"); } } + +void dm_dump_drivers(void) +{ + struct driver *d = ll_entry_start(struct driver, driver); + const int n_ents = ll_entry_count(struct driver, driver); + struct driver *entry; + const struct udevice_id *match; + + puts("Driver Compatible\n"); + puts("--------------------------------\n"); + for (entry = d; entry < d + n_ents; entry++) { + for (match = entry->of_match; match->compatible; match++) + printf("%-20.20s %s\n", + match == entry->of_match ? entry->name : "", + match->compatible); + if (match == entry->of_match) + printf("%-20.20s\n", entry->name); + } +} diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c index 575798fae9..33811e62f7 100644 --- a/drivers/core/fdtaddr.c +++ b/drivers/core/fdtaddr.c @@ -16,7 +16,7 @@ DECLARE_GLOBAL_DATA_PTR; -fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index) +fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index) { #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) fdt_addr_t addr; @@ -91,8 +91,8 @@ fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index) #endif } -fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index, - fdt_size_t *size) +fdt_addr_t devfdt_get_addr_size_index(const struct udevice *dev, int index, + fdt_size_t *size) { #if CONFIG_IS_ENABLED(OF_CONTROL) /* @@ -113,7 +113,7 @@ fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index, #endif } -fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name) +fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name) { #if CONFIG_IS_ENABLED(OF_CONTROL) int index; @@ -129,8 +129,8 @@ fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name) #endif } -fdt_addr_t devfdt_get_addr_size_name(struct udevice *dev, const char *name, - fdt_size_t *size) +fdt_addr_t devfdt_get_addr_size_name(const struct udevice *dev, + const char *name, fdt_size_t *size) { #if CONFIG_IS_ENABLED(OF_CONTROL) int index; @@ -146,17 +146,17 @@ fdt_addr_t devfdt_get_addr_size_name(struct udevice *dev, const char *name, #endif } -fdt_addr_t devfdt_get_addr(struct udevice *dev) +fdt_addr_t devfdt_get_addr(const struct udevice *dev) { return devfdt_get_addr_index(dev, 0); } -void *devfdt_get_addr_ptr(struct udevice *dev) +void *devfdt_get_addr_ptr(const struct udevice *dev) { return (void *)(uintptr_t)devfdt_get_addr_index(dev, 0); } -void *devfdt_remap_addr_index(struct udevice *dev, int index) +void *devfdt_remap_addr_index(const struct udevice *dev, int index) { fdt_addr_t addr = devfdt_get_addr_index(dev, index); @@ -166,7 +166,7 @@ void *devfdt_remap_addr_index(struct udevice *dev, int index) return map_physmem(addr, 0, MAP_NOCACHE); } -void *devfdt_remap_addr_name(struct udevice *dev, const char *name) +void *devfdt_remap_addr_name(const struct udevice *dev, const char *name) { fdt_addr_t addr = devfdt_get_addr_name(dev, name); @@ -176,12 +176,12 @@ void *devfdt_remap_addr_name(struct udevice *dev, const char *name) return map_physmem(addr, 0, MAP_NOCACHE); } -void *devfdt_remap_addr(struct udevice *dev) +void *devfdt_remap_addr(const struct udevice *dev) { return devfdt_remap_addr_index(dev, 0); } -void *devfdt_map_physmem(struct udevice *dev, unsigned long size) +void *devfdt_map_physmem(const struct udevice *dev, unsigned long size) { fdt_addr_t addr = devfdt_get_addr(dev); @@ -191,7 +191,7 @@ void *devfdt_map_physmem(struct udevice *dev, unsigned long size) return map_physmem(addr, size, MAP_NOCACHE); } -fdt_addr_t devfdt_get_addr_pci(struct udevice *dev) +fdt_addr_t devfdt_get_addr_pci(const struct udevice *dev) { ulong addr; diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c index 945b81448c..acd745c121 100644 --- a/drivers/core/of_access.c +++ b/drivers/core/of_access.c @@ -20,6 +20,7 @@ */ #include <common.h> +#include <malloc.h> #include <linux/libfdt.h> #include <dm/of_access.h> #include <linux/ctype.h> diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 8f0eab2ca6..96a5dd20bd 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -8,6 +8,7 @@ #include <dm.h> #include <fdtdec.h> #include <fdt_support.h> +#include <malloc.h> #include <linux/libfdt.h> #include <dm/of_access.h> #include <dm/of_addr.h> @@ -101,30 +102,47 @@ bool ofnode_read_bool(ofnode node, const char *propname) return prop ? true : false; } -const char *ofnode_read_string(ofnode node, const char *propname) +const void *ofnode_read_prop(ofnode node, const char *propname, int *sizep) { - const char *str = NULL; - int len = -1; + const char *val = NULL; + int len; assert(ofnode_valid(node)); debug("%s: %s: ", __func__, propname); if (ofnode_is_np(node)) { struct property *prop = of_find_property( - ofnode_to_np(node), propname, NULL); + ofnode_to_np(node), propname, &len); if (prop) { - str = prop->value; + val = prop->value; len = prop->length; } } else { - str = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), + val = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname, &len); } - if (!str) { + if (!val) { debug("<not found>\n"); + if (sizep) + *sizep = -FDT_ERR_NOTFOUND; return NULL; } + if (sizep) + *sizep = len; + + return val; +} + +const char *ofnode_read_string(ofnode node, const char *propname) +{ + const char *str; + int len; + + str = ofnode_read_prop(node, propname, &len); + if (!str) + return NULL; + if (strnlen(str, len) >= len) { debug("<invalid>\n"); return NULL; @@ -134,6 +152,16 @@ const char *ofnode_read_string(ofnode node, const char *propname) return str; } +int ofnode_read_size(ofnode node, const char *propname) +{ + int len; + + if (!ofnode_read_prop(node, propname, &len)) + return -EINVAL; + + return len; +} + ofnode ofnode_find_subnode(ofnode node, const char *subnode_name) { ofnode subnode; @@ -236,25 +264,6 @@ ofnode ofnode_get_by_phandle(uint phandle) return node; } -int ofnode_read_size(ofnode node, const char *propname) -{ - int len; - - if (ofnode_is_np(node)) { - struct property *prop = of_find_property( - ofnode_to_np(node), propname, NULL); - - if (prop) - return prop->length; - } else { - if (fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname, - &len)) - return len; - } - - return -EINVAL; -} - fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size) { int na, ns; @@ -419,20 +428,25 @@ ofnode ofnode_path(const char *path) return offset_to_ofnode(fdt_path_offset(gd->fdt_blob, path)); } -const char *ofnode_get_chosen_prop(const char *name) +const void *ofnode_read_chosen_prop(const char *propname, int *sizep) { ofnode chosen_node; chosen_node = ofnode_path("/chosen"); - return ofnode_read_string(chosen_node, name); + return ofnode_read_prop(chosen_node, propname, sizep); +} + +const char *ofnode_read_chosen_string(const char *propname) +{ + return ofnode_read_chosen_prop(propname, NULL); } ofnode ofnode_get_chosen_node(const char *name) { const char *prop; - prop = ofnode_get_chosen_prop(name); + prop = ofnode_read_chosen_prop(name, NULL); if (!prop) return ofnode_null(); diff --git a/drivers/core/read.c b/drivers/core/read.c index 9602e52d1b..1f999b1b31 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -11,27 +11,29 @@ #include <mapmem.h> #include <dm/of_access.h> -int dev_read_u32(struct udevice *dev, const char *propname, u32 *outp) +int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp) { return ofnode_read_u32(dev_ofnode(dev), propname, outp); } -int dev_read_u32_default(struct udevice *dev, const char *propname, int def) +int dev_read_u32_default(const struct udevice *dev, const char *propname, + int def) { return ofnode_read_u32_default(dev_ofnode(dev), propname, def); } -int dev_read_s32(struct udevice *dev, const char *propname, s32 *outp) +int dev_read_s32(const struct udevice *dev, const char *propname, s32 *outp) { return ofnode_read_u32(dev_ofnode(dev), propname, (u32 *)outp); } -int dev_read_s32_default(struct udevice *dev, const char *propname, int def) +int dev_read_s32_default(const struct udevice *dev, const char *propname, + int def) { return ofnode_read_u32_default(dev_ofnode(dev), propname, def); } -int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp) +int dev_read_u32u(const struct udevice *dev, const char *propname, uint *outp) { u32 val; int ret; @@ -44,32 +46,33 @@ int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp) return 0; } -int dev_read_u64(struct udevice *dev, const char *propname, u64 *outp) +int dev_read_u64(const struct udevice *dev, const char *propname, u64 *outp) { return ofnode_read_u64(dev_ofnode(dev), propname, outp); } -u64 dev_read_u64_default(struct udevice *dev, const char *propname, u64 def) +u64 dev_read_u64_default(const struct udevice *dev, const char *propname, + u64 def) { return ofnode_read_u64_default(dev_ofnode(dev), propname, def); } -const char *dev_read_string(struct udevice *dev, const char *propname) +const char *dev_read_string(const struct udevice *dev, const char *propname) { return ofnode_read_string(dev_ofnode(dev), propname); } -bool dev_read_bool(struct udevice *dev, const char *propname) +bool dev_read_bool(const struct udevice *dev, const char *propname) { return ofnode_read_bool(dev_ofnode(dev), propname); } -ofnode dev_read_subnode(struct udevice *dev, const char *subnode_name) +ofnode dev_read_subnode(const struct udevice *dev, const char *subnode_name) { return ofnode_find_subnode(dev_ofnode(dev), subnode_name); } -ofnode dev_read_first_subnode(struct udevice *dev) +ofnode dev_read_first_subnode(const struct udevice *dev) { return ofnode_first_subnode(dev_ofnode(dev)); } @@ -79,12 +82,12 @@ ofnode dev_read_next_subnode(ofnode node) return ofnode_next_subnode(node); } -int dev_read_size(struct udevice *dev, const char *propname) +int dev_read_size(const struct udevice *dev, const char *propname) { return ofnode_read_size(dev_ofnode(dev), propname); } -fdt_addr_t dev_read_addr_index(struct udevice *dev, int index) +fdt_addr_t dev_read_addr_index(const struct udevice *dev, int index) { if (ofnode_is_np(dev_ofnode(dev))) return ofnode_get_addr_index(dev_ofnode(dev), index); @@ -92,7 +95,7 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index) return devfdt_get_addr_index(dev, index); } -fdt_addr_t dev_read_addr_size_index(struct udevice *dev, int index, +fdt_addr_t dev_read_addr_size_index(const struct udevice *dev, int index, fdt_size_t *size) { if (ofnode_is_np(dev_ofnode(dev))) @@ -101,7 +104,7 @@ fdt_addr_t dev_read_addr_size_index(struct udevice *dev, int index, return devfdt_get_addr_size_index(dev, index, size); } -void *dev_remap_addr_index(struct udevice *dev, int index) +void *dev_remap_addr_index(const struct udevice *dev, int index) { fdt_addr_t addr = dev_read_addr_index(dev, index); @@ -111,7 +114,7 @@ void *dev_remap_addr_index(struct udevice *dev, int index) return map_physmem(addr, 0, MAP_NOCACHE); } -fdt_addr_t dev_read_addr_name(struct udevice *dev, const char *name) +fdt_addr_t dev_read_addr_name(const struct udevice *dev, const char *name) { int index = dev_read_stringlist_search(dev, "reg-names", name); @@ -121,7 +124,7 @@ fdt_addr_t dev_read_addr_name(struct udevice *dev, const char *name) return dev_read_addr_index(dev, index); } -fdt_addr_t dev_read_addr_size_name(struct udevice *dev, const char *name, +fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name, fdt_size_t *size) { int index = dev_read_stringlist_search(dev, "reg-names", name); @@ -132,7 +135,7 @@ fdt_addr_t dev_read_addr_size_name(struct udevice *dev, const char *name, return dev_read_addr_size_index(dev, index, size); } -void *dev_remap_addr_name(struct udevice *dev, const char *name) +void *dev_remap_addr_name(const struct udevice *dev, const char *name) { fdt_addr_t addr = dev_read_addr_name(dev, name); @@ -142,52 +145,52 @@ void *dev_remap_addr_name(struct udevice *dev, const char *name) return map_physmem(addr, 0, MAP_NOCACHE); } -fdt_addr_t dev_read_addr(struct udevice *dev) +fdt_addr_t dev_read_addr(const struct udevice *dev) { return dev_read_addr_index(dev, 0); } -void *dev_read_addr_ptr(struct udevice *dev) +void *dev_read_addr_ptr(const struct udevice *dev) { fdt_addr_t addr = dev_read_addr(dev); return (addr == FDT_ADDR_T_NONE) ? NULL : map_sysmem(addr, 0); } -void *dev_remap_addr(struct udevice *dev) +void *dev_remap_addr(const struct udevice *dev) { return dev_remap_addr_index(dev, 0); } -fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property, +fdt_addr_t dev_read_addr_size(const struct udevice *dev, const char *property, fdt_size_t *sizep) { return ofnode_get_addr_size(dev_ofnode(dev), property, sizep); } -const char *dev_read_name(struct udevice *dev) +const char *dev_read_name(const struct udevice *dev) { return ofnode_get_name(dev_ofnode(dev)); } -int dev_read_stringlist_search(struct udevice *dev, const char *property, +int dev_read_stringlist_search(const struct udevice *dev, const char *property, const char *string) { return ofnode_stringlist_search(dev_ofnode(dev), property, string); } -int dev_read_string_index(struct udevice *dev, const char *propname, int index, - const char **outp) +int dev_read_string_index(const struct udevice *dev, const char *propname, + int index, const char **outp) { return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp); } -int dev_read_string_count(struct udevice *dev, const char *propname) +int dev_read_string_count(const struct udevice *dev, const char *propname) { return ofnode_read_string_count(dev_ofnode(dev), propname); } -int dev_read_phandle_with_args(struct udevice *dev, const char *list_name, +int dev_read_phandle_with_args(const struct udevice *dev, const char *list_name, const char *cells_name, int cell_count, int index, struct ofnode_phandle_args *out_args) { @@ -196,34 +199,34 @@ int dev_read_phandle_with_args(struct udevice *dev, const char *list_name, out_args); } -int dev_count_phandle_with_args(struct udevice *dev, const char *list_name, - const char *cells_name) +int dev_count_phandle_with_args(const struct udevice *dev, + const char *list_name, const char *cells_name) { return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name, cells_name); } -int dev_read_addr_cells(struct udevice *dev) +int dev_read_addr_cells(const struct udevice *dev) { return ofnode_read_addr_cells(dev_ofnode(dev)); } -int dev_read_size_cells(struct udevice *dev) +int dev_read_size_cells(const struct udevice *dev) { return ofnode_read_size_cells(dev_ofnode(dev)); } -int dev_read_simple_addr_cells(struct udevice *dev) +int dev_read_simple_addr_cells(const struct udevice *dev) { return ofnode_read_simple_addr_cells(dev_ofnode(dev)); } -int dev_read_simple_size_cells(struct udevice *dev) +int dev_read_simple_size_cells(const struct udevice *dev) { return ofnode_read_simple_size_cells(dev_ofnode(dev)); } -int dev_read_phandle(struct udevice *dev) +int dev_read_phandle(const struct udevice *dev) { ofnode node = dev_ofnode(dev); @@ -233,12 +236,13 @@ int dev_read_phandle(struct udevice *dev) return fdt_get_phandle(gd->fdt_blob, ofnode_to_offset(node)); } -const void *dev_read_prop(struct udevice *dev, const char *propname, int *lenp) +const void *dev_read_prop(const struct udevice *dev, const char *propname, + int *lenp) { return ofnode_get_property(dev_ofnode(dev), propname, lenp); } -int dev_read_alias_seq(struct udevice *dev, int *devnump) +int dev_read_alias_seq(const struct udevice *dev, int *devnump) { ofnode node = dev_ofnode(dev); const char *uc_name = dev->uclass->uc_drv->name; @@ -256,19 +260,19 @@ int dev_read_alias_seq(struct udevice *dev, int *devnump) return ret; } -int dev_read_u32_array(struct udevice *dev, const char *propname, +int dev_read_u32_array(const struct udevice *dev, const char *propname, u32 *out_values, size_t sz) { return ofnode_read_u32_array(dev_ofnode(dev), propname, out_values, sz); } -const uint8_t *dev_read_u8_array_ptr(struct udevice *dev, const char *propname, - size_t sz) +const uint8_t *dev_read_u8_array_ptr(const struct udevice *dev, + const char *propname, size_t sz) { return ofnode_read_u8_array_ptr(dev_ofnode(dev), propname, sz); } -int dev_read_enabled(struct udevice *dev) +int dev_read_enabled(const struct udevice *dev) { ofnode node = dev_ofnode(dev); @@ -279,23 +283,24 @@ int dev_read_enabled(struct udevice *dev) ofnode_to_offset(node)); } -int dev_read_resource(struct udevice *dev, uint index, struct resource *res) +int dev_read_resource(const struct udevice *dev, uint index, + struct resource *res) { return ofnode_read_resource(dev_ofnode(dev), index, res); } -int dev_read_resource_byname(struct udevice *dev, const char *name, +int dev_read_resource_byname(const struct udevice *dev, const char *name, struct resource *res) { return ofnode_read_resource_byname(dev_ofnode(dev), name, res); } -u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr) +u64 dev_translate_address(const struct udevice *dev, const fdt32_t *in_addr) { return ofnode_translate_address(dev_ofnode(dev), in_addr); } -u64 dev_translate_dma_address(struct udevice *dev, const fdt32_t *in_addr) +u64 dev_translate_dma_address(const struct udevice *dev, const fdt32_t *in_addr) { return ofnode_translate_dma_address(dev_ofnode(dev), in_addr); } @@ -308,7 +313,7 @@ int dev_read_alias_highest_id(const char *stem) return fdtdec_get_alias_highest_id(gd->fdt_blob, stem); } -fdt_addr_t dev_read_addr_pci(struct udevice *dev) +fdt_addr_t dev_read_addr_pci(const struct udevice *dev) { ulong addr; diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c index b9ae82174e..15f0e42a85 100644 --- a/drivers/core/syscon-uclass.c +++ b/drivers/core/syscon-uclass.c @@ -10,6 +10,7 @@ #include <errno.h> #include <regmap.h> #include <dm/device-internal.h> +#include <dm/device_compat.h> #include <dm/lists.h> #include <dm/root.h> #include <linux/err.h> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 61192d8a9f..58b19a4210 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -271,9 +271,6 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name, return -ENODEV; } -#if !CONFIG_IS_ENABLED(OF_CONTROL) || \ - CONFIG_IS_ENABLED(OF_PLATDATA) || \ - CONFIG_IS_ENABLED(OF_PRIOR_STAGE) int uclass_find_next_free_req_seq(enum uclass_id id) { struct uclass *uc; @@ -295,7 +292,6 @@ int uclass_find_next_free_req_seq(enum uclass_id id) return max + 1; } -#endif int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, bool find_req_seq, struct udevice **devp) |