diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2018-09-28 14:38:44 +0300 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2018-10-01 13:34:17 +0300 |
commit | 5b394355927e6b633a7cd0307f0c8056a5db182b (patch) | |
tree | 33116ce5e4c8fffc6592d591edce15b7e9452b04 /drivers/net/wireless/mediatek/mt76/mt76x0/init.c | |
parent | 62e04f8a31fcc375c978b7f83b4229a10c3e746d (diff) | |
download | linux-5b394355927e6b633a7cd0307f0c8056a5db182b.tar.xz |
mt76x0: use mt76_poll in mt76x0_set_wlan_state
Use mt76_poll utility routine in mt76x0_set_wlan_state to check
if the PLL/XTAL is ready
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt76x0/init.c')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c index 3a88be267daf..5e3ec1bef144 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c @@ -43,7 +43,7 @@ static void mt76x0_vht_cap_mask(struct ieee80211_supported_band *sband) static void mt76x0_set_wlan_state(struct mt76x0_dev *dev, u32 val, bool enable) { - int i; + u32 mask = MT_CMB_CTRL_XTAL_RDY | MT_CMB_CTRL_PLL_LD; /* Note: we don't turn off WLAN_CLK because that makes the device * not respond properly on the probe path. @@ -60,24 +60,12 @@ mt76x0_set_wlan_state(struct mt76x0_dev *dev, u32 val, bool enable) mt76_wr(dev, MT_WLAN_FUN_CTRL, val); udelay(20); - if (!enable) - return; - - for (i = 200; i; i--) { - val = mt76_rr(dev, MT_CMB_CTRL); - - if (val & MT_CMB_CTRL_XTAL_RDY && val & MT_CMB_CTRL_PLL_LD) - break; - - udelay(20); - } - /* Note: vendor driver tries to disable/enable wlan here and retry * but the code which does it is so buggy it must have never * triggered, so don't bother. */ - if (!i) - dev_err(dev->mt76.dev, "Error: PLL and XTAL check failed!\n"); + if (enable && !mt76_poll(dev, MT_CMB_CTRL, mask, mask, 2000)) + dev_err(dev->mt76.dev, "PLL and XTAL check failed\n"); } void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset) |