1802d0beec
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 655 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
71 lines
1.2 KiB
C
71 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
|
|
* Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
|
|
*/
|
|
|
|
#include "mt7601u.h"
|
|
|
|
int mt7601u_wait_asic_ready(struct mt7601u_dev *dev)
|
|
{
|
|
int i = 100;
|
|
u32 val;
|
|
|
|
do {
|
|
if (test_bit(MT7601U_STATE_REMOVED, &dev->state))
|
|
return -EIO;
|
|
|
|
val = mt7601u_rr(dev, MT_MAC_CSR0);
|
|
if (val && ~val)
|
|
return 0;
|
|
|
|
udelay(10);
|
|
} while (i--);
|
|
|
|
return -EIO;
|
|
}
|
|
|
|
bool mt76_poll(struct mt7601u_dev *dev, u32 offset, u32 mask, u32 val,
|
|
int timeout)
|
|
{
|
|
u32 cur;
|
|
|
|
timeout /= 10;
|
|
do {
|
|
if (test_bit(MT7601U_STATE_REMOVED, &dev->state))
|
|
return false;
|
|
|
|
cur = mt7601u_rr(dev, offset) & mask;
|
|
if (cur == val)
|
|
return true;
|
|
|
|
udelay(10);
|
|
} while (timeout-- > 0);
|
|
|
|
dev_err(dev->dev, "Error: Time out with reg %08x\n", offset);
|
|
|
|
return false;
|
|
}
|
|
|
|
bool mt76_poll_msec(struct mt7601u_dev *dev, u32 offset, u32 mask, u32 val,
|
|
int timeout)
|
|
{
|
|
u32 cur;
|
|
|
|
timeout /= 10;
|
|
do {
|
|
if (test_bit(MT7601U_STATE_REMOVED, &dev->state))
|
|
return false;
|
|
|
|
cur = mt7601u_rr(dev, offset) & mask;
|
|
if (cur == val)
|
|
return true;
|
|
|
|
msleep(10);
|
|
} while (timeout-- > 0);
|
|
|
|
dev_err(dev->dev, "Error: Time out with reg %08x\n", offset);
|
|
|
|
return false;
|
|
}
|