^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * FDT Address translation based on u-boot fdt_support.c which in turn was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * based on the kernel unflattened DT address translation code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * (C) Copyright 2007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright 2010-2011 Freescale Semiconductor, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define pr_fmt(fmt) "OF: fdt: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/libfdt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/of_fdt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/sizes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* Max address size we deal with */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define OF_MAX_ADDR_CELLS 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) (ns) > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /* Debug utility */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static void __init of_dump_addr(const char *s, const __be32 *addr, int na)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) pr_debug("%s", s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) while(na--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) pr_cont(" %08x", *(addr++));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static void __init of_dump_addr(const char *s, const __be32 *addr, int na) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* Callbacks for bus specific translators */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct of_bus {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) void (*count_cells)(const void *blob, int parentoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int *addrc, int *sizec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) u64 (*map)(__be32 *addr, const __be32 *range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) int na, int ns, int pna);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) int (*translate)(__be32 *addr, u64 offset, int na);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* Default translator (generic bus) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static void __init fdt_bus_default_count_cells(const void *blob, int parentoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int *addrc, int *sizec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) const __be32 *prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (addrc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) prop = fdt_getprop(blob, parentoffset, "#address-cells", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (prop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) *addrc = be32_to_cpup(prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) *addrc = dt_root_addr_cells;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (sizec) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) prop = fdt_getprop(blob, parentoffset, "#size-cells", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (prop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) *sizec = be32_to_cpup(prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) *sizec = dt_root_size_cells;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static u64 __init fdt_bus_default_map(__be32 *addr, const __be32 *range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) int na, int ns, int pna)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u64 cp, s, da;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) cp = of_read_number(range, na);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) s = of_read_number(range + na + pna, ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) da = of_read_number(addr, na);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) pr_debug("default map, cp=%llx, s=%llx, da=%llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) cp, s, da);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if (da < cp || da >= (cp + s))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) return OF_BAD_ADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return da - cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static int __init fdt_bus_default_translate(__be32 *addr, u64 offset, int na)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) u64 a = of_read_number(addr, na);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) memset(addr, 0, na * 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) a += offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) if (na > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) addr[na - 2] = cpu_to_fdt32(a >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) addr[na - 1] = cpu_to_fdt32(a & 0xffffffffu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /* Array of bus specific translators */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static const struct of_bus of_busses[] __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* Default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .count_cells = fdt_bus_default_count_cells,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .map = fdt_bus_default_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .translate = fdt_bus_default_translate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static int __init fdt_translate_one(const void *blob, int parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) const struct of_bus *bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) const struct of_bus *pbus, __be32 *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) int na, int ns, int pna, const char *rprop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) const __be32 *ranges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int rlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int rone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) u64 offset = OF_BAD_ADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) ranges = fdt_getprop(blob, parent, rprop, &rlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (!ranges)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (rlen == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) offset = of_read_number(addr, na);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) memset(addr, 0, pna * 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) pr_debug("empty ranges, 1:1 translation\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) goto finish;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) pr_debug("walking ranges...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /* Now walk through the ranges */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) rlen /= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) rone = na + pna + ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) for (; rlen >= rone; rlen -= rone, ranges += rone) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) offset = bus->map(addr, ranges, na, ns, pna);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (offset != OF_BAD_ADDR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) if (offset == OF_BAD_ADDR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) pr_debug("not found !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) memcpy(addr, ranges + na, 4 * pna);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) finish:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) of_dump_addr("parent translation for:", addr, pna);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) pr_debug("with offset: %llx\n", offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* Translate it into parent bus space */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return pbus->translate(addr, offset, pna);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * Translate an address from the device-tree into a CPU physical address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * this walks up the tree and applies the various bus mappings on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * way.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * Note: We consider that crossing any level with #size-cells == 0 to mean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * that translation is impossible (that is we are not dealing with a value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * that can be mapped to a cpu physical address). This is not really specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * that way, but this is traditionally the way IBM at least do things
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static u64 __init fdt_translate_address(const void *blob, int node_offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int parent, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) const struct of_bus *bus, *pbus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) const __be32 *reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) __be32 addr[OF_MAX_ADDR_CELLS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) int na, ns, pna, pns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) u64 result = OF_BAD_ADDR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) pr_debug("** translation for device %s **\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) fdt_get_name(blob, node_offset, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) reg = fdt_getprop(blob, node_offset, "reg", &len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (!reg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) pr_err("warning: device tree node '%s' has no address.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) fdt_get_name(blob, node_offset, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /* Get parent & match bus type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) parent = fdt_parent_offset(blob, node_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (parent < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) bus = &of_busses[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) /* Cound address cells & copy address locally */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) bus->count_cells(blob, parent, &na, &ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (!OF_CHECK_COUNTS(na, ns)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) pr_err("Bad cell count for %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) fdt_get_name(blob, node_offset, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) memcpy(addr, reg, na * 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) pr_debug("bus (na=%d, ns=%d) on %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) na, ns, fdt_get_name(blob, parent, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) of_dump_addr("translating address:", addr, na);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /* Translate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) /* Switch to parent bus */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) node_offset = parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) parent = fdt_parent_offset(blob, node_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /* If root, we have finished */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (parent < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) pr_debug("reached root node\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) result = of_read_number(addr, na);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /* Get new parent bus and counts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) pbus = &of_busses[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) pbus->count_cells(blob, parent, &pna, &pns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) if (!OF_CHECK_COUNTS(pna, pns)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) pr_err("Bad cell count for %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) fdt_get_name(blob, node_offset, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) pr_debug("parent bus (na=%d, ns=%d) on %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) pna, pns, fdt_get_name(blob, parent, NULL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /* Apply bus translation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) if (fdt_translate_one(blob, node_offset, bus, pbus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) addr, na, ns, pna, "ranges"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /* Complete the move up one level */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) na = pna;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) ns = pns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) bus = pbus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) of_dump_addr("one level translation:", addr, na);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) bail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * of_flat_dt_translate_address - translate DT addr into CPU phys addr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * @node: node in the flat blob
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) u64 __init of_flat_dt_translate_address(unsigned long node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return fdt_translate_address(initial_boot_params, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }