brintos

brintos / linux-shallow public Read only

0
0
Text · 1.2 KiB · 907443b Raw
71 lines · c
1// SPDX-License-Identifier: GPL-2.0-only2/*3 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>4 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>5 */6 7#include "mt7601u.h"8 9int mt7601u_wait_asic_ready(struct mt7601u_dev *dev)10{11	int i = 100;12	u32 val;13 14	do {15		if (test_bit(MT7601U_STATE_REMOVED, &dev->state))16			return -EIO;17 18		val = mt7601u_rr(dev, MT_MAC_CSR0);19		if (val && ~val)20			return 0;21 22		udelay(10);23	} while (i--);24 25	return -EIO;26}27 28bool mt76_poll(struct mt7601u_dev *dev, u32 offset, u32 mask, u32 val,29	       int timeout)30{31	u32 cur;32 33	timeout /= 10;34	do {35		if (test_bit(MT7601U_STATE_REMOVED, &dev->state))36			return false;37 38		cur = mt7601u_rr(dev, offset) & mask;39		if (cur == val)40			return true;41 42		udelay(10);43	} while (timeout-- > 0);44 45	dev_err(dev->dev, "Error: Time out with reg %08x\n", offset);46 47	return false;48}49 50bool mt76_poll_msec(struct mt7601u_dev *dev, u32 offset, u32 mask, u32 val,51		    int timeout)52{53	u32 cur;54 55	timeout /= 10;56	do {57		if (test_bit(MT7601U_STATE_REMOVED, &dev->state))58			return false;59 60		cur = mt7601u_rr(dev, offset) & mask;61		if (cur == val)62			return true;63 64		msleep(10);65	} while (timeout-- > 0);66 67	dev_err(dev->dev, "Error: Time out with reg %08x\n", offset);68 69	return false;70}71