Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7cb4461520f307a6e3fb2bb32cb8daee45aa1fae
Commit:     7cb4461520f307a6e3fb2bb32cb8daee45aa1fae
Parent:     53521d8c90d366191b6c134f88a8ebe83de60614
Author:     Michael Buesch <[EMAIL PROTECTED]>
AuthorDate: Tue Feb 19 17:46:48 2008 +0100
Committer:  John W. Linville <[EMAIL PROTECTED]>
CommitDate: Wed Feb 20 20:11:49 2008 -0500

    ssb: Fix pcicore cardbus mode
    
    This fixes the pcicore driver to not die a horrible
    crash death when inserting a cardbus card.
    
    Signed-off-by: Michael Buesch <[EMAIL PROTECTED]>
    Signed-off-by: John W. Linville <[EMAIL PROTECTED]>
---
 drivers/ssb/driver_pcicore.c       |   28 ++++++++++++++++++++++++++--
 drivers/ssb/main.c                 |    1 +
 include/linux/ssb/ssb.h            |    7 +++++++
 include/linux/ssb/ssb_driver_pci.h |    5 +++++
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/ssb/driver_pcicore.c b/drivers/ssb/driver_pcicore.c
index 2faaa90..059452f 100644
--- a/drivers/ssb/driver_pcicore.c
+++ b/drivers/ssb/driver_pcicore.c
@@ -11,6 +11,7 @@
 #include <linux/ssb/ssb.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
+#include <linux/ssb/ssb_embedded.h>
 
 #include "ssb_private.h"
 
@@ -27,6 +28,18 @@ void pcicore_write32(struct ssb_pcicore *pc, u16 offset, u32 
value)
        ssb_write32(pc->dev, offset, value);
 }
 
+static inline
+u16 pcicore_read16(struct ssb_pcicore *pc, u16 offset)
+{
+       return ssb_read16(pc->dev, offset);
+}
+
+static inline
+void pcicore_write16(struct ssb_pcicore *pc, u16 offset, u16 value)
+{
+       ssb_write16(pc->dev, offset, value);
+}
+
 /**************************************************
  * Code for hostmode operation.
  **************************************************/
@@ -117,8 +130,10 @@ static u32 get_cfgspace_addr(struct ssb_pcicore *pc,
        u32 addr = 0;
        u32 tmp;
 
-       if (unlikely(pc->cardbusmode && dev > 1))
+       /* We do only have one cardbus device behind the bridge. */
+       if (pc->cardbusmode && (dev >= 1))
                goto out;
+
        if (bus == 0) {
                /* Type 0 transaction */
                if (unlikely(dev >= SSB_PCI_SLOT_MAX))
@@ -318,7 +333,16 @@ static void ssb_pcicore_init_hostmode(struct ssb_pcicore 
*pc)
        pcicore_write32(pc, SSB_PCICORE_ARBCTL, val);
        udelay(1); /* Assertion time demanded by the PCI standard */
 
-       /*TODO cardbus mode */
+       if (pc->dev->bus->has_cardbus_slot) {
+               ssb_dprintk(KERN_INFO PFX "CardBus slot detected\n");
+               pc->cardbusmode = 1;
+               /* GPIO 1 resets the bridge */
+               ssb_gpio_out(pc->dev->bus, 1, 1);
+               ssb_gpio_outen(pc->dev->bus, 1, 1);
+               pcicore_write16(pc, SSB_PCICORE_SPROM(0),
+                               pcicore_read16(pc, SSB_PCICORE_SPROM(0))
+                               | 0x0400);
+       }
 
        /* 64MB I/O window */
        pcicore_write32(pc, SSB_PCICORE_SBTOPCI0,
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index af07ab2..bedb2b4 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -557,6 +557,7 @@ static int ssb_fetch_invariants(struct ssb_bus *bus,
                goto out;
        memcpy(&bus->boardinfo, &iv.boardinfo, sizeof(iv.boardinfo));
        memcpy(&bus->sprom, &iv.sprom, sizeof(iv.sprom));
+       bus->has_cardbus_slot = iv.has_cardbus_slot;
 out:
        return err;
 }
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index d14c036..20add65 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -282,6 +282,8 @@ struct ssb_bus {
        struct ssb_boardinfo boardinfo;
        /* Contents of the SPROM. */
        struct ssb_sprom sprom;
+       /* If the board has a cardbus slot, this is set to true. */
+       bool has_cardbus_slot;
 
 #ifdef CONFIG_SSB_EMBEDDED
        /* Lock for GPIO register access. */
@@ -299,8 +301,13 @@ struct ssb_bus {
 
 /* The initialization-invariants. */
 struct ssb_init_invariants {
+       /* Versioning information about the PCB. */
        struct ssb_boardinfo boardinfo;
+       /* The SPROM information. That's either stored in an
+        * EEPROM or NVRAM on the board. */
        struct ssb_sprom sprom;
+       /* If the board has a cardbus slot, this is set to true. */
+       bool has_cardbus_slot;
 };
 /* Type of function to fetch the invariants. */
 typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus,
diff --git a/include/linux/ssb/ssb_driver_pci.h 
b/include/linux/ssb/ssb_driver_pci.h
index 9cfffb7..5e25bac 100644
--- a/include/linux/ssb/ssb_driver_pci.h
+++ b/include/linux/ssb/ssb_driver_pci.h
@@ -51,6 +51,11 @@
 #define  SSB_PCICORE_SBTOPCI1_MASK     0xFC000000
 #define SSB_PCICORE_SBTOPCI2           0x0108  /* Backplane to PCI translation 
2 (sbtopci2) */
 #define  SSB_PCICORE_SBTOPCI2_MASK     0xC0000000
+#define SSB_PCICORE_PCICFG0            0x0400  /* PCI config space 0 (rev >= 
8) */
+#define SSB_PCICORE_PCICFG1            0x0500  /* PCI config space 1 (rev >= 
8) */
+#define SSB_PCICORE_PCICFG2            0x0600  /* PCI config space 2 (rev >= 
8) */
+#define SSB_PCICORE_PCICFG3            0x0700  /* PCI config space 3 (rev >= 
8) */
+#define SSB_PCICORE_SPROM(wordoffset)  (0x0800 + ((wordoffset) * 2)) /* SPROM 
shadow area (72 bytes) */
 
 /* SBtoPCIx */
 #define SSB_PCICORE_SBTOPCI_MEM                0x00000000
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to