[PATCH] powerpc: Add of_parse_dma_window()
authorJeremy Kerr <jk@ozlabs.org>
Thu, 18 May 2006 08:05:15 +0000 (18:05 +1000)
committerPaul Mackerras <paulus@samba.org>
Fri, 19 May 2006 05:02:21 +0000 (15:02 +1000)
Add a function for generic parsing of dma-window properties (ie,
ibm,dma-window and ibm,my-dma-window) of pci and virtual device nodes.

This function will also be used by cell.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kernel/prom_parse.c
include/asm-powerpc/prom.h

index 3934c227549b07a1f08ba59c86ac497ce6c0a45f..23bb060330ef897012a6957f597afabc7ae49529 100644 (file)
@@ -548,3 +548,25 @@ int of_pci_address_to_resource(struct device_node *dev, int bar,
        return __of_address_to_resource(dev, addrp, size, flags, r);
 }
 EXPORT_SYMBOL_GPL(of_pci_address_to_resource);
+
+void of_parse_dma_window(struct device_node *dn, unsigned char *dma_window_prop,
+               unsigned long *busno, unsigned long *phys, unsigned long *size)
+{
+       u32 *dma_window, cells;
+       unsigned char *prop;
+
+       dma_window = (u32 *)dma_window_prop;
+
+       /* busno is always one cell */
+       *busno = *(dma_window++);
+
+       prop = get_property(dn, "ibm,#dma-address-cells", NULL);
+       cells = prop ? *(u32 *)prop : prom_n_addr_cells(dn);
+       *phys = of_read_addr(dma_window, cells);
+
+       dma_window += cells;
+
+       prop = get_property(dn, "ibm,#dma-size-cells", NULL);
+       cells = prop ? *(u32 *)prop : prom_n_size_cells(dn);
+       *size = of_read_addr(dma_window, cells);
+}
index 97ef1cd71a4da2ed226b58e9fd121d7970f52a19..c79d58ab7441898e6b68ee8a5504b66754cd8222 100644 (file)
@@ -230,6 +230,12 @@ extern int of_address_to_resource(struct device_node *dev, int index,
 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
                                      struct resource *r);
 
+/* Parse the ibm,dma-window property of an OF node into the busno, phys and
+ * size parameters.
+ */
+void of_parse_dma_window(struct device_node *dn, unsigned char *dma_window_prop,
+               unsigned long *busno, unsigned long *phys, unsigned long *size);
+
 extern void kdump_move_device_tree(void);
 
 #endif /* __KERNEL__ */