]> git.karo-electronics.de Git - linux-beck.git/commitdiff
bcma: add bcma_core_pci_fixcfg()
authorHauke Mehrtens <hauke@hauke-m.de>
Sun, 29 Apr 2012 00:18:51 +0000 (02:18 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 16 May 2012 16:45:22 +0000 (12:45 -0400)
This code is based on code from pcicore_fixcfg() in brcmsmac. This
patch is part of the move of pci specific code from brcmsmac to bcma.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Tested-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/bcma/driver_pci.c
include/linux/bcma/bcma_driver_pci.h

index 949206674dc8cfcf42a45d0312cafbe03eb0d2a8..472d14fad643d86bc1e0384edf06c2407edd3c7b 100644 (file)
@@ -168,12 +168,31 @@ static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
                                     tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
 }
 
+static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
+{
+       struct bcma_device *core = pc->core;
+       u16 val16, core_index;
+       uint regoff;
+
+       regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET);
+       core_index = (u16)core->core_index;
+
+       val16 = pcicore_read16(pc, regoff);
+       if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT)
+            != core_index) {
+               val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) |
+                       (val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK);
+               pcicore_write16(pc, regoff, val16);
+       }
+}
+
 /**************************************************
  * Init.
  **************************************************/
 
 static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
 {
+       bcma_core_pci_fixcfg(pc);
        bcma_pcicore_serdes_workaround(pc);
 }
 
index 20c9f96d40705af53d39588dcab7c202702d56d6..5b0542c336eda1b53e8d480ebac15bb1bdc3b6ca 100644 (file)
@@ -87,6 +87,9 @@ struct pci_dev;
 #define BCMA_CORE_PCI_PCICFG2                  0x0600  /* PCI config space 2 (rev >= 8) */
 #define BCMA_CORE_PCI_PCICFG3                  0x0700  /* PCI config space 3 (rev >= 8) */
 #define BCMA_CORE_PCI_SPROM(wordoffset)                (0x0800 + ((wordoffset) * 2)) /* SPROM shadow area (72 bytes) */
+#define  BCMA_CORE_PCI_SPROM_PI_OFFSET         0       /* first word */
+#define   BCMA_CORE_PCI_SPROM_PI_MASK          0xf000  /* bit 15:12 */
+#define   BCMA_CORE_PCI_SPROM_PI_SHIFT         12      /* bit 15:12 */
 
 /* SBtoPCIx */
 #define BCMA_CORE_PCI_SBTOPCI_MEM              0x00000000
@@ -202,7 +205,9 @@ struct bcma_drv_pci {
 };
 
 /* Register access */
+#define pcicore_read16(pc, offset)             bcma_read16((pc)->core, offset)
 #define pcicore_read32(pc, offset)             bcma_read32((pc)->core, offset)
+#define pcicore_write16(pc, offset, val)       bcma_write16((pc)->core, offset, val)
 #define pcicore_write32(pc, offset, val)       bcma_write32((pc)->core, offset, val)
 
 extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc);