Esempio n. 1
0
/**
 * vio_bus_init: - Initialize the virtual IO bus
 */
static int __init vio_bus_init(void)
{
	int err;
	struct device_node *node_vroot;

#ifdef CONFIG_PPC_ISERIES
	if (firmware_has_feature(FW_FEATURE_ISERIES)) {
		iommu_vio_init();
		vio_bus_device.iommu_table = &vio_iommu_table;
		iSeries_vio_dev = &vio_bus_device.dev;
	}
#endif

	err = bus_register(&vio_bus_type);
	if (err) {
		printk(KERN_ERR "failed to register VIO bus\n");
		return err;
	}

	/*
	 * The fake parent of all vio devices, just to give us
	 * a nice directory
	 */
	err = device_register(&vio_bus_device.dev);
	if (err) {
		printk(KERN_WARNING "%s: device_register returned %i\n",
				__FUNCTION__, err);
		return err;
	}

	node_vroot = find_devices("vdevice");
	if (node_vroot) {
		struct device_node *of_node;

		/*
		 * Create struct vio_devices for each virtual device in
		 * the device tree. Drivers will associate with them later.
		 */
		for (of_node = node_vroot->child; of_node != NULL;
				of_node = of_node->sibling) {
			printk(KERN_DEBUG "%s: processing %p\n",
					__FUNCTION__, of_node);
			vio_register_device_node(of_node);
		}
	}

	return 0;
}
Esempio n. 2
0
int rpaphp_enable_vio_slot(struct slot *slot)
{
	int retval = 0;

	if ((slot->dev.vio_dev = vio_register_device_node(slot->dn))) {
		info("%s: VIO adapter %s in slot[%s] has been configured\n",
			__FUNCTION__, slot->dn->name, slot->name);
		slot->state = CONFIGURED;
	} else {
		info("%s: no vio_dev struct for adapter in slot[%s]\n",
			__FUNCTION__, slot->name);
		slot->state = NOT_CONFIGURED;
	}
	
	return retval;
}
Esempio n. 3
0
/*
 * This is here so that we can dynamically add viodasd
 * devices without exposing all the above infrastructure.
 */
struct vio_dev *vio_create_viodasd(u32 unit)
{
	struct device_node *vio_root;
	struct device_node *np;
	struct vio_dev *vdev = NULL;

	vio_root = of_find_node_by_path("/vdevice");
	if (!vio_root)
		return NULL;
	np = do_device_node(vio_root, "viodasd", FIRST_VIODASD + unit, unit,
			"block", "IBM,iSeries-viodasd", NULL);
	of_node_put(vio_root);
	if (np) {
		vdev = vio_register_device_node(np);
		if (!vdev)
			free_node(np);
	}
	return vdev;
}
Esempio n. 4
0
int register_vio_slot(struct device_node *dn)
{
	u32 *index;
	char *name;
	int rc = 1;
	struct slot *slot = NULL;
	
	rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL);
	if (rc)
		goto exit_rc;
	index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL);
	if (!index)
		goto exit_rc;
	if (!(slot = alloc_slot_struct(dn, *index, name, 0))) {
		rc = -ENOMEM;
		goto exit_rc;
	}
	slot->dev_type = VIO_DEV;
	slot->dev.vio_dev = vio_find_node(dn);
	if (slot->dev.vio_dev) {
		/*
		 * rpaphp is the only owner of vio devices and
		 * does not need extra reference taken by
		 * vio_find_node
		 */
		put_device(&slot->dev.vio_dev->dev);
	} else
		slot->dev.vio_dev = vio_register_device_node(dn);
	if (slot->dev.vio_dev)
		slot->state = CONFIGURED;
	else
		slot->state = NOT_CONFIGURED;
	if (setup_vio_hotplug_slot_info(slot))
		goto exit_rc;
	strcpy(slot->name, slot->dev.vio_dev->dev.bus_id);
	info("%s: registered VIO device[name=%s vio_dev=%p]\n",
		__FUNCTION__, slot->name, slot->dev.vio_dev); 
	rc = register_slot(slot);
exit_rc:
	if (rc && slot)
		dealloc_slot_struct(slot);
	return (rc);
}
Esempio n. 5
0
/**
 * vio_bus_init: - Initialize the virtual IO bus
 */
static int __init vio_bus_init(void)
{
	int err;
	struct device_node *node_vroot;

	err = bus_register(&vio_bus_type);
	if (err) {
		printk(KERN_ERR "failed to register VIO bus\n");
		return err;
	}

	/*
	 * The fake parent of all vio devices, just to give us
	 * a nice directory
	 */
	err = device_register(&vio_bus_device.dev);
	if (err) {
		printk(KERN_WARNING "%s: device_register returned %i\n",
				__func__, err);
		return err;
	}

	node_vroot = of_find_node_by_name(NULL, "vdevice");
	if (node_vroot) {
		struct device_node *of_node;

		/*
		 * Create struct vio_devices for each virtual device in
		 * the device tree. Drivers will associate with them later.
		 */
		for (of_node = node_vroot->child; of_node != NULL;
				of_node = of_node->sibling)
			vio_register_device_node(of_node);
		of_node_put(node_vroot);
	}

	return 0;
}