Re: [PATCH] staging: comedi: adv_pci_dio: restore PCI-1753E support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/03/13 17:12, Ian Abbott wrote:
Advantech has their own Linux (non-Comedi) driver for the PCI-1753 which
detects whether the PCI-1753E expansion card is connected to the
PCI-1753 by fiddling with the control register of an emulated 8255 chip
in the address space of the expansion card.  The test doesn't actually
seem to make much sense for a _real_ 8255 chip, but let's assume it
works for whatever hardware is on this board.

I messed up there. Advantech's test uses register offset 53 whereas my test used register offset PCI1753E_DIO + 3 == 32 + 3 == 35. Offset 53 is not a register of any of the 8255 chips. The braino occurred when I converted 53 to hex 35, saw that as 0x32 + 3, noticed that PCI1753E_DIO was 32, but failed to notice the different radix. Oops.

+unsigned long pci_dio_detect_pci1753e(struct pci_dev *pcidev,
+				      unsigned long cardtype)
+{
+	if (cardtype != TYPE_PCI1753)
+		return cardtype;
+
+	/*
+	 * Change cardtype from TYPE_PCI1753 to TYPE_PCI1753E if expansion
+	 * board available.  Need to enable PCI device temporarily to perform
+	 * the test.
+	 */
+	if (comedi_pci_enable(pcidev, "adv_pci_dio") == 0) {
+		/*
+		 * This test is based on Advantech's "advdaq" driver source
+		 * (which declares its module licence as "GPL" although the
+		 * driver source does not include a "COPYING" file).  The test
+		 * does not make a lot of sense for a real 8255 chip as the
+		 * 8255 "single bit set/reset" commands used below shouldn't
+		 * affect the values read back from the 8255 command register.
+		 * However, the board only claims to emulate 8255 mode 0 and
+		 * is not using real 8255 chips.  I assume Advantech know what
+		 * they are doing in their own driver.  -- Ian Abbott
+		 */
+		unsigned long cr = pci_resource_start(pcidev, PCIDIO_MAINREG) +
+				   PCI1753E_DIO + 3;

I should just use offset 53 (from resource start) there and fix the remark about it not making sense. It makes perfect sense for a non-8255, custom register!

+
+		outb(0x05, cr);
+		if ((inb(cr) & 0x07) == 0x02) {
+			outb(0x02, cr);
+			if ((inb(cr) & 0x07) == 0x05)
+				cardtype = TYPE_PCI1753E;
+		}
+		comedi_pci_disable(pcidev);
+	}
+	return cardtype;
+}

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux