[PATCH] Fix bug in VIA 82C586B PCI IRQ routing

Linux Kernel Mailing List <[email protected]> Tue, 24 May 2005 13:09:54 +0000
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
ChangeSet 1.1560, 2005/05/24 10:09:54-03:00, [email protected]

	[PATCH] Fix bug in VIA 82C586B PCI IRQ routing
	
	Previously posted patch for 2.6 had been verified by Karsten Keil
	<[email protected]>.
	
	According to the VIA 82C586B datasheet (still available from
	http://gkernel.sourceforge.net/specs/via/586b.pdf.bz2) this chip needs
	a special PIRQ mapping. Again, according to appropriate datasheets,=20
	82C596, 82C686 & 8231 should continue utilize old scheme.
	
	Signed-off-by: Aleksey Gorelov <[email protected]>



 pci-irq.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+)


diff -Nru a/arch/i386/kernel/pci-irq.c b/arch/i386/kernel/pci-irq.c
--- a/arch/i386/kernel/pci-irq.c	2005-05-24 14:07:22 -07:00
+++ b/arch/i386/kernel/pci-irq.c	2005-05-24 14:07:22 -07:00
@@ -215,6 +215,24 @@
 }
 
 /*
+ * The VIA pirq rules are nibble-based, like ALI,
+ * but without the ugly irq number munging.
+ * However, for 82C586, nibble map is different .
+ */
+static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
+{
+	static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
+	return read_config_nybble(router, 0x55, pirqmap[pirq-1]);
+}
+
+static int pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
+{
+	static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
+	write_config_nybble(router, 0x55, pirqmap[pirq-1], irq);
+	return 1;
+}
+
+/*
  * ITE 8330G pirq rules are nibble-based
  * FIXME: pirqmap may be { 1, 0, 3, 2 },
  * 	  2+3 are both mapped to irq 9 on my system
@@ -649,6 +667,10 @@
 	switch(device)
 	{
 		case PCI_DEVICE_ID_VIA_82C586_0:
+			r->name = "VIA";
+			r->get = pirq_via586_get;
+			r->set = pirq_via586_set;
+			return 1;
 		case PCI_DEVICE_ID_VIA_82C596:
 		case PCI_DEVICE_ID_VIA_82C686:
 		case PCI_DEVICE_ID_VIA_8231: