[PATCH] powerpc: use a common vio_match_device routine
[linux-2.6/btrfs-unstable.git] / arch / powerpc / platforms / iseries / vio.c
blobbdd2b7d97d15df209764197cd6acfc2b99c47ec8
1 /*
2 * IBM PowerPC iSeries Virtual I/O Infrastructure Support.
4 * Copyright (c) 2005 Stephen Rothwell, IBM Corp.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
11 #include <linux/types.h>
12 #include <linux/device.h>
13 #include <linux/init.h>
15 #include <asm/vio.h>
16 #include <asm/iommu.h>
17 #include <asm/tce.h>
18 #include <asm/abs_addr.h>
19 #include <asm/page.h>
20 #include <asm/iseries/vio.h>
21 #include <asm/iseries/hv_types.h>
22 #include <asm/iseries/hv_lp_config.h>
23 #include <asm/iseries/hv_call_xm.h>
25 #include "iommu.h"
27 struct device *iSeries_vio_dev = &vio_bus_device.dev;
28 EXPORT_SYMBOL(iSeries_vio_dev);
30 static struct iommu_table veth_iommu_table;
31 static struct iommu_table vio_iommu_table;
33 static void __init iommu_vio_init(void)
35 iommu_table_getparms_iSeries(255, 0, 0xff, &veth_iommu_table);
36 veth_iommu_table.it_size /= 2;
37 vio_iommu_table = veth_iommu_table;
38 vio_iommu_table.it_offset += veth_iommu_table.it_size;
40 if (!iommu_init_table(&veth_iommu_table))
41 printk("Virtual Bus VETH TCE table failed.\n");
42 if (!iommu_init_table(&vio_iommu_table))
43 printk("Virtual Bus VIO TCE table failed.\n");
46 static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
48 if (strcmp(dev->type, "vlan") == 0)
49 return &veth_iommu_table;
50 return &vio_iommu_table;
53 static struct vio_bus_ops vio_bus_ops_iseries = {
54 .build_iommu_table = vio_build_iommu_table,
57 /**
58 * vio_bus_init_iseries: - Initialize the iSeries virtual IO bus
60 static int __init vio_bus_init_iseries(void)
62 iommu_vio_init();
63 vio_bus_device.iommu_table = &vio_iommu_table;
64 iSeries_vio_dev = &vio_bus_device.dev;
65 return vio_bus_init(&vio_bus_ops_iseries);
67 __initcall(vio_bus_init_iseries);