SAMA5D4 Xplained Ultra Board BSP
guowenxue
2019-08-19 2e7235d10c6dbff81960282e1a1e2e798f9b8db8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
 *
 * 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.
 */
 
#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;
}