pcmcia fixes for apple powerbook

From: Paul Mackerras (paulus@linuxcare.com.au)
Date: Sat Sep 16 2000 - 02:05:40 EST


David,

The patch below fixes some problems I found in trying to use the
in-kernel pcmcia/cardbus support in 2.4.0-test9-pre1 on my 1999 G3
powerbook, which has a TI 1211 cardbus controller.

The first part of the patch fixes a simple endianness problem in cs.c.
Following that is a small change that removes a compile warning when
CONFIG_ISA is not set (as in my case). The change to ti113x.h adds a
special open routine for the TI1211; in my case I need to set the
multifunction pin routing register (config offset 0x8c) to 2 in order
to route the INTA signal out the MFUNC0 pin, and the firmware doesn't
do this automatically. Finally I have added #ifdef CONFIG_ISA in a
couple of places in yenta.c to make sure we don't try to use ISA
interrupt routing when we don't have an ISA bus.

I'm also seeing some contact bounce problems when cards are inserted,
although test9-pre1 is slightly better than test8 in this respect. If
I kill cardmgr, install the card, and restart cardmgr, it comes up
just fine.

Assuming this patch looks OK to you, could you send it to Linus?

Thanks,
Paul.

diff -urN linux/drivers/pcmcia/cs.c pmac/drivers/pcmcia/cs.c
--- linux/drivers/pcmcia/cs.c Sat Sep 16 16:25:57 2000
+++ pmac/drivers/pcmcia/cs.c Sat Sep 16 16:54:07 2000
@@ -1634,6 +1634,7 @@
                                  config_req_t *req)
 {
     int i;
+ u_char b;
     u_int base;
     socket_info_t *s;
     config_t *c;
@@ -1726,14 +1727,14 @@
         write_cis_mem(s, 1, (base + CISREG_ESR)>>1, 1, &c->ExtStatus);
     }
     if (req->Present & PRESENT_IOBASE_0) {
- i = c->io.BasePort1 & 0xff;
- write_cis_mem(s, 1, (base + CISREG_IOBASE_0)>>1, 1, &i);
- i = (c->io.BasePort1 >> 8) & 0xff;
- write_cis_mem(s, 1, (base + CISREG_IOBASE_1)>>1, 1, &i);
+ b = c->io.BasePort1 & 0xff;
+ write_cis_mem(s, 1, (base + CISREG_IOBASE_0)>>1, 1, &b);
+ b = (c->io.BasePort1 >> 8) & 0xff;
+ write_cis_mem(s, 1, (base + CISREG_IOBASE_1)>>1, 1, &b);
     }
     if (req->Present & PRESENT_IOSIZE) {
- i = c->io.NumPorts1 + c->io.NumPorts2 - 1;
- write_cis_mem(s, 1, (base + CISREG_IOSIZE)>>1, 1, &i);
+ b = c->io.NumPorts1 + c->io.NumPorts2 - 1;
+ write_cis_mem(s, 1, (base + CISREG_IOSIZE)>>1, 1, &b);
     }
     
     /* Configure I/O windows */
@@ -1840,8 +1841,7 @@
 {
     socket_info_t *s;
     config_t *c;
- int try, ret = 0, irq = 0;
- u_int mask;
+ int ret = 0, irq = 0;
     
     if (CHECK_HANDLE(handle))
         return CS_BAD_HANDLE;
@@ -1862,6 +1862,7 @@
         /* If the interrupt is already assigned, it must match */
         irq = s->irq.AssignedIRQ;
         if (req->IRQInfo1 & IRQ_INFO2_VALID) {
+ u_int mask;
             mask = req->IRQInfo2 & s->cap.irq_mask;
             ret = ((mask >> irq) & 1) ? 0 : CS_BAD_ARGS;
         } else
@@ -1869,6 +1870,7 @@
     } else {
         ret = CS_IN_USE;
         if (req->IRQInfo1 & IRQ_INFO2_VALID) {
+ u_int mask, try;
             mask = req->IRQInfo2 & s->cap.irq_mask;
             for (try = 0; try < 2; try++) {
                 for (irq = 0; irq < 32; irq++)
diff -urN linux/drivers/pcmcia/ti113x.h pmac/drivers/pcmcia/ti113x.h
--- linux/drivers/pcmcia/ti113x.h Thu May 25 12:53:52 2000
+++ pmac/drivers/pcmcia/ti113x.h Fri Sep 15 23:36:53 2000
@@ -272,6 +272,36 @@
         yenta_proc_setup
 };
 
+static int ti1211_open(pci_socket_t *socket)
+{
+#ifdef CONFIG_PPC
+ /*
+ * On Powerbooks with the TI1211 cardbus chip, we have to set the
+ * multifunction pin routing register to route the PCI INTA to the
+ * MFUNC0 pin.
+ */
+ config_writel(socket, TI122X_IRQMUX, 2);
+#endif /* CONFIG_PPC */
+
+ ti_open(socket);
+ return 0;
+}
+
+static struct pci_socket_ops ti1211_ops = {
+ ti1211_open,
+ yenta_close,
+ ti_init,
+ yenta_suspend,
+ yenta_get_status,
+ yenta_get_socket,
+ yenta_set_socket,
+ yenta_get_io_map,
+ yenta_set_io_map,
+ yenta_get_mem_map,
+ yenta_set_mem_map,
+ yenta_proc_setup
+};
+
 #endif /* CONFIG_CARDBUS */
 
 #endif /* _LINUX_TI113X_H */
diff -urN linux/drivers/pcmcia/yenta.c pmac/drivers/pcmcia/yenta.c
--- linux/drivers/pcmcia/yenta.c Sat Sep 16 16:25:57 2000
+++ pmac/drivers/pcmcia/yenta.c Sat Sep 16 17:13:38 2000
@@ -245,6 +245,7 @@
                 u8 intr;
                 bridge |= (state->flags & SS_RESET) ? CB_BRIDGE_CRST : 0;
 
+#ifdef CONFIG_ISA
                 /* ISA interrupt control? */
                 intr = exca_readb(socket, I365_INTCTL);
                 intr = (intr & ~0xf);
@@ -253,10 +254,13 @@
                         bridge |= CB_BRIDGE_INTR;
                 }
                 exca_writeb(socket, I365_INTCTL, intr);
+#endif /* CONFIG_ISA */
         } else {
                 u8 reg;
 
+#ifdef CONFIG_ISA
                 bridge |= CB_BRIDGE_INTR;
+#endif /* CONFIG_ISA */
                 reg = exca_readb(socket, I365_INTCTL) & (I365_RING_ENA | I365_INTR_ENA);
                 reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET;
                 reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0;
@@ -487,6 +491,7 @@
 
 static unsigned int yenta_probe_irq(pci_socket_t *socket, u32 isa_irq_mask)
 {
+#ifdef CONFIG_ISA
         int i;
         unsigned long val;
         u16 bridge_ctrl;
@@ -524,6 +529,9 @@
         config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
 
         return mask;
+#else
+ return 0;
+#endif /* CONFIG_ISA */
 }
 
 /*
@@ -770,7 +778,7 @@
         { PD(TI,1450), &ti_ops },
         { PD(TI,1225), &ti_ops },
         { PD(TI,1251A), &ti_ops },
- { PD(TI,1211), &ti_ops },
+ { PD(TI,1211), &ti1211_ops },
         { PD(TI,1251B), &ti_ops },
         { PD(TI,1420), &ti_ops },
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 21:00:12 EST