Lines Matching refs:np

27 static int ofw_bus_addr_cells(struct rt_ofw_node *np)  in ofw_bus_addr_cells()  argument
31 for (rt_uint32_t cells; np; np = np->parent) in ofw_bus_addr_cells()
33 if (!rt_ofw_prop_read_u32(np, "#address-cells", &cells)) in ofw_bus_addr_cells()
43 static int ofw_bus_size_cells(struct rt_ofw_node *np) in ofw_bus_size_cells() argument
47 for (rt_uint32_t cells; np; np = np->parent) in ofw_bus_size_cells()
49 if (!rt_ofw_prop_read_u32(np, "#size-cells", &cells)) in ofw_bus_size_cells()
59 int rt_ofw_bus_addr_cells(struct rt_ofw_node *np) in rt_ofw_bus_addr_cells() argument
61 return np ? ofw_bus_addr_cells(np) : -RT_EINVAL; in rt_ofw_bus_addr_cells()
64 int rt_ofw_bus_size_cells(struct rt_ofw_node *np) in rt_ofw_bus_size_cells() argument
66 return np ? ofw_bus_size_cells(np) : -RT_EINVAL; in rt_ofw_bus_size_cells()
69 int rt_ofw_io_addr_cells(struct rt_ofw_node *np) in rt_ofw_io_addr_cells() argument
71 return np ? ofw_bus_addr_cells(np->parent ? np->parent : np) : -RT_EINVAL; in rt_ofw_io_addr_cells()
74 int rt_ofw_io_size_cells(struct rt_ofw_node *np) in rt_ofw_io_size_cells() argument
76 return np ? ofw_bus_size_cells(np->parent ? np->parent : np) : -RT_EINVAL; in rt_ofw_io_size_cells()
79 int rt_ofw_get_address_count(struct rt_ofw_node *np) in rt_ofw_get_address_count() argument
83 if (np) in rt_ofw_get_address_count()
89 if (rt_ofw_get_prop(np, "reg", &len)) in rt_ofw_get_address_count()
91 count = len / (sizeof(fdt32_t) * (rt_ofw_io_addr_cells(np) + rt_ofw_io_size_cells(np))); in rt_ofw_get_address_count()
102 static rt_err_t ofw_get_address(struct rt_ofw_node *np, int index, rt_uint64_t *out_address, rt_uin… in ofw_get_address() argument
106 int addr_cells = rt_ofw_io_addr_cells(np); in ofw_get_address()
107 int size_cells = rt_ofw_io_size_cells(np); in ofw_get_address()
109 const fdt32_t *cell = rt_ofw_prop_read_raw(np, "reg", &len); in ofw_get_address()
115 *out_address = rt_ofw_translate_address(np, RT_NULL, *out_address); in ofw_get_address()
126 rt_err_t rt_ofw_get_address(struct rt_ofw_node *np, int index, rt_uint64_t *out_address, rt_uint64_… in rt_ofw_get_address() argument
130 if (np && index >= 0 && (out_address || out_size)) in rt_ofw_get_address()
134 err = ofw_get_address(np, index, &address, &size); in rt_ofw_get_address()
156 static rt_err_t ofw_get_address_by_name(struct rt_ofw_node *np, const char *name, in ofw_get_address_by_name() argument
165 rt_ofw_foreach_prop_string(np, "reg-names", prop, reg_name) in ofw_get_address_by_name()
169 err = rt_ofw_get_address(np, index, out_address, out_size); in ofw_get_address_by_name()
180 rt_err_t rt_ofw_get_address_by_name(struct rt_ofw_node *np, const char *name, in rt_ofw_get_address_by_name() argument
185 if (np && name && (out_address || out_size)) in rt_ofw_get_address_by_name()
189 err = ofw_get_address_by_name(np, name, &address, &size); in rt_ofw_get_address_by_name()
211 int rt_ofw_get_address_array(struct rt_ofw_node *np, int nr, rt_uint64_t *out_regs) in rt_ofw_get_address_array() argument
215 if (np && nr > 0 && out_regs) in rt_ofw_get_address_array()
219 int addr_cells = rt_ofw_io_addr_cells(np); in rt_ofw_get_address_array()
220 int size_cells = rt_ofw_io_size_cells(np); in rt_ofw_get_address_array()
221 const fdt32_t *cell = rt_ofw_prop_read_raw(np, "reg", &len); in rt_ofw_get_address_array()
235 *out_regs = rt_ofw_translate_address(np, RT_NULL, *out_regs); in rt_ofw_get_address_array()
250 static struct bus_ranges *ofw_bus_ranges(struct rt_ofw_node *np, struct rt_ofw_prop *prop) in ofw_bus_ranges() argument
290 child_address_cells = rt_ofw_bus_addr_cells(np); in ofw_bus_ranges()
291 child_size_cells = rt_ofw_bus_size_cells(np); in ofw_bus_ranges()
292 parent_address_cells = rt_ofw_io_addr_cells(np); in ofw_bus_ranges()
297 np->full_name, child_address_cells, child_size_cells, parent_address_cells); in ofw_bus_ranges()
330 ranges->np = np; in ofw_bus_ranges()
341 rt_uint64_t rt_ofw_translate_address(struct rt_ofw_node *np, const char *range_type, rt_uint64_t ad… in rt_ofw_translate_address() argument
350 rt_ofw_foreach_parent_node(np) in rt_ofw_translate_address()
356 prop = rt_ofw_get_prop(np, range_type, &len); in rt_ofw_translate_address()
370 if (_bus_ranges[i]->np == np) in rt_ofw_translate_address()
379 ranges = ofw_bus_ranges(np, prop); in rt_ofw_translate_address()
402 rt_ofw_node_put(np); in rt_ofw_translate_address()
410 rt_uint64_t rt_ofw_reverse_address(struct rt_ofw_node *np, const char *range_type, rt_uint64_t addr… in rt_ofw_reverse_address() argument
419 rt_ofw_foreach_parent_node(np) in rt_ofw_reverse_address()
425 prop = rt_ofw_get_prop(np, range_type, &len); in rt_ofw_reverse_address()
439 if (_bus_ranges[i]->np == np) in rt_ofw_reverse_address()
448 ranges = ofw_bus_ranges(np, prop); in rt_ofw_reverse_address()
471 rt_ofw_node_put(np); in rt_ofw_reverse_address()
480 #define ofw_address_cpu_cast(np, address) (void *)(address) argument
482 #define ofw_address_cpu_cast(np, address) \ argument
487 rt_ofw_node_full_name(np), \
495 void *rt_ofw_iomap(struct rt_ofw_node *np, int index) in rt_ofw_iomap() argument
499 if (np) in rt_ofw_iomap()
503 if (!ofw_get_address(np, index, &regs[0], &regs[1])) in rt_ofw_iomap()
505 iomem = rt_ioremap(ofw_address_cpu_cast(np, regs[0]), (size_t)regs[1]); in rt_ofw_iomap()
512 void *rt_ofw_iomap_by_name(struct rt_ofw_node *np, const char *name) in rt_ofw_iomap_by_name() argument
516 if (np) in rt_ofw_iomap_by_name()
520 if (!ofw_get_address_by_name(np, name, &regs[0], &regs[1])) in rt_ofw_iomap_by_name()
522 iomem = rt_ioremap(ofw_address_cpu_cast(np, regs[0]), (size_t)regs[1]); in rt_ofw_iomap_by_name()