Ejemplo n.º 1
0
me_device_t *me1000_pci_constructor(struct pci_dev * pci_device)
{
	me1000_device_t *me1000_device;
	me_subdevice_t *subdevice;
	int err;
	int i;

	PDEBUG("executed.\n");

	// Allocate structure for device instance.
	me1000_device = kmalloc(sizeof(me1000_device_t), GFP_KERNEL);

	if (!me1000_device) {
		PERROR("Cannot get memory for ME-1000 device instance.\n");
		return NULL;
	}

	memset(me1000_device, 0, sizeof(me1000_device_t));

	// Initialize base class structure.
	err = me_device_pci_init((me_device_t *) me1000_device, pci_device);

	if (err) {
		kfree(me1000_device);
		PERROR("Cannot initialize device base class.\n");
		return NULL;
	}
	// Initialize spin lock .
	spin_lock_init(&me1000_device->ctrl_lock);

	for (i = 0; i < 4; i++) {
		subdevice =
		    (me_subdevice_t *) me1000_dio_constructor(me1000_device->
							      base.info.pci.
							      reg_bases[2], i,
							      &me1000_device->
							      ctrl_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me1000_device);
			kfree(me1000_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me1000_device->base.slist,
					    subdevice);
	}

	// Overwrite base class methods.
	me1000_device->base.me_device_config_load = me1000_config_load;

	return (me_device_t *) me1000_device;
}
me_device_t *me8200_pci_constructor(struct pci_dev *pci_device)
{
	me8200_device_t *me8200_device;
	me_subdevice_t *subdevice;
	unsigned int version_idx;
	int err;
	int i;

	PDEBUG("executed.\n");

	// Allocate structure for device instance.
	me8200_device = kmalloc(sizeof(me8200_device_t), GFP_KERNEL);

	if (!me8200_device) {
		PERROR("Cannot get memory for device instance.\n");
		return NULL;
	}

	memset(me8200_device, 0, sizeof(me8200_device_t));

	// Initialize base class structure.
	err = me_device_pci_init((me_device_t *) me8200_device, pci_device);

	if (err) {
		kfree(me8200_device);
		PERROR("Cannot initialize device base class.\n");
		return NULL;
	}

	/* Get the index in the device version information table. */
	version_idx =
	    me8200_versions_get_device_index(me8200_device->base.info.pci.
					     device_id);

	// Initialize spin lock .
	spin_lock_init(&me8200_device->irq_ctrl_lock);
	spin_lock_init(&me8200_device->irq_mode_lock);
	spin_lock_init(&me8200_device->dio_ctrl_lock);

	/* Setup the PLX interrupt configuration */
	outl(PLX_INTCSR_LOCAL_INT1_EN |
	     PLX_INTCSR_LOCAL_INT1_POL |
	     PLX_INTCSR_LOCAL_INT2_EN |
	     PLX_INTCSR_LOCAL_INT2_POL |
	     PLX_INTCSR_PCI_INT_EN,
	     me8200_device->base.info.pci.reg_bases[1] + PLX_INTCSR);

	// Create subdevice instances.

	for (i = 0; i < me8200_versions[version_idx].di_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me8200_di_constructor(me8200_device->
							     base.info.pci.
							     reg_bases[2], i,
							     me8200_device->
							     base.irq,
							     &me8200_device->
							     irq_ctrl_lock,
							     &me8200_device->
							     irq_mode_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me8200_device);
			kfree(me8200_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me8200_device->base.slist,
					    subdevice);
	}

	for (i = 0; i < me8200_versions[version_idx].do_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me8200_do_constructor(me8200_device->
							     base.info.pci.
							     reg_bases[2], i,
							     me8200_device->
							     base.irq,
							     &me8200_device->
							     irq_mode_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me8200_device);
			kfree(me8200_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me8200_device->base.slist,
					    subdevice);
	}

	for (i = 0; i < me8200_versions[version_idx].dio_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me8200_dio_constructor(me8200_device->
							      base.info.pci.
							      reg_bases[2], i,
							      &me8200_device->
							      dio_ctrl_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me8200_device);
			kfree(me8200_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me8200_device->base.slist,
					    subdevice);
	}

	return (me_device_t *) me8200_device;
}
Ejemplo n.º 3
0
me_device_t *me0900_pci_constructor(struct pci_dev *pci_device)
{
	me0900_device_t *me0900_device;
	me_subdevice_t *subdevice;
	unsigned int version_idx;
	int err;
	int i;
	int port_shift;

	PDEBUG("executed.\n");

	// Allocate structure for device instance.
	me0900_device = kmalloc(sizeof(me0900_device_t), GFP_KERNEL);

	if (!me0900_device) {
		PERROR("Cannot get memory for device instance.\n");
		return NULL;
	}

	memset(me0900_device, 0, sizeof(me0900_device_t));

	// Initialize base class structure.
	err = me_device_pci_init((me_device_t *) me0900_device, pci_device);

	if (err) {
		kfree(me0900_device);
		PERROR("Cannot initialize device base class.\n");
		return NULL;
	}

	/* Get the index in the device version information table. */
	version_idx =
	    me0900_versions_get_device_index(me0900_device->base.info.pci.
					     device_id);

	/* Initialize 8255 chip to desired mode */
	if (me0900_device->base.info.pci.device_id ==
	    PCI_DEVICE_ID_MEILHAUS_ME0940) {
		outb(0x9B,
		     me0900_device->base.info.pci.reg_bases[2] +
		     ME0900_CTRL_REG);
	} else if (me0900_device->base.info.pci.device_id ==
		   PCI_DEVICE_ID_MEILHAUS_ME0950) {
		outb(0x89,
		     me0900_device->base.info.pci.reg_bases[2] +
		     ME0900_CTRL_REG);
		outb(0x00,
		     me0900_device->base.info.pci.reg_bases[2] +
		     ME0900_WRITE_ENABLE_REG);
	} else if (me0900_device->base.info.pci.device_id ==
		   PCI_DEVICE_ID_MEILHAUS_ME0960) {
		outb(0x8B,
		     me0900_device->base.info.pci.reg_bases[2] +
		     ME0900_CTRL_REG);
		outb(0x00,
		     me0900_device->base.info.pci.reg_bases[2] +
		     ME0900_WRITE_ENABLE_REG);
	}

	port_shift =
	    (me0900_device->base.info.pci.device_id ==
	     PCI_DEVICE_ID_MEILHAUS_ME0960) ? 1 : 0;
	// Create subdevice instances.

	for (i = 0; i < me0900_versions[version_idx].di_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me0900_di_constructor(me0900_device->
							     base.info.pci.
							     reg_bases[2],
							     i + port_shift);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me0900_device);
			kfree(me0900_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me0900_device->base.slist,
					    subdevice);
	}

	for (i = 0; i < me0900_versions[version_idx].do_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me0900_do_constructor(me0900_device->
							     base.info.pci.
							     reg_bases[2], i);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me0900_device);
			kfree(me0900_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me0900_device->base.slist,
					    subdevice);
	}

	return (me_device_t *) me0900_device;
}
Ejemplo n.º 4
0
me_device_t *me6000_pci_constructor(struct pci_dev *pci_device)
{
	me6000_device_t *me6000_device;
	me_subdevice_t *subdevice;
	unsigned int version_idx;
	int err;
	int i;
	int high_range = 0;
	int fifo;

	PDEBUG("executed.\n");

	// Allocate structure for device instance.
	me6000_device = kmalloc(sizeof(me6000_device_t), GFP_KERNEL);

	if (!me6000_device) {
		PERROR("Cannot get memory for device instance.\n");
		return NULL;
	}

	memset(me6000_device, 0, sizeof(me6000_device_t));

	// Initialize base class structure.
	err = me_device_pci_init((me_device_t *) me6000_device, pci_device);

	if (err) {
		kfree(me6000_device);
		PERROR("Cannot initialize device base class.\n");
		return NULL;
	}

	/* Download the xilinx firmware */
	err = me_xilinx_download(me6000_device->base.info.pci.reg_bases[1],
				 me6000_device->base.info.pci.reg_bases[2],
				 &pci_device->dev, "me6000.bin");

	if (err) {
		me_device_deinit((me_device_t *) me6000_device);
		kfree(me6000_device);
		PERROR("Can't download firmware.\n");
		return NULL;
	}

	/* Get the index in the device version information table. */
	version_idx =
	    me6000_versions_get_device_index(me6000_device->base.info.pci.
					     device_id);

	// Initialize spin lock .
	spin_lock_init(&me6000_device->preload_reg_lock);
	spin_lock_init(&me6000_device->dio_ctrl_reg_lock);

	/* Create digital input/output instances. */
	for (i = 0; i < me6000_versions[version_idx].dio_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me6000_dio_constructor(me6000_device->
							      base.info.pci.
							      reg_bases[3], i,
							      &me6000_device->
							      dio_ctrl_reg_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me6000_device);
			kfree(me6000_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me6000_device->base.slist,
					    subdevice);
	}

	/* Create analog output instances. */
	for (i = 0; i < me6000_versions[version_idx].ao_subdevices; i++) {
		high_range = ((i == 8)
			      &&
			      ((me6000_device->base.info.pci.device_id ==
				PCI_DEVICE_ID_MEILHAUS_ME6359)
			       || (me6000_device->base.info.pci.device_id ==
				   PCI_DEVICE_ID_MEILHAUS_ME6259)
			      )
		    )? 1 : 0;

		fifo =
		    (i <
		     me6000_versions[version_idx].
		     ao_fifo) ? ME6000_AO_HAS_FIFO : 0x0;
		fifo |= (i < 4) ? ME6000_AO_EXTRA_HARDWARE : 0x0;

		subdevice =
		    (me_subdevice_t *) me6000_ao_constructor(me6000_device->
							     base.info.pci.
							     reg_bases[2],
							     &me6000_device->
							     preload_reg_lock,
							     &me6000_device->
							     preload_flags,
							     &me6000_device->
							     triggering_flags,
							     i, fifo,
							     me6000_device->
							     base.irq,
							     high_range,
							     me6000_workqueue);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me6000_device);
			kfree(me6000_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me6000_device->base.slist,
					    subdevice);
	}

	return (me_device_t *) me6000_device;
}
me_device_t *me1400_pci_constructor(struct pci_dev *pci_device)
{
	int err;
	me1400_device_t *me1400_device;
	me_subdevice_t *subdevice;
	unsigned int version_idx;
	unsigned int me8255_idx;
	unsigned int dio_idx;
	unsigned int me8254_idx;
	unsigned int ctr_idx;
	unsigned int ext_irq_idx;

	PDEBUG("executed.\n");

	// Allocate structure for device instance.
	me1400_device = kmalloc(sizeof(me1400_device_t), GFP_KERNEL);

	if (!me1400_device) {
		PERROR("Cannot get memory for 1400ate device instance.\n");
		return NULL;
	}

	memset(me1400_device, 0, sizeof(me1400_device_t));

	// Initialize base class structure.
	err = me_device_pci_init((me_device_t *) me1400_device, pci_device);

	if (err) {
		kfree(me1400_device);
		PERROR("Cannot initialize device base class.\n");
		return NULL;
	}

	/* Check for ME1400 extension device. If detected we fake a ME-1400 D device id. */
	if (me1400_device->base.info.pci.device_id ==
	    PCI_DEVICE_ID_MEILHAUS_ME140C) {
		uint8_t ctrl;
		ctrl =
		    inb(me1400_device->base.info.pci.reg_bases[2] +
			ME1400D_CLK_SRC_2_REG);
		PDEBUG_REG("xxx_reg inb(0x%X+0x%X)=0x%x\n",
			   me1400_device->base.info.pci.reg_bases[2],
			   ME1400D_CLK_SRC_2_REG, ctrl);
		outb(ctrl | 0xF0,
		     me1400_device->base.info.pci.reg_bases[2] +
		     ME1400D_CLK_SRC_2_REG);
		PDEBUG_REG("xxx_reg outb(0x%X+0x%X)=0x%x\n",
			   me1400_device->base.info.pci.reg_bases[2],
			   ME1400D_CLK_SRC_2_REG, ctrl | 0xF0);
		ctrl =
		    inb(me1400_device->base.info.pci.reg_bases[2] +
			ME1400D_CLK_SRC_2_REG);
		PDEBUG_REG("xxx_reg inb(0x%X+0x%X)=0x%x\n",
			   me1400_device->base.info.pci.reg_bases[2],
			   ME1400D_CLK_SRC_2_REG, ctrl);

		if ((ctrl & 0xF0) == 0xF0) {
			PINFO("ME1400 D detected.\n");
			me1400_device->base.info.pci.device_id =
			    PCI_DEVICE_ID_MEILHAUS_ME140D;
		}
	}

	/* Initialize global stuff of digital i/o subdevices. */
	for (me8255_idx = 0; me8255_idx < ME1400_MAX_8255; me8255_idx++) {
		me1400_device->dio_current_mode[me8255_idx] = 0;
		spin_lock_init(&me1400_device->dio_ctrl_reg_lock[me8255_idx]);
	}

	/* Initialize global stuff of counter subdevices. */
	spin_lock_init(&me1400_device->clk_src_reg_lock);

	for (me8254_idx = 0; me8254_idx < ME1400_MAX_8254; me8254_idx++)
		spin_lock_init(&me1400_device->ctr_ctrl_reg_lock[me8254_idx]);

	/* Get the index in the device version information table. */
	version_idx =
	    me1400_versions_get_device_index(me1400_device->base.info.pci.
					     device_id);

	/* Generate DIO subdevice instances. */
	for (me8255_idx = 0;
	     me8255_idx < me1400_versions[version_idx].dio_chips;
	     me8255_idx++) {
		for (dio_idx = 0; dio_idx < 3; dio_idx++) {
			subdevice =
			    (me_subdevice_t *)
			    me8255_constructor(me1400_versions[version_idx].
					       device_id,
					       me1400_device->base.info.pci.
					       reg_bases[2], me8255_idx,
					       dio_idx,
					       &me1400_device->
					       dio_current_mode[me8255_idx],
					       &me1400_device->
					       dio_ctrl_reg_lock[me8255_idx]);

			if (!subdevice) {
				me_device_deinit((me_device_t *) me1400_device);
				kfree(me1400_device);
				PERROR("Cannot get memory for subdevice.\n");
				return NULL;
			}

			me_slist_add_subdevice_tail(&me1400_device->base.slist,
						    subdevice);
		}
	}

	/* Generate counter subdevice instances. */
	for (me8254_idx = 0;
	     me8254_idx < me1400_versions[version_idx].ctr_chips;
	     me8254_idx++) {
		for (ctr_idx = 0; ctr_idx < 3; ctr_idx++) {
			subdevice =
			    (me_subdevice_t *)
			    me8254_constructor(me1400_device->base.info.pci.
					       device_id,
					       me1400_device->base.info.pci.
					       reg_bases[2], me8254_idx,
					       ctr_idx,
					       &me1400_device->
					       ctr_ctrl_reg_lock[me8254_idx],
					       &me1400_device->
					       clk_src_reg_lock);

			if (!subdevice) {
				me_device_deinit((me_device_t *) me1400_device);
				kfree(me1400_device);
				PERROR("Cannot get memory for subdevice.\n");
				return NULL;
			}

			me_slist_add_subdevice_tail(&me1400_device->base.slist,
						    subdevice);
		}
	}

	/* Generate external interrupt subdevice instances. */
	for (ext_irq_idx = 0;
	     ext_irq_idx < me1400_versions[version_idx].ext_irq_subdevices;
	     ext_irq_idx++) {
		subdevice =
		    (me_subdevice_t *)
		    me1400_ext_irq_constructor(me1400_device->base.info.pci.
					       device_id,
					       me1400_device->base.info.pci.
					       reg_bases[1],
					       me1400_device->base.info.pci.
					       reg_bases[2],
					       &me1400_device->clk_src_reg_lock,
					       me1400_device->base.irq);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me1400_device);
			kfree(me1400_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me1400_device->base.slist,
					    subdevice);
	}

	return (me_device_t *) me1400_device;
}
Ejemplo n.º 6
0
me_device_t *me4600_pci_constructor(struct pci_dev *pci_device)
#endif				//BOSCH
{
	me4600_device_t *me4600_device;
	me_subdevice_t *subdevice;
	unsigned int version_idx;
	int err;
	int i;

	PDEBUG("executed.\n");

	// Allocate structure for device instance.
	me4600_device = kmalloc(sizeof(me4600_device_t), GFP_KERNEL);

	if (!me4600_device) {
		PERROR("Cannot get memory for ME-4600 device instance.\n");
		return NULL;
	}

	memset(me4600_device, 0, sizeof(me4600_device_t));

	// Initialize base class structure.
	err = me_device_pci_init((me_device_t *) me4600_device, pci_device);

	if (err) {
		kfree(me4600_device);
		PERROR("Cannot initialize device base class.\n");
		return NULL;
	}
	// Download the xilinx firmware.
	if (me4600_device->base.info.pci.device_id == PCI_DEVICE_ID_MEILHAUS_ME4610) {	//Jekyll <=> me4610
		err =
		    me_xilinx_download(me4600_device->base.info.pci.
				       reg_bases[1],
				       me4600_device->base.info.pci.
				       reg_bases[5], &pci_device->dev,
				       "me4610.bin");
	} else {		// General me4600 firmware
#ifdef BOSCH
		err =
		    me_xilinx_download(me4600_device->base.info.pci.
				       reg_bases[1],
				       me4600_device->base.info.pci.
				       reg_bases[5], &pci_device->dev,
				       (me_bosch_fw) ? "me4600_bosch.bin" :
				       "me4600.bin");
#else //~BOSCH
		err =
		    me_xilinx_download(me4600_device->base.info.pci.
				       reg_bases[1],
				       me4600_device->base.info.pci.
				       reg_bases[5], &pci_device->dev,
				       "me4600.bin");
#endif
	}

	if (err) {
		me_device_deinit((me_device_t *) me4600_device);
		kfree(me4600_device);
		PERROR("Cannot download firmware.\n");
		return NULL;
	}
	// Get the index in the device version information table.
	version_idx =
	    me4600_versions_get_device_index(me4600_device->base.info.pci.
					     device_id);

	// Initialize spin locks.
	spin_lock_init(&me4600_device->preload_reg_lock);

	me4600_device->preload_flags = 0;

	spin_lock_init(&me4600_device->dio_lock);
	spin_lock_init(&me4600_device->ai_ctrl_lock);
	spin_lock_init(&me4600_device->ctr_ctrl_reg_lock);
	spin_lock_init(&me4600_device->ctr_clk_src_reg_lock);

	// Create digital input instances.
	for (i = 0; i < me4600_versions[version_idx].di_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me4600_di_constructor(me4600_device->
							     base.info.pci.
							     reg_bases[2],
							     &me4600_device->
							     dio_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me4600_device);
			kfree(me4600_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me4600_device->base.slist,
					    subdevice);
	}

	// Create digital output instances.
	for (i = 0; i < me4600_versions[version_idx].do_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me4600_do_constructor(me4600_device->
							     base.info.pci.
							     reg_bases[2],
							     &me4600_device->
							     dio_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me4600_device);
			kfree(me4600_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me4600_device->base.slist,
					    subdevice);
	}

	// Create digital input/output instances.
	for (i = 0; i < me4600_versions[version_idx].dio_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me4600_dio_constructor(me4600_device->
							      base.info.pci.
							      reg_bases[2],
							      me4600_versions
							      [version_idx].
							      do_subdevices +
							      me4600_versions
							      [version_idx].
							      di_subdevices + i,
							      &me4600_device->
							      dio_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me4600_device);
			kfree(me4600_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me4600_device->base.slist,
					    subdevice);
	}

	// Create analog input instances.
	for (i = 0; i < me4600_versions[version_idx].ai_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me4600_ai_constructor(me4600_device->
							     base.info.pci.
							     reg_bases[2],
							     me4600_versions
							     [version_idx].
							     ai_channels,
							     me4600_versions
							     [version_idx].
							     ai_ranges,
							     me4600_versions
							     [version_idx].
							     ai_isolated,
							     me4600_versions
							     [version_idx].
							     ai_sh,
							     me4600_device->
							     base.irq,
							     &me4600_device->
							     ai_ctrl_lock,
							     me4600_workqueue);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me4600_device);
			kfree(me4600_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me4600_device->base.slist,
					    subdevice);
	}

	// Create analog output instances.
	for (i = 0; i < me4600_versions[version_idx].ao_subdevices; i++) {
#ifdef BOSCH
		subdevice =
		    (me_subdevice_t *) me4600_ao_constructor(me4600_device->
							     base.info.pci.
							     reg_bases[2],
							     &me4600_device->
							     preload_reg_lock,
							     &me4600_device->
							     preload_flags, i,
							     me4600_versions
							     [version_idx].
							     ao_fifo,
							     me4600_device->
							     base.irq);
#else //~BOSCH
		subdevice =
		    (me_subdevice_t *) me4600_ao_constructor(me4600_device->
							     base.info.pci.
							     reg_bases[2],
							     &me4600_device->
							     preload_reg_lock,
							     &me4600_device->
							     preload_flags, i,
							     me4600_versions
							     [version_idx].
							     ao_fifo,
							     me4600_device->
							     base.irq,
							     me4600_workqueue);
#endif

		if (!subdevice) {
			me_device_deinit((me_device_t *) me4600_device);
			kfree(me4600_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me4600_device->base.slist,
					    subdevice);
	}

	// Create counter instances.
	for (i = 0; i < me4600_versions[version_idx].ctr_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *) me8254_constructor(me4600_device->base.
							  info.pci.device_id,
							  me4600_device->base.
							  info.pci.reg_bases[3],
							  0, i,
							  &me4600_device->
							  ctr_ctrl_reg_lock,
							  &me4600_device->
							  ctr_clk_src_reg_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me4600_device);
			kfree(me4600_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me4600_device->base.slist,
					    subdevice);
	}

	// Create external interrupt instances.
	for (i = 0; i < me4600_versions[version_idx].ext_irq_subdevices; i++) {
		subdevice =
		    (me_subdevice_t *)
		    me4600_ext_irq_constructor(me4600_device->base.info.pci.
					       reg_bases[2],
					       me4600_device->base.irq,
					       &me4600_device->ai_ctrl_lock);

		if (!subdevice) {
			me_device_deinit((me_device_t *) me4600_device);
			kfree(me4600_device);
			PERROR("Cannot get memory for subdevice.\n");
			return NULL;
		}

		me_slist_add_subdevice_tail(&me4600_device->base.slist,
					    subdevice);
	}

	return (me_device_t *) me4600_device;
}