prom_parse.c 909 字节
Newer Older
1 2 3 4 5
#undef DEBUG

#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/module.h>
6
#include <linux/ioport.h>
7
#include <linux/etherdevice.h>
8
#include <linux/of_address.h>
9
#include <asm/prom.h>
10

11
void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
12 13
		unsigned long *busno, unsigned long *phys, unsigned long *size)
{
14 15 16
	const u32 *dma_window;
	u32 cells;
	const unsigned char *prop;
17

18
	dma_window = dma_window_prop;
19 20 21 22

	/* busno is always one cell */
	*busno = *(dma_window++);

23
	prop = of_get_property(dn, "ibm,#dma-address-cells", NULL);
24
	if (!prop)
25
		prop = of_get_property(dn, "#address-cells", NULL);
26

27
	cells = prop ? *(u32 *)prop : of_n_addr_cells(dn);
28
	*phys = of_read_number(dma_window, cells);
29 30 31

	dma_window += cells;

32
	prop = of_get_property(dn, "ibm,#dma-size-cells", NULL);
33
	cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
34 35
	*size = of_read_number(dma_window, cells);
}