@@ -83,4 +83,8 @@ config OF_MTD
depends on MTD
def_bool y
+config OF_DMA
+ depends on HAS_DMA
+ def_bool y
+
endmenu # OF
@@ -11,3 +11,4 @@ obj-$(CONFIG_OF_MDIO) += of_mdio.o
obj-$(CONFIG_OF_PCI) += of_pci.o
obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o
obj-$(CONFIG_OF_MTD) += of_mtd.o
+obj-$(CONFIG_OF_DMA) += of_dma.o
new file mode 100644
@@ -0,0 +1,35 @@
+/*
+ * Stealed from:
+ * "arch/microblaze/kernel/prom_parse.c"
+ * "arch/powerpc/kernel/prom_parse.c"
+ */
+
+#include <linux/of_address.h>
+
+void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
+ unsigned long *busno, unsigned long *phys, unsigned long *size)
+{
+ const u32 *dma_window;
+ u32 cells;
+ const unsigned char *prop;
+
+ dma_window = dma_window_prop;
+
+ /* busno is always one cell */
+ if (busno)
+ *busno = *(dma_window++);
+
+ prop = of_get_property(dn, "#dma-address-cells", NULL);
+ if (!prop)
+ prop = of_get_property(dn, "#address-cells", NULL);
+
+ cells = prop ? *(u32 *)prop : of_n_addr_cells(dn);
+ *phys = of_read_number(dma_window, cells);
+
+ dma_window += cells;
+
+ prop = of_get_property(dn, "#dma-size-cells", NULL);
+ cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
+ *size = of_read_number(dma_window, cells);
+}
+
@@ -21,6 +21,10 @@ extern void __iomem *of_iomap(struct device_node *device, int index);
extern const u32 *of_get_address(struct device_node *dev, int index,
u64 *size, unsigned int *flags);
+extern void of_parse_dma_window(struct device_node *dn,
+ const void *dma_window_prop, unsigned long *busno,
+ unsigned long *phys, unsigned long *size);
+
#ifndef pci_address_to_pio
static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
#define pci_address_to_pio pci_address_to_pio
@@ -48,6 +52,12 @@ static inline const u32 *of_get_address(struct device_node *dev, int index,
{
return NULL;
}
+
+static inline void of_parse_dma_window(struct device_node *dn,
+ const void *dma_window_prop, unsigned long *busno,
+ unsigned long *phys, unsigned long *size)
+{
+}
#endif /* CONFIG_OF_ADDRESS */