| 209 | } |
| 210 | |
| 211 | int rt_ofw_get_address_array(struct rt_ofw_node *np, int nr, rt_uint64_t *out_regs) |
| 212 | { |
| 213 | int count; |
| 214 | |
| 215 | if (np && nr > 0 && out_regs) |
| 216 | { |
| 217 | rt_ssize_t len; |
| 218 | int max_nr; |
| 219 | int addr_cells = rt_ofw_io_addr_cells(np); |
| 220 | int size_cells = rt_ofw_io_size_cells(np); |
| 221 | const fdt32_t *cell = rt_ofw_prop_read_raw(np, "reg", &len); |
| 222 | |
| 223 | max_nr = len / (sizeof(*cell) * (addr_cells + size_cells)); |
| 224 | |
| 225 | if (nr > max_nr) |
| 226 | { |
| 227 | nr = max_nr; |
| 228 | } |
| 229 | |
| 230 | count = nr; |
| 231 | |
| 232 | while (nr --> 0) |
| 233 | { |
| 234 | *out_regs = rt_fdt_next_cell(&cell, addr_cells); |
| 235 | *out_regs = rt_ofw_translate_address(np, RT_NULL, *out_regs); |
| 236 | ++out_regs; |
| 237 | |
| 238 | *out_regs = rt_fdt_next_cell(&cell, size_cells); |
| 239 | ++out_regs; |
| 240 | } |
| 241 | } |
| 242 | else |
| 243 | { |
| 244 | count = -RT_EINVAL; |
| 245 | } |
| 246 | |
| 247 | return count; |
| 248 | } |
| 249 | |
| 250 | static struct bus_ranges *ofw_bus_ranges(struct rt_ofw_node *np, struct rt_ofw_prop *prop) |
| 251 | { |
no test coverage detected