Lines Matching +full:reg +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * devtree.c - convenience functions for device tree manipulation
25 if (getprop(root, "#address-cells", &naddr, sizeof(naddr)) < 0) in dt_fixup_memory()
30 fatal("Can't cope with #address-cells == %d in /\n\r", naddr); in dt_fixup_memory()
32 if (getprop(root, "#size-cells", &nsize, sizeof(nsize)) < 0) in dt_fixup_memory()
37 fatal("Can't cope with #size-cells == %d in /\n\r", nsize); in dt_fixup_memory()
53 printf("Memory <- <0x%x", be32_to_cpu(memreg[0])); in dt_fixup_memory()
58 setprop(memory, "reg", memreg, (naddr + nsize)*sizeof(u32)); in dt_fixup_memory()
67 printf("CPU clock-frequency <- 0x%x (%dMHz)\n\r", cpu, MHZ(cpu)); in dt_fixup_cpu_clocks()
68 printf("CPU timebase-frequency <- 0x%x (%dMHz)\n\r", tb, MHZ(tb)); in dt_fixup_cpu_clocks()
70 printf("CPU bus-frequency <- 0x%x (%dMHz)\n\r", bus, MHZ(bus)); in dt_fixup_cpu_clocks()
73 setprop_val(devp, "clock-frequency", cpu_to_be32(cpu)); in dt_fixup_cpu_clocks()
74 setprop_val(devp, "timebase-frequency", cpu_to_be32(tb)); in dt_fixup_cpu_clocks()
76 setprop_val(devp, "bus-frequency", cpu_to_be32(bus)); in dt_fixup_cpu_clocks()
87 printf("%s: clock-frequency <- %x (%dMHz)\n\r", path, freq, MHZ(freq)); in dt_fixup_clock()
88 setprop_val(devp, "clock-frequency", cpu_to_be32(freq)); in dt_fixup_clock()
92 void dt_fixup_mac_address_by_alias(const char *alias, const u8 *addr) in dt_fixup_mac_address_by_alias() argument
97 printf("%s: local-mac-address <-" in dt_fixup_mac_address_by_alias()
99 addr[0], addr[1], addr[2], in dt_fixup_mac_address_by_alias()
100 addr[3], addr[4], addr[5]); in dt_fixup_mac_address_by_alias()
102 setprop(devp, "local-mac-address", addr, 6); in dt_fixup_mac_address_by_alias()
106 void dt_fixup_mac_address(u32 index, const u8 *addr) in dt_fixup_mac_address() argument
108 void *devp = find_node_by_prop_value(NULL, "linux,network-index", in dt_fixup_mac_address()
112 printf("ENET%d: local-mac-address <-" in dt_fixup_mac_address()
114 addr[0], addr[1], addr[2], in dt_fixup_mac_address()
115 addr[3], addr[4], addr[5]); in dt_fixup_mac_address()
117 setprop(devp, "local-mac-address", addr, 6); in dt_fixup_mac_address()
125 const u8 *addr; in __dt_fixup_mac_addresses() local
129 while ((addr = va_arg(ap, const u8 *))) in __dt_fixup_mac_addresses()
130 dt_fixup_mac_address(index++, addr); in __dt_fixup_mac_addresses()
139 if (getprop(node, "#address-cells", naddr, 4) != 4) in dt_get_reg_format()
143 if (getprop(node, "#size-cells", nsize, 4) != 4) in dt_get_reg_format()
151 int pad = MAX_ADDR_CELLS - naddr; in copy_val()
157 static int sub_reg(u32 *reg, u32 *sub) in sub_reg() argument
161 for (i = MAX_ADDR_CELLS - 1; i >= 0; i--) { in sub_reg()
163 borrow = reg[i] < sub[i] + prev_borrow; in sub_reg()
164 reg[i] -= sub[i] + prev_borrow; in sub_reg()
170 static int add_reg(u32 *reg, u32 *add, int naddr) in add_reg() argument
174 for (i = MAX_ADDR_CELLS - 1; i >= MAX_ADDR_CELLS - naddr; i--) { in add_reg()
175 u64 tmp = (u64)be32_to_cpu(reg[i]) + be32_to_cpu(add[i]) + carry; in add_reg()
177 reg[i] = cpu_to_be32((u32)tmp); in add_reg()
183 /* It is assumed that if the first byte of reg fits in a
184 * range, then the whole reg block fits.
186 static int compare_reg(u32 *reg, u32 *range, u32 *rangesize) in compare_reg() argument
192 if (be32_to_cpu(reg[i]) < be32_to_cpu(range[i])) in compare_reg()
194 if (be32_to_cpu(reg[i]) > be32_to_cpu(range[i])) in compare_reg()
201 if (be32_to_cpu(reg[i]) < end) in compare_reg()
203 if (be32_to_cpu(reg[i]) > end) in compare_reg()
207 return reg[i] != end; in compare_reg()
210 /* reg must be MAX_ADDR_CELLS */
211 static int find_range(u32 *reg, u32 *ranges, int nregaddr, in find_range() argument
224 if (compare_reg(reg, range_addr, range_size)) in find_range()
228 return -1; in find_range()
233 * reg block is tracked; size is ignored except in ranges.
237 static int dt_xlate(void *node, int res, int reglen, unsigned long *addr, in dt_xlate() argument
312 *addr = ret_addr; in dt_xlate()
319 int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size) in dt_xlate_reg() argument
323 reglen = getprop(node, "reg", prop_buf, sizeof(prop_buf)) / 4; in dt_xlate_reg()
324 return dt_xlate(node, res, reglen, addr, size); in dt_xlate_reg()
350 pos += strnlen(&buf[pos], len - pos); in dt_is_compatible()
356 int dt_get_virtual_reg(void *node, void **addr, int nres) in dt_get_virtual_reg() argument
361 n = getprop(node, "virtual-reg", addr, nres * 4); in dt_get_virtual_reg()
364 ((u32 *)addr)[i] = be32_to_cpu(((u32 *)addr)[i]); in dt_get_virtual_reg()
372 addr[n] = (void *)xaddr; in dt_get_virtual_reg()