1 // SPDX-License-Identifier: ISC
3 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
4 * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
9 void mt76x2_mac_stop(struct mt76x02_dev
*dev
, bool force
)
15 mt76_clear(dev
, MT_TXOP_CTRL_CFG
, MT_TXOP_ED_CCA_EN
);
16 mt76_clear(dev
, MT_TXOP_HLDR_ET
, MT_TXOP_HLDR_TX40M_BLK_EN
);
18 mt76_wr(dev
, MT_MAC_SYS_CTRL
, 0);
20 rts_cfg
= mt76_rr(dev
, MT_TX_RTS_CFG
);
21 mt76_wr(dev
, MT_TX_RTS_CFG
, rts_cfg
& ~MT_TX_RTS_CFG_RETRY_LIMIT
);
23 /* Wait for MAC to become idle */
24 for (i
= 0; i
< 300; i
++) {
25 if ((mt76_rr(dev
, MT_MAC_STATUS
) &
26 (MT_MAC_STATUS_RX
| MT_MAC_STATUS_TX
)) ||
27 mt76_rr(dev
, MT_BBP(IBI
, 12))) {
36 if (force
&& !stopped
) {
37 mt76_set(dev
, MT_BBP(CORE
, 4), BIT(1));
38 mt76_clear(dev
, MT_BBP(CORE
, 4), BIT(1));
40 mt76_set(dev
, MT_BBP(CORE
, 4), BIT(0));
41 mt76_clear(dev
, MT_BBP(CORE
, 4), BIT(0));
44 mt76_wr(dev
, MT_TX_RTS_CFG
, rts_cfg
);
46 EXPORT_SYMBOL_GPL(mt76x2_mac_stop
);