Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jul 2002 18:42:04 -0600 (MDT)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        tony@valemount.com
Cc:        mobile@FreeBSD.ORG
Subject:   Re: PCI -> PCMCIA Adapter woes - patch
Message-ID:  <20020723.184204.123399222.imp@bsdimp.com>
In-Reply-To: <104501c23293$64515bb0$114c35d1@tonyxp>
References:  <100401c23290$cf2568d0$114c35d1@tonyxp> <20020723.153953.76074374.imp@bsdimp.com> <104501c23293$64515bb0$114c35d1@tonyxp>

next in thread | previous in thread | raw e-mail | index | archive | help
OK.  Here's my first cut at a patch.  Lemme know if it works for you?
Seems to work for me on my laptop, but its IRQMUX register is
initialized so this code has no effect.  Also, if you are using
hw.pcic.init_routing=1 can you try it w/o it too.  It is a little
longer than your patch, but should work well.

Warner

Index: pcic_pci.c
===================================================================
RCS file: /cache/ncvs/src/sys/pccard/pcic_pci.c,v
diff -u -r1.58 -r1.57
--- //depot/user/imp/newcard/pccard/pcic_pci.c	2002/07/20 15:35:40
+++ //depot/user/imp/newcard/pccard/pcic_pci.c	2002/07/23 21:54:33
@@ -699,6 +699,61 @@
 static int
 pcic_pci_ti12xx_func(struct pcic_slot *sp, enum pcic_intr_way way)
 {
+	u_int32_t	syscntl, devcntl, cardcntl, muxctl;
+	device_t	dev = sp->sc->dev;
+
+	syscntl  = pci_read_config(dev, TI113X_PCI_SYSTEM_CONTROL, 4);
+	devcntl  = pci_read_config(dev, TI113X_PCI_DEVICE_CONTROL, 1);
+	cardcntl = pci_read_config(dev, TI113X_PCI_CARD_CONTROL,   1);
+	muxctl  = pci_read_config(dev, TI12XX_PCI_IRQMUX, 4);
+
+	/*
+	 * Special code for the Orinoco cards (and a few others).  They
+	 * seem to need this special code to make them work only over pci
+	 * interrupts.  Sadly, doing this code also causes problems for
+	 * many laptops, so we have to make it controlled by a tunable.
+	 * Actually, experience has shown that this rarely, if ever,
+	 * helps.
+	 */
+	if (way == pcic_iw_pci) {
+		/*
+		 * pcic_init_routing seems to do nothing useful towards
+		 * fixing the hang problems.  I plan on removing it in
+		 * 4.8 or so.
+		 */
+		if (pcic_init_routing) {
+			devcntl &= ~TI113X_DEVCNTL_INTR_MASK;
+			pci_write_config(dev, TI113X_PCI_DEVICE_CONTROL,
+			    devcntl, 1);
+			syscntl |= TI113X_SYSCNTL_INTRTIE;
+		}
+		/* 
+		 * I'm not sure that this helps/hurts things at all and
+		 * plan on removing it in the 4.8 time frame unless someone
+		 * can show that it really helps.
+		 */
+		syscntl &= ~TI113X_SYSCNTL_SMIENB;
+		pci_write_config(dev, TI113X_PCI_SYSTEM_CONTROL, syscntl, 1);
+
+		/*
+		 * Some PCI add-in cards don't have good EEPROMs on them,
+		 * so they get this MUX register wrong.  The MUX register
+		 * defaults to 0, which is usually wrong for this register,
+		 * so we initialize it to make sense.
+		 *
+		 * We don't bother to turn it off in the ISA case since it
+		 * is an initialization issue.
+		 */
+		if (muxctl == 0) {
+			muxctl = (muxctl & ~TI12XX_IRQMUX_PIN0) |
+			    TI12XX_IRQMUX_PIN0_INTA;
+			if ((syscntl & TI113X_SYSCNTL_INTRTIE) == 0)
+				muxctl = (muxctl & ~TI12XX_IRQMUX_PIN1) |
+				    TI12XX_IRQMUX_PIN1_INTB;
+			pci_write_config(dev, TI12XX_PCI_IRQMUX, muxctl, 4);
+		}
+		
+	}
 	return (pcic_pci_gen_func(sp, way));
 }
 
