Commit 0f941777 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by John W. Linville

b43: add helper waiting for given value in radio reg

Signed-off-by: default avatarRafał Miłecki <zajec5@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 6e6a2cd5
...@@ -240,6 +240,21 @@ void b43_radio_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set) ...@@ -240,6 +240,21 @@ void b43_radio_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set)
(b43_radio_read16(dev, offset) & mask) | set); (b43_radio_read16(dev, offset) & mask) | set);
} }
bool b43_radio_wait_value(struct b43_wldev *dev, u16 offset, u16 mask,
u16 value, int delay, int timeout)
{
u16 val;
int i;
for (i = 0; i < timeout; i += delay) {
val = b43_radio_read(dev, offset);
if ((val & mask) == value)
return true;
udelay(delay);
}
return false;
}
u16 b43_phy_read(struct b43_wldev *dev, u16 reg) u16 b43_phy_read(struct b43_wldev *dev, u16 reg)
{ {
assert_mac_suspended(dev); assert_mac_suspended(dev);
......
...@@ -364,6 +364,12 @@ void b43_radio_set(struct b43_wldev *dev, u16 offset, u16 set); ...@@ -364,6 +364,12 @@ void b43_radio_set(struct b43_wldev *dev, u16 offset, u16 set);
*/ */
void b43_radio_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set); void b43_radio_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set);
/**
* b43_radio_wait_value - Waits for a given value in masked register read
*/
bool b43_radio_wait_value(struct b43_wldev *dev, u16 offset, u16 mask,
u16 value, int delay, int timeout);
/** /**
* b43_radio_lock - Lock firmware radio register access * b43_radio_lock - Lock firmware radio register access
*/ */
......
...@@ -753,8 +753,6 @@ static void b43_radio_init2055_post(struct b43_wldev *dev) ...@@ -753,8 +753,6 @@ static void b43_radio_init2055_post(struct b43_wldev *dev)
{ {
struct b43_phy_n *nphy = dev->phy.n; struct b43_phy_n *nphy = dev->phy.n;
struct ssb_sprom *sprom = dev->dev->bus_sprom; struct ssb_sprom *sprom = dev->dev->bus_sprom;
int i;
u16 val;
bool workaround = false; bool workaround = false;
if (sprom->revision < 4) if (sprom->revision < 4)
...@@ -777,15 +775,7 @@ static void b43_radio_init2055_post(struct b43_wldev *dev) ...@@ -777,15 +775,7 @@ static void b43_radio_init2055_post(struct b43_wldev *dev)
b43_radio_set(dev, B2055_CAL_MISC, 0x1); b43_radio_set(dev, B2055_CAL_MISC, 0x1);
msleep(1); msleep(1);
b43_radio_set(dev, B2055_CAL_MISC, 0x40); b43_radio_set(dev, B2055_CAL_MISC, 0x40);
for (i = 0; i < 200; i++) { if (!b43_radio_wait_value(dev, B2055_CAL_COUT2, 0x80, 0x80, 10, 2000))
val = b43_radio_read(dev, B2055_CAL_COUT2);
if (val & 0x80) {
i = 0;
break;
}
udelay(10);
}
if (i)
b43err(dev->wl, "radio post init timeout\n"); b43err(dev->wl, "radio post init timeout\n");
b43_radio_mask(dev, B2055_CAL_LPOCTL, 0xFF7F); b43_radio_mask(dev, B2055_CAL_LPOCTL, 0xFF7F);
b43_switch_channel(dev, dev->phy.channel); b43_switch_channel(dev, dev->phy.channel);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment