Skip to contentSkip to conversation

[2.4] PCI chipset Opti Viper M/N+

PATCH Malware 1 participant 3 messages Oct 24, 2003 1 message not in the archive

lore
Share & tools
lore

Malware

author
#0 lore raw

Hi Martin and linux-kernel readers,

I had problems using CardBus cards in my laptop, they simply got no IRQ assigned. The kernel currently used is 2.4.22.

BIOS settings and telling the kernel to use the PCI BIOS provided no solution. The BIOS settings available are minimal and the PCI BIOS is buggy causing crashes when called from the kernel.

So finally I added support for the specific PCI chipset, Opti Viper M/N+, to the kernel PCI code. See the patch below which is relative to the 2.4.22 kernel. Now the CardBus cards get an interrupt assigned as excepted. It worked fine with a Xircom modem/ethernet card which I got access to for a short testing.

Michael

arch/i386/kernel/pci-irq.c renamed from arch/i386/kernel/pci-irq.c.orig +39 -0
@@ -243,6 +243,44 @@
 }
 
 /*
+ * OPTI Viper-M/N+: Bit field with 3 bits per entry.
+ * Due to the lack of a specification the information about this chipset
+ * was taken from the NetBSD source code.
+ */
+static int pirq_viper_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
+{
+	static const int viper_irq_decode[] = { 0, 5, 9, 10, 11, 12, 14, 15 };
+	u32 irq;
+
+	pci_read_config_dword(router, 0x40, &irq);
+	irq >>= (pirq-1)*3;
+	irq &= 7;
+
+	return viper_irq_decode[irq];
+}
+
+static int pirq_viper_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
+{
+	static const int viper_irq_map[] = { -1, -1, -1, -1, -1, 1, -1, -1, -1, 2, 3, 4, 5, -1, 6, 7 };
+	int newval = viper_irq_map[irq];
+	u32 val;
+	u32 mask = 7 << (3*(pirq-1));
+#if 0
+	mask |= 0x10000UL << (pirq-1);	/* edge triggered */
+#endif
+
+	if ( newval == -1 )
+		return 0;
+	
+	pci_read_config_dword(router, 0x40, &val);
+	val &= ~mask;
+	val |= newval << (3*(pirq*1));
+	pci_write_config_dword(router, 0x40, val);
+
+	return 1;
+}
+
+/*
  * Cyrix: nibble offset 0x5C
  */
 static int pirq_cyrix_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
@@ -485,6 +523,7 @@
 	{ "VIA", PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, pirq_via_get, pirq_via_set },
 
 	{ "OPTI", PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C700, pirq_opti_get, pirq_opti_set },
+	{ "OPTI VIPER", PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558, pirq_viper_get, pirq_viper_set },
 
 	{ "NatSemi", PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5520, pirq_cyrix_get, pirq_cyrix_set },
 	{ "SIS", PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, pirq_sis_get, pirq_sis_set },
#1 lore raw

Hi Martin and linux-kernel readers,

receiving my previous mail myself did give me another view to it and now I am curious why it did work that fine with following typo present:

Quoted 1 line

+ val |= newval << (3*(pirq*1));

it should read:
val |= newval << (3*(pirq-1));

With this changed it still works with the PCMCIA card, but I still need to gain access to a CardBus card to test it with.

Michael

Signature · 2 lines
Linux@TekXpress
http://www-users.rwth-aachen.de/Michael.Mueller4/tekxp/tekxp.html

A message that is not in the archive (sent off-list or not yet received): md5:FBD343F3435F79857BDF1297AFE82D42

#3 lore raw

Hi Martin and linux-kernel readers,

Quoted 5 lines · I wrote:

it should read:

   val |= newval << (3*(pirq-1));

With this changed it still works with the PCMCIA card, but I still need to gain access to a CardBus card to test it with.

Ok, tested it with a LevelOne 10/100MBit CardBus card in a local computer store. It works fine.

Michael

Signature · 2 lines
Linux@TekXpress
http://www-users.rwth-aachen.de/Michael.Mueller4/tekxp/tekxp.html