21 #include <linux/kernel.h>
24 #include <linux/pci.h>
27 #include <asm/machdep.h>
31 #define DMA_FLAGS 0xf800000000000000UL
34 static int __init find_dma_window(
u64 *io_space_id,
u64 *ioid,
38 const unsigned long *dma_window;
40 for_each_node_by_type(dn,
"ioif") {
43 *io_space_id = (dma_window[0] >> 32) & 0xffffffffUL;
44 *ioid = dma_window[0] & 0x7ff
UL;
45 *base = dma_window[1];
46 *size = dma_window[2];
47 *io_page_size = 1 << dma_window[3];
55 static unsigned long celleb_dma_direct_offset;
57 static void __init celleb_init_direct_mapping(
void)
60 u64 io_space_id, ioid, dma_base, dma_size, io_page_size;
62 if (!find_dma_window(&io_space_id, &ioid, &dma_base, &dma_size,
64 pr_info(
"No dma window found !\n");
68 for (lpar_addr = 0; lpar_addr < dma_size; lpar_addr += io_page_size) {
69 io_addr = lpar_addr + dma_base;
70 (
void)beat_put_iopte(io_space_id, io_addr, lpar_addr,
74 celleb_dma_direct_offset = dma_base;
77 static void celleb_dma_dev_setup(
struct device *
dev)
80 set_dma_offset(dev, celleb_dma_direct_offset);
83 static void celleb_pci_dma_dev_setup(
struct pci_dev *pdev)
85 celleb_dma_dev_setup(&pdev->
dev);
97 celleb_dma_dev_setup(dev);
103 .notifier_call = celleb_of_bus_notify
106 static int __init celleb_init_iommu(
void)
108 celleb_init_direct_mapping();
109 ppc_md.pci_dma_dev_setup = celleb_pci_dma_dev_setup;