aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/vio.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/vio.c')
-rw-r--r--arch/powerpc/kernel/vio.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 63f72ede4341..3052a931f2b5 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -37,8 +37,6 @@
37#include <asm/page.h> 37#include <asm/page.h>
38#include <asm/hvcall.h> 38#include <asm/hvcall.h>
39 39
40static struct bus_type vio_bus_type;
41
42static struct vio_dev vio_bus_device = { /* fake "parent" device */ 40static struct vio_dev vio_bus_device = { /* fake "parent" device */
43 .name = "vio", 41 .name = "vio",
44 .type = "", 42 .type = "",
@@ -625,7 +623,7 @@ struct dma_map_ops vio_dma_mapping_ops = {
625 * vio_cmo_set_dev_desired - Set desired entitlement for a device 623 * vio_cmo_set_dev_desired - Set desired entitlement for a device
626 * 624 *
627 * @viodev: struct vio_dev for device to alter 625 * @viodev: struct vio_dev for device to alter
628 * @new_desired: new desired entitlement level in bytes 626 * @desired: new desired entitlement level in bytes
629 * 627 *
630 * For use by devices to request a change to their entitlement at runtime or 628 * For use by devices to request a change to their entitlement at runtime or
631 * through sysfs. The desired entitlement level is changed and a balancing 629 * through sysfs. The desired entitlement level is changed and a balancing
@@ -1262,7 +1260,7 @@ static int vio_bus_remove(struct device *dev)
1262 1260
1263/** 1261/**
1264 * vio_register_driver: - Register a new vio driver 1262 * vio_register_driver: - Register a new vio driver
1265 * @drv: The vio_driver structure to be registered. 1263 * @viodrv: The vio_driver structure to be registered.
1266 */ 1264 */
1267int __vio_register_driver(struct vio_driver *viodrv, struct module *owner, 1265int __vio_register_driver(struct vio_driver *viodrv, struct module *owner,
1268 const char *mod_name) 1266 const char *mod_name)
@@ -1282,7 +1280,7 @@ EXPORT_SYMBOL(__vio_register_driver);
1282 1280
1283/** 1281/**
1284 * vio_unregister_driver - Remove registration of vio driver. 1282 * vio_unregister_driver - Remove registration of vio driver.
1285 * @driver: The vio_driver struct to be removed form registration 1283 * @viodrv: The vio_driver struct to be removed form registration
1286 */ 1284 */
1287void vio_unregister_driver(struct vio_driver *viodrv) 1285void vio_unregister_driver(struct vio_driver *viodrv)
1288{ 1286{
@@ -1396,21 +1394,27 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
1396 viodev->name = of_node->name; 1394 viodev->name = of_node->name;
1397 viodev->dev.of_node = of_node_get(of_node); 1395 viodev->dev.of_node = of_node_get(of_node);
1398 1396
1399 if (firmware_has_feature(FW_FEATURE_CMO))
1400 vio_cmo_set_dma_ops(viodev);
1401 else
1402 set_dma_ops(&viodev->dev, &dma_iommu_ops);
1403 set_iommu_table_base(&viodev->dev, vio_build_iommu_table(viodev));
1404 set_dev_node(&viodev->dev, of_node_to_nid(of_node)); 1397 set_dev_node(&viodev->dev, of_node_to_nid(of_node));
1405 1398
1406 /* init generic 'struct device' fields: */ 1399 /* init generic 'struct device' fields: */
1407 viodev->dev.parent = &vio_bus_device.dev; 1400 viodev->dev.parent = &vio_bus_device.dev;
1408 viodev->dev.bus = &vio_bus_type; 1401 viodev->dev.bus = &vio_bus_type;
1409 viodev->dev.release = vio_dev_release; 1402 viodev->dev.release = vio_dev_release;
1410 /* needed to ensure proper operation of coherent allocations 1403
1411 * later, in case driver doesn't set it explicitly */ 1404 if (of_get_property(viodev->dev.of_node, "ibm,my-dma-window", NULL)) {
1412 dma_set_mask(&viodev->dev, DMA_BIT_MASK(64)); 1405 if (firmware_has_feature(FW_FEATURE_CMO))
1413 dma_set_coherent_mask(&viodev->dev, DMA_BIT_MASK(64)); 1406 vio_cmo_set_dma_ops(viodev);
1407 else
1408 set_dma_ops(&viodev->dev, &dma_iommu_ops);
1409
1410 set_iommu_table_base(&viodev->dev,
1411 vio_build_iommu_table(viodev));
1412
1413 /* needed to ensure proper operation of coherent allocations
1414 * later, in case driver doesn't set it explicitly */
1415 dma_set_mask(&viodev->dev, DMA_BIT_MASK(64));
1416 dma_set_coherent_mask(&viodev->dev, DMA_BIT_MASK(64));
1417 }
1414 1418
1415 /* register with generic device framework */ 1419 /* register with generic device framework */
1416 if (device_register(&viodev->dev)) { 1420 if (device_register(&viodev->dev)) {
@@ -1490,12 +1494,18 @@ static int __init vio_bus_init(void)
1490 if (firmware_has_feature(FW_FEATURE_CMO)) 1494 if (firmware_has_feature(FW_FEATURE_CMO))
1491 vio_cmo_bus_init(); 1495 vio_cmo_bus_init();
1492 1496
1497 return 0;
1498}
1499postcore_initcall(vio_bus_init);
1500
1501static int __init vio_device_init(void)
1502{
1493 vio_bus_scan_register_devices("vdevice"); 1503 vio_bus_scan_register_devices("vdevice");
1494 vio_bus_scan_register_devices("ibm,platform-facilities"); 1504 vio_bus_scan_register_devices("ibm,platform-facilities");
1495 1505
1496 return 0; 1506 return 0;
1497} 1507}
1498__initcall(vio_bus_init); 1508device_initcall(vio_device_init);
1499 1509
1500static ssize_t name_show(struct device *dev, 1510static ssize_t name_show(struct device *dev,
1501 struct device_attribute *attr, char *buf) 1511 struct device_attribute *attr, char *buf)
@@ -1567,7 +1577,7 @@ static int vio_hotplug(struct device *dev, struct kobj_uevent_env *env)
1567 return 0; 1577 return 0;
1568} 1578}
1569 1579
1570static struct bus_type vio_bus_type = { 1580struct bus_type vio_bus_type = {
1571 .name = "vio", 1581 .name = "vio",
1572 .dev_attrs = vio_dev_attrs, 1582 .dev_attrs = vio_dev_attrs,
1573 .uevent = vio_hotplug, 1583 .uevent = vio_hotplug,