summaryrefslogtreecommitdiffstats
path: root/arch/sparc/mm/iommu.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-25 22:47:20 -0700
committerDavid S. Miller <davem@davemloft.net>2008-08-29 02:13:11 -0700
commite003934876e75f96f1445565d8c9084c07943253 (patch)
treeef44d634c4c1c98248bf3976a9ab0fa7231fd393 /arch/sparc/mm/iommu.c
parent334ae614772b1147435dce9be3911f9040dff0d9 (diff)
downloadblackbird-op-linux-e003934876e75f96f1445565d8c9084c07943253.tar.gz
blackbird-op-linux-e003934876e75f96f1445565d8c9084c07943253.zip
sparc32: Make IOMMU and IO-UNIT init work with device nodes.
And stick the iommu archdata pointer into the generic OF device tree of_device struct as well. We still have to pass the sbus_bus object down into the routines so that the SBUS bus objects get the iommu cookies set properly. After drivers get converted to being pure OF drivers, that can go away. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/mm/iommu.c')
-rw-r--r--arch/sparc/mm/iommu.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
index 4b934270f05e..a86c9f552fa1 100644
--- a/arch/sparc/mm/iommu.c
+++ b/arch/sparc/mm/iommu.c
@@ -55,30 +55,34 @@ static pgprot_t dvma_prot; /* Consistent mapping pte flags */
#define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID)
#define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ)
-void __init
-iommu_init(int iommund, struct sbus_bus *sbus)
+void __init iommu_init(struct device_node *parent, struct sbus_bus *sbus)
{
- unsigned int impl, vers;
- unsigned long tmp;
+ struct of_device *parent_op, *op;
struct iommu_struct *iommu;
- struct linux_prom_registers iommu_promregs[PROMREG_MAX];
- struct resource r;
+ unsigned int impl, vers;
unsigned long *bitmap;
+ unsigned long tmp;
+
+ parent_op = of_find_device_by_node(parent);
+ if (!parent_op) {
+ prom_printf("Unable to find IOMMU of_device\n");
+ prom_halt();
+ }
+
+ op = of_find_device_by_node(sbus->ofdev.node);
+ if (!op) {
+ prom_printf("Unable to find SBUS of_device\n");
+ prom_halt();
+ }
iommu = kmalloc(sizeof(struct iommu_struct), GFP_ATOMIC);
if (!iommu) {
prom_printf("Unable to allocate iommu structure\n");
prom_halt();
}
- iommu->regs = NULL;
- if (prom_getproperty(iommund, "reg", (void *) iommu_promregs,
- sizeof(iommu_promregs)) != -1) {
- memset(&r, 0, sizeof(r));
- r.flags = iommu_promregs[0].which_io;
- r.start = iommu_promregs[0].phys_addr;
- iommu->regs = (struct iommu_regs *)
- sbus_ioremap(&r, 0, PAGE_SIZE * 3, "iommu_regs");
- }
+
+ iommu->regs = of_ioremap(&parent_op->resource[0], 0, PAGE_SIZE * 3,
+ "iommu_regs");
if (!iommu->regs) {
prom_printf("Cannot map IOMMU registers\n");
prom_halt();
@@ -133,6 +137,7 @@ iommu_init(int iommund, struct sbus_bus *sbus)
(int)(IOMMU_NPTES*sizeof(iopte_t)), (int)IOMMU_NPTES);
sbus->ofdev.dev.archdata.iommu = iommu;
+ op->dev.archdata.iommu = iommu;
}
/* This begs to be btfixup-ed by srmmu. */
OpenPOWER on IntegriCloud