Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / powerpc / kernel / prom_parse.c
blob9cb7f88df563b52aa6dd8f7594dd8cddeb14b92b
1 // SPDX-License-Identifier: GPL-2.0
2 #undef DEBUG
4 #include <linux/kernel.h>
5 #include <linux/string.h>
6 #include <linux/ioport.h>
7 #include <linux/etherdevice.h>
8 #include <linux/of_address.h>
9 #include <asm/prom.h>
11 void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window,
12 unsigned long *busno, unsigned long *phys,
13 unsigned long *size)
15 u32 cells;
16 const __be32 *prop;
18 /* busno is always one cell */
19 *busno = of_read_number(dma_window, 1);
20 dma_window++;
22 prop = of_get_property(dn, "ibm,#dma-address-cells", NULL);
23 if (!prop)
24 prop = of_get_property(dn, "#address-cells", NULL);
26 cells = prop ? of_read_number(prop, 1) : of_n_addr_cells(dn);
27 *phys = of_read_number(dma_window, cells);
29 dma_window += cells;
31 prop = of_get_property(dn, "ibm,#dma-size-cells", NULL);
32 cells = prop ? of_read_number(prop, 1) : of_n_size_cells(dn);
33 *size = of_read_number(dma_window, cells);