aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/mm/io-unit.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-26 01:47:20 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-29 05:13:11 -0400
commite003934876e75f96f1445565d8c9084c07943253 (patch)
treeef44d634c4c1c98248bf3976a9ab0fa7231fd393 /arch/sparc/mm/io-unit.c
parent334ae614772b1147435dce9be3911f9040dff0d9 (diff)
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/io-unit.c')
-rw-r--r--arch/sparc/mm/io-unit.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
index f167835db3df..1093514a5773 100644
--- a/arch/sparc/mm/io-unit.c
+++ b/arch/sparc/mm/io-unit.c
@@ -34,13 +34,18 @@
34#define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID) 34#define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID)
35#define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM) 35#define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM)
36 36
37void __init 37void __init iounit_init(struct sbus_bus *sbus)
38iounit_init(int sbi_node, int io_node, struct sbus_bus *sbus)
39{ 38{
40 iopte_t *xpt, *xptend; 39 struct device_node *dp = sbus->ofdev.node;
41 struct iounit_struct *iounit; 40 struct iounit_struct *iounit;
42 struct linux_prom_registers iommu_promregs[PROMREG_MAX]; 41 iopte_t *xpt, *xptend;
43 struct resource r; 42 struct of_device *op;
43
44 op = of_find_device_by_node(dp);
45 if (!op) {
46 prom_printf("SUN4D: Cannot find SBI of_device.\n");
47 prom_halt();
48 }
44 49
45 iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC); 50 iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC);
46 if (!iounit) { 51 if (!iounit) {
@@ -55,18 +60,14 @@ iounit_init(int sbi_node, int io_node, struct sbus_bus *sbus)
55 iounit->rotor[1] = IOUNIT_BMAP2_START; 60 iounit->rotor[1] = IOUNIT_BMAP2_START;
56 iounit->rotor[2] = IOUNIT_BMAPM_START; 61 iounit->rotor[2] = IOUNIT_BMAPM_START;
57 62
58 xpt = NULL; 63 xpt = of_ioremap(&op->resource[2], 0, PAGE_SIZE * 16, "XPT");
59 if(prom_getproperty(sbi_node, "reg", (void *) iommu_promregs, 64 if (!xpt) {
60 sizeof(iommu_promregs)) != -1) { 65 prom_printf("SUN4D: Cannot map External Page Table.");
61 prom_apply_generic_ranges(io_node, 0, iommu_promregs, 3); 66 prom_halt();
62 memset(&r, 0, sizeof(r));
63 r.flags = iommu_promregs[2].which_io;
64 r.start = iommu_promregs[2].phys_addr;
65 xpt = (iopte_t *) sbus_ioremap(&r, 0, PAGE_SIZE * 16, "XPT");
66 } 67 }
67 if(!xpt) panic("Cannot map External Page Table.");
68 68
69 sbus->ofdev.dev.archdata.iommu = iounit; 69 sbus->ofdev.dev.archdata.iommu = iounit;
70 op->dev.archdata.iommu = iounit;
70 iounit->page_table = xpt; 71 iounit->page_table = xpt;
71 spin_lock_init(&iounit->lock); 72 spin_lock_init(&iounit->lock);
72 73