xref: /openbmc/linux/arch/powerpc/kernel/prom_parse.c (revision 7490ca1e)
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 void *dma_window_prop,
11 		unsigned long *busno, unsigned long *phys, unsigned long *size)
12 {
13 	const u32 *dma_window;
14 	u32 cells;
15 	const unsigned char *prop;
16 
17 	dma_window = dma_window_prop;
18 
19 	/* busno is always one cell */
20 	*busno = *(dma_window++);
21 
22 	prop = of_get_property(dn, "ibm,#dma-address-cells", NULL);
23 	if (!prop)
24 		prop = of_get_property(dn, "#address-cells", NULL);
25 
26 	cells = prop ? *(u32 *)prop : of_n_addr_cells(dn);
27 	*phys = of_read_number(dma_window, cells);
28 
29 	dma_window += cells;
30 
31 	prop = of_get_property(dn, "ibm,#dma-size-cells", NULL);
32 	cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
33 	*size = of_read_number(dma_window, cells);
34 }
35