@@ -727,7 +782,6 @@
 {
 	u_int32_t	syscntl, diagctl, devcntl, cardcntl;
 	u_int32_t	device_id = pci_get_devid(dev);
-	struct pcic_softc *sc = device_get_softc(dev);
 	int	 	ti113x = (device_id == PCI_DEVICE_ID_PCIC_TI1031) ||
 	    (device_id == PCI_DEVICE_ID_PCIC_TI1130) ||
 	    (device_id == PCI_DEVICE_ID_PCIC_TI1131);
@@ -762,28 +816,10 @@
 		 * register doesn't exist on the 1130 (and likely the 1131,
 		 * but without a datasheet it is impossible to know).
 		 * Some 12xx chips may not have it, but setting it is
-		 * believed to be harmless.
+		 * believed to be harmless on those models.
 		 */
 		pci_write_config(dev, TI12XX_PCI_MULTIMEDIA_CONTROL, 0, 4);
 	}
-	/*
-	 * Special code for the Orinoco cards (and a few others).  They
-	 * seem to need this special code to make them work only over pci
-	 * interrupts.  Sadly, doing this code also causes problems for
-	 * many laptops, so we have to make it controlled by a tunable.
-	 */
-	if (sc->func_route == pcic_iw_pci) {
-		if (pcic_init_routing) {
-			devcntl &= ~TI113X_DEVCNTL_INTR_MASK;
-			pci_write_config(dev, TI113X_PCI_DEVICE_CONTROL,
-			    devcntl, 1);
-			devcntl = pci_read_config(dev,
-			    TI113X_PCI_DEVICE_CONTROL, 1);
-			syscntl |= TI113X_SYSCNTL_INTRTIE;
-		}
-		syscntl &= ~TI113X_SYSCNTL_SMIENB;
-		pci_write_config(dev, TI113X_PCI_SYSTEM_CONTROL, syscntl, 1);
-	}
 	if (cardcntl & TI113X_CARDCNTL_RING_ENA)
 		printf("[ring enable]");
 	if (cardcntl & TI113X_CARDCNTL_SPKR_ENA)
Index: pcic_pci.h
===================================================================
RCS file: /cache/ncvs/src/sys/pccard/pcic_pci.h,v
diff -u -r1.58 -r1.57
--- //depot/user/imp/newcard/pccard/pcic_pci.h	2002/07/20 09:03:01
+++ //depot/user/imp/newcard/pccard/pcic_pci.h	2002/07/23 21:54:33
@@ -43,6 +43,7 @@
 /* Texas Instruments PCI-1130/1131 CardBus Controller */
 #define TI113X_PCI_SYSTEM_CONTROL	0x80	/* System Control */
 #define TI12XX_PCI_MULTIMEDIA_CONTROL	0x84	/* Zoom Video */
+#define TI12XX_PCI_IRQMUX		0x8c	/* multifunction pins */
 #define TI113X_PCI_RETRY_STATUS		0x90	/* Retry Status */
 #define TI113X_PCI_CARD_CONTROL		0x91	/* Card Control */
 #define TI113X_PCI_DEVICE_CONTROL	0x92	/* Device Control */
@@ -60,6 +61,17 @@
 #define TI113X_SYSCNTL_KEEP_CLK		0x00000002u
 #define TI113X_SYSCNTL_CLKRUN_ENA	0x00000001u
 
+/* IRQMUX register (TI12XX_IRQMUX == 0x8c) */
+#define TI12XX_IRQMUX_PIN0		0x0000000fu
+#define   TI12XX_IRQMUX_PIN0_INTA	0x2
+#define TI12XX_IRQMUX_PIN1		0x000000f0u
+#define   TI12XX_IRQMUX_PIN1_INTB	0x20
+#define TI12XX_IRQMUX_PIN2		0x00000f00u
+#define TI12XX_IRQMUX_PIN3		0x0000f000u
+#define TI12XX_IRQMUX_PIN4		0x000f0000u
+#define TI12XX_IRQMUX_PIN5		0x00f00000u
+#define TI12XX_IRQMUX_PIN6		0x0f000000u
+
 /* Card control register (TI113X_CARD_CONTROL == 0x91) */
 #define TI113X_CARDCNTL_RING_ENA	0x80u
 #define TI113X_CARDCNTL_ZOOM_VIDEO	0x40u

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020723.184204.123399222.imp>