xref: /openbmc/linux/arch/powerpc/kernel/prom_parse.c (revision d7a3d85e)
1 #undef DEBUG
2 
3 #include <linux/kernel.h>
4 #include <linux/string.h>
5 #include <linux/ioport.h>
6 #include <linux/etherdevice.h>
7 #include <linux/of_address.h>
8 #include <asm/prom.h>
9 
10 void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window,
11 			 unsigned long *busno, unsigned long *phys,
12 			 unsigned long *size)
13 {
14 	u32 cells;
15 	const __be32 *prop;
16 
17 	/* busno is always one cell */
18 	*busno = of_read_number(dma_window, 1);
19 	dma_window++;
20 
21 	prop = of_get_property(dn, "ibm,#dma-address-cells", NULL);
22 	if (!prop)
23 		prop = of_get_property(dn, "#address-cells", NULL);
24 
25 	cells = prop ? of_read_number(prop, 1) : of_n_addr_cells(dn);
26 	*phys = of_read_number(dma_window, cells);
27 
28 	dma_window += cells;
29 
30 	prop = of_get_property(dn, "ibm,#dma-size-cells", NULL);
31 	cells = prop ? of_read_number(prop, 1) : of_n_size_cells(dn);
32 	*size = of_read_number(dma_window, cells);
33 }
34