Skip to content

Commit

Permalink
mwl8k: pci BAR mapping changes
Browse files Browse the repository at this point in the history
Map BAR0 as well, as we need to write to it during init on some chips.

Also, if BAR0 is a 64bit BAR, the register BAR becomes BAR2, so try
mapping BAR2 if mapping BAR1 fails.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Lennert Buytenhek authored and John W. Linville committed Nov 4, 2009
1 parent 45eb400 commit 5b9482d
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions drivers/net/wireless/mwl8k.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ struct mwl8k_firmware {
};

struct mwl8k_priv {
void __iomem *sram;
void __iomem *regs;
struct ieee80211_hw *hw;

Expand Down Expand Up @@ -2987,13 +2988,27 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev,
SET_IEEE80211_DEV(hw, &pdev->dev);
pci_set_drvdata(pdev, hw);

priv->regs = pci_iomap(pdev, 1, 0x10000);
if (priv->regs == NULL) {
printk(KERN_ERR "%s: Cannot map device memory\n",
priv->sram = pci_iomap(pdev, 0, 0x10000);
if (priv->sram == NULL) {
printk(KERN_ERR "%s: Cannot map device SRAM\n",
wiphy_name(hw->wiphy));
goto err_iounmap;
}

/*
* If BAR0 is a 32 bit BAR, the register BAR will be BAR1.
* If BAR0 is a 64 bit BAR, the register BAR will be BAR2.
*/
priv->regs = pci_iomap(pdev, 1, 0x10000);
if (priv->regs == NULL) {
priv->regs = pci_iomap(pdev, 2, 0x10000);
if (priv->regs == NULL) {
printk(KERN_ERR "%s: Cannot map device registers\n",
wiphy_name(hw->wiphy));
goto err_iounmap;
}
}

memcpy(priv->channels, mwl8k_channels, sizeof(mwl8k_channels));
priv->band.band = IEEE80211_BAND_2GHZ;
priv->band.channels = priv->channels;
Expand Down Expand Up @@ -3165,6 +3180,9 @@ static int __devinit mwl8k_probe(struct pci_dev *pdev,
if (priv->regs != NULL)
pci_iounmap(pdev, priv->regs);

if (priv->sram != NULL)
pci_iounmap(pdev, priv->sram);

pci_set_drvdata(pdev, NULL);
ieee80211_free_hw(hw);

Expand Down Expand Up @@ -3212,6 +3230,7 @@ static void __devexit mwl8k_remove(struct pci_dev *pdev)
pci_free_consistent(priv->pdev, 4, priv->cookie, priv->cookie_dma);

pci_iounmap(pdev, priv->regs);
pci_iounmap(pdev, priv->sram);
pci_set_drvdata(pdev, NULL);
ieee80211_free_hw(hw);
pci_release_regions(pdev);
Expand Down

0 comments on commit 5b9482d

Please sign in to comment.