USB: add missing delay during remote wakeup
[safe/jmp/linux-2.6] / drivers / pcmcia / cardbus.c
index a1bd763..d99f846 100644 (file)
 #include <linux/mm.h>
 #include <linux/pci.h>
 #include <linux/ioport.h>
+#include <linux/io.h>
 #include <asm/irq.h>
-#include <asm/io.h>
 
-#define IN_CARD_SERVICES
 #include <pcmcia/cs_types.h>
 #include <pcmcia/ss.h>
 #include <pcmcia/cs.h>
-#include <pcmcia/bulkmem.h>
 #include <pcmcia/cistpl.h>
 #include "cs_internal.h"
 
@@ -60,7 +58,7 @@
     image number and an offset within that image.  xlate_rom_addr()
     converts an image/offset address to an absolute offset from the
     ROM's base address.
-    
+
 =====================================================================*/
 
 static u_int xlate_rom_addr(void __iomem *b, u_int addr)
@@ -87,20 +85,20 @@ static u_int xlate_rom_addr(void __iomem *b, u_int addr)
     These are similar to setup_cis_mem and release_cis_mem for 16-bit
     cards.  The "result" that is used externally is the cb_cis_virt
     pointer in the struct pcmcia_socket structure.
-    
+
 =====================================================================*/
 
-static void cb_release_cis_mem(struct pcmcia_socket * s)
+static void cb_release_cis_mem(struct pcmcia_socket *s)
 {
        if (s->cb_cis_virt) {
-               cs_dbg(s, 1, "cb_release_cis_mem()\n");
+               dev_dbg(&s->dev, "cb_release_cis_mem()\n");
                iounmap(s->cb_cis_virt);
                s->cb_cis_virt = NULL;
                s->cb_cis_res = NULL;
        }
 }
 
-static int cb_setup_cis_mem(struct pcmcia_socket * s, struct resource *res)
+static int cb_setup_cis_mem(struct pcmcia_socket *s, struct resource *res)
 {
        unsigned int start, size;
 
@@ -126,15 +124,16 @@ static int cb_setup_cis_mem(struct pcmcia_socket * s, struct resource *res)
 
     This is used by the CIS processing code to read CIS information
     from a CardBus device.
-    
+
 =====================================================================*/
 
-int read_cb_mem(struct pcmcia_socket * s, int space, u_int addr, u_int len, void *ptr)
+int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len,
+               void *ptr)
 {
        struct pci_dev *dev;
        struct resource *res;
 
-       cs_dbg(s, 3, "read_cb_mem(%d, %#x, %u)\n", space, addr, len);
+       dev_dbg(&s->dev, "read_cb_mem(%d, %#x, %u)\n", space, addr, len);
 
        dev = pci_get_slot(s->cb_dev->subordinate, 0);
        if (!dev)
@@ -143,7 +142,7 @@ int read_cb_mem(struct pcmcia_socket * s, int space, u_int addr, u_int len, void
        /* Config space? */
        if (space == 0) {
                if (addr + len > 0x100)
-                       goto fail;
+                       goto failput;
                for (; len; addr++, ptr++, len--)
                        pci_read_config_byte(dev, addr, ptr);
                return 0;
@@ -171,6 +170,8 @@ int read_cb_mem(struct pcmcia_socket * s, int space, u_int addr, u_int len, void
        memcpy_fromio(ptr, s->cb_cis_virt + addr, len);
        return 0;
 
+failput:
+       pci_dev_put(dev);
 fail:
        memset(ptr, 0xff, len);
        return -1;
@@ -181,40 +182,47 @@ fail:
     cb_alloc() and cb_free() allocate and free the kernel data
     structures for a Cardbus device, and handle the lowest level PCI
     device setup issues.
-    
+
 =====================================================================*/
 
-/*
- * Since there is only one interrupt available to CardBus
- * devices, all devices downstream of this device must
- * be using this IRQ.
- */
-static void cardbus_assign_irqs(struct pci_bus *bus, int irq)
+static void cardbus_config_irq_and_cls(struct pci_bus *bus, int irq)
 {
        struct pci_dev *dev;
 
        list_for_each_entry(dev, &bus->devices, bus_list) {
                u8 irq_pin;
 
+               /*
+                * Since there is only one interrupt available to
+                * CardBus devices, all devices downstream of this
+                * device must be using this IRQ.
+                */
                pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq_pin);
                if (irq_pin) {
                        dev->irq = irq;
                        pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
                }
 
+               /*
+                * Some controllers transfer very slowly with 0 CLS.
+                * Configure it.  This may fail as CLS configuration
+                * is mandatory only for MWI.
+                */
+               pci_set_cacheline_size(dev);
+
                if (dev->subordinate)
-                       cardbus_assign_irqs(dev->subordinate, irq);
+                       cardbus_config_irq_and_cls(dev->subordinate, irq);
        }
 }
 
-int cb_alloc(struct pcmcia_socket * s)
+int __ref cb_alloc(struct pcmcia_socket *s)
 {
        struct pci_bus *bus = s->cb_dev->subordinate;
        struct pci_dev *dev;
        unsigned int max, pass;
 
        s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0));
-//     pcibios_fixup_bus(bus);
+       pci_fixup_cardbus(bus); 
 
        max = bus->secondary;
        for (pass = 0; pass < 2; pass++)
@@ -228,7 +236,7 @@ int cb_alloc(struct pcmcia_socket * s)
         */
        pci_bus_size_bridges(bus);
        pci_bus_assign_resources(bus);
-       cardbus_assign_irqs(bus, s->pci_irq);
+       cardbus_config_irq_and_cls(bus, s->pci_irq);
 
        /* socket specific tune function */
        if (s->tune_bridge)
@@ -238,10 +246,10 @@ int cb_alloc(struct pcmcia_socket * s)
        pci_bus_add_devices(bus);
 
        s->irq.AssignedIRQ = s->pci_irq;
-       return CS_SUCCESS;
+       return 0;
 }
 
-void cb_free(struct pcmcia_socket * s)
+void cb_free(struct pcmcia_socket *s)
 {
        struct pci_dev *bridge = s->cb_dev;