staging: brcm80211: removed log after kzalloc()/kmalloc() failure
[pandora-kernel.git] / drivers / staging / brcm80211 / brcmsmac / nicpci.c
index 2d46e70..f5a2695 100644 (file)
 /* PCIE protocol TLP diagnostic registers */
 #define PCIE_TLP_WORKAROUNDSREG                0x004   /* TLP Workarounds */
 
+/* Sonics to PCI translation types */
+#define        SBTOPCI_PREF    0x4             /* prefetch enable */
+#define        SBTOPCI_BURST   0x8             /* burst enable */
+#define        SBTOPCI_RC_READMULTI    0x20    /* memory read multiple */
+
+#define PCI_CLKRUN_DSBL        0x8000  /* Bit 15 forceClkrun */
+
+/* PCI core index in SROM shadow area */
+#define SRSH_PI_OFFSET 0       /* first word */
+#define SRSH_PI_MASK   0xf000  /* bit 15:12 */
+#define SRSH_PI_SHIFT  12      /* bit 15:12 */
+
 /* Sonics side: PCI core and host control registers */
 struct sbpciregs {
        u32 control;            /* PCI control */
@@ -211,36 +223,17 @@ struct pcicore_info {
        bool pmecap;            /* Capable of generating PME */
 };
 
-/* debug/trace */
-#define        PCI_ERROR(args)
-#define PCIE_PUB(sih) ((sih)->buscoretype == PCIE_CORE_ID)
-
-/* routines to access mdio slave device registers */
-static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk);
-static int pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr,
-                      bool write, uint *val);
-static int pcie_mdiowrite(struct pcicore_info *pi, uint physmedia, uint readdr,
-                         uint val);
-static int pcie_mdioread(struct pcicore_info *pi, uint physmedia, uint readdr,
-                        uint *ret_val);
-
-static void pcie_extendL1timer(struct pcicore_info *pi, bool extend);
-static void pcie_clkreq_upd(struct pcicore_info *pi, uint state);
-
-static void pcie_war_aspm_clkreq(struct pcicore_info *pi);
-static void pcie_war_serdes(struct pcicore_info *pi);
-static void pcie_war_noplldown(struct pcicore_info *pi);
-static void pcie_war_polarity(struct pcicore_info *pi);
-static void pcie_war_pci_setup(struct pcicore_info *pi);
-
 #define PCIE_ASPM(sih)                                                 \
-       ((PCIE_PUB(sih)) &&                                             \
+       (((sih)->buscoretype == PCIE_CORE_ID) &&                        \
         (((sih)->buscorerev >= 3) &&                                   \
          ((sih)->buscorerev <= 5)))
 
 
 /* delay needed between the mdio control/ mdiodata register data access */
-#define PR28829_DELAY() udelay(10)
+static void pr28829_delay(void)
+{
+       udelay(10);
+}
 
 /* Initialize the PCI core.
  * It's caller's responsibility to make sure that this is done only once
@@ -252,10 +245,8 @@ struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev,
 
        /* alloc struct pcicore_info */
        pi = kzalloc(sizeof(struct pcicore_info), GFP_ATOMIC);
-       if (pi == NULL) {
-               PCI_ERROR(("pci_attach: malloc failed!\n"));
+       if (pi == NULL)
                return NULL;
-       }
 
        pi->sih = sih;
        pi->dev = pdev;
@@ -393,7 +384,7 @@ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk)
                    (blk << 4));
        W_REG(&pcieregs->mdiodata, mdiodata);
 
-       PR28829_DELAY();
+       pr28829_delay();
        /* retry till the transaction is complete */
        while (i < pcie_serdes_spinwait) {
                if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE)
@@ -404,7 +395,6 @@ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk)
        }
 
        if (i >= pcie_serdes_spinwait) {
-               PCI_ERROR(("pcie_mdiosetblock: timed out\n"));
                return false;
        }
 
@@ -445,13 +435,13 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write,
 
        W_REG(&pcieregs->mdiodata, mdiodata);
 
-       PR28829_DELAY();
+       pr28829_delay();
 
        /* retry till the transaction is complete */
        while (i < pcie_serdes_spinwait) {
                if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) {
                        if (!write) {
-                               PR28829_DELAY();
+                               pr28829_delay();
                                *val = (R_REG(&pcieregs->mdiodata) &
                                        MDIODATA_MASK);
                        }
@@ -463,8 +453,7 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write,
                i++;
        }
 
-       PCI_ERROR(("pcie_mdioop: timed out op: %d\n", write));
-       /* Disable mdio access to SERDES */
+       /* Timed out. Disable mdio access to SERDES. */
        W_REG(&pcieregs->mdiocontrol, 0);
        return 1;
 }
@@ -516,7 +505,7 @@ static void pcie_extendL1timer(struct pcicore_info *pi, bool extend)
        struct si_pub *sih = pi->sih;
        struct sbpcieregs *pcieregs = pi->regs.pcieregs;
 
-       if (!PCIE_PUB(sih) || sih->buscorerev < 7)
+       if (sih->buscoretype != PCIE_CORE_ID || sih->buscorerev < 7)
                return;
 
        w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG);
@@ -754,7 +743,7 @@ void pcicore_attach(struct pcicore_info *pi, char *pvars, int state)
 
 void pcicore_hwup(struct pcicore_info *pi)
 {
-       if (!pi || !PCIE_PUB(pi->sih))
+       if (!pi || pi->sih->buscoretype != PCIE_CORE_ID)
                return;
 
        pcie_war_pci_setup(pi);
@@ -762,7 +751,7 @@ void pcicore_hwup(struct pcicore_info *pi)
 
 void pcicore_up(struct pcicore_info *pi, int state)
 {
-       if (!pi || !PCIE_PUB(pi->sih))
+       if (!pi || pi->sih->buscoretype != PCIE_CORE_ID)
                return;
 
        /* Restore L1 timer for better performance */
@@ -790,7 +779,7 @@ void pcicore_sleep(struct pcicore_info *pi)
 
 void pcicore_down(struct pcicore_info *pi, int state)
 {
-       if (!pi || !PCIE_PUB(pi->sih))
+       if (!pi || pi->sih->buscoretype != PCIE_CORE_ID)
                return;
 
        pcie_clkreq_upd(pi, state);
@@ -802,7 +791,7 @@ void pcicore_down(struct pcicore_info *pi, int state)
 /* precondition: current core is sii->buscoretype */
 static void pcicore_fixcfg(struct pcicore_info *pi, u16 *reg16)
 {
-       struct si_info *sii = SI_INFO(pi->sih);
+       struct si_info *sii = (struct si_info *)(pi->sih);
        u16 val16;
        uint pciidx;
 
@@ -832,7 +821,7 @@ void pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs *pciregs)
 
        OR_REG(&pciregs->sbtopci2, SBTOPCI_PREF | SBTOPCI_BURST);
 
-       if (SI_INFO(pi->sih)->pub.buscorerev >= 11) {
+       if (((struct si_info *)(pi->sih))->pub.buscorerev >= 11) {
                OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI);
                w = R_REG(&pciregs->clkrun);
                W_REG(&pciregs->clkrun, w | PCI_CLKRUN_DSBL);