Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2017 Google, Inc |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
Álvaro Fernández Rojas | 67036129 | 2018-04-29 21:56:54 +0200 | [diff] [blame] | 7 | #include <asm/types.h> |
| 8 | #include <asm/io.h> |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 9 | #include <common.h> |
| 10 | #include <dm.h> |
Simon Glass | c47a388 | 2017-09-28 06:35:15 -0600 | [diff] [blame] | 11 | #include <mapmem.h> |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 12 | #include <dm/of_access.h> |
| 13 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 14 | int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp) |
Masahiro Yamada | 71d115f | 2017-12-30 02:00:05 +0900 | [diff] [blame] | 15 | { |
| 16 | return ofnode_read_u32(dev_ofnode(dev), propname, outp); |
| 17 | } |
| 18 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 19 | int dev_read_u32_default(const struct udevice *dev, const char *propname, |
| 20 | int def) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 21 | { |
| 22 | return ofnode_read_u32_default(dev_ofnode(dev), propname, def); |
| 23 | } |
| 24 | |
Dario Binacchi | 81d80b5 | 2020-03-29 18:04:41 +0200 | [diff] [blame] | 25 | int dev_read_u32_index(struct udevice *dev, const char *propname, int index, |
| 26 | u32 *outp) |
| 27 | { |
| 28 | return ofnode_read_u32_index(dev_ofnode(dev), propname, index, outp); |
| 29 | } |
| 30 | |
| 31 | u32 dev_read_u32_index_default(struct udevice *dev, const char *propname, |
| 32 | int index, u32 def) |
| 33 | { |
| 34 | return ofnode_read_u32_index_default(dev_ofnode(dev), propname, index, |
| 35 | def); |
| 36 | } |
| 37 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 38 | int dev_read_s32(const struct udevice *dev, const char *propname, s32 *outp) |
Simon Glass | 6df01f9 | 2018-12-10 10:37:37 -0700 | [diff] [blame] | 39 | { |
| 40 | return ofnode_read_u32(dev_ofnode(dev), propname, (u32 *)outp); |
| 41 | } |
| 42 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 43 | int dev_read_s32_default(const struct udevice *dev, const char *propname, |
| 44 | int def) |
Simon Glass | 6df01f9 | 2018-12-10 10:37:37 -0700 | [diff] [blame] | 45 | { |
| 46 | return ofnode_read_u32_default(dev_ofnode(dev), propname, def); |
| 47 | } |
| 48 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 49 | int dev_read_u32u(const struct udevice *dev, const char *propname, uint *outp) |
Simon Glass | 6df01f9 | 2018-12-10 10:37:37 -0700 | [diff] [blame] | 50 | { |
| 51 | u32 val; |
| 52 | int ret; |
| 53 | |
| 54 | ret = ofnode_read_u32(dev_ofnode(dev), propname, &val); |
| 55 | if (ret) |
| 56 | return ret; |
| 57 | *outp = val; |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 62 | int dev_read_u64(const struct udevice *dev, const char *propname, u64 *outp) |
T Karthik Reddy | 478860d | 2019-09-02 16:34:30 +0200 | [diff] [blame] | 63 | { |
| 64 | return ofnode_read_u64(dev_ofnode(dev), propname, outp); |
| 65 | } |
| 66 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 67 | u64 dev_read_u64_default(const struct udevice *dev, const char *propname, |
| 68 | u64 def) |
T Karthik Reddy | 478860d | 2019-09-02 16:34:30 +0200 | [diff] [blame] | 69 | { |
| 70 | return ofnode_read_u64_default(dev_ofnode(dev), propname, def); |
| 71 | } |
| 72 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 73 | const char *dev_read_string(const struct udevice *dev, const char *propname) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 74 | { |
| 75 | return ofnode_read_string(dev_ofnode(dev), propname); |
| 76 | } |
| 77 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 78 | bool dev_read_bool(const struct udevice *dev, const char *propname) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 79 | { |
| 80 | return ofnode_read_bool(dev_ofnode(dev), propname); |
| 81 | } |
| 82 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 83 | ofnode dev_read_subnode(const struct udevice *dev, const char *subnode_name) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 84 | { |
| 85 | return ofnode_find_subnode(dev_ofnode(dev), subnode_name); |
| 86 | } |
| 87 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 88 | ofnode dev_read_first_subnode(const struct udevice *dev) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 89 | { |
| 90 | return ofnode_first_subnode(dev_ofnode(dev)); |
| 91 | } |
| 92 | |
| 93 | ofnode dev_read_next_subnode(ofnode node) |
| 94 | { |
| 95 | return ofnode_next_subnode(node); |
| 96 | } |
| 97 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 98 | int dev_read_size(const struct udevice *dev, const char *propname) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 99 | { |
| 100 | return ofnode_read_size(dev_ofnode(dev), propname); |
| 101 | } |
| 102 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 103 | fdt_addr_t dev_read_addr_index(const struct udevice *dev, int index) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 104 | { |
| 105 | if (ofnode_is_np(dev_ofnode(dev))) |
| 106 | return ofnode_get_addr_index(dev_ofnode(dev), index); |
| 107 | else |
| 108 | return devfdt_get_addr_index(dev, index); |
| 109 | } |
| 110 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 111 | fdt_addr_t dev_read_addr_size_index(const struct udevice *dev, int index, |
Sekhar Nori | f677c6f | 2019-08-01 19:12:56 +0530 | [diff] [blame] | 112 | fdt_size_t *size) |
| 113 | { |
| 114 | if (ofnode_is_np(dev_ofnode(dev))) |
| 115 | return ofnode_get_addr_size_index(dev_ofnode(dev), index, size); |
| 116 | else |
| 117 | return devfdt_get_addr_size_index(dev, index, size); |
| 118 | } |
| 119 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 120 | void *dev_remap_addr_index(const struct udevice *dev, int index) |
Álvaro Fernández Rojas | 67036129 | 2018-04-29 21:56:54 +0200 | [diff] [blame] | 121 | { |
| 122 | fdt_addr_t addr = dev_read_addr_index(dev, index); |
| 123 | |
| 124 | if (addr == FDT_ADDR_T_NONE) |
| 125 | return NULL; |
| 126 | |
| 127 | return map_physmem(addr, 0, MAP_NOCACHE); |
| 128 | } |
| 129 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 130 | fdt_addr_t dev_read_addr_name(const struct udevice *dev, const char *name) |
Álvaro Fernández Rojas | a318115 | 2018-12-03 19:37:09 +0100 | [diff] [blame] | 131 | { |
| 132 | int index = dev_read_stringlist_search(dev, "reg-names", name); |
| 133 | |
| 134 | if (index < 0) |
| 135 | return FDT_ADDR_T_NONE; |
| 136 | else |
| 137 | return dev_read_addr_index(dev, index); |
| 138 | } |
| 139 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 140 | fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name, |
Sekhar Nori | f677c6f | 2019-08-01 19:12:56 +0530 | [diff] [blame] | 141 | fdt_size_t *size) |
| 142 | { |
| 143 | int index = dev_read_stringlist_search(dev, "reg-names", name); |
| 144 | |
| 145 | if (index < 0) |
| 146 | return FDT_ADDR_T_NONE; |
| 147 | else |
| 148 | return dev_read_addr_size_index(dev, index, size); |
| 149 | } |
| 150 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 151 | void *dev_remap_addr_name(const struct udevice *dev, const char *name) |
Álvaro Fernández Rojas | a318115 | 2018-12-03 19:37:09 +0100 | [diff] [blame] | 152 | { |
| 153 | fdt_addr_t addr = dev_read_addr_name(dev, name); |
| 154 | |
| 155 | if (addr == FDT_ADDR_T_NONE) |
| 156 | return NULL; |
| 157 | |
| 158 | return map_physmem(addr, 0, MAP_NOCACHE); |
| 159 | } |
| 160 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 161 | fdt_addr_t dev_read_addr(const struct udevice *dev) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 162 | { |
| 163 | return dev_read_addr_index(dev, 0); |
| 164 | } |
| 165 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 166 | void *dev_read_addr_ptr(const struct udevice *dev) |
Philipp Tomsich | 7719b39 | 2017-09-11 22:04:12 +0200 | [diff] [blame] | 167 | { |
| 168 | fdt_addr_t addr = dev_read_addr(dev); |
| 169 | |
Simon Glass | c47a388 | 2017-09-28 06:35:15 -0600 | [diff] [blame] | 170 | return (addr == FDT_ADDR_T_NONE) ? NULL : map_sysmem(addr, 0); |
Philipp Tomsich | 7719b39 | 2017-09-11 22:04:12 +0200 | [diff] [blame] | 171 | } |
| 172 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 173 | void *dev_remap_addr(const struct udevice *dev) |
Álvaro Fernández Rojas | 67036129 | 2018-04-29 21:56:54 +0200 | [diff] [blame] | 174 | { |
| 175 | return dev_remap_addr_index(dev, 0); |
| 176 | } |
| 177 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 178 | fdt_addr_t dev_read_addr_size(const struct udevice *dev, const char *property, |
Mario Six | 6eac222 | 2018-01-15 11:07:18 +0100 | [diff] [blame] | 179 | fdt_size_t *sizep) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 180 | { |
| 181 | return ofnode_get_addr_size(dev_ofnode(dev), property, sizep); |
| 182 | } |
| 183 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 184 | const char *dev_read_name(const struct udevice *dev) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 185 | { |
| 186 | return ofnode_get_name(dev_ofnode(dev)); |
| 187 | } |
| 188 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 189 | int dev_read_stringlist_search(const struct udevice *dev, const char *property, |
Mario Six | 6eac222 | 2018-01-15 11:07:18 +0100 | [diff] [blame] | 190 | const char *string) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 191 | { |
| 192 | return ofnode_stringlist_search(dev_ofnode(dev), property, string); |
| 193 | } |
| 194 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 195 | int dev_read_string_index(const struct udevice *dev, const char *propname, |
| 196 | int index, const char **outp) |
Jean-Jacques Hiblot | 8365ebd | 2017-09-21 17:03:09 +0200 | [diff] [blame] | 197 | { |
| 198 | return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp); |
| 199 | } |
| 200 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 201 | int dev_read_string_count(const struct udevice *dev, const char *propname) |
Jean-Jacques Hiblot | 8365ebd | 2017-09-21 17:03:09 +0200 | [diff] [blame] | 202 | { |
| 203 | return ofnode_read_string_count(dev_ofnode(dev), propname); |
| 204 | } |
| 205 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 206 | int dev_read_phandle_with_args(const struct udevice *dev, const char *list_name, |
Mario Six | 6eac222 | 2018-01-15 11:07:18 +0100 | [diff] [blame] | 207 | const char *cells_name, int cell_count, |
| 208 | int index, struct ofnode_phandle_args *out_args) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 209 | { |
| 210 | return ofnode_parse_phandle_with_args(dev_ofnode(dev), list_name, |
| 211 | cells_name, cell_count, index, |
| 212 | out_args); |
| 213 | } |
| 214 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 215 | int dev_count_phandle_with_args(const struct udevice *dev, |
| 216 | const char *list_name, const char *cells_name) |
Patrice Chotard | 99503c1 | 2017-11-29 09:06:10 +0100 | [diff] [blame] | 217 | { |
| 218 | return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name, |
| 219 | cells_name); |
| 220 | } |
| 221 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 222 | int dev_read_addr_cells(const struct udevice *dev) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 223 | { |
| 224 | return ofnode_read_addr_cells(dev_ofnode(dev)); |
| 225 | } |
| 226 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 227 | int dev_read_size_cells(const struct udevice *dev) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 228 | { |
| 229 | return ofnode_read_size_cells(dev_ofnode(dev)); |
| 230 | } |
| 231 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 232 | int dev_read_simple_addr_cells(const struct udevice *dev) |
Simon Glass | 4191dc1 | 2017-06-12 06:21:31 -0600 | [diff] [blame] | 233 | { |
| 234 | return ofnode_read_simple_addr_cells(dev_ofnode(dev)); |
| 235 | } |
| 236 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 237 | int dev_read_simple_size_cells(const struct udevice *dev) |
Simon Glass | 4191dc1 | 2017-06-12 06:21:31 -0600 | [diff] [blame] | 238 | { |
| 239 | return ofnode_read_simple_size_cells(dev_ofnode(dev)); |
| 240 | } |
| 241 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 242 | int dev_read_phandle(const struct udevice *dev) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 243 | { |
| 244 | ofnode node = dev_ofnode(dev); |
| 245 | |
| 246 | if (ofnode_is_np(node)) |
| 247 | return ofnode_to_np(node)->phandle; |
| 248 | else |
| 249 | return fdt_get_phandle(gd->fdt_blob, ofnode_to_offset(node)); |
| 250 | } |
| 251 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 252 | const void *dev_read_prop(const struct udevice *dev, const char *propname, |
| 253 | int *lenp) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 254 | { |
Masahiro Yamada | 9cf85cb | 2017-06-22 16:54:05 +0900 | [diff] [blame] | 255 | return ofnode_get_property(dev_ofnode(dev), propname, lenp); |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 256 | } |
| 257 | |
Patrick Delaunay | caee155 | 2020-01-13 11:34:56 +0100 | [diff] [blame^] | 258 | int dev_read_first_prop(const struct udevice *dev, struct ofprop *prop) |
| 259 | { |
| 260 | return ofnode_get_first_property(dev_ofnode(dev), prop); |
| 261 | } |
| 262 | |
| 263 | int dev_read_next_prop(struct ofprop *prop) |
| 264 | { |
| 265 | return ofnode_get_next_property(prop); |
| 266 | } |
| 267 | |
| 268 | const void *dev_read_prop_by_prop(struct ofprop *prop, |
| 269 | const char **propname, int *lenp) |
| 270 | { |
| 271 | return ofnode_get_property_by_prop(prop, propname, lenp); |
| 272 | } |
| 273 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 274 | int dev_read_alias_seq(const struct udevice *dev, int *devnump) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 275 | { |
| 276 | ofnode node = dev_ofnode(dev); |
| 277 | const char *uc_name = dev->uclass->uc_drv->name; |
| 278 | int ret; |
| 279 | |
| 280 | if (ofnode_is_np(node)) { |
| 281 | ret = of_alias_get_id(ofnode_to_np(node), uc_name); |
| 282 | if (ret >= 0) |
| 283 | *devnump = ret; |
| 284 | } else { |
| 285 | ret = fdtdec_get_alias_seq(gd->fdt_blob, uc_name, |
| 286 | ofnode_to_offset(node), devnump); |
| 287 | } |
| 288 | |
| 289 | return ret; |
| 290 | } |
| 291 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 292 | int dev_read_u32_array(const struct udevice *dev, const char *propname, |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 293 | u32 *out_values, size_t sz) |
| 294 | { |
| 295 | return ofnode_read_u32_array(dev_ofnode(dev), propname, out_values, sz); |
| 296 | } |
| 297 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 298 | const uint8_t *dev_read_u8_array_ptr(const struct udevice *dev, |
| 299 | const char *propname, size_t sz) |
Simon Glass | cfdae5c | 2017-05-18 20:09:04 -0600 | [diff] [blame] | 300 | { |
| 301 | return ofnode_read_u8_array_ptr(dev_ofnode(dev), propname, sz); |
| 302 | } |
Simon Glass | fa031f8 | 2017-06-12 06:21:30 -0600 | [diff] [blame] | 303 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 304 | int dev_read_enabled(const struct udevice *dev) |
Simon Glass | fa031f8 | 2017-06-12 06:21:30 -0600 | [diff] [blame] | 305 | { |
| 306 | ofnode node = dev_ofnode(dev); |
| 307 | |
| 308 | if (ofnode_is_np(node)) |
| 309 | return of_device_is_available(ofnode_to_np(node)); |
| 310 | else |
| 311 | return fdtdec_get_is_enabled(gd->fdt_blob, |
| 312 | ofnode_to_offset(node)); |
| 313 | } |
Simon Glass | f7bfcc4 | 2017-07-25 08:29:55 -0600 | [diff] [blame] | 314 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 315 | int dev_read_resource(const struct udevice *dev, uint index, |
| 316 | struct resource *res) |
Simon Glass | f7bfcc4 | 2017-07-25 08:29:55 -0600 | [diff] [blame] | 317 | { |
| 318 | return ofnode_read_resource(dev_ofnode(dev), index, res); |
| 319 | } |
Masahiro Yamada | 4dada2c | 2017-08-26 01:12:30 +0900 | [diff] [blame] | 320 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 321 | int dev_read_resource_byname(const struct udevice *dev, const char *name, |
Masahiro Yamada | 4dada2c | 2017-08-26 01:12:30 +0900 | [diff] [blame] | 322 | struct resource *res) |
| 323 | { |
| 324 | return ofnode_read_resource_byname(dev_ofnode(dev), name, res); |
| 325 | } |
Mario Six | aefac06 | 2018-01-15 11:07:19 +0100 | [diff] [blame] | 326 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 327 | u64 dev_translate_address(const struct udevice *dev, const fdt32_t *in_addr) |
Mario Six | aefac06 | 2018-01-15 11:07:19 +0100 | [diff] [blame] | 328 | { |
| 329 | return ofnode_translate_address(dev_ofnode(dev), in_addr); |
| 330 | } |
Michal Simek | d0e30a0 | 2019-01-31 16:30:59 +0100 | [diff] [blame] | 331 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 332 | u64 dev_translate_dma_address(const struct udevice *dev, const fdt32_t *in_addr) |
Fabien Dessenne | 22236e0 | 2019-05-31 15:11:30 +0200 | [diff] [blame] | 333 | { |
| 334 | return ofnode_translate_dma_address(dev_ofnode(dev), in_addr); |
| 335 | } |
| 336 | |
Michal Simek | d0e30a0 | 2019-01-31 16:30:59 +0100 | [diff] [blame] | 337 | int dev_read_alias_highest_id(const char *stem) |
| 338 | { |
| 339 | if (of_live_active()) |
| 340 | return of_alias_get_highest_id(stem); |
| 341 | |
| 342 | return fdtdec_get_alias_highest_id(gd->fdt_blob, stem); |
| 343 | } |
Simon Glass | 23b2759 | 2019-09-15 12:08:58 -0600 | [diff] [blame] | 344 | |
Simon Glass | 2f9a612 | 2020-01-27 08:49:40 -0700 | [diff] [blame] | 345 | fdt_addr_t dev_read_addr_pci(const struct udevice *dev) |
Simon Glass | 23b2759 | 2019-09-15 12:08:58 -0600 | [diff] [blame] | 346 | { |
| 347 | ulong addr; |
| 348 | |
| 349 | addr = dev_read_addr(dev); |
| 350 | if (addr == FDT_ADDR_T_NONE && !of_live_active()) |
| 351 | addr = devfdt_get_addr_pci(dev); |
| 352 | |
| 353 | return addr; |
| 354 | } |