1 /*
2  * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
3  * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2
7  * as published by the Free Software Foundation
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14 
15 #include "mt76x0.h"
16 
mt76x0_wait_asic_ready(struct mt76x0_dev * dev)17 int mt76x0_wait_asic_ready(struct mt76x0_dev *dev)
18 {
19 	int i = 100;
20 	u32 val;
21 
22 	do {
23 		if (test_bit(MT76_REMOVED, &dev->mt76.state))
24 			return -EIO;
25 
26 		val = mt76_rr(dev, MT_MAC_CSR0);
27 		if (val && ~val)
28 			return 0;
29 
30 		udelay(10);
31 	} while (i--);
32 
33 	return -EIO;
34 }
35