From: Daniel Golle Date: Wed, 13 Feb 2019 18:47:18 +0000 (+0100) Subject: mac80211: rt2x00: backport accepted and pending patches from upstream X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d4c999bb891725b71ae38416cc6d5cfa99938ae4;p=openwrt%2Fstaging%2Fnoltari.git mac80211: rt2x00: backport accepted and pending patches from upstream backport from wireless-drivers-next, replacing some existing patches in our tree (marked with '=' are those which were already present): f483039cf51a rt2x00: use simple_read_from_buffer() =5c656c71b1bf rt2800: move usb specific txdone/txstatus routines to rt2800lib =0b0d556e0ebb rt2800mmio: use txdone/txstatus routines from lib =5022efb50f62 rt2x00: do not check for txstatus timeout every time on tasklet =adf26a356f13 rt2x00: use different txstatus timeouts when flushing =0240564430c0 rt2800: flush and txstatus rework for rt2800mmio 6eba8fd22352 rt2x00: rt2400pci: mark expected switch fall-through 10bb92217747 rt2x00: rt2500pci: mark expected switch fall-through 916e6bbcfcff rt2x00: rt2800lib: mark expected switch fall-throughs 641dd8068ecb rt2x00: rt61pci: mark expected switch fall-through 750afb08ca71 cross-tree: phase out dma_zalloc_coherent() =c2e28ef7711f rt2x00: reduce tx power to nominal level on RT6352 a4296994eb80 rt2x00: Work around a firmware bug with shared keys 2587791d5758 rt2x00: no need to check return value of debugfs_create functions pending on linux-wireless: rt2x00: remove unneeded check rt2x00: remove confusing AGC register rt2800: enable TX_PIN_CFG_LNA_PE_ bits per band rt2800: enable TX_PIN_CFG_RFRX_EN only for MT7620 rt2800: comment and simplify AGC init for RT6352 rt2x00: do not print error when queue is full rt2800: partially restore old mmio txstatus behaviour rt2800: new flush implementation for SoC devices rt2800: move txstatus pending routine rt2800mmio: fetch tx status changes rt2800mmio: use timer and work for handling tx statuses timeouts rt2x00: remove last_nostatus_check rt2x00: remove not used entry field rt2x00mmio: remove legacy comment While at it also rename some existing patches now that there are separate folders with patches for each driver to make things a bit nicer to handle. Signed-off-by: Daniel Golle --- diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile index a13ef41193..d10db7c06c 100644 --- a/package/kernel/mac80211/Makefile +++ b/package/kernel/mac80211/Makefile @@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mac80211 PKG_VERSION:=4.19.23-1 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v4.19.23/ PKG_HASH:=703e940b542eb56067fcd847a7c69398dcc9829f34472647eea4211cb2ab3b83 diff --git a/package/kernel/mac80211/patches/rt2x00/001-rt2x00-use-simple_read_from_buffer.patch b/package/kernel/mac80211/patches/rt2x00/001-rt2x00-use-simple_read_from_buffer.patch new file mode 100644 index 0000000000..1319cc244c --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/001-rt2x00-use-simple_read_from_buffer.patch @@ -0,0 +1,59 @@ +From f483039cf51acf30494cd754194562c22cf98764 Mon Sep 17 00:00:00 2001 +From: Dan Carpenter +Date: Wed, 22 Aug 2018 13:41:26 +0300 +Subject: [PATCH 01/28] rt2x00: use simple_read_from_buffer() + +The problem with this copy_to_user() calls is that they don't ensure +that "size" is less than the "length" which the user provided. + +Obviously, this is debugfs and "size" is normally going to be very small +so it probably doesn't matter, but this is the correct thing to do. + +Signed-off-by: Dan Carpenter +Acked-by: Stanislaw Gruszka +Signed-off-by: Kalle Valo +--- + .../net/wireless/ralink/rt2x00/rt2x00debug.c | 18 +++--------------- + 1 file changed, 3 insertions(+), 15 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c +@@ -464,11 +464,7 @@ static ssize_t rt2x00debug_read_##__name + \ + size = sprintf(line, __format, value); \ + \ +- if (copy_to_user(buf, line, size)) \ +- return -EFAULT; \ +- \ +- *offset += size; \ +- return size; \ ++ return simple_read_from_buffer(buf, length, offset, line, size); \ + } + + #define RT2X00DEBUGFS_OPS_WRITE(__name, __type) \ +@@ -545,11 +541,7 @@ static ssize_t rt2x00debug_read_dev_flag + + size = sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->flags); + +- if (copy_to_user(buf, line, size)) +- return -EFAULT; +- +- *offset += size; +- return size; ++ return simple_read_from_buffer(buf, length, offset, line, size); + } + + static const struct file_operations rt2x00debug_fop_dev_flags = { +@@ -574,11 +566,7 @@ static ssize_t rt2x00debug_read_cap_flag + + size = sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->cap_flags); + +- if (copy_to_user(buf, line, size)) +- return -EFAULT; +- +- *offset += size; +- return size; ++ return simple_read_from_buffer(buf, length, offset, line, size); + } + + static const struct file_operations rt2x00debug_fop_cap_flags = { diff --git a/package/kernel/mac80211/patches/rt2x00/002-rt2800-move-usb-specific-txdone-txstatus-routines-to.patch b/package/kernel/mac80211/patches/rt2x00/002-rt2800-move-usb-specific-txdone-txstatus-routines-to.patch new file mode 100644 index 0000000000..a883258a4c --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/002-rt2800-move-usb-specific-txdone-txstatus-routines-to.patch @@ -0,0 +1,357 @@ +From 5c656c71b1bf5611ce8262bab338104e04d10b8d Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Wed, 26 Sep 2018 12:24:53 +0200 +Subject: [PATCH 02/28] rt2800: move usb specific txdone/txstatus routines to + rt2800lib + +In order to reuse usb txdone/txstatus routines for mmio, move them +to common rt2800lib.c file. + +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Kalle Valo +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 138 +++++++++++++++++ + .../net/wireless/ralink/rt2x00/rt2800lib.h | 3 + + .../net/wireless/ralink/rt2x00/rt2800usb.c | 143 +----------------- + 3 files changed, 145 insertions(+), 139 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -957,6 +957,47 @@ static void rt2800_rate_from_status(stru + skbdesc->tx_rate_flags = flags; + } + ++static bool rt2800_txdone_entry_check(struct queue_entry *entry, u32 reg) ++{ ++ __le32 *txwi; ++ u32 word; ++ int wcid, ack, pid; ++ int tx_wcid, tx_ack, tx_pid, is_agg; ++ ++ /* ++ * This frames has returned with an IO error, ++ * so the status report is not intended for this ++ * frame. ++ */ ++ if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) ++ return false; ++ ++ wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID); ++ ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED); ++ pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE); ++ is_agg = rt2x00_get_field32(reg, TX_STA_FIFO_TX_AGGRE); ++ ++ /* ++ * Validate if this TX status report is intended for ++ * this entry by comparing the WCID/ACK/PID fields. ++ */ ++ txwi = rt2800_drv_get_txwi(entry); ++ ++ word = rt2x00_desc_read(txwi, 1); ++ tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID); ++ tx_ack = rt2x00_get_field32(word, TXWI_W1_ACK); ++ tx_pid = rt2x00_get_field32(word, TXWI_W1_PACKETID); ++ ++ if (wcid != tx_wcid || ack != tx_ack || (!is_agg && pid != tx_pid)) { ++ rt2x00_dbg(entry->queue->rt2x00dev, ++ "TX status report missed for queue %d entry %d\n", ++ entry->queue->qid, entry->entry_idx); ++ return false; ++ } ++ ++ return true; ++} ++ + void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi, + bool match) + { +@@ -1059,6 +1100,103 @@ void rt2800_txdone_entry(struct queue_en + } + EXPORT_SYMBOL_GPL(rt2800_txdone_entry); + ++void rt2800_txdone(struct rt2x00_dev *rt2x00dev) ++{ ++ struct data_queue *queue; ++ struct queue_entry *entry; ++ u32 reg; ++ u8 qid; ++ bool match; ++ ++ while (kfifo_get(&rt2x00dev->txstatus_fifo, ®)) { ++ /* ++ * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is ++ * guaranteed to be one of the TX QIDs . ++ */ ++ qid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_QUEUE); ++ queue = rt2x00queue_get_tx_queue(rt2x00dev, qid); ++ ++ if (unlikely(rt2x00queue_empty(queue))) { ++ rt2x00_dbg(rt2x00dev, "Got TX status for an empty queue %u, dropping\n", ++ qid); ++ break; ++ } ++ ++ entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); ++ ++ if (unlikely(test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || ++ !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))) { ++ rt2x00_warn(rt2x00dev, "Data pending for entry %u in queue %u\n", ++ entry->entry_idx, qid); ++ break; ++ } ++ ++ match = rt2800_txdone_entry_check(entry, reg); ++ rt2800_txdone_entry(entry, reg, rt2800_drv_get_txwi(entry), match); ++ } ++} ++EXPORT_SYMBOL_GPL(rt2800_txdone); ++ ++static inline bool rt2800_entry_txstatus_timeout(struct queue_entry *entry) ++{ ++ bool tout; ++ ++ if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) ++ return false; ++ ++ tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500)); ++ if (unlikely(tout)) ++ rt2x00_dbg(entry->queue->rt2x00dev, ++ "TX status timeout for entry %d in queue %d\n", ++ entry->entry_idx, entry->queue->qid); ++ return tout; ++ ++} ++ ++bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev) ++{ ++ struct data_queue *queue; ++ struct queue_entry *entry; ++ ++ tx_queue_for_each(rt2x00dev, queue) { ++ entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); ++ if (rt2800_entry_txstatus_timeout(entry)) ++ return true; ++ } ++ return false; ++} ++EXPORT_SYMBOL_GPL(rt2800_txstatus_timeout); ++ ++void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev) ++{ ++ struct data_queue *queue; ++ struct queue_entry *entry; ++ ++ /* ++ * Process any trailing TX status reports for IO failures, ++ * we loop until we find the first non-IO error entry. This ++ * can either be a frame which is free, is being uploaded, ++ * or has completed the upload but didn't have an entry ++ * in the TX_STAT_FIFO register yet. ++ */ ++ tx_queue_for_each(rt2x00dev, queue) { ++ while (!rt2x00queue_empty(queue)) { ++ entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); ++ ++ if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || ++ !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) ++ break; ++ ++ if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) || ++ rt2800_entry_txstatus_timeout(entry)) ++ rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE); ++ else ++ break; ++ } ++ } ++} ++EXPORT_SYMBOL_GPL(rt2800_txdone_nostatus); ++ + static unsigned int rt2800_hw_beacon_base(struct rt2x00_dev *rt2x00dev, + unsigned int index) + { +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +@@ -195,6 +195,9 @@ void rt2800_process_rxwi(struct queue_en + + void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi, + bool match); ++void rt2800_txdone(struct rt2x00_dev *rt2x00dev); ++void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev); ++bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev); + + void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc); + void rt2800_clear_beacon(struct queue_entry *entry); +--- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c +@@ -116,35 +116,6 @@ static bool rt2800usb_txstatus_pending(s + return false; + } + +-static inline bool rt2800usb_entry_txstatus_timeout(struct queue_entry *entry) +-{ +- bool tout; +- +- if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) +- return false; +- +- tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500)); +- if (unlikely(tout)) +- rt2x00_dbg(entry->queue->rt2x00dev, +- "TX status timeout for entry %d in queue %d\n", +- entry->entry_idx, entry->queue->qid); +- return tout; +- +-} +- +-static bool rt2800usb_txstatus_timeout(struct rt2x00_dev *rt2x00dev) +-{ +- struct data_queue *queue; +- struct queue_entry *entry; +- +- tx_queue_for_each(rt2x00dev, queue) { +- entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); +- if (rt2800usb_entry_txstatus_timeout(entry)) +- return true; +- } +- return false; +-} +- + #define TXSTATUS_READ_INTERVAL 1000000 + + static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev, +@@ -171,7 +142,7 @@ static bool rt2800usb_tx_sta_fifo_read_c + } + + /* Check if there is any entry that timedout waiting on TX status */ +- if (rt2800usb_txstatus_timeout(rt2x00dev)) ++ if (rt2800_txstatus_timeout(rt2x00dev)) + queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work); + + if (rt2800usb_txstatus_pending(rt2x00dev)) { +@@ -501,123 +472,17 @@ static int rt2800usb_get_tx_data_len(str + /* + * TX control handlers + */ +-static bool rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg) +-{ +- __le32 *txwi; +- u32 word; +- int wcid, ack, pid; +- int tx_wcid, tx_ack, tx_pid, is_agg; +- +- /* +- * This frames has returned with an IO error, +- * so the status report is not intended for this +- * frame. +- */ +- if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) +- return false; +- +- wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID); +- ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED); +- pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE); +- is_agg = rt2x00_get_field32(reg, TX_STA_FIFO_TX_AGGRE); +- +- /* +- * Validate if this TX status report is intended for +- * this entry by comparing the WCID/ACK/PID fields. +- */ +- txwi = rt2800usb_get_txwi(entry); +- +- word = rt2x00_desc_read(txwi, 1); +- tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID); +- tx_ack = rt2x00_get_field32(word, TXWI_W1_ACK); +- tx_pid = rt2x00_get_field32(word, TXWI_W1_PACKETID); +- +- if (wcid != tx_wcid || ack != tx_ack || (!is_agg && pid != tx_pid)) { +- rt2x00_dbg(entry->queue->rt2x00dev, +- "TX status report missed for queue %d entry %d\n", +- entry->queue->qid, entry->entry_idx); +- return false; +- } +- +- return true; +-} +- +-static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev) +-{ +- struct data_queue *queue; +- struct queue_entry *entry; +- u32 reg; +- u8 qid; +- bool match; +- +- while (kfifo_get(&rt2x00dev->txstatus_fifo, ®)) { +- /* +- * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is +- * guaranteed to be one of the TX QIDs . +- */ +- qid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_QUEUE); +- queue = rt2x00queue_get_tx_queue(rt2x00dev, qid); +- +- if (unlikely(rt2x00queue_empty(queue))) { +- rt2x00_dbg(rt2x00dev, "Got TX status for an empty queue %u, dropping\n", +- qid); +- break; +- } +- +- entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); +- +- if (unlikely(test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || +- !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))) { +- rt2x00_warn(rt2x00dev, "Data pending for entry %u in queue %u\n", +- entry->entry_idx, qid); +- break; +- } +- +- match = rt2800usb_txdone_entry_check(entry, reg); +- rt2800_txdone_entry(entry, reg, rt2800usb_get_txwi(entry), match); +- } +-} +- +-static void rt2800usb_txdone_nostatus(struct rt2x00_dev *rt2x00dev) +-{ +- struct data_queue *queue; +- struct queue_entry *entry; +- +- /* +- * Process any trailing TX status reports for IO failures, +- * we loop until we find the first non-IO error entry. This +- * can either be a frame which is free, is being uploaded, +- * or has completed the upload but didn't have an entry +- * in the TX_STAT_FIFO register yet. +- */ +- tx_queue_for_each(rt2x00dev, queue) { +- while (!rt2x00queue_empty(queue)) { +- entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); +- +- if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || +- !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) +- break; +- +- if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) || +- rt2800usb_entry_txstatus_timeout(entry)) +- rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE); +- else +- break; +- } +- } +-} +- + static void rt2800usb_work_txdone(struct work_struct *work) + { + struct rt2x00_dev *rt2x00dev = + container_of(work, struct rt2x00_dev, txdone_work); + + while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) || +- rt2800usb_txstatus_timeout(rt2x00dev)) { ++ rt2800_txstatus_timeout(rt2x00dev)) { + +- rt2800usb_txdone(rt2x00dev); ++ rt2800_txdone(rt2x00dev); + +- rt2800usb_txdone_nostatus(rt2x00dev); ++ rt2800_txdone_nostatus(rt2x00dev); + + /* + * The hw may delay sending the packet after DMA complete diff --git a/package/kernel/mac80211/patches/rt2x00/003-rt2800mmio-use-txdone-txstatus-routines-from-lib.patch b/package/kernel/mac80211/patches/rt2x00/003-rt2800mmio-use-txdone-txstatus-routines-from-lib.patch new file mode 100644 index 0000000000..48f0c27011 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/003-rt2800mmio-use-txdone-txstatus-routines-from-lib.patch @@ -0,0 +1,244 @@ +From 0b0d556e0ebb6c966bc993e21a22a156812d8fdf Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Wed, 26 Sep 2018 12:24:54 +0200 +Subject: [PATCH 03/28] rt2800mmio: use txdone/txstatus routines from lib + +Use usb txdone/txstatus routines (now in rt2800libc) for mmio devices. + +Note this also change how we handle INT_SOURCE_CSR_TX_FIFO_STATUS +interrupt. Now it is disabled since IRQ routine till end of the txstatus +tasklet (the same behaviour like others interrupts). Reason to do not +disable this interrupt was not to miss any tx status from 16 entries +FIFO register. Now, since we check for tx status timeout, we can +allow to miss some tx statuses. However this will be improved in further +patch where I also implement read status FIFO register in the tasklet. + +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Kalle Valo +--- + .../net/wireless/ralink/rt2x00/rt2800mmio.c | 180 +----------------- + .../net/wireless/ralink/rt2x00/rt2x00queue.c | 1 + + 2 files changed, 9 insertions(+), 172 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c +@@ -175,161 +175,6 @@ static void rt2800mmio_wakeup(struct rt2 + rt2800_config(rt2x00dev, &libconf, IEEE80211_CONF_CHANGE_PS); + } + +-static bool rt2800mmio_txdone_entry_check(struct queue_entry *entry, u32 status) +-{ +- __le32 *txwi; +- u32 word; +- int wcid, tx_wcid; +- +- wcid = rt2x00_get_field32(status, TX_STA_FIFO_WCID); +- +- txwi = rt2800_drv_get_txwi(entry); +- word = rt2x00_desc_read(txwi, 1); +- tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID); +- +- return (tx_wcid == wcid); +-} +- +-static bool rt2800mmio_txdone_find_entry(struct queue_entry *entry, void *data) +-{ +- u32 status = *(u32 *)data; +- +- /* +- * rt2800pci hardware might reorder frames when exchanging traffic +- * with multiple BA enabled STAs. +- * +- * For example, a tx queue +- * [ STA1 | STA2 | STA1 | STA2 ] +- * can result in tx status reports +- * [ STA1 | STA1 | STA2 | STA2 ] +- * when the hw decides to aggregate the frames for STA1 into one AMPDU. +- * +- * To mitigate this effect, associate the tx status to the first frame +- * in the tx queue with a matching wcid. +- */ +- if (rt2800mmio_txdone_entry_check(entry, status) && +- !test_bit(ENTRY_DATA_STATUS_SET, &entry->flags)) { +- /* +- * Got a matching frame, associate the tx status with +- * the frame +- */ +- entry->status = status; +- set_bit(ENTRY_DATA_STATUS_SET, &entry->flags); +- return true; +- } +- +- /* Check the next frame */ +- return false; +-} +- +-static bool rt2800mmio_txdone_match_first(struct queue_entry *entry, void *data) +-{ +- u32 status = *(u32 *)data; +- +- /* +- * Find the first frame without tx status and assign this status to it +- * regardless if it matches or not. +- */ +- if (!test_bit(ENTRY_DATA_STATUS_SET, &entry->flags)) { +- /* +- * Got a matching frame, associate the tx status with +- * the frame +- */ +- entry->status = status; +- set_bit(ENTRY_DATA_STATUS_SET, &entry->flags); +- return true; +- } +- +- /* Check the next frame */ +- return false; +-} +-static bool rt2800mmio_txdone_release_entries(struct queue_entry *entry, +- void *data) +-{ +- if (test_bit(ENTRY_DATA_STATUS_SET, &entry->flags)) { +- rt2800_txdone_entry(entry, entry->status, +- rt2800mmio_get_txwi(entry), true); +- return false; +- } +- +- /* No more frames to release */ +- return true; +-} +- +-static bool rt2800mmio_txdone(struct rt2x00_dev *rt2x00dev) +-{ +- struct data_queue *queue; +- u32 status; +- u8 qid; +- int max_tx_done = 16; +- +- while (kfifo_get(&rt2x00dev->txstatus_fifo, &status)) { +- qid = rt2x00_get_field32(status, TX_STA_FIFO_PID_QUEUE); +- if (unlikely(qid >= QID_RX)) { +- /* +- * Unknown queue, this shouldn't happen. Just drop +- * this tx status. +- */ +- rt2x00_warn(rt2x00dev, "Got TX status report with unexpected pid %u, dropping\n", +- qid); +- break; +- } +- +- queue = rt2x00queue_get_tx_queue(rt2x00dev, qid); +- if (unlikely(queue == NULL)) { +- /* +- * The queue is NULL, this shouldn't happen. Stop +- * processing here and drop the tx status +- */ +- rt2x00_warn(rt2x00dev, "Got TX status for an unavailable queue %u, dropping\n", +- qid); +- break; +- } +- +- if (unlikely(rt2x00queue_empty(queue))) { +- /* +- * The queue is empty. Stop processing here +- * and drop the tx status. +- */ +- rt2x00_warn(rt2x00dev, "Got TX status for an empty queue %u, dropping\n", +- qid); +- break; +- } +- +- /* +- * Let's associate this tx status with the first +- * matching frame. +- */ +- if (!rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, +- Q_INDEX, &status, +- rt2800mmio_txdone_find_entry)) { +- /* +- * We cannot match the tx status to any frame, so just +- * use the first one. +- */ +- if (!rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, +- Q_INDEX, &status, +- rt2800mmio_txdone_match_first)) { +- rt2x00_warn(rt2x00dev, "No frame found for TX status on queue %u, dropping\n", +- qid); +- break; +- } +- } +- +- /* +- * Release all frames with a valid tx status. +- */ +- rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, +- Q_INDEX, NULL, +- rt2800mmio_txdone_release_entries); +- +- if (--max_tx_done == 0) +- break; +- } +- +- return !max_tx_done; +-} +- + static inline void rt2800mmio_enable_interrupt(struct rt2x00_dev *rt2x00dev, + struct rt2x00_field32 irq_field) + { +@@ -349,14 +194,14 @@ static inline void rt2800mmio_enable_int + void rt2800mmio_txstatus_tasklet(unsigned long data) + { + struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; +- if (rt2800mmio_txdone(rt2x00dev)) +- tasklet_schedule(&rt2x00dev->txstatus_tasklet); + +- /* +- * No need to enable the tx status interrupt here as we always +- * leave it enabled to minimize the possibility of a tx status +- * register overflow. See comment in interrupt handler. +- */ ++ rt2800_txdone(rt2x00dev); ++ ++ rt2800_txdone_nostatus(rt2x00dev); ++ ++ if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) ++ rt2800mmio_enable_interrupt(rt2x00dev, ++ INT_SOURCE_CSR_TX_FIFO_STATUS); + } + EXPORT_SYMBOL_GPL(rt2800mmio_txstatus_tasklet); + +@@ -440,10 +285,6 @@ static void rt2800mmio_txstatus_interrup + * because we can schedule the tasklet multiple times (when the + * interrupt fires again during tx status processing). + * +- * Furthermore we don't disable the TX_FIFO_STATUS +- * interrupt here but leave it enabled so that the TX_STA_FIFO +- * can also be read while the tx status tasklet gets executed. +- * + * Since we have only one producer and one consumer we don't + * need to lock the kfifo. + */ +@@ -485,13 +326,8 @@ irqreturn_t rt2800mmio_interrupt(int irq + */ + mask = ~reg; + +- if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) { ++ if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) + rt2800mmio_txstatus_interrupt(rt2x00dev); +- /* +- * Never disable the TX_FIFO_STATUS interrupt. +- */ +- rt2x00_set_field32(&mask, INT_MASK_CSR_TX_FIFO_STATUS, 1); +- } + + if (rt2x00_get_field32(reg, INT_SOURCE_CSR_PRE_TBTT)) + tasklet_hi_schedule(&rt2x00dev->pretbtt_tasklet); +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c +@@ -113,6 +113,7 @@ int rt2x00queue_map_txskb(struct queue_e + return -ENOMEM; + + skbdesc->flags |= SKBDESC_DMA_MAPPED_TX; ++ rt2x00lib_dmadone(entry); + return 0; + } + EXPORT_SYMBOL_GPL(rt2x00queue_map_txskb); diff --git a/package/kernel/mac80211/patches/rt2x00/004-rt2x00-do-not-check-for-txstatus-timeout-every-time-.patch b/package/kernel/mac80211/patches/rt2x00/004-rt2x00-do-not-check-for-txstatus-timeout-every-time-.patch new file mode 100644 index 0000000000..832768d042 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/004-rt2x00-do-not-check-for-txstatus-timeout-every-time-.patch @@ -0,0 +1,72 @@ +From 5022efb50f625d11fdf18b1fee0f64ebb1863664 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Wed, 26 Sep 2018 12:24:55 +0200 +Subject: [PATCH 04/28] rt2x00: do not check for txstatus timeout every time on + tasklet + +Do not check for tx status timeout everytime we perform txstatus tasklet. +Perform check once per half a second. + +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 7 +++++++ + drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 3 ++- + drivers/net/wireless/ralink/rt2x00/rt2x00.h | 2 ++ + drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 1 + + 4 files changed, 12 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -1158,11 +1158,18 @@ bool rt2800_txstatus_timeout(struct rt2x + struct data_queue *queue; + struct queue_entry *entry; + ++ if (time_before(jiffies, ++ rt2x00dev->last_nostatus_check + msecs_to_jiffies(500))) ++ return false; ++ ++ rt2x00dev->last_nostatus_check = jiffies; ++ + tx_queue_for_each(rt2x00dev, queue) { + entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); + if (rt2800_entry_txstatus_timeout(entry)) + return true; + } ++ + return false; + } + EXPORT_SYMBOL_GPL(rt2800_txstatus_timeout); +--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c +@@ -197,7 +197,8 @@ void rt2800mmio_txstatus_tasklet(unsigne + + rt2800_txdone(rt2x00dev); + +- rt2800_txdone_nostatus(rt2x00dev); ++ if (rt2800_txstatus_timeout(rt2x00dev)) ++ rt2800_txdone_nostatus(rt2x00dev); + + if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) + rt2800mmio_enable_interrupt(rt2x00dev, +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -980,6 +980,8 @@ struct rt2x00_dev { + */ + DECLARE_KFIFO_PTR(txstatus_fifo, u32); + ++ unsigned long last_nostatus_check; ++ + /* + * Timer to ensure tx status reports are read (rt2800usb). + */ +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c +@@ -1039,6 +1039,7 @@ void rt2x00queue_start_queues(struct rt2 + */ + tx_queue_for_each(rt2x00dev, queue) + rt2x00queue_start_queue(queue); ++ rt2x00dev->last_nostatus_check = jiffies; + + rt2x00queue_start_queue(rt2x00dev->rx); + } diff --git a/package/kernel/mac80211/patches/rt2x00/005-rt2x00-use-different-txstatus-timeouts-when-flushing.patch b/package/kernel/mac80211/patches/rt2x00/005-rt2x00-use-different-txstatus-timeouts-when-flushing.patch new file mode 100644 index 0000000000..0f29026373 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/005-rt2x00-use-different-txstatus-timeouts-when-flushing.patch @@ -0,0 +1,112 @@ +From adf26a356f132e35093585521ea3e36cd185af83 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Wed, 26 Sep 2018 12:24:56 +0200 +Subject: [PATCH 05/28] rt2x00: use different txstatus timeouts when flushing + +Use different tx status timeouts for normal operation and when flushing. +This increase timeout to 2s for normal operation as when there are bad +radio conditions and frames are reposted many times device can not provide +the status for quite long. With new timeout we can still get valid status +on such bad conditions. + +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Kalle Valo +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 31 +++++++++++++------ + drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 + + .../net/wireless/ralink/rt2x00/rt2x00mac.c | 4 +++ + 3 files changed, 26 insertions(+), 10 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -1137,36 +1137,47 @@ void rt2800_txdone(struct rt2x00_dev *rt + } + EXPORT_SYMBOL_GPL(rt2800_txdone); + +-static inline bool rt2800_entry_txstatus_timeout(struct queue_entry *entry) ++static inline bool rt2800_entry_txstatus_timeout(struct rt2x00_dev *rt2x00dev, ++ struct queue_entry *entry) + { +- bool tout; ++ bool ret; ++ unsigned long tout; + + if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) + return false; + +- tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500)); +- if (unlikely(tout)) ++ if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) ++ tout = msecs_to_jiffies(100); ++ else ++ tout = msecs_to_jiffies(2000); ++ ++ ret = time_after(jiffies, entry->last_action + tout); ++ if (unlikely(ret)) + rt2x00_dbg(entry->queue->rt2x00dev, + "TX status timeout for entry %d in queue %d\n", + entry->entry_idx, entry->queue->qid); +- return tout; +- ++ return ret; + } + + bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev) + { + struct data_queue *queue; + struct queue_entry *entry; ++ unsigned long tout; ++ ++ if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) ++ tout = msecs_to_jiffies(50); ++ else ++ tout = msecs_to_jiffies(1000); + +- if (time_before(jiffies, +- rt2x00dev->last_nostatus_check + msecs_to_jiffies(500))) ++ if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout)) + return false; + + rt2x00dev->last_nostatus_check = jiffies; + + tx_queue_for_each(rt2x00dev, queue) { + entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); +- if (rt2800_entry_txstatus_timeout(entry)) ++ if (rt2800_entry_txstatus_timeout(rt2x00dev, entry)) + return true; + } + +@@ -1195,7 +1206,7 @@ void rt2800_txdone_nostatus(struct rt2x0 + break; + + if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) || +- rt2800_entry_txstatus_timeout(entry)) ++ rt2800_entry_txstatus_timeout(rt2x00dev, entry)) + rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE); + else + break; +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -665,6 +665,7 @@ enum rt2x00_state_flags { + DEVICE_STATE_STARTED, + DEVICE_STATE_ENABLED_RADIO, + DEVICE_STATE_SCANNING, ++ DEVICE_STATE_FLUSHING, + + /* + * Driver configuration +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c +@@ -720,8 +720,12 @@ void rt2x00mac_flush(struct ieee80211_hw + if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) + return; + ++ set_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags); ++ + tx_queue_for_each(rt2x00dev, queue) + rt2x00queue_flush_queue(queue, drop); ++ ++ clear_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags); + } + EXPORT_SYMBOL_GPL(rt2x00mac_flush); + diff --git a/package/kernel/mac80211/patches/rt2x00/006-rt2800-flush-and-txstatus-rework-for-rt2800mmio.patch b/package/kernel/mac80211/patches/rt2x00/006-rt2800-flush-and-txstatus-rework-for-rt2800mmio.patch new file mode 100644 index 0000000000..784fbb16f1 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/006-rt2800-flush-and-txstatus-rework-for-rt2800mmio.patch @@ -0,0 +1,238 @@ +From 0240564430c0697d8fde3743d70346a922466b36 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Wed, 26 Sep 2018 12:24:57 +0200 +Subject: [PATCH 06/28] rt2800: flush and txstatus rework for rt2800mmio + +Implement custom rt2800mmio flush routine and change txstatus +routine to read TX_STA_FIFO also in the tasklet. + +Signed-off-by: Stanislaw Gruszka +Signed-off-by: Kalle Valo +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 14 +-- + .../net/wireless/ralink/rt2x00/rt2800mmio.c | 118 +++++++++++++----- + .../net/wireless/ralink/rt2x00/rt2800mmio.h | 1 + + .../net/wireless/ralink/rt2x00/rt2800pci.c | 2 +- + 4 files changed, 97 insertions(+), 38 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -1147,7 +1147,7 @@ static inline bool rt2800_entry_txstatus + return false; + + if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) +- tout = msecs_to_jiffies(100); ++ tout = msecs_to_jiffies(50); + else + tout = msecs_to_jiffies(2000); + +@@ -1163,15 +1163,13 @@ bool rt2800_txstatus_timeout(struct rt2x + { + struct data_queue *queue; + struct queue_entry *entry; +- unsigned long tout; + +- if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) +- tout = msecs_to_jiffies(50); +- else +- tout = msecs_to_jiffies(1000); ++ if (!test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) { ++ unsigned long tout = msecs_to_jiffies(1000); + +- if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout)) +- return false; ++ if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout)) ++ return false; ++ } + + rt2x00dev->last_nostatus_check = jiffies; + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c +@@ -191,21 +191,6 @@ static inline void rt2800mmio_enable_int + spin_unlock_irq(&rt2x00dev->irqmask_lock); + } + +-void rt2800mmio_txstatus_tasklet(unsigned long data) +-{ +- struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; +- +- rt2800_txdone(rt2x00dev); +- +- if (rt2800_txstatus_timeout(rt2x00dev)) +- rt2800_txdone_nostatus(rt2x00dev); +- +- if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) +- rt2800mmio_enable_interrupt(rt2x00dev, +- INT_SOURCE_CSR_TX_FIFO_STATUS); +-} +-EXPORT_SYMBOL_GPL(rt2800mmio_txstatus_tasklet); +- + void rt2800mmio_pretbtt_tasklet(unsigned long data) + { + struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; +@@ -270,12 +255,26 @@ void rt2800mmio_autowake_tasklet(unsigne + } + EXPORT_SYMBOL_GPL(rt2800mmio_autowake_tasklet); + +-static void rt2800mmio_txstatus_interrupt(struct rt2x00_dev *rt2x00dev) ++static void rt2800mmio_txdone(struct rt2x00_dev *rt2x00dev) ++{ ++ bool timeout = false; ++ ++ while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) || ++ (timeout = rt2800_txstatus_timeout(rt2x00dev))) { ++ ++ rt2800_txdone(rt2x00dev); ++ ++ if (timeout) ++ rt2800_txdone_nostatus(rt2x00dev); ++ } ++} ++ ++static bool rt2800mmio_fetch_txstatus(struct rt2x00_dev *rt2x00dev) + { + u32 status; +- int i; ++ bool more = false; + +- /* ++ /* FIXEME: rewrite this comment + * The TX_FIFO_STATUS interrupt needs special care. We should + * read TX_STA_FIFO but we should do it immediately as otherwise + * the register can overflow and we would lose status reports. +@@ -286,25 +285,37 @@ static void rt2800mmio_txstatus_interrup + * because we can schedule the tasklet multiple times (when the + * interrupt fires again during tx status processing). + * +- * Since we have only one producer and one consumer we don't ++ * txstatus tasklet is called with INT_SOURCE_CSR_TX_FIFO_STATUS ++ * disabled so have only one producer and one consumer - we don't + * need to lock the kfifo. + */ +- for (i = 0; i < rt2x00dev->tx->limit; i++) { ++ while (!kfifo_is_full(&rt2x00dev->txstatus_fifo)) { + status = rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO); +- + if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID)) + break; + +- if (!kfifo_put(&rt2x00dev->txstatus_fifo, status)) { +- rt2x00_warn(rt2x00dev, "TX status FIFO overrun, drop tx status report\n"); +- break; +- } ++ kfifo_put(&rt2x00dev->txstatus_fifo, status); ++ more = true; + } + +- /* Schedule the tasklet for processing the tx status. */ +- tasklet_schedule(&rt2x00dev->txstatus_tasklet); ++ return more; + } + ++void rt2800mmio_txstatus_tasklet(unsigned long data) ++{ ++ struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; ++ ++ do { ++ rt2800mmio_txdone(rt2x00dev); ++ ++ } while (rt2800mmio_fetch_txstatus(rt2x00dev)); ++ ++ if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) ++ rt2800mmio_enable_interrupt(rt2x00dev, ++ INT_SOURCE_CSR_TX_FIFO_STATUS); ++} ++EXPORT_SYMBOL_GPL(rt2800mmio_txstatus_tasklet); ++ + irqreturn_t rt2800mmio_interrupt(int irq, void *dev_instance) + { + struct rt2x00_dev *rt2x00dev = dev_instance; +@@ -327,8 +338,10 @@ irqreturn_t rt2800mmio_interrupt(int irq + */ + mask = ~reg; + +- if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) +- rt2800mmio_txstatus_interrupt(rt2x00dev); ++ if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) { ++ rt2800mmio_fetch_txstatus(rt2x00dev); ++ tasklet_schedule(&rt2x00dev->txstatus_tasklet); ++ } + + if (rt2x00_get_field32(reg, INT_SOURCE_CSR_PRE_TBTT)) + tasklet_hi_schedule(&rt2x00dev->pretbtt_tasklet); +@@ -453,6 +466,53 @@ void rt2800mmio_kick_queue(struct data_q + } + EXPORT_SYMBOL_GPL(rt2800mmio_kick_queue); + ++void rt2800mmio_flush_queue(struct data_queue *queue, bool drop) ++{ ++ struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; ++ bool tx_queue = false; ++ unsigned int i; ++ ++ switch (queue->qid) { ++ case QID_AC_VO: ++ case QID_AC_VI: ++ case QID_AC_BE: ++ case QID_AC_BK: ++ tx_queue = true; ++ break; ++ case QID_RX: ++ break; ++ default: ++ return; ++ } ++ ++ for (i = 0; i < 5; i++) { ++ /* ++ * Check if the driver is already done, otherwise we ++ * have to sleep a little while to give the driver/hw ++ * the oppurtunity to complete interrupt process itself. ++ */ ++ if (rt2x00queue_empty(queue)) ++ break; ++ ++ /* ++ * For TX queues schedule completion tasklet to catch ++ * tx status timeouts, othewise just wait. ++ */ ++ if (tx_queue) { ++ tasklet_disable(&rt2x00dev->txstatus_tasklet); ++ rt2800mmio_txdone(rt2x00dev); ++ tasklet_enable(&rt2x00dev->txstatus_tasklet); ++ } ++ ++ /* ++ * Wait for a little while to give the driver ++ * the oppurtunity to recover itself. ++ */ ++ msleep(50); ++ } ++} ++EXPORT_SYMBOL_GPL(rt2800mmio_flush_queue); ++ + void rt2800mmio_stop_queue(struct data_queue *queue) + { + struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; +--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.h +@@ -148,6 +148,7 @@ void rt2800mmio_toggle_irq(struct rt2x00 + /* Queue handlers */ + void rt2800mmio_start_queue(struct data_queue *queue); + void rt2800mmio_kick_queue(struct data_queue *queue); ++void rt2800mmio_flush_queue(struct data_queue *queue, bool drop); + void rt2800mmio_stop_queue(struct data_queue *queue); + void rt2800mmio_queue_init(struct data_queue *queue); + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800pci.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800pci.c +@@ -364,7 +364,7 @@ static const struct rt2x00lib_ops rt2800 + .start_queue = rt2800mmio_start_queue, + .kick_queue = rt2800mmio_kick_queue, + .stop_queue = rt2800mmio_stop_queue, +- .flush_queue = rt2x00mmio_flush_queue, ++ .flush_queue = rt2800mmio_flush_queue, + .write_tx_desc = rt2800mmio_write_tx_desc, + .write_tx_data = rt2800_write_tx_data, + .write_beacon = rt2800_write_beacon, diff --git a/package/kernel/mac80211/patches/rt2x00/007-rt2x00-rt2400pci-mark-expected-switch-fall-through.patch b/package/kernel/mac80211/patches/rt2x00/007-rt2x00-rt2400pci-mark-expected-switch-fall-through.patch new file mode 100644 index 0000000000..2161ad9ef3 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/007-rt2x00-rt2400pci-mark-expected-switch-fall-through.patch @@ -0,0 +1,25 @@ +From 6eba8fd2235237784dfd01da55c3210d493aebdb Mon Sep 17 00:00:00 2001 +From: "Gustavo A. R. Silva" +Date: Mon, 22 Oct 2018 22:44:34 +0200 +Subject: [PATCH 07/28] rt2x00: rt2400pci: mark expected switch fall-through + +In preparation to enabling -Wimplicit-fallthrough, mark switch cases +where we are expecting to fall through. + +Signed-off-by: Gustavo A. R. Silva +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/ralink/rt2x00/rt2400pci.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2400pci.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2400pci.c +@@ -1302,7 +1302,7 @@ static void rt2400pci_txdone(struct rt2x + break; + case 2: /* Failure, excessive retries */ + __set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags); +- /* Don't break, this is a failed frame! */ ++ /* Fall through - this is a failed frame! */ + default: /* Failure */ + __set_bit(TXDONE_FAILURE, &txdesc.flags); + } diff --git a/package/kernel/mac80211/patches/rt2x00/008-rt2x00-rt2500pci-mark-expected-switch-fall-through.patch b/package/kernel/mac80211/patches/rt2x00/008-rt2x00-rt2500pci-mark-expected-switch-fall-through.patch new file mode 100644 index 0000000000..d10de6b0e5 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/008-rt2x00-rt2500pci-mark-expected-switch-fall-through.patch @@ -0,0 +1,25 @@ +From 10bb92217747c3384a01ebec005faa2f5e72bbd8 Mon Sep 17 00:00:00 2001 +From: "Gustavo A. R. Silva" +Date: Mon, 22 Oct 2018 22:45:19 +0200 +Subject: [PATCH 08/28] rt2x00: rt2500pci: mark expected switch fall-through + +In preparation to enabling -Wimplicit-fallthrough, mark switch cases +where we are expecting to fall through. + +Signed-off-by: Gustavo A. R. Silva +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/ralink/rt2x00/rt2500pci.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2500pci.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2500pci.c +@@ -1430,7 +1430,7 @@ static void rt2500pci_txdone(struct rt2x + break; + case 2: /* Failure, excessive retries */ + __set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags); +- /* Don't break, this is a failed frame! */ ++ /* Fall through - this is a failed frame! */ + default: /* Failure */ + __set_bit(TXDONE_FAILURE, &txdesc.flags); + } diff --git a/package/kernel/mac80211/patches/rt2x00/009-rt2x00-rt2800lib-mark-expected-switch-fall-throughs.patch b/package/kernel/mac80211/patches/rt2x00/009-rt2x00-rt2800lib-mark-expected-switch-fall-throughs.patch new file mode 100644 index 0000000000..99f971b95f --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/009-rt2x00-rt2800lib-mark-expected-switch-fall-throughs.patch @@ -0,0 +1,44 @@ +From 916e6bbcfcff6cc5d7d33bba8557a30f3af50326 Mon Sep 17 00:00:00 2001 +From: "Gustavo A. R. Silva" +Date: Mon, 22 Oct 2018 22:46:03 +0200 +Subject: [PATCH 09/28] rt2x00: rt2800lib: mark expected switch fall-throughs + +In preparation to enabling -Wimplicit-fallthrough, mark switch cases +where we are expecting to fall through. + +Addresses-Coverity-ID: 145198 ("Missing break in switch") +Signed-off-by: Gustavo A. R. Silva +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -2482,6 +2482,7 @@ static void rt2800_config_channel_rf3052 + switch (rt2x00dev->default_ant.tx_chain_num) { + case 1: + rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 1); ++ /* fall through */ + case 2: + rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 1); + break; +@@ -2490,6 +2491,7 @@ static void rt2800_config_channel_rf3052 + switch (rt2x00dev->default_ant.rx_chain_num) { + case 1: + rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 1); ++ /* fall through */ + case 2: + rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 1); + break; +@@ -9457,8 +9459,10 @@ static int rt2800_probe_hw_mode(struct r + switch (rx_chains) { + case 3: + spec->ht.mcs.rx_mask[2] = 0xff; ++ /* fall through */ + case 2: + spec->ht.mcs.rx_mask[1] = 0xff; ++ /* fall through */ + case 1: + spec->ht.mcs.rx_mask[0] = 0xff; + spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */ diff --git a/package/kernel/mac80211/patches/rt2x00/010-rt2x00-rt61pci-mark-expected-switch-fall-through.patch b/package/kernel/mac80211/patches/rt2x00/010-rt2x00-rt61pci-mark-expected-switch-fall-through.patch new file mode 100644 index 0000000000..5b0f96d293 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/010-rt2x00-rt61pci-mark-expected-switch-fall-through.patch @@ -0,0 +1,25 @@ +From 641dd8068ecb078e7d12efe465df202bc16ca5eb Mon Sep 17 00:00:00 2001 +From: "Gustavo A. R. Silva" +Date: Mon, 22 Oct 2018 22:46:47 +0200 +Subject: [PATCH 10/28] rt2x00: rt61pci: mark expected switch fall-through + +In preparation to enabling -Wimplicit-fallthrough, mark switch cases +where we are expecting to fall through. + +Signed-off-by: Gustavo A. R. Silva +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/ralink/rt2x00/rt61pci.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt61pci.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt61pci.c +@@ -2226,7 +2226,7 @@ static void rt61pci_txdone(struct rt2x00 + break; + case 6: /* Failure, excessive retries */ + __set_bit(TXDONE_EXCESSIVE_RETRY, &txdesc.flags); +- /* Don't break, this is a failed frame! */ ++ /* Fall through - this is a failed frame! */ + default: /* Failure */ + __set_bit(TXDONE_FAILURE, &txdesc.flags); + } diff --git a/package/kernel/mac80211/patches/rt2x00/011-cross-tree-phase-out-dma_zalloc_coherent.patch b/package/kernel/mac80211/patches/rt2x00/011-cross-tree-phase-out-dma_zalloc_coherent.patch new file mode 100644 index 0000000000..8100eb063b --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/011-cross-tree-phase-out-dma_zalloc_coherent.patch @@ -0,0 +1,40 @@ +From 750afb08ca71310fcf0c4e2cb1565c63b8235b60 Mon Sep 17 00:00:00 2001 +From: Luis Chamberlain +Date: Fri, 4 Jan 2019 09:23:09 +0100 +Subject: [PATCH 11/28] cross-tree: phase out dma_zalloc_coherent() + +We already need to zero out memory for dma_alloc_coherent(), as such +using dma_zalloc_coherent() is superflous. Phase it out. + +This change was generated with the following Coccinelle SmPL patch: + +@ replace_dma_zalloc_coherent @ +expression dev, size, data, handle, flags; +@@ + +-dma_zalloc_coherent(dev, size, handle, flags) ++dma_alloc_coherent(dev, size, handle, flags) + +Suggested-by: Christoph Hellwig +Signed-off-by: Luis Chamberlain +[hch: re-ran the script on the latest tree] +Signed-off-by: Christoph Hellwig +--- + drivers/net/wireless/ralink/rt2x00/rt2x00mmio.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00mmio.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mmio.c +@@ -119,9 +119,9 @@ static int rt2x00mmio_alloc_queue_dma(st + /* + * Allocate DMA memory for descriptor and buffer. + */ +- addr = dma_zalloc_coherent(rt2x00dev->dev, +- queue->limit * queue->desc_size, &dma, +- GFP_KERNEL); ++ addr = dma_alloc_coherent(rt2x00dev->dev, ++ queue->limit * queue->desc_size, &dma, ++ GFP_KERNEL); + if (!addr) + return -ENOMEM; + diff --git a/package/kernel/mac80211/patches/rt2x00/012-rt2x00-reduce-tx-power-to-nominal-level-on-RT6352.patch b/package/kernel/mac80211/patches/rt2x00/012-rt2x00-reduce-tx-power-to-nominal-level-on-RT6352.patch new file mode 100644 index 0000000000..a07832e97c --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/012-rt2x00-reduce-tx-power-to-nominal-level-on-RT6352.patch @@ -0,0 +1,32 @@ +From c2e28ef7711ffcb083474ee5f154264c6ec1ec07 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tomislav=20Po=C5=BEega?= +Date: Thu, 27 Dec 2018 15:05:25 +0100 +Subject: [PATCH 12/28] rt2x00: reduce tx power to nominal level on RT6352 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Current implementation of RT6352 support provides too high tx power +at least on iPA/eLNA devices. Reduce amplification of variable gain +amplifier by 6dB to match board target power of 17dBm. +Transmited signal strength with this patch is similar to that of +stock firmware or pandorabox firmware. Throughput measured with iperf +improves. Device tested: Xiaomi Miwifi Mini. + +Signed-off-by: Tomislav Požega +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -5477,7 +5477,7 @@ static int rt2800_init_registers(struct + rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); + rt2800_register_write(rt2x00dev, MIMO_PS_CFG, 0x00000002); + rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0x00150F0F); +- rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x06060606); ++ rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x00000000); + rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0); + rt2800_register_write(rt2x00dev, TX1_BB_GAIN_ATTEN, 0x0); + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C666C); diff --git a/package/kernel/mac80211/patches/rt2x00/013-rt2x00-Work-around-a-firmware-bug-with-shared-keys.patch b/package/kernel/mac80211/patches/rt2x00/013-rt2x00-Work-around-a-firmware-bug-with-shared-keys.patch new file mode 100644 index 0000000000..dc884c17d2 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/013-rt2x00-Work-around-a-firmware-bug-with-shared-keys.patch @@ -0,0 +1,143 @@ +From a4296994eb8061ee3455721a296c387c639bf635 Mon Sep 17 00:00:00 2001 +From: Bernd Edlinger +Date: Tue, 15 Jan 2019 14:01:29 +0000 +Subject: [PATCH 13/28] rt2x00: Work around a firmware bug with shared keys + +Apparently the rt2x61 firmware fails temporarily to decode +broadcast packets if the shared keys are not assigned +in the "correct" sequence. At the same time unicast +packets work fine, since they are encrypted with the +pairwise key. + +At least with WPA2 CCMP mode the shared keys are +set in the following sequence: keyidx=1, 2, 1, 2. +After a while only keyidx 2 gets decrypted, and +keyidx 1 is ignored, probably because there is never +a keyidx 3. + +Symptoms are arping -b works for 10 minutes, since +keyidx=2 is used for broadcast, and then it stops +working for 10 minutes, because keyidx=1 is used. +That failure mode repeats forever. + +Note, the firmware does not even know which keyidx +corresponds to which hw_key_idx so the firmware is +trying to be smarter than the driver, which is bound +to fail. + +As workaround the function rt61pci_config_shared_key +requests software decryption of the shared keys, +by returning EOPNOTSUPP. However, pairwise keys are +still handled by hardware which works just fine. + +Signed-off-by: Bernd Edlinger +Acked-by: Stanislaw Gruszka +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/ralink/rt2x00/rt61pci.c | 93 +------------------- + 1 file changed, 4 insertions(+), 89 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt61pci.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt61pci.c +@@ -321,97 +321,12 @@ static int rt61pci_config_shared_key(str + struct rt2x00lib_crypto *crypto, + struct ieee80211_key_conf *key) + { +- struct hw_key_entry key_entry; +- struct rt2x00_field32 field; +- u32 mask; +- u32 reg; +- +- if (crypto->cmd == SET_KEY) { +- /* +- * rt2x00lib can't determine the correct free +- * key_idx for shared keys. We have 1 register +- * with key valid bits. The goal is simple, read +- * the register, if that is full we have no slots +- * left. +- * Note that each BSS is allowed to have up to 4 +- * shared keys, so put a mask over the allowed +- * entries. +- */ +- mask = (0xf << crypto->bssidx); +- +- reg = rt2x00mmio_register_read(rt2x00dev, SEC_CSR0); +- reg &= mask; +- +- if (reg && reg == mask) +- return -ENOSPC; +- +- key->hw_key_idx += reg ? ffz(reg) : 0; +- +- /* +- * Upload key to hardware +- */ +- memcpy(key_entry.key, crypto->key, +- sizeof(key_entry.key)); +- memcpy(key_entry.tx_mic, crypto->tx_mic, +- sizeof(key_entry.tx_mic)); +- memcpy(key_entry.rx_mic, crypto->rx_mic, +- sizeof(key_entry.rx_mic)); +- +- reg = SHARED_KEY_ENTRY(key->hw_key_idx); +- rt2x00mmio_register_multiwrite(rt2x00dev, reg, +- &key_entry, sizeof(key_entry)); +- +- /* +- * The cipher types are stored over 2 registers. +- * bssidx 0 and 1 keys are stored in SEC_CSR1 and +- * bssidx 1 and 2 keys are stored in SEC_CSR5. +- * Using the correct defines correctly will cause overhead, +- * so just calculate the correct offset. +- */ +- if (key->hw_key_idx < 8) { +- field.bit_offset = (3 * key->hw_key_idx); +- field.bit_mask = 0x7 << field.bit_offset; +- +- reg = rt2x00mmio_register_read(rt2x00dev, SEC_CSR1); +- rt2x00_set_field32(®, field, crypto->cipher); +- rt2x00mmio_register_write(rt2x00dev, SEC_CSR1, reg); +- } else { +- field.bit_offset = (3 * (key->hw_key_idx - 8)); +- field.bit_mask = 0x7 << field.bit_offset; +- +- reg = rt2x00mmio_register_read(rt2x00dev, SEC_CSR5); +- rt2x00_set_field32(®, field, crypto->cipher); +- rt2x00mmio_register_write(rt2x00dev, SEC_CSR5, reg); +- } +- +- /* +- * The driver does not support the IV/EIV generation +- * in hardware. However it doesn't support the IV/EIV +- * inside the ieee80211 frame either, but requires it +- * to be provided separately for the descriptor. +- * rt2x00lib will cut the IV/EIV data out of all frames +- * given to us by mac80211, but we must tell mac80211 +- * to generate the IV/EIV data. +- */ +- key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; +- } +- + /* +- * SEC_CSR0 contains only single-bit fields to indicate +- * a particular key is valid. Because using the FIELD32() +- * defines directly will cause a lot of overhead, we use +- * a calculation to determine the correct bit directly. ++ * Let the software handle the shared keys, ++ * since the hardware decryption does not work reliably, ++ * because the firmware does not know the key's keyidx. + */ +- mask = 1 << key->hw_key_idx; +- +- reg = rt2x00mmio_register_read(rt2x00dev, SEC_CSR0); +- if (crypto->cmd == SET_KEY) +- reg |= mask; +- else if (crypto->cmd == DISABLE_KEY) +- reg &= ~mask; +- rt2x00mmio_register_write(rt2x00dev, SEC_CSR0, reg); +- +- return 0; ++ return -EOPNOTSUPP; + } + + static int rt61pci_config_pairwise_key(struct rt2x00_dev *rt2x00dev, diff --git a/package/kernel/mac80211/patches/rt2x00/014-rt2x00-no-need-to-check-return-value-of-debugfs_crea.patch b/package/kernel/mac80211/patches/rt2x00/014-rt2x00-no-need-to-check-return-value-of-debugfs_crea.patch new file mode 100644 index 0000000000..26f2df10e0 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/014-rt2x00-no-need-to-check-return-value-of-debugfs_crea.patch @@ -0,0 +1,107 @@ +From 2587791d57588562c21e5ef7e678f02ab2f3eb82 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Tue, 22 Jan 2019 16:21:34 +0100 +Subject: [PATCH 14/28] rt2x00: no need to check return value of debugfs_create + functions + +When calling debugfs functions, there is no need to ever check the +return value. The function can work or not, but the code logic should +never do something different based on this. + +Cc: Stanislaw Gruszka +Cc: Helmut Schaa +Cc: Kalle Valo +Cc: linux-wireless@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +Acked-by: Stanislaw Gruszka +Signed-off-by: Kalle Valo +--- + .../net/wireless/ralink/rt2x00/rt2x00debug.c | 27 ------------------- + 1 file changed, 27 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c +@@ -656,36 +656,24 @@ void rt2x00debug_register(struct rt2x00_ + intf->driver_folder = + debugfs_create_dir(intf->rt2x00dev->ops->name, + rt2x00dev->hw->wiphy->debugfsdir); +- if (IS_ERR(intf->driver_folder) || !intf->driver_folder) +- goto exit; + + intf->driver_entry = + rt2x00debug_create_file_driver("driver", intf, &intf->driver_blob); +- if (IS_ERR(intf->driver_entry) || !intf->driver_entry) +- goto exit; + + intf->chipset_entry = + rt2x00debug_create_file_chipset("chipset", + intf, &intf->chipset_blob); +- if (IS_ERR(intf->chipset_entry) || !intf->chipset_entry) +- goto exit; + + intf->dev_flags = debugfs_create_file("dev_flags", 0400, + intf->driver_folder, intf, + &rt2x00debug_fop_dev_flags); +- if (IS_ERR(intf->dev_flags) || !intf->dev_flags) +- goto exit; + + intf->cap_flags = debugfs_create_file("cap_flags", 0400, + intf->driver_folder, intf, + &rt2x00debug_fop_cap_flags); +- if (IS_ERR(intf->cap_flags) || !intf->cap_flags) +- goto exit; + + intf->register_folder = + debugfs_create_dir("register", intf->driver_folder); +- if (IS_ERR(intf->register_folder) || !intf->register_folder) +- goto exit; + + #define RT2X00DEBUGFS_CREATE_REGISTER_ENTRY(__intf, __name) \ + ({ \ +@@ -695,9 +683,6 @@ void rt2x00debug_register(struct rt2x00_ + 0600, \ + (__intf)->register_folder, \ + &(__intf)->offset_##__name); \ +- if (IS_ERR((__intf)->__name##_off_entry) || \ +- !(__intf)->__name##_off_entry) \ +- goto exit; \ + \ + (__intf)->__name##_val_entry = \ + debugfs_create_file(__stringify(__name) "_value", \ +@@ -705,9 +690,6 @@ void rt2x00debug_register(struct rt2x00_ + (__intf)->register_folder, \ + (__intf), \ + &rt2x00debug_fop_##__name); \ +- if (IS_ERR((__intf)->__name##_val_entry) || \ +- !(__intf)->__name##_val_entry) \ +- goto exit; \ + } \ + }) + +@@ -721,15 +703,10 @@ void rt2x00debug_register(struct rt2x00_ + + intf->queue_folder = + debugfs_create_dir("queue", intf->driver_folder); +- if (IS_ERR(intf->queue_folder) || !intf->queue_folder) +- goto exit; + + intf->queue_frame_dump_entry = + debugfs_create_file("dump", 0400, intf->queue_folder, + intf, &rt2x00debug_fop_queue_dump); +- if (IS_ERR(intf->queue_frame_dump_entry) +- || !intf->queue_frame_dump_entry) +- goto exit; + + skb_queue_head_init(&intf->frame_dump_skbqueue); + init_waitqueue_head(&intf->frame_dump_waitqueue); +@@ -747,10 +724,6 @@ void rt2x00debug_register(struct rt2x00_ + #endif + + return; +- +-exit: +- rt2x00debug_deregister(rt2x00dev); +- rt2x00_err(rt2x00dev, "Failed to register debug handler\n"); + } + + void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev) diff --git a/package/kernel/mac80211/patches/rt2x00/015-rt2x00-remove-unneeded-check.patch b/package/kernel/mac80211/patches/rt2x00/015-rt2x00-remove-unneeded-check.patch new file mode 100644 index 0000000000..f896ea5bcb --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/015-rt2x00-remove-unneeded-check.patch @@ -0,0 +1,136 @@ +From 0bffbc98e6999bba38d8185a0ddb1ee77369eaec Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tomislav=20Po=C5=BEega?= +Date: Wed, 13 Feb 2019 11:09:12 +0100 +Subject: [PATCH 15/28] rt2x00: remove unneeded check +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Remove band check from rf53xx channel config routine since all chips +using it are single band. + +Signed-off-by: Tomislav Požega +Signed-off-by: Stanislaw Gruszka +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 103 +++++++++--------- + 1 file changed, 50 insertions(+), 53 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -2966,6 +2966,7 @@ static void rt2800_config_channel_rf53xx + struct channel_info *info) + { + u8 rfcsr; ++ int idx = rf->channel-1; + + rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); + rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); +@@ -3003,60 +3004,56 @@ static void rt2800_config_channel_rf53xx + + rt2800_freq_cal_mode1(rt2x00dev); + +- if (rf->channel <= 14) { +- int idx = rf->channel-1; ++ if (rt2x00_has_cap_bt_coexist(rt2x00dev)) { ++ if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F)) { ++ /* r55/r59 value array of channel 1~14 */ ++ static const char r55_bt_rev[] = {0x83, 0x83, ++ 0x83, 0x73, 0x73, 0x63, 0x53, 0x53, ++ 0x53, 0x43, 0x43, 0x43, 0x43, 0x43}; ++ static const char r59_bt_rev[] = {0x0e, 0x0e, ++ 0x0e, 0x0e, 0x0e, 0x0b, 0x0a, 0x09, ++ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07}; ++ ++ rt2800_rfcsr_write(rt2x00dev, 55, ++ r55_bt_rev[idx]); ++ rt2800_rfcsr_write(rt2x00dev, 59, ++ r59_bt_rev[idx]); ++ } else { ++ static const char r59_bt[] = {0x8b, 0x8b, 0x8b, ++ 0x8b, 0x8b, 0x8b, 0x8b, 0x8a, 0x89, ++ 0x88, 0x88, 0x86, 0x85, 0x84}; + +- if (rt2x00_has_cap_bt_coexist(rt2x00dev)) { +- if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F)) { +- /* r55/r59 value array of channel 1~14 */ +- static const char r55_bt_rev[] = {0x83, 0x83, +- 0x83, 0x73, 0x73, 0x63, 0x53, 0x53, +- 0x53, 0x43, 0x43, 0x43, 0x43, 0x43}; +- static const char r59_bt_rev[] = {0x0e, 0x0e, +- 0x0e, 0x0e, 0x0e, 0x0b, 0x0a, 0x09, +- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07}; +- +- rt2800_rfcsr_write(rt2x00dev, 55, +- r55_bt_rev[idx]); +- rt2800_rfcsr_write(rt2x00dev, 59, +- r59_bt_rev[idx]); +- } else { +- static const char r59_bt[] = {0x8b, 0x8b, 0x8b, +- 0x8b, 0x8b, 0x8b, 0x8b, 0x8a, 0x89, +- 0x88, 0x88, 0x86, 0x85, 0x84}; ++ rt2800_rfcsr_write(rt2x00dev, 59, r59_bt[idx]); ++ } ++ } else { ++ if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F)) { ++ static const char r55_nonbt_rev[] = {0x23, 0x23, ++ 0x23, 0x23, 0x13, 0x13, 0x03, 0x03, ++ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}; ++ static const char r59_nonbt_rev[] = {0x07, 0x07, ++ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, ++ 0x07, 0x07, 0x06, 0x05, 0x04, 0x04}; ++ ++ rt2800_rfcsr_write(rt2x00dev, 55, ++ r55_nonbt_rev[idx]); ++ rt2800_rfcsr_write(rt2x00dev, 59, ++ r59_nonbt_rev[idx]); ++ } else if (rt2x00_rt(rt2x00dev, RT5390) || ++ rt2x00_rt(rt2x00dev, RT5392) || ++ rt2x00_rt(rt2x00dev, RT6352)) { ++ static const char r59_non_bt[] = {0x8f, 0x8f, ++ 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8d, ++ 0x8a, 0x88, 0x88, 0x87, 0x87, 0x86}; ++ ++ rt2800_rfcsr_write(rt2x00dev, 59, ++ r59_non_bt[idx]); ++ } else if (rt2x00_rt(rt2x00dev, RT5350)) { ++ static const char r59_non_bt[] = {0x0b, 0x0b, ++ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0a, ++ 0x0a, 0x09, 0x08, 0x07, 0x07, 0x06}; + +- rt2800_rfcsr_write(rt2x00dev, 59, r59_bt[idx]); +- } +- } else { +- if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F)) { +- static const char r55_nonbt_rev[] = {0x23, 0x23, +- 0x23, 0x23, 0x13, 0x13, 0x03, 0x03, +- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}; +- static const char r59_nonbt_rev[] = {0x07, 0x07, +- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, +- 0x07, 0x07, 0x06, 0x05, 0x04, 0x04}; +- +- rt2800_rfcsr_write(rt2x00dev, 55, +- r55_nonbt_rev[idx]); +- rt2800_rfcsr_write(rt2x00dev, 59, +- r59_nonbt_rev[idx]); +- } else if (rt2x00_rt(rt2x00dev, RT5390) || +- rt2x00_rt(rt2x00dev, RT5392) || +- rt2x00_rt(rt2x00dev, RT6352)) { +- static const char r59_non_bt[] = {0x8f, 0x8f, +- 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8d, +- 0x8a, 0x88, 0x88, 0x87, 0x87, 0x86}; +- +- rt2800_rfcsr_write(rt2x00dev, 59, +- r59_non_bt[idx]); +- } else if (rt2x00_rt(rt2x00dev, RT5350)) { +- static const char r59_non_bt[] = {0x0b, 0x0b, +- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0a, +- 0x0a, 0x09, 0x08, 0x07, 0x07, 0x06}; +- +- rt2800_rfcsr_write(rt2x00dev, 59, +- r59_non_bt[idx]); +- } ++ rt2800_rfcsr_write(rt2x00dev, 59, ++ r59_non_bt[idx]); + } + } + } diff --git a/package/kernel/mac80211/patches/rt2x00/016-rt2x00-remove-confusing-AGC-register.patch b/package/kernel/mac80211/patches/rt2x00/016-rt2x00-remove-confusing-AGC-register.patch new file mode 100644 index 0000000000..194e1d8154 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/016-rt2x00-remove-confusing-AGC-register.patch @@ -0,0 +1,33 @@ +From dce31f739d4c901725a23c7939d7e04d4c2eacac Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tomislav=20Po=C5=BEega?= +Date: Wed, 13 Feb 2019 11:09:13 +0100 +Subject: [PATCH 16/28] rt2x00: remove confusing AGC register +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Register 66 was causing issues on RT6352 if set to the same value as +in MTK driver. With 1c reg value device was working fine in both HT20 +and HT40 modes. + +Signed-off-by: Tomislav Požega +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -3983,11 +3983,7 @@ static void rt2800_config_channel(struct + rt2800_bbp_write(rt2x00dev, 196, reg); + + /* AGC init */ +- if (rt2x00_rt(rt2x00dev, RT6352)) +- reg = 0x04; +- else +- reg = rf->channel <= 14 ? 0x1c : 0x24; +- ++ reg = rf->channel <= 14 ? 0x1c : 0x24; + reg += 2 * rt2x00dev->lna_gain; + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); + diff --git a/package/kernel/mac80211/patches/rt2x00/017-rt2800-enable-TX_PIN_CFG_LNA_PE_-bits-per-band.patch b/package/kernel/mac80211/patches/rt2x00/017-rt2800-enable-TX_PIN_CFG_LNA_PE_-bits-per-band.patch new file mode 100644 index 0000000000..a469fae69c --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/017-rt2800-enable-TX_PIN_CFG_LNA_PE_-bits-per-band.patch @@ -0,0 +1,46 @@ +From 9c9bf1af644ad16fca1fd601cfc3a2a2c6bbc58b Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Wed, 13 Feb 2019 11:09:14 +0100 +Subject: [PATCH 17/28] rt2800: enable TX_PIN_CFG_LNA_PE_ bits per band + +Do not enable TX_PIN_CFG_LNA_PE_A* bits for 2.4GHz band and +vice versa TX_PIN_CFG_LNA_PE_G* bits for 5GHz. + +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -3893,18 +3893,24 @@ static void rt2800_config_channel(struct + switch (rt2x00dev->default_ant.rx_chain_num) { + case 3: + /* Turn on tertiary LNAs */ +- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A2_EN, 1); +- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G2_EN, 1); ++ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A2_EN, ++ rf->channel > 14); ++ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G2_EN, ++ rf->channel <= 14); + /* fall-through */ + case 2: + /* Turn on secondary LNAs */ +- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1); +- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1); ++ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, ++ rf->channel > 14); ++ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, ++ rf->channel <= 14); + /* fall-through */ + case 1: + /* Turn on primary LNAs */ +- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1); +- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1); ++ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, ++ rf->channel > 14); ++ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, ++ rf->channel <= 14); + break; + } + diff --git a/package/kernel/mac80211/patches/rt2x00/018-rt2800-enable-TX_PIN_CFG_RFRX_EN-only-for-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/018-rt2800-enable-TX_PIN_CFG_RFRX_EN-only-for-MT7620.patch new file mode 100644 index 0000000000..445e3eade6 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/018-rt2800-enable-TX_PIN_CFG_RFRX_EN-only-for-MT7620.patch @@ -0,0 +1,40 @@ +From 4c0475ad8b73072b5b638163c2eb8309310406ed Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Wed, 13 Feb 2019 11:09:15 +0100 +Subject: [PATCH 18/28] rt2800: enable TX_PIN_CFG_RFRX_EN only for MT7620 + +The TX_PIN_CFG_RFRX_EN bit was not set on other devices than MT7620, +restore old behavaviour since setting this bit maight not be +correct for older devices. + +Fixes: 41977e86c984 ("rt2x00: add support for MT7620") +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -3858,10 +3858,12 @@ static void rt2800_config_channel(struct + if (rt2x00_rt(rt2x00dev, RT3572)) + rt2800_rfcsr_write(rt2x00dev, 8, 0); + +- if (rt2x00_rt(rt2x00dev, RT6352)) ++ if (rt2x00_rt(rt2x00dev, RT6352)) { + tx_pin = rt2800_register_read(rt2x00dev, TX_PIN_CFG); +- else ++ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFRX_EN, 1); ++ } else { + tx_pin = 0; ++ } + + switch (rt2x00dev->default_ant.tx_chain_num) { + case 3: +@@ -3916,7 +3918,6 @@ static void rt2800_config_channel(struct + + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1); + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1); +- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFRX_EN, 1); /* mt7620 */ + + rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); + diff --git a/package/kernel/mac80211/patches/rt2x00/019-rt2800-comment-and-simplify-AGC-init-for-RT6352.patch b/package/kernel/mac80211/patches/rt2x00/019-rt2800-comment-and-simplify-AGC-init-for-RT6352.patch new file mode 100644 index 0000000000..936651c0ba --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/019-rt2800-comment-and-simplify-AGC-init-for-RT6352.patch @@ -0,0 +1,32 @@ +From cb77f0f92f596a2ef54246db7321e319305e8156 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Wed, 13 Feb 2019 11:09:16 +0100 +Subject: [PATCH 19/28] rt2800: comment and simplify AGC init for RT6352 + +We do not need separate lines for calculating register values. +Also add comment that value is different than in vendor driver. + +Suggested-by: Daniel Golle +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -3989,9 +3989,12 @@ static void rt2800_config_channel(struct + rt2800_bbp_write(rt2x00dev, 195, 141); + rt2800_bbp_write(rt2x00dev, 196, reg); + +- /* AGC init */ +- reg = rf->channel <= 14 ? 0x1c : 0x24; +- reg += 2 * rt2x00dev->lna_gain; ++ /* AGC init. ++ * Despite the vendor driver using different values here for ++ * RT6352 chip, we use 0x1c for now. This may have to be changed ++ * once TSSI got implemented. ++ */ ++ reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); + + rt2800_iq_calibrate(rt2x00dev, rf->channel); diff --git a/package/kernel/mac80211/patches/rt2x00/020-rt2x00-do-not-print-error-when-queue-is-full.patch b/package/kernel/mac80211/patches/rt2x00/020-rt2x00-do-not-print-error-when-queue-is-full.patch new file mode 100644 index 0000000000..1c3d86a7c2 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/020-rt2x00-do-not-print-error-when-queue-is-full.patch @@ -0,0 +1,30 @@ +From 1a8a8989b779e51e4652a30e9f22c36a1b6ffc4b Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Thu, 20 Dec 2018 16:16:11 +0100 +Subject: [PATCH 20/28] rt2x00: do not print error when queue is full + +For unknown reasons printk() on some context can cause CPU hung on +embedded MT7620 AP/router MIPS platforms. What can result on wifi +disconnects. + +This patch move queue full messages to debug level what is consistent +with other mac80211 drivers which drop packet silently if tx queue is +full. This make MT7620 OpenWRT routers more stable, what was reported +by various users. + +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c +@@ -671,7 +671,7 @@ int rt2x00queue_write_tx_frame(struct da + spin_lock(&queue->tx_lock); + + if (unlikely(rt2x00queue_full(queue))) { +- rt2x00_err(queue->rt2x00dev, "Dropping frame due to full tx queue %d\n", ++ rt2x00_dbg(queue->rt2x00dev, "Dropping frame due to full tx queue %d\n", + queue->qid); + ret = -ENOBUFS; + goto out; diff --git a/package/kernel/mac80211/patches/rt2x00/021-rt2800-partially-restore-old-mmio-txstatus-behaviour.patch b/package/kernel/mac80211/patches/rt2x00/021-rt2800-partially-restore-old-mmio-txstatus-behaviour.patch new file mode 100644 index 0000000000..6214ad30db --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/021-rt2800-partially-restore-old-mmio-txstatus-behaviour.patch @@ -0,0 +1,125 @@ +From 91a5340db0526b7263bc8da14b120ea3129b5f28 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Sat, 9 Feb 2019 12:08:31 +0100 +Subject: [PATCH 21/28] rt2800: partially restore old mmio txstatus behaviour + +Do not disable txstatus interrupt and add quota of processed tx statuses in +one tasklet. Quota is needed to allow to fed device with new frames during +processing of tx statuses. + +Patch fixes about 15% performance degradation on some scenarios coused by +0b0d556e0ebb ("rt2800mmio: use txdone/txstatus routines from lib"). + +Signed-off-by: Stanislaw Gruszka +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 4 +-- + .../net/wireless/ralink/rt2x00/rt2800lib.h | 2 +- + .../net/wireless/ralink/rt2x00/rt2800mmio.c | 30 +++++-------------- + .../net/wireless/ralink/rt2x00/rt2800usb.c | 2 +- + 4 files changed, 12 insertions(+), 26 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -1100,7 +1100,7 @@ void rt2800_txdone_entry(struct queue_en + } + EXPORT_SYMBOL_GPL(rt2800_txdone_entry); + +-void rt2800_txdone(struct rt2x00_dev *rt2x00dev) ++void rt2800_txdone(struct rt2x00_dev *rt2x00dev, unsigned int quota) + { + struct data_queue *queue; + struct queue_entry *entry; +@@ -1108,7 +1108,7 @@ void rt2800_txdone(struct rt2x00_dev *rt + u8 qid; + bool match; + +- while (kfifo_get(&rt2x00dev->txstatus_fifo, ®)) { ++ while (quota-- > 0 && kfifo_get(&rt2x00dev->txstatus_fifo, ®)) { + /* + * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is + * guaranteed to be one of the TX QIDs . +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +@@ -195,7 +195,7 @@ void rt2800_process_rxwi(struct queue_en + + void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi, + bool match); +-void rt2800_txdone(struct rt2x00_dev *rt2x00dev); ++void rt2800_txdone(struct rt2x00_dev *rt2x00dev, unsigned int quota); + void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev); + bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev); + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c +@@ -255,20 +255,6 @@ void rt2800mmio_autowake_tasklet(unsigne + } + EXPORT_SYMBOL_GPL(rt2800mmio_autowake_tasklet); + +-static void rt2800mmio_txdone(struct rt2x00_dev *rt2x00dev) +-{ +- bool timeout = false; +- +- while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) || +- (timeout = rt2800_txstatus_timeout(rt2x00dev))) { +- +- rt2800_txdone(rt2x00dev); +- +- if (timeout) +- rt2800_txdone_nostatus(rt2x00dev); +- } +-} +- + static bool rt2800mmio_fetch_txstatus(struct rt2x00_dev *rt2x00dev) + { + u32 status; +@@ -305,14 +291,11 @@ void rt2800mmio_txstatus_tasklet(unsigne + { + struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; + +- do { +- rt2800mmio_txdone(rt2x00dev); ++ rt2800_txdone(rt2x00dev, 16); + +- } while (rt2800mmio_fetch_txstatus(rt2x00dev)); ++ if (!kfifo_is_empty(&rt2x00dev->txstatus_fifo)) ++ tasklet_schedule(&rt2x00dev->txstatus_tasklet); + +- if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) +- rt2800mmio_enable_interrupt(rt2x00dev, +- INT_SOURCE_CSR_TX_FIFO_STATUS); + } + EXPORT_SYMBOL_GPL(rt2800mmio_txstatus_tasklet); + +@@ -339,8 +322,10 @@ irqreturn_t rt2800mmio_interrupt(int irq + mask = ~reg; + + if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) { ++ rt2x00_set_field32(&mask, INT_MASK_CSR_TX_FIFO_STATUS, 1); + rt2800mmio_fetch_txstatus(rt2x00dev); +- tasklet_schedule(&rt2x00dev->txstatus_tasklet); ++ if (!kfifo_is_empty(&rt2x00dev->txstatus_fifo)) ++ tasklet_schedule(&rt2x00dev->txstatus_tasklet); + } + + if (rt2x00_get_field32(reg, INT_SOURCE_CSR_PRE_TBTT)) +@@ -500,7 +485,8 @@ void rt2800mmio_flush_queue(struct data_ + */ + if (tx_queue) { + tasklet_disable(&rt2x00dev->txstatus_tasklet); +- rt2800mmio_txdone(rt2x00dev); ++ rt2800_txdone(rt2x00dev, UINT_MAX); ++ rt2800_txdone_nostatus(rt2x00dev); + tasklet_enable(&rt2x00dev->txstatus_tasklet); + } + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c +@@ -480,7 +480,7 @@ static void rt2800usb_work_txdone(struct + while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) || + rt2800_txstatus_timeout(rt2x00dev)) { + +- rt2800_txdone(rt2x00dev); ++ rt2800_txdone(rt2x00dev, UINT_MAX); + + rt2800_txdone_nostatus(rt2x00dev); + diff --git a/package/kernel/mac80211/patches/rt2x00/022-rt2800-new-flush-implementation-for-SoC-devices.patch b/package/kernel/mac80211/patches/rt2x00/022-rt2800-new-flush-implementation-for-SoC-devices.patch new file mode 100644 index 0000000000..89368ada1c --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/022-rt2800-new-flush-implementation-for-SoC-devices.patch @@ -0,0 +1,24 @@ +From 11f8ad1656035176bad9d89de7ea0e7fe6d82c32 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Sat, 9 Feb 2019 12:08:32 +0100 +Subject: [PATCH 22/28] rt2800: new flush implementation for SoC devices + +Use new flush_queue() calback for SoC devices, what was already done for +PCIe devices. + +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800soc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c +@@ -203,7 +203,7 @@ static const struct rt2x00lib_ops rt2800 + .start_queue = rt2800mmio_start_queue, + .kick_queue = rt2800mmio_kick_queue, + .stop_queue = rt2800mmio_stop_queue, +- .flush_queue = rt2x00mmio_flush_queue, ++ .flush_queue = rt2800mmio_flush_queue, + .write_tx_desc = rt2800mmio_write_tx_desc, + .write_tx_data = rt2800_write_tx_data, + .write_beacon = rt2800_write_beacon, diff --git a/package/kernel/mac80211/patches/rt2x00/023-rt2800-move-txstatus-pending-routine.patch b/package/kernel/mac80211/patches/rt2x00/023-rt2800-move-txstatus-pending-routine.patch new file mode 100644 index 0000000000..c7bc4cbbab --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/023-rt2800-move-txstatus-pending-routine.patch @@ -0,0 +1,103 @@ +From 2bbea7645c3d095014a080db170941818650e141 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Sat, 9 Feb 2019 12:08:33 +0100 +Subject: [PATCH 23/28] rt2800: move txstatus pending routine + +Move rt2800usb_txstatus_pending routine to rt2800lib. It will be reused +by rt2800mmio code. + +Signed-off-by: Stanislaw Gruszka +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 17 ++++++++++++++ + .../net/wireless/ralink/rt2x00/rt2800lib.h | 1 + + .../net/wireless/ralink/rt2x00/rt2800usb.c | 22 +++---------------- + 3 files changed, 21 insertions(+), 19 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -1183,6 +1183,23 @@ bool rt2800_txstatus_timeout(struct rt2x + } + EXPORT_SYMBOL_GPL(rt2800_txstatus_timeout); + ++/* ++ * test if there is an entry in any TX queue for which DMA is done ++ * but the TX status has not been returned yet ++ */ ++bool rt2800_txstatus_pending(struct rt2x00_dev *rt2x00dev) ++{ ++ struct data_queue *queue; ++ ++ tx_queue_for_each(rt2x00dev, queue) { ++ if (rt2x00queue_get_entry(queue, Q_INDEX_DMA_DONE) != ++ rt2x00queue_get_entry(queue, Q_INDEX_DONE)) ++ return true; ++ } ++ return false; ++} ++EXPORT_SYMBOL_GPL(rt2800_txstatus_pending); ++ + void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev) + { + struct data_queue *queue; +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +@@ -198,6 +198,7 @@ void rt2800_txdone_entry(struct queue_en + void rt2800_txdone(struct rt2x00_dev *rt2x00dev, unsigned int quota); + void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev); + bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev); ++bool rt2800_txstatus_pending(struct rt2x00_dev *rt2x00dev); + + void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc); + void rt2800_clear_beacon(struct queue_entry *entry); +--- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c +@@ -100,22 +100,6 @@ static void rt2800usb_stop_queue(struct + } + } + +-/* +- * test if there is an entry in any TX queue for which DMA is done +- * but the TX status has not been returned yet +- */ +-static bool rt2800usb_txstatus_pending(struct rt2x00_dev *rt2x00dev) +-{ +- struct data_queue *queue; +- +- tx_queue_for_each(rt2x00dev, queue) { +- if (rt2x00queue_get_entry(queue, Q_INDEX_DMA_DONE) != +- rt2x00queue_get_entry(queue, Q_INDEX_DONE)) +- return true; +- } +- return false; +-} +- + #define TXSTATUS_READ_INTERVAL 1000000 + + static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev, +@@ -145,7 +129,7 @@ static bool rt2800usb_tx_sta_fifo_read_c + if (rt2800_txstatus_timeout(rt2x00dev)) + queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work); + +- if (rt2800usb_txstatus_pending(rt2x00dev)) { ++ if (rt2800_txstatus_pending(rt2x00dev)) { + /* Read register after 1 ms */ + hrtimer_start(&rt2x00dev->txstatus_timer, + TXSTATUS_READ_INTERVAL, +@@ -160,7 +144,7 @@ stop_reading: + * clear_bit someone could do rt2x00usb_interrupt_txdone, so recheck + * here again if status reading is needed. + */ +- if (rt2800usb_txstatus_pending(rt2x00dev) && ++ if (rt2800_txstatus_pending(rt2x00dev) && + !test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags)) + return true; + else +@@ -489,7 +473,7 @@ static void rt2800usb_work_txdone(struct + * if the medium is busy, thus the TX_STA_FIFO entry is + * also delayed -> use a timer to retrieve it. + */ +- if (rt2800usb_txstatus_pending(rt2x00dev)) ++ if (rt2800_txstatus_pending(rt2x00dev)) + rt2800usb_async_read_tx_status(rt2x00dev); + } + } diff --git a/package/kernel/mac80211/patches/rt2x00/024-rt2800mmio-fetch-tx-status-changes.patch b/package/kernel/mac80211/patches/rt2x00/024-rt2800mmio-fetch-tx-status-changes.patch new file mode 100644 index 0000000000..927325401c --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/024-rt2800mmio-fetch-tx-status-changes.patch @@ -0,0 +1,58 @@ +From f6a9618198e190a2ba09ce3f0aa8e9ee1763bd38 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Sat, 9 Feb 2019 12:08:34 +0100 +Subject: [PATCH 24/28] rt2800mmio: fetch tx status changes + +Prepare to use rt2800mmio_fetch_txstatus() in concurrent manner and drop +return value since is not longer needed. + +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 17 +++++++++-------- + 1 file changed, 9 insertions(+), 8 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c +@@ -255,12 +255,12 @@ void rt2800mmio_autowake_tasklet(unsigne + } + EXPORT_SYMBOL_GPL(rt2800mmio_autowake_tasklet); + +-static bool rt2800mmio_fetch_txstatus(struct rt2x00_dev *rt2x00dev) ++static void rt2800mmio_fetch_txstatus(struct rt2x00_dev *rt2x00dev) + { + u32 status; +- bool more = false; ++ unsigned long flags; + +- /* FIXEME: rewrite this comment ++ /* + * The TX_FIFO_STATUS interrupt needs special care. We should + * read TX_STA_FIFO but we should do it immediately as otherwise + * the register can overflow and we would lose status reports. +@@ -271,20 +271,21 @@ static bool rt2800mmio_fetch_txstatus(st + * because we can schedule the tasklet multiple times (when the + * interrupt fires again during tx status processing). + * +- * txstatus tasklet is called with INT_SOURCE_CSR_TX_FIFO_STATUS +- * disabled so have only one producer and one consumer - we don't +- * need to lock the kfifo. ++ * We also read statuses from tx status timeout timer, use ++ * lock to prevent concurent writes to fifo. + */ ++ ++ spin_lock_irqsave(&rt2x00dev->irqmask_lock, flags); ++ + while (!kfifo_is_full(&rt2x00dev->txstatus_fifo)) { + status = rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO); + if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID)) + break; + + kfifo_put(&rt2x00dev->txstatus_fifo, status); +- more = true; + } + +- return more; ++ spin_unlock_irqrestore(&rt2x00dev->irqmask_lock, flags); + } + + void rt2800mmio_txstatus_tasklet(unsigned long data) diff --git a/package/kernel/mac80211/patches/rt2x00/025-rt2800mmio-use-timer-and-work-for-handling-tx-status.patch b/package/kernel/mac80211/patches/rt2x00/025-rt2800mmio-use-timer-and-work-for-handling-tx-status.patch new file mode 100644 index 0000000000..60fa522354 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/025-rt2800mmio-use-timer-and-work-for-handling-tx-status.patch @@ -0,0 +1,191 @@ +From 175c2548332b45b144af673e70fdbb1a947d7aba Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Sat, 9 Feb 2019 12:08:35 +0100 +Subject: [PATCH 25/28] rt2800mmio: use timer and work for handling tx statuses + timeouts + +Sometimes we can get into situation when there are pending statuses, +but we do not get INT_SOURCE_CSR_TX_FIFO_STATUS. Handle this situation +by arming timeout timer and read statuses (it will fix case when +we just do not have irq) and queue work to handle case we missed +statues from hardware FIFO. + +Signed-off-by: Stanislaw Gruszka +--- + .../net/wireless/ralink/rt2x00/rt2800mmio.c | 81 +++++++++++++++++-- + .../net/wireless/ralink/rt2x00/rt2800mmio.h | 1 + + .../net/wireless/ralink/rt2x00/rt2800pci.c | 2 +- + .../net/wireless/ralink/rt2x00/rt2800soc.c | 2 +- + .../net/wireless/ralink/rt2x00/rt2x00dev.c | 4 + + 5 files changed, 82 insertions(+), 8 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c +@@ -426,6 +426,9 @@ void rt2800mmio_start_queue(struct data_ + } + EXPORT_SYMBOL_GPL(rt2800mmio_start_queue); + ++/* 200 ms */ ++#define TXSTATUS_TIMEOUT 200000000 ++ + void rt2800mmio_kick_queue(struct data_queue *queue) + { + struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; +@@ -440,6 +443,8 @@ void rt2800mmio_kick_queue(struct data_q + entry = rt2x00queue_get_entry(queue, Q_INDEX); + rt2x00mmio_register_write(rt2x00dev, TX_CTX_IDX(queue->qid), + entry->entry_idx); ++ hrtimer_start(&rt2x00dev->txstatus_timer, ++ TXSTATUS_TIMEOUT, HRTIMER_MODE_REL); + break; + case QID_MGMT: + entry = rt2x00queue_get_entry(queue, Q_INDEX); +@@ -484,12 +489,8 @@ void rt2800mmio_flush_queue(struct data_ + * For TX queues schedule completion tasklet to catch + * tx status timeouts, othewise just wait. + */ +- if (tx_queue) { +- tasklet_disable(&rt2x00dev->txstatus_tasklet); +- rt2800_txdone(rt2x00dev, UINT_MAX); +- rt2800_txdone_nostatus(rt2x00dev); +- tasklet_enable(&rt2x00dev->txstatus_tasklet); +- } ++ if (tx_queue) ++ queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work); + + /* + * Wait for a little while to give the driver +@@ -627,6 +628,10 @@ void rt2800mmio_clear_entry(struct queue + word = rt2x00_desc_read(entry_priv->desc, 1); + rt2x00_set_field32(&word, TXD_W1_DMA_DONE, 1); + rt2x00_desc_write(entry_priv->desc, 1, word); ++ ++ /* If last entry stop txstatus timer */ ++ if (entry->queue->length == 1) ++ hrtimer_cancel(&rt2x00dev->txstatus_timer); + } + } + EXPORT_SYMBOL_GPL(rt2800mmio_clear_entry); +@@ -759,6 +764,70 @@ int rt2800mmio_enable_radio(struct rt2x0 + } + EXPORT_SYMBOL_GPL(rt2800mmio_enable_radio); + ++static void rt2800mmio_work_txdone(struct work_struct *work) ++{ ++ struct rt2x00_dev *rt2x00dev = ++ container_of(work, struct rt2x00_dev, txdone_work); ++ ++ if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) ++ return; ++ ++ while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) || ++ rt2800_txstatus_timeout(rt2x00dev)) { ++ ++ tasklet_disable(&rt2x00dev->txstatus_tasklet); ++ rt2800_txdone(rt2x00dev, UINT_MAX); ++ rt2800_txdone_nostatus(rt2x00dev); ++ tasklet_enable(&rt2x00dev->txstatus_tasklet); ++ } ++ ++ if (rt2800_txstatus_pending(rt2x00dev)) ++ hrtimer_start(&rt2x00dev->txstatus_timer, ++ TXSTATUS_TIMEOUT, HRTIMER_MODE_REL); ++} ++ ++static enum hrtimer_restart rt2800mmio_tx_sta_fifo_timeout(struct hrtimer *timer) ++{ ++ struct rt2x00_dev *rt2x00dev = ++ container_of(timer, struct rt2x00_dev, txstatus_timer); ++ ++ if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) ++ goto out; ++ ++ if (!rt2800_txstatus_pending(rt2x00dev)) ++ goto out; ++ ++ rt2800mmio_fetch_txstatus(rt2x00dev); ++ if (!kfifo_is_empty(&rt2x00dev->txstatus_fifo)) ++ tasklet_schedule(&rt2x00dev->txstatus_tasklet); ++ else ++ queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work); ++out: ++ return HRTIMER_NORESTART; ++} ++ ++int rt2800mmio_probe_hw(struct rt2x00_dev *rt2x00dev) ++{ ++ int retval; ++ ++ retval = rt2800_probe_hw(rt2x00dev); ++ if (retval) ++ return retval; ++ ++ /* ++ * Set txstatus timer function. ++ */ ++ rt2x00dev->txstatus_timer.function = rt2800mmio_tx_sta_fifo_timeout; ++ ++ /* ++ * Overwrite TX done handler ++ */ ++ INIT_WORK(&rt2x00dev->txdone_work, rt2800mmio_work_txdone); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(rt2800mmio_probe_hw); ++ + MODULE_AUTHOR(DRV_PROJECT); + MODULE_VERSION(DRV_VERSION); + MODULE_DESCRIPTION("rt2800 MMIO library"); +--- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.h +@@ -153,6 +153,7 @@ void rt2800mmio_stop_queue(struct data_q + void rt2800mmio_queue_init(struct data_queue *queue); + + /* Initialization functions */ ++int rt2800mmio_probe_hw(struct rt2x00_dev *rt2x00dev); + bool rt2800mmio_get_entry_state(struct queue_entry *entry); + void rt2800mmio_clear_entry(struct queue_entry *entry); + int rt2800mmio_init_queues(struct rt2x00_dev *rt2x00dev); +--- a/drivers/net/wireless/ralink/rt2x00/rt2800pci.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800pci.c +@@ -346,7 +346,7 @@ static const struct rt2x00lib_ops rt2800 + .tbtt_tasklet = rt2800mmio_tbtt_tasklet, + .rxdone_tasklet = rt2800mmio_rxdone_tasklet, + .autowake_tasklet = rt2800mmio_autowake_tasklet, +- .probe_hw = rt2800_probe_hw, ++ .probe_hw = rt2800mmio_probe_hw, + .get_firmware_name = rt2800pci_get_firmware_name, + .check_firmware = rt2800_check_firmware, + .load_firmware = rt2800_load_firmware, +--- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c +@@ -185,7 +185,7 @@ static const struct rt2x00lib_ops rt2800 + .tbtt_tasklet = rt2800mmio_tbtt_tasklet, + .rxdone_tasklet = rt2800mmio_rxdone_tasklet, + .autowake_tasklet = rt2800mmio_autowake_tasklet, +- .probe_hw = rt2800_probe_hw, ++ .probe_hw = rt2800mmio_probe_hw, + .get_firmware_name = rt2800soc_get_firmware_name, + .check_firmware = rt2800soc_check_firmware, + .load_firmware = rt2800soc_load_firmware, +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +@@ -1391,6 +1391,8 @@ int rt2x00lib_probe_dev(struct rt2x00_de + mutex_init(&rt2x00dev->conf_mutex); + INIT_LIST_HEAD(&rt2x00dev->bar_list); + spin_lock_init(&rt2x00dev->bar_list_lock); ++ hrtimer_init(&rt2x00dev->txstatus_timer, CLOCK_MONOTONIC, ++ HRTIMER_MODE_REL); + + set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); + +@@ -1515,6 +1517,8 @@ void rt2x00lib_remove_dev(struct rt2x00_ + cancel_delayed_work_sync(&rt2x00dev->autowakeup_work); + cancel_work_sync(&rt2x00dev->sleep_work); + ++ hrtimer_cancel(&rt2x00dev->txstatus_timer); ++ + /* + * Kill the tx status tasklet. + */ diff --git a/package/kernel/mac80211/patches/rt2x00/026-rt2x00-remove-last_nostatus_check.patch b/package/kernel/mac80211/patches/rt2x00/026-rt2x00-remove-last_nostatus_check.patch new file mode 100644 index 0000000000..7af13e83ed --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/026-rt2x00-remove-last_nostatus_check.patch @@ -0,0 +1,54 @@ +From 6013a91f15c9dabd668d5736652b9bcfb0ef0378 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Sat, 9 Feb 2019 12:08:36 +0100 +Subject: [PATCH 26/28] rt2x00: remove last_nostatus_check + +We do not any longer check txstatus timeout from tasklet, so do not need +this optimization. + +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 9 --------- + drivers/net/wireless/ralink/rt2x00/rt2x00.h | 2 -- + drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 1 - + 3 files changed, 12 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -1164,15 +1164,6 @@ bool rt2800_txstatus_timeout(struct rt2x + struct data_queue *queue; + struct queue_entry *entry; + +- if (!test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) { +- unsigned long tout = msecs_to_jiffies(1000); +- +- if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout)) +- return false; +- } +- +- rt2x00dev->last_nostatus_check = jiffies; +- + tx_queue_for_each(rt2x00dev, queue) { + entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); + if (rt2800_entry_txstatus_timeout(rt2x00dev, entry)) +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h +@@ -981,8 +981,6 @@ struct rt2x00_dev { + */ + DECLARE_KFIFO_PTR(txstatus_fifo, u32); + +- unsigned long last_nostatus_check; +- + /* + * Timer to ensure tx status reports are read (rt2800usb). + */ +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c +@@ -1039,7 +1039,6 @@ void rt2x00queue_start_queues(struct rt2 + */ + tx_queue_for_each(rt2x00dev, queue) + rt2x00queue_start_queue(queue); +- rt2x00dev->last_nostatus_check = jiffies; + + rt2x00queue_start_queue(rt2x00dev->rx); + } diff --git a/package/kernel/mac80211/patches/rt2x00/027-rt2x00-remove-not-used-entry-field.patch b/package/kernel/mac80211/patches/rt2x00/027-rt2x00-remove-not-used-entry-field.patch new file mode 100644 index 0000000000..3b3af81720 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/027-rt2x00-remove-not-used-entry-field.patch @@ -0,0 +1,31 @@ +From 2758f09b22bc08e89e0391486b2d707ad2479599 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Sat, 9 Feb 2019 12:08:37 +0100 +Subject: [PATCH 27/28] rt2x00: remove not used entry field + +Remove not used any longer queue_entry field and flag. + +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2x00queue.h | 3 --- + 1 file changed, 3 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.h +@@ -361,7 +361,6 @@ enum queue_entry_flags { + ENTRY_DATA_PENDING, + ENTRY_DATA_IO_FAILED, + ENTRY_DATA_STATUS_PENDING, +- ENTRY_DATA_STATUS_SET, + }; + + /** +@@ -387,8 +386,6 @@ struct queue_entry { + + unsigned int entry_idx; + +- u32 status; +- + void *priv_data; + }; + diff --git a/package/kernel/mac80211/patches/rt2x00/028-rt2x00mmio-remove-legacy-comment.patch b/package/kernel/mac80211/patches/rt2x00/028-rt2x00mmio-remove-legacy-comment.patch new file mode 100644 index 0000000000..fea745f3f5 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/028-rt2x00mmio-remove-legacy-comment.patch @@ -0,0 +1,23 @@ +From f44e145869bb517460648e4ed71b7e9001964d06 Mon Sep 17 00:00:00 2001 +From: Stanislaw Gruszka +Date: Sat, 9 Feb 2019 12:08:38 +0100 +Subject: [PATCH 28/28] rt2x00mmio: remove legacy comment + +Remove comment about fields that ware removed. + +Signed-off-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2x00mmio.h | 2 -- + 1 file changed, 2 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2x00mmio.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mmio.h +@@ -80,8 +80,6 @@ int rt2x00mmio_regbusy_read(struct rt2x0 + * + * @desc: Pointer to device descriptor + * @desc_dma: DMA pointer to &desc. +- * @data: Pointer to device's entry memory. +- * @data_dma: DMA pointer to &data. + */ + struct queue_entry_priv_mmio { + __le32 *desc; diff --git a/package/kernel/mac80211/patches/rt2x00/030-rt2x00_options.patch b/package/kernel/mac80211/patches/rt2x00/030-rt2x00_options.patch deleted file mode 100644 index 9dd348151c..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/030-rt2x00_options.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/drivers/net/wireless/ralink/rt2x00/Kconfig -+++ b/drivers/net/wireless/ralink/rt2x00/Kconfig -@@ -225,36 +225,37 @@ config RT2800SOC - - - config RT2800_LIB -- tristate -+ tristate "RT2800 USB/PCI support" - depends on m - - config RT2800_LIB_MMIO -- tristate -+ tristate "RT2800 MMIO support" - depends on m - select RT2X00_LIB_MMIO - select RT2800_LIB - - config RT2X00_LIB_MMIO -- tristate -+ tristate "RT2x00 MMIO support" - depends on m - - config RT2X00_LIB_PCI -- tristate -+ tristate "RT2x00 PCI support" - depends on m - select RT2X00_LIB - - config RT2X00_LIB_SOC -- tristate -+ tristate "RT2x00 SoC support" -+ depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 - depends on m - select RT2X00_LIB - - config RT2X00_LIB_USB -- tristate -+ tristate "RT2x00 USB support" - depends on m - select RT2X00_LIB - - config RT2X00_LIB -- tristate -+ tristate "RT2x00 support" - depends on m - - config RT2X00_LIB_FIRMWARE diff --git a/package/kernel/mac80211/patches/rt2x00/100-rt2x00_options.patch b/package/kernel/mac80211/patches/rt2x00/100-rt2x00_options.patch new file mode 100644 index 0000000000..9dd348151c --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/100-rt2x00_options.patch @@ -0,0 +1,47 @@ +--- a/drivers/net/wireless/ralink/rt2x00/Kconfig ++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig +@@ -225,36 +225,37 @@ config RT2800SOC + + + config RT2800_LIB +- tristate ++ tristate "RT2800 USB/PCI support" + depends on m + + config RT2800_LIB_MMIO +- tristate ++ tristate "RT2800 MMIO support" + depends on m + select RT2X00_LIB_MMIO + select RT2800_LIB + + config RT2X00_LIB_MMIO +- tristate ++ tristate "RT2x00 MMIO support" + depends on m + + config RT2X00_LIB_PCI +- tristate ++ tristate "RT2x00 PCI support" + depends on m + select RT2X00_LIB + + config RT2X00_LIB_SOC +- tristate ++ tristate "RT2x00 SoC support" ++ depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 + depends on m + select RT2X00_LIB + + config RT2X00_LIB_USB +- tristate ++ tristate "RT2x00 USB support" + depends on m + select RT2X00_LIB + + config RT2X00_LIB +- tristate ++ tristate "RT2x00 support" + depends on m + + config RT2X00_LIB_FIRMWARE diff --git a/package/kernel/mac80211/patches/rt2x00/501-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/501-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch new file mode 100644 index 0000000000..699989baa0 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/501-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch @@ -0,0 +1,30 @@ +From 91094ed065f7794886b4a5490fd6de942f036bb4 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:26 +0100 +Subject: [PATCH] rt2x00: allow to build rt2800soc module for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/Kconfig ++++ b/drivers/net/wireless/ralink/rt2x00/Kconfig +@@ -210,7 +210,7 @@ endif + config RT2800SOC + tristate "Ralink WiSoC support" + depends on m +- depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 ++ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883 || SOC_MT7620 + select RT2X00_LIB_SOC + select RT2X00_LIB_MMIO + select RT2X00_LIB_CRYPTO +@@ -245,7 +245,7 @@ config RT2X00_LIB_PCI + + config RT2X00_LIB_SOC + tristate "RT2x00 SoC support" +- depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 ++ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883 || SOC_MT7620 + depends on m + select RT2X00_LIB + diff --git a/package/kernel/mac80211/patches/rt2x00/502-rt2x00-rt2800lib-enable-support-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/502-rt2x00-rt2800lib-enable-support-for-RT3883.patch new file mode 100644 index 0000000000..95cdc7fa6a --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/502-rt2x00-rt2800lib-enable-support-for-RT3883.patch @@ -0,0 +1,20 @@ +From 4f16582c93a71eba9d389e0f0a8aa9099a9587cd Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:26 +0100 +Subject: [PATCH] rt2x00: rt2800lib: enable support for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -9578,6 +9578,7 @@ static int rt2800_probe_rt(struct rt2x00 + case RT3390: + case RT3572: + case RT3593: ++ case RT3883: + case RT5350: + case RT5390: + case RT5392: diff --git a/package/kernel/mac80211/patches/rt2x00/503-rt2x00-rt2800lib-add-rf_vals-for-RF3853.patch b/package/kernel/mac80211/patches/rt2x00/503-rt2x00-rt2800lib-add-rf_vals-for-RF3853.patch new file mode 100644 index 0000000000..160319633b --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/503-rt2x00-rt2800lib-add-rf_vals-for-RF3853.patch @@ -0,0 +1,112 @@ +From ecb394ccf248d8652c463133c4f404458a57a9c1 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:26 +0100 +Subject: [PATCH] rt2x00: rt2800lib: add rf_vals for RF3853 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800.h | 4 +- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 65 +++++++++++++++++++++++++++++++ + 2 files changed, 68 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h +@@ -48,7 +48,8 @@ + * RF2853 2.4G/5G 3T3R + * RF3320 2.4G 1T1R(RT3350/RT3370/RT3390) + * RF3322 2.4G 2T2R(RT3352/RT3371/RT3372/RT3391/RT3392) +- * RF3053 2.4G/5G 3T3R(RT3883/RT3563/RT3573/RT3593/RT3662) ++ * RF3053 2.4G/5G 3T3R(RT3563/RT3573/RT3593) ++ * RF3853 2.4G/5G 3T3R(RT3883/RT3662) + * RF5592 2.4G/5G 2T2R + * RF3070 2.4G 1T1R + * RF5360 2.4G 1T1R +@@ -72,6 +73,7 @@ + #define RF5592 0x000f + #define RF3070 0x3070 + #define RF3290 0x3290 ++#define RF3853 0x3853 + #define RF5350 0x5350 + #define RF5360 0x5360 + #define RF5362 0x5362 +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -9154,6 +9154,66 @@ static const struct rf_channel rf_vals_3 + {14, 0xF0, 2, 0x18}, + }; + ++static const struct rf_channel rf_vals_3853[] = { ++ {1, 241, 6, 2}, ++ {2, 241, 6, 7}, ++ {3, 242, 6, 2}, ++ {4, 242, 6, 7}, ++ {5, 243, 6, 2}, ++ {6, 243, 6, 7}, ++ {7, 244, 6, 2}, ++ {8, 244, 6, 7}, ++ {9, 245, 6, 2}, ++ {10, 245, 6, 7}, ++ {11, 246, 6, 2}, ++ {12, 246, 6, 7}, ++ {13, 247, 6, 2}, ++ {14, 248, 6, 4}, ++ ++ {36, 0x56, 8, 4}, ++ {38, 0x56, 8, 6}, ++ {40, 0x56, 8, 8}, ++ {44, 0x57, 8, 0}, ++ {46, 0x57, 8, 2}, ++ {48, 0x57, 8, 4}, ++ {52, 0x57, 8, 8}, ++ {54, 0x57, 8, 10}, ++ {56, 0x58, 8, 0}, ++ {60, 0x58, 8, 4}, ++ {62, 0x58, 8, 6}, ++ {64, 0x58, 8, 8}, ++ ++ {100, 0x5b, 8, 8}, ++ {102, 0x5b, 8, 10}, ++ {104, 0x5c, 8, 0}, ++ {108, 0x5c, 8, 4}, ++ {110, 0x5c, 8, 6}, ++ {112, 0x5c, 8, 8}, ++ {114, 0x5c, 8, 10}, ++ {116, 0x5d, 8, 0}, ++ {118, 0x5d, 8, 2}, ++ {120, 0x5d, 8, 4}, ++ {124, 0x5d, 8, 8}, ++ {126, 0x5d, 8, 10}, ++ {128, 0x5e, 8, 0}, ++ {132, 0x5e, 8, 4}, ++ {134, 0x5e, 8, 6}, ++ {136, 0x5e, 8, 8}, ++ {140, 0x5f, 8, 0}, ++ ++ {149, 0x5f, 8, 9}, ++ {151, 0x5f, 8, 11}, ++ {153, 0x60, 8, 1}, ++ {157, 0x60, 8, 5}, ++ {159, 0x60, 8, 7}, ++ {161, 0x60, 8, 9}, ++ {165, 0x61, 8, 1}, ++ {167, 0x61, 8, 3}, ++ {169, 0x61, 8, 5}, ++ {171, 0x61, 8, 7}, ++ {173, 0x61, 8, 9}, ++}; ++ + static const struct rf_channel rf_vals_5592_xtal20[] = { + /* Channel, N, K, mod, R */ + {1, 482, 4, 10, 3}, +@@ -9417,6 +9477,11 @@ static int rt2800_probe_hw_mode(struct r + spec->channels = rf_vals_3x; + break; + ++ case RF3853: ++ spec->num_channels = ARRAY_SIZE(rf_vals_3853); ++ spec->channels = rf_vals_3853; ++ break; ++ + case RF5592: + reg = rt2800_register_read(rt2x00dev, MAC_DEBUG_INDEX); + if (rt2x00_get_field32(reg, MAC_DEBUG_INDEX_XTAL)) { diff --git a/package/kernel/mac80211/patches/rt2x00/504-rt2x00-rt2800lib-enable-VCO-calibration-for-RF3853.patch b/package/kernel/mac80211/patches/rt2x00/504-rt2x00-rt2800lib-enable-VCO-calibration-for-RF3853.patch new file mode 100644 index 0000000000..dbe592646b --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/504-rt2x00-rt2800lib-enable-VCO-calibration-for-RF3853.patch @@ -0,0 +1,28 @@ +From f8e3fcf18e1f2d7f9e6a9680c5452da090f33d88 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Thu, 1 Aug 2013 14:40:44 +0200 +Subject: [PATCH] rt2x00: rt2800lib: enable VCO calibration for RF3853 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -5051,6 +5051,7 @@ void rt2800_vco_calibration(struct rt2x0 + case RF3053: + case RF3070: + case RF3290: ++ case RF3853: + case RF5350: + case RF5360: + case RF5362: +@@ -9601,6 +9602,7 @@ static int rt2800_probe_hw_mode(struct r + case RF3053: + case RF3070: + case RF3290: ++ case RF3853: + case RF5350: + case RF5360: + case RF5362: diff --git a/package/kernel/mac80211/patches/rt2x00/505-rt2x00-rt2800lib-add-channel-configuration-function-.patch b/package/kernel/mac80211/patches/rt2x00/505-rt2x00-rt2800lib-add-channel-configuration-function-.patch new file mode 100644 index 0000000000..dc538df484 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/505-rt2x00-rt2800lib-add-channel-configuration-function-.patch @@ -0,0 +1,235 @@ +From 6e3a17190815c6aa4dc53c2cfe9125fb1154f187 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:27 +0100 +Subject: [PATCH] rt2x00: rt2800lib: add channel configuration function for + RF3853 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 208 +++++++++++++++++++++++++++++++ + 1 file changed, 208 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -2880,6 +2880,211 @@ static void rt2800_config_channel_rf3053 + } + } + ++static void rt2800_config_channel_rf3853(struct rt2x00_dev *rt2x00dev, ++ struct ieee80211_conf *conf, ++ struct rf_channel *rf, ++ struct channel_info *info) ++{ ++ u8 rfcsr; ++ u8 bbp; ++ u8 pwr1, pwr2, pwr3; ++ ++ const bool txbf_enabled = false; /* TODO */ ++ ++ /* TODO: add band selection */ ++ ++ if (rf->channel <= 14) ++ rt2800_rfcsr_write(rt2x00dev, 6, 0x40); ++ else if (rf->channel < 132) ++ rt2800_rfcsr_write(rt2x00dev, 6, 0x80); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 6, 0x40); ++ ++ rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); ++ rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); ++ ++ if (rf->channel <= 14) ++ rt2800_rfcsr_write(rt2x00dev, 11, 0x46); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 11, 0x48); ++ ++ if (rf->channel <= 14) ++ rt2800_rfcsr_write(rt2x00dev, 12, 0x1a); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 12, 0x52); ++ ++ rt2800_rfcsr_write(rt2x00dev, 13, 0x12); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 1); ++ rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 0); ++ rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 0); ++ rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 0); ++ rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 0); ++ rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 0); ++ rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 0); ++ rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1); ++ rt2x00_set_field8(&rfcsr, RFCSR1_PLL_PD, 1); ++ ++ switch (rt2x00dev->default_ant.tx_chain_num) { ++ case 3: ++ rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 1); ++ /* fallthrough */ ++ case 2: ++ rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 1); ++ /* fallthrough */ ++ case 1: ++ rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 1); ++ break; ++ } ++ ++ switch (rt2x00dev->default_ant.rx_chain_num) { ++ case 3: ++ rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 1); ++ /* fallthrough */ ++ case 2: ++ rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 1); ++ /* fallthrough */ ++ case 1: ++ rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 1); ++ break; ++ } ++ rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); ++ ++ rt2800_freq_cal_mode1(rt2x00dev); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 30); ++ if (!conf_is_ht40(conf)) ++ rfcsr &= ~(0x06); ++ else ++ rfcsr |= 0x06; ++ rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); ++ ++ if (rf->channel <= 14) ++ rt2800_rfcsr_write(rt2x00dev, 31, 0xa0); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 31, 0x80); ++ ++ if (conf_is_ht40(conf)) ++ rt2800_rfcsr_write(rt2x00dev, 32, 0x80); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 32, 0xd8); ++ ++ if (rf->channel <= 14) ++ rt2800_rfcsr_write(rt2x00dev, 34, 0x3c); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 34, 0x20); ++ ++ /* loopback RF_BS */ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 36); ++ if (rf->channel <= 14) ++ rt2x00_set_field8(&rfcsr, RFCSR36_RF_BS, 1); ++ else ++ rt2x00_set_field8(&rfcsr, RFCSR36_RF_BS, 0); ++ rt2800_rfcsr_write(rt2x00dev, 36, rfcsr); ++ ++ if (rf->channel <= 14) ++ rfcsr = 0x23; ++ else if (rf->channel < 100) ++ rfcsr = 0x36; ++ else if (rf->channel < 132) ++ rfcsr = 0x32; ++ else ++ rfcsr = 0x30; ++ ++ if (txbf_enabled) ++ rfcsr |= 0x40; ++ ++ rt2800_rfcsr_write(rt2x00dev, 39, rfcsr); ++ ++ if (rf->channel <= 14) ++ rt2800_rfcsr_write(rt2x00dev, 44, 0x93); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 44, 0x9b); ++ ++ if (rf->channel <= 14) ++ rfcsr = 0xbb; ++ else if (rf->channel < 100) ++ rfcsr = 0xeb; ++ else if (rf->channel < 132) ++ rfcsr = 0xb3; ++ else ++ rfcsr = 0x9b; ++ rt2800_rfcsr_write(rt2x00dev, 45, rfcsr); ++ ++ if (rf->channel <= 14) ++ rfcsr = 0x8e; ++ else ++ rfcsr = 0x8a; ++ ++ if (txbf_enabled) ++ rfcsr |= 0x20; ++ ++ rt2800_rfcsr_write(rt2x00dev, 49, rfcsr); ++ ++ rt2800_rfcsr_write(rt2x00dev, 50, 0x86); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 51); ++ if (rf->channel <= 14) ++ rt2800_rfcsr_write(rt2x00dev, 51, 0x75); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 51, 0x51); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 52); ++ if (rf->channel <= 14) ++ rt2800_rfcsr_write(rt2x00dev, 52, 0x45); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 52, 0x05); ++ ++ if (rf->channel <= 14) { ++ pwr1 = info->default_power1 & 0x1f; ++ pwr2 = info->default_power2 & 0x1f; ++ pwr3 = info->default_power3 & 0x1f; ++ } else { ++ pwr1 = 0x48 | ((info->default_power1 & 0x18) << 1) | ++ (info->default_power1 & 0x7); ++ pwr2 = 0x48 | ((info->default_power2 & 0x18) << 1) | ++ (info->default_power2 & 0x7); ++ pwr3 = 0x48 | ((info->default_power3 & 0x18) << 1) | ++ (info->default_power3 & 0x7); ++ } ++ ++ rt2800_rfcsr_write(rt2x00dev, 53, pwr1); ++ rt2800_rfcsr_write(rt2x00dev, 54, pwr2); ++ rt2800_rfcsr_write(rt2x00dev, 55, pwr3); ++ ++ rt2x00_dbg(rt2x00dev, "Channel:%d, pwr1:%02x, pwr2:%02x, pwr3:%02x\n", ++ rf->channel, pwr1, pwr2, pwr3); ++ ++ bbp = (info->default_power1 >> 5) | ++ ((info->default_power2 & 0xe0) >> 1); ++ rt2800_bbp_write(rt2x00dev, 109, bbp); ++ ++ bbp = rt2800_bbp_read(rt2x00dev, 110); ++ bbp &= 0x0f; ++ bbp |= (info->default_power3 & 0xe0) >> 1; ++ rt2800_bbp_write(rt2x00dev, 110, bbp); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 57); ++ if (rf->channel <= 14) ++ rt2800_rfcsr_write(rt2x00dev, 57, 0x6e); ++ else ++ rt2800_rfcsr_write(rt2x00dev, 57, 0x3e); ++ ++ /* Enable RF tuning */ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 3); ++ rt2x00_set_field8(&rfcsr, RFCSR3_VCOCAL_EN, 1); ++ rt2800_rfcsr_write(rt2x00dev, 3, rfcsr); ++ ++ udelay(2000); ++ ++ bbp = rt2800_bbp_read(rt2x00dev, 49); ++ /* clear update flag */ ++ rt2800_bbp_write(rt2x00dev, 49, bbp & 0xfe); ++ rt2800_bbp_write(rt2x00dev, 49, bbp); ++ ++ /* TODO: add calibration for TxBF */ ++} ++ + #define POWER_BOUND 0x27 + #define POWER_BOUND_5G 0x2b + +@@ -3734,6 +3939,9 @@ static void rt2800_config_channel(struct + case RF3322: + rt2800_config_channel_rf3322(rt2x00dev, conf, rf, info); + break; ++ case RF3853: ++ rt2800_config_channel_rf3853(rt2x00dev, conf, rf, info); ++ break; + case RF3070: + case RF5350: + case RF5360: diff --git a/package/kernel/mac80211/patches/rt2x00/506-rt2x00-rt2800lib-enable-RF3853-support.patch b/package/kernel/mac80211/patches/rt2x00/506-rt2x00-rt2800lib-enable-RF3853-support.patch new file mode 100644 index 0000000000..c6ffd7a374 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/506-rt2x00-rt2800lib-enable-RF3853-support.patch @@ -0,0 +1,20 @@ +From afd38ae82226551bf879b6c7c4b620c271fee9d2 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Thu, 1 Aug 2013 14:42:05 +0200 +Subject: [PATCH] rt2x00: rt2800lib: enable RF3853 support + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -9077,6 +9077,7 @@ static int rt2800_init_eeprom(struct rt2 + case RF3290: + case RF3320: + case RF3322: ++ case RF3853: + case RF5350: + case RF5360: + case RF5362: diff --git a/package/kernel/mac80211/patches/rt2x00/507-rt2x00-rt2800lib-add-MAC-register-initialization-for.patch b/package/kernel/mac80211/patches/rt2x00/507-rt2x00-rt2800lib-add-MAC-register-initialization-for.patch new file mode 100644 index 0000000000..102374a474 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/507-rt2x00-rt2800lib-add-MAC-register-initialization-for.patch @@ -0,0 +1,62 @@ +From 0094872a5e8e4664c6ea1b2dfa487063d39ae363 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:26 +0100 +Subject: [PATCH] rt2x00: rt2800lib: add MAC register initialization for + RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800.h | 14 ++++++++++++++ + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 19 ++++++++++++++++--- + 2 files changed, 30 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h +@@ -1728,6 +1728,20 @@ + #define TX_PWR_CFG_9B_STBC_MCS7 FIELD32(0x000000ff) + + /* ++ * TX_TXBF_CFG: ++ */ ++#define TX_TXBF_CFG_0 0x138c ++#define TX_TXBF_CFG_1 0x13a4 ++#define TX_TXBF_CFG_2 0x13a8 ++#define TX_TXBF_CFG_3 0x13ac ++ ++/* ++ * TX_FBK_CFG_3S: ++ */ ++#define TX_FBK_CFG_3S_0 0x13c4 ++#define TX_FBK_CFG_3S_1 0x13c8 ++ ++/* + * RX_FILTER_CFG: RX configuration register. + */ + #define RX_FILTER_CFG 0x1400 +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -5679,6 +5679,12 @@ static int rt2800_init_registers(struct + rt2800_register_write(rt2x00dev, TX_SW_CFG2, + 0x00000000); + } ++ } else if (rt2x00_rt(rt2x00dev, RT3883)) { ++ rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000402); ++ rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000); ++ rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00040000); ++ rt2800_register_write(rt2x00dev, TX_TXBF_CFG_0, 0x8000fc21); ++ rt2800_register_write(rt2x00dev, TX_TXBF_CFG_3, 0x00009c40); + } else if (rt2x00_rt(rt2x00dev, RT5390) || + rt2x00_rt(rt2x00dev, RT5392) || + rt2x00_rt(rt2x00dev, RT6352)) { +@@ -5892,6 +5898,11 @@ static int rt2800_init_registers(struct + reg = rt2x00_rt(rt2x00dev, RT5592) ? 0x00000082 : 0x00000002; + rt2800_register_write(rt2x00dev, TXOP_HLDR_ET, reg); + ++ if (rt2x00_rt(rt2x00dev, RT3883)) { ++ rt2800_register_write(rt2x00dev, TX_FBK_CFG_3S_0, 0x12111008); ++ rt2800_register_write(rt2x00dev, TX_FBK_CFG_3S_1, 0x16151413); ++ } ++ + reg = rt2800_register_read(rt2x00dev, TX_RTS_CFG); + rt2x00_set_field32(®, TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT, 7); + rt2x00_set_field32(®, TX_RTS_CFG_RTS_THRES, diff --git a/package/kernel/mac80211/patches/rt2x00/508-rt2x00-rt2800soc-fix-rt2800soc_disable_radio-for-RT3.patch b/package/kernel/mac80211/patches/rt2x00/508-rt2x00-rt2800soc-fix-rt2800soc_disable_radio-for-RT3.patch new file mode 100644 index 0000000000..d68ad50447 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/508-rt2x00-rt2800soc-fix-rt2800soc_disable_radio-for-RT3.patch @@ -0,0 +1,30 @@ +From 6c2d32478159fffff0b85abb6817a21bb2338231 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:27 +0100 +Subject: [PATCH] rt2x00: rt2800soc: fix rt2800soc_disable_radio for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800soc.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c +@@ -51,9 +51,16 @@ static bool rt2800soc_hwcrypt_disabled(s + + static void rt2800soc_disable_radio(struct rt2x00_dev *rt2x00dev) + { ++ u32 reg; ++ + rt2800_disable_radio(rt2x00dev); + rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0); +- rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, 0); ++ ++ reg = 0; ++ if (rt2x00_rt(rt2x00dev, RT3883)) ++ rt2x00_set_field32(®, TX_PIN_CFG_RFTR_EN, 1); ++ ++ rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, reg); + } + + static int rt2800soc_set_device_state(struct rt2x00_dev *rt2x00dev, diff --git a/package/kernel/mac80211/patches/rt2x00/509-rt2x00-rt2800lib-add-BBP-register-initialization-for.patch b/package/kernel/mac80211/patches/rt2x00/509-rt2x00-rt2800lib-add-BBP-register-initialization-for.patch new file mode 100644 index 0000000000..3879d0f712 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/509-rt2x00-rt2800lib-add-BBP-register-initialization-for.patch @@ -0,0 +1,71 @@ +From 84833056aa7dd25f5b097e31c78f2a0914c5160c Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:26 +0100 +Subject: [PATCH] rt2x00: rt2800lib: add BBP register initialization for + RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 44 +++++++++++++++++++++++++++++++ + 1 file changed, 44 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -6519,6 +6519,47 @@ static void rt2800_init_bbp_3593(struct + rt2800_bbp_write(rt2x00dev, 103, 0xc0); + } + ++static void rt2800_init_bbp_3883(struct rt2x00_dev *rt2x00dev) ++{ ++ rt2800_init_bbp_early(rt2x00dev); ++ ++ rt2800_bbp_write(rt2x00dev, 4, 0x50); ++ rt2800_bbp_write(rt2x00dev, 47, 0x48); ++ ++ rt2800_bbp_write(rt2x00dev, 86, 0x46); ++ rt2800_bbp_write(rt2x00dev, 88, 0x90); ++ ++ rt2800_bbp_write(rt2x00dev, 92, 0x02); ++ ++ rt2800_bbp_write(rt2x00dev, 103, 0xc0); ++ rt2800_bbp_write(rt2x00dev, 104, 0x92); ++ rt2800_bbp_write(rt2x00dev, 105, 0x34); ++ rt2800_bbp_write(rt2x00dev, 106, 0x12); ++ rt2800_bbp_write(rt2x00dev, 120, 0x50); ++ rt2800_bbp_write(rt2x00dev, 137, 0x0f); ++ rt2800_bbp_write(rt2x00dev, 163, 0x9d); ++ ++ /* Set ITxBF timeout to 0x9C40=1000msec */ ++ rt2800_bbp_write(rt2x00dev, 179, 0x02); ++ rt2800_bbp_write(rt2x00dev, 180, 0x00); ++ rt2800_bbp_write(rt2x00dev, 182, 0x40); ++ rt2800_bbp_write(rt2x00dev, 180, 0x01); ++ rt2800_bbp_write(rt2x00dev, 182, 0x9c); ++ ++ rt2800_bbp_write(rt2x00dev, 179, 0x00); ++ ++ /* Reprogram the inband interface to put right values in RXWI */ ++ rt2800_bbp_write(rt2x00dev, 142, 0x04); ++ rt2800_bbp_write(rt2x00dev, 143, 0x3b); ++ rt2800_bbp_write(rt2x00dev, 142, 0x06); ++ rt2800_bbp_write(rt2x00dev, 143, 0xa0); ++ rt2800_bbp_write(rt2x00dev, 142, 0x07); ++ rt2800_bbp_write(rt2x00dev, 143, 0xa1); ++ rt2800_bbp_write(rt2x00dev, 142, 0x08); ++ rt2800_bbp_write(rt2x00dev, 143, 0xa2); ++ rt2800_bbp_write(rt2x00dev, 148, 0xc8); ++} ++ + static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev) + { + int ant, div_mode; +@@ -6963,6 +7004,9 @@ static void rt2800_init_bbp(struct rt2x0 + case RT3593: + rt2800_init_bbp_3593(rt2x00dev); + return; ++ case RT3883: ++ rt2800_init_bbp_3883(rt2x00dev); ++ return; + case RT5390: + case RT5392: + rt2800_init_bbp_53xx(rt2x00dev); diff --git a/package/kernel/mac80211/patches/rt2x00/510-rt2x00-rt2800lib-add-RFCSR-initialization-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/510-rt2x00-rt2800lib-add-RFCSR-initialization-for-RT3883.patch new file mode 100644 index 0000000000..c3c37e902f --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/510-rt2x00-rt2800lib-add-RFCSR-initialization-for-RT3883.patch @@ -0,0 +1,178 @@ +From 99c659cf345640fd0f733cbcaf4583cc2c868ec0 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Mon, 29 Apr 2013 13:21:48 +0200 +Subject: [PATCH] rt2x00: rt2800lib: add RFCSR initialization for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800.h | 1 + + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 141 +++++++++++++++++++++++++++++++ + 2 files changed, 142 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h +@@ -2312,6 +2312,7 @@ struct mac_iveiv_entry { + /* + * RFCSR 2: + */ ++#define RFCSR2_RESCAL_BP FIELD8(0x40) + #define RFCSR2_RESCAL_EN FIELD8(0x80) + #define RFCSR2_RX2_EN_MT7620 FIELD8(0x02) + #define RFCSR2_TX2_EN_MT7620 FIELD8(0x20) +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -7878,6 +7878,144 @@ static void rt2800_init_rfcsr_5350(struc + rt2800_rfcsr_write(rt2x00dev, 63, 0x00); + } + ++static void rt2800_init_rfcsr_3883(struct rt2x00_dev *rt2x00dev) ++{ ++ u8 rfcsr; ++ ++ /* TODO: get the actual ECO value from the SoC */ ++ const unsigned int eco = 5; ++ ++ rt2800_rf_init_calibration(rt2x00dev, 2); ++ ++ rt2800_rfcsr_write(rt2x00dev, 0, 0xe0); ++ rt2800_rfcsr_write(rt2x00dev, 1, 0x03); ++ rt2800_rfcsr_write(rt2x00dev, 2, 0x50); ++ rt2800_rfcsr_write(rt2x00dev, 3, 0x20); ++ rt2800_rfcsr_write(rt2x00dev, 4, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 5, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 6, 0x40); ++ rt2800_rfcsr_write(rt2x00dev, 7, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 8, 0x5b); ++ rt2800_rfcsr_write(rt2x00dev, 9, 0x08); ++ rt2800_rfcsr_write(rt2x00dev, 10, 0xd3); ++ rt2800_rfcsr_write(rt2x00dev, 11, 0x48); ++ rt2800_rfcsr_write(rt2x00dev, 12, 0x1a); ++ rt2800_rfcsr_write(rt2x00dev, 13, 0x12); ++ rt2800_rfcsr_write(rt2x00dev, 14, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 15, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 16, 0x00); ++ ++ /* RFCSR 17 will be initialized later based on the ++ * frequency offset stored in the EEPROM ++ */ ++ ++ rt2800_rfcsr_write(rt2x00dev, 18, 0x40); ++ rt2800_rfcsr_write(rt2x00dev, 19, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 20, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 21, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 22, 0x20); ++ rt2800_rfcsr_write(rt2x00dev, 23, 0xc0); ++ rt2800_rfcsr_write(rt2x00dev, 24, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 25, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 26, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 27, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 28, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 29, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 30, 0x10); ++ rt2800_rfcsr_write(rt2x00dev, 31, 0x80); ++ rt2800_rfcsr_write(rt2x00dev, 32, 0x80); ++ rt2800_rfcsr_write(rt2x00dev, 33, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 34, 0x20); ++ rt2800_rfcsr_write(rt2x00dev, 35, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 36, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 37, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 38, 0x86); ++ rt2800_rfcsr_write(rt2x00dev, 39, 0x23); ++ rt2800_rfcsr_write(rt2x00dev, 40, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 41, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 42, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 43, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 44, 0x93); ++ rt2800_rfcsr_write(rt2x00dev, 45, 0xbb); ++ rt2800_rfcsr_write(rt2x00dev, 46, 0x60); ++ rt2800_rfcsr_write(rt2x00dev, 47, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 48, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 49, 0x8e); ++ rt2800_rfcsr_write(rt2x00dev, 50, 0x86); ++ rt2800_rfcsr_write(rt2x00dev, 51, 0x51); ++ rt2800_rfcsr_write(rt2x00dev, 52, 0x05); ++ rt2800_rfcsr_write(rt2x00dev, 53, 0x76); ++ rt2800_rfcsr_write(rt2x00dev, 54, 0x76); ++ rt2800_rfcsr_write(rt2x00dev, 55, 0x76); ++ rt2800_rfcsr_write(rt2x00dev, 56, 0xdb); ++ rt2800_rfcsr_write(rt2x00dev, 57, 0x3e); ++ rt2800_rfcsr_write(rt2x00dev, 58, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 59, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 60, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 61, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 62, 0x00); ++ rt2800_rfcsr_write(rt2x00dev, 63, 0x00); ++ ++ /* TODO: rx filter calibration? */ ++ ++ rt2800_bbp_write(rt2x00dev, 137, 0x0f); ++ ++ rt2800_bbp_write(rt2x00dev, 163, 0x9d); ++ ++ rt2800_bbp_write(rt2x00dev, 105, 0x05); ++ ++ rt2800_bbp_write(rt2x00dev, 179, 0x02); ++ rt2800_bbp_write(rt2x00dev, 180, 0x00); ++ rt2800_bbp_write(rt2x00dev, 182, 0x40); ++ rt2800_bbp_write(rt2x00dev, 180, 0x01); ++ rt2800_bbp_write(rt2x00dev, 182, 0x9c); ++ ++ rt2800_bbp_write(rt2x00dev, 179, 0x00); ++ ++ rt2800_bbp_write(rt2x00dev, 142, 0x04); ++ rt2800_bbp_write(rt2x00dev, 143, 0x3b); ++ rt2800_bbp_write(rt2x00dev, 142, 0x06); ++ rt2800_bbp_write(rt2x00dev, 143, 0xa0); ++ rt2800_bbp_write(rt2x00dev, 142, 0x07); ++ rt2800_bbp_write(rt2x00dev, 143, 0xa1); ++ rt2800_bbp_write(rt2x00dev, 142, 0x08); ++ rt2800_bbp_write(rt2x00dev, 143, 0xa2); ++ rt2800_bbp_write(rt2x00dev, 148, 0xc8); ++ ++ if (eco == 5) { ++ rt2800_rfcsr_write(rt2x00dev, 32, 0xd8); ++ rt2800_rfcsr_write(rt2x00dev, 33, 0x32); ++ } ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 2); ++ rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_BP, 0); ++ rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 1); ++ rt2800_rfcsr_write(rt2x00dev, 2, rfcsr); ++ msleep(1); ++ rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 0); ++ rt2800_rfcsr_write(rt2x00dev, 2, rfcsr); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 1); ++ rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1); ++ rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 6); ++ rfcsr |= 0xc0; ++ rt2800_rfcsr_write(rt2x00dev, 6, rfcsr); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 22); ++ rfcsr |= 0x20; ++ rt2800_rfcsr_write(rt2x00dev, 22, rfcsr); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 46); ++ rfcsr |= 0x20; ++ rt2800_rfcsr_write(rt2x00dev, 46, rfcsr); ++ ++ rfcsr = rt2800_rfcsr_read(rt2x00dev, 20); ++ rfcsr &= ~0xee; ++ rt2800_rfcsr_write(rt2x00dev, 20, rfcsr); ++} ++ + static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev) + { + rt2800_rf_init_calibration(rt2x00dev, 2); +@@ -8720,6 +8858,9 @@ static void rt2800_init_rfcsr(struct rt2 + case RT3390: + rt2800_init_rfcsr_3390(rt2x00dev); + break; ++ case RT3883: ++ rt2800_init_rfcsr_3883(rt2x00dev); ++ break; + case RT3572: + rt2800_init_rfcsr_3572(rt2x00dev); + break; diff --git a/package/kernel/mac80211/patches/rt2x00/511-rt2x00-rt2800lib-use-the-extended-EEPROM-map-for-RT3.patch b/package/kernel/mac80211/patches/rt2x00/511-rt2x00-rt2800lib-use-the-extended-EEPROM-map-for-RT3.patch new file mode 100644 index 0000000000..e74f399e65 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/511-rt2x00-rt2800lib-use-the-extended-EEPROM-map-for-RT3.patch @@ -0,0 +1,22 @@ +From 86022438ffeb1b87dfcd018bf477fdbb43076691 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Wed, 8 May 2013 19:35:33 +0200 +Subject: [PATCH] rt2x00: rt2800lib: use the extended EEPROM map for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -381,7 +381,8 @@ static unsigned int rt2800_eeprom_word_i + wiphy_name(rt2x00dev->hw->wiphy), word)) + return 0; + +- if (rt2x00_rt(rt2x00dev, RT3593)) ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + map = rt2800_eeprom_map_ext; + else + map = rt2800_eeprom_map; diff --git a/package/kernel/mac80211/patches/rt2x00/512-rt2x00-rt2800lib-force-rf-type-to-RF3853-on-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/512-rt2x00-rt2800lib-force-rf-type-to-RF3853-on-RT3883.patch new file mode 100644 index 0000000000..62a199d61f --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/512-rt2x00-rt2800lib-force-rf-type-to-RF3853-on-RT3883.patch @@ -0,0 +1,21 @@ +From 4cf5403f02fa65dc2207f61d223cffa9ae50e907 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Thu, 1 Aug 2013 14:48:21 +0200 +Subject: [PATCH] rt2x00: rt2800lib: force rf type to RF3853 on RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -9254,6 +9254,8 @@ static int rt2800_init_eeprom(struct rt2 + rf = rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID); + else if (rt2x00_rt(rt2x00dev, RT3352)) + rf = RF3322; ++ else if (rt2x00_rt(rt2x00dev, RT3883)) ++ rf = RF3853; + else if (rt2x00_rt(rt2x00dev, RT5350)) + rf = RF5350; + else diff --git a/package/kernel/mac80211/patches/rt2x00/513-rt2x00-rt2800lib-add-channel-configuration-code-for-.patch b/package/kernel/mac80211/patches/rt2x00/513-rt2x00-rt2800lib-add-channel-configuration-code-for-.patch new file mode 100644 index 0000000000..2b0869099e --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/513-rt2x00-rt2800lib-add-channel-configuration-code-for-.patch @@ -0,0 +1,136 @@ +From 269f19c848a2380db03a3f207cafb88e28d71c53 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:28 +0100 +Subject: [PATCH] rt2x00: rt2800lib: add channel configuration code for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 72 +++++++++++++++++++++++++++++-- + 1 file changed, 69 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -3902,6 +3902,36 @@ static char rt2800_txpower_to_dev(struct + return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER); + } + ++static void rt3883_bbp_adjust(struct rt2x00_dev *rt2x00dev, ++ struct rf_channel *rf) ++{ ++ u8 bbp; ++ ++ bbp = (rf->channel > 14) ? 0x48 : 0x38; ++ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); ++ ++ rt2800_bbp_write(rt2x00dev, 69, 0x12); ++ ++ if (rf->channel <= 14) { ++ rt2800_bbp_write(rt2x00dev, 70, 0x0a); ++ } else { ++ /* Disable CCK packet detection */ ++ rt2800_bbp_write(rt2x00dev, 70, 0x00); ++ } ++ ++ rt2800_bbp_write(rt2x00dev, 73, 0x10); ++ ++ if (rf->channel > 14) { ++ rt2800_bbp_write(rt2x00dev, 62, 0x1d); ++ rt2800_bbp_write(rt2x00dev, 63, 0x1d); ++ rt2800_bbp_write(rt2x00dev, 64, 0x1d); ++ } else { ++ rt2800_bbp_write(rt2x00dev, 62, 0x2d); ++ rt2800_bbp_write(rt2x00dev, 63, 0x2d); ++ rt2800_bbp_write(rt2x00dev, 64, 0x2d); ++ } ++} ++ + static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, + struct ieee80211_conf *conf, + struct rf_channel *rf, +@@ -3920,6 +3950,12 @@ static void rt2800_config_channel(struct + rt2800_txpower_to_dev(rt2x00dev, rf->channel, + info->default_power3); + ++ switch (rt2x00dev->chip.rt) { ++ case RT3883: ++ rt3883_bbp_adjust(rt2x00dev, rf); ++ break; ++ } ++ + switch (rt2x00dev->chip.rf) { + case RF2020: + case RF3020: +@@ -4024,6 +4060,15 @@ static void rt2800_config_channel(struct + rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); + rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); + rt2800_bbp_write(rt2x00dev, 77, 0x98); ++ } else if (rt2x00_rt(rt2x00dev, RT3883)) { ++ rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); ++ rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); ++ rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); ++ ++ if (rt2x00dev->default_ant.rx_chain_num > 1) ++ rt2800_bbp_write(rt2x00dev, 86, 0x46); ++ else ++ rt2800_bbp_write(rt2x00dev, 86, 0); + } else { + rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); + rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); +@@ -4037,6 +4082,7 @@ static void rt2800_config_channel(struct + !rt2x00_rt(rt2x00dev, RT6352)) { + if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { + rt2800_bbp_write(rt2x00dev, 82, 0x62); ++ rt2800_bbp_write(rt2x00dev, 82, 0x62); + rt2800_bbp_write(rt2x00dev, 75, 0x46); + } else { + if (rt2x00_rt(rt2x00dev, RT3593)) +@@ -4045,19 +4091,22 @@ static void rt2800_config_channel(struct + rt2800_bbp_write(rt2x00dev, 82, 0x84); + rt2800_bbp_write(rt2x00dev, 75, 0x50); + } +- if (rt2x00_rt(rt2x00dev, RT3593)) ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + rt2800_bbp_write(rt2x00dev, 83, 0x8a); + } + + } else { + if (rt2x00_rt(rt2x00dev, RT3572)) + rt2800_bbp_write(rt2x00dev, 82, 0x94); +- else if (rt2x00_rt(rt2x00dev, RT3593)) ++ else if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + rt2800_bbp_write(rt2x00dev, 82, 0x82); + else if (!rt2x00_rt(rt2x00dev, RT6352)) + rt2800_bbp_write(rt2x00dev, 82, 0xf2); + +- if (rt2x00_rt(rt2x00dev, RT3593)) ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + rt2800_bbp_write(rt2x00dev, 83, 0x9a); + + if (rt2x00_has_cap_external_lna_a(rt2x00dev)) +@@ -4190,6 +4239,23 @@ static void rt2800_config_channel(struct + + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); + ++ usleep_range(1000, 1500); ++ } ++ ++ if (rt2x00_rt(rt2x00dev, RT3883)) { ++ if (!conf_is_ht40(conf)) ++ rt2800_bbp_write(rt2x00dev, 105, 0x34); ++ else ++ rt2800_bbp_write(rt2x00dev, 105, 0x04); ++ ++ /* AGC init */ ++ if (rf->channel <= 14) ++ reg = 0x2e + rt2x00dev->lna_gain; ++ else ++ reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3); ++ ++ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); ++ + usleep_range(1000, 1500); + } + diff --git a/package/kernel/mac80211/patches/rt2x00/514-rt2x00-rt2800lib-fix-txpower_to_dev-function-for-RT3.patch b/package/kernel/mac80211/patches/rt2x00/514-rt2x00-rt2800lib-fix-txpower_to_dev-function-for-RT3.patch new file mode 100644 index 0000000000..48283ce709 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/514-rt2x00-rt2800lib-fix-txpower_to_dev-function-for-RT3.patch @@ -0,0 +1,30 @@ +From e37d93abaabe3ab72b0332a18092acc162307274 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Mon, 30 Sep 2013 13:57:26 +0200 +Subject: [PATCH] rt2x00: rt2800lib: fix txpower_to_dev function for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -3889,13 +3889,15 @@ static char rt2800_txpower_to_dev(struct + unsigned int channel, + char txpower) + { +- if (rt2x00_rt(rt2x00dev, RT3593)) ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + txpower = rt2x00_get_field8(txpower, EEPROM_TXPOWER_ALC); + + if (channel <= 14) + return clamp_t(char, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER); + +- if (rt2x00_rt(rt2x00dev, RT3593)) ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + return clamp_t(char, txpower, MIN_A_TXPOWER_3593, + MAX_A_TXPOWER_3593); + else diff --git a/package/kernel/mac80211/patches/rt2x00/515-rt2x00-rt2800lib-use-correct-txpower-calculation-fun.patch b/package/kernel/mac80211/patches/rt2x00/515-rt2x00-rt2800lib-use-correct-txpower-calculation-fun.patch new file mode 100644 index 0000000000..a764c91f1b --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/515-rt2x00-rt2800lib-use-correct-txpower-calculation-fun.patch @@ -0,0 +1,23 @@ +From c4d79e344bd580d85821390d49f92dced7d8e125 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sun, 24 Mar 2013 19:26:29 +0100 +Subject: [PATCH] rt2x00: rt2800lib: use correct txpower calculation function + for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -5281,7 +5281,8 @@ static void rt2800_config_txpower(struct + struct ieee80211_channel *chan, + int power_level) + { +- if (rt2x00_rt(rt2x00dev, RT3593)) ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + rt2800_config_txpower_rt3593(rt2x00dev, chan, power_level); + else if (rt2x00_rt(rt2x00dev, RT6352)) + rt2800_config_txpower_rt6352(rt2x00dev, chan, power_level); diff --git a/package/kernel/mac80211/patches/rt2x00/516-rt2x00-rt2800lib-hardcode-txmixer-gain-values-to-zer.patch b/package/kernel/mac80211/patches/rt2x00/516-rt2x00-rt2800lib-hardcode-txmixer-gain-values-to-zer.patch new file mode 100644 index 0000000000..37239c31b2 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/516-rt2x00-rt2800lib-hardcode-txmixer-gain-values-to-zer.patch @@ -0,0 +1,33 @@ +From caea0671cd8fd9ade4f5969cbe0ee545e94ae105 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Sat, 24 Aug 2013 11:49:55 +0200 +Subject: [PATCH] rt2x00: rt2800lib: hardcode txmixer gain values to zero for + RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -9136,7 +9136,8 @@ static u8 rt2800_get_txmixer_gain_24g(st + { + u16 word; + +- if (rt2x00_rt(rt2x00dev, RT3593)) ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + return 0; + + word = rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG); +@@ -9150,7 +9151,8 @@ static u8 rt2800_get_txmixer_gain_5g(str + { + u16 word; + +- if (rt2x00_rt(rt2x00dev, RT3593)) ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + return 0; + + word = rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A); diff --git a/package/kernel/mac80211/patches/rt2x00/517-rt2x00-rt2800lib-use-correct-RT-XWI-size-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/517-rt2x00-rt2800lib-use-correct-RT-XWI-size-for-RT3883.patch new file mode 100644 index 0000000000..197aabd7bc --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/517-rt2x00-rt2800lib-use-correct-RT-XWI-size-for-RT3883.patch @@ -0,0 +1,20 @@ +From 11c40fb47c4a4dd6ad060c2ae127ced89ffb9fe1 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Thu, 18 Apr 2013 14:33:33 +0200 +Subject: [PATCH] rt2x00: rt2800lib: use correct [RT]XWI size for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -591,6 +591,7 @@ void rt2800_get_txwi_rxwi_size(struct rt + { + switch (rt2x00dev->chip.rt) { + case RT3593: ++ case RT3883: + *txwi_size = TXWI_DESC_SIZE_4WORDS; + *rxwi_size = RXWI_DESC_SIZE_5WORDS; + break; diff --git a/package/kernel/mac80211/patches/rt2x00/518-rt2x00-rt2800lib-fix-antenna-configuration-for-RT388.patch b/package/kernel/mac80211/patches/rt2x00/518-rt2x00-rt2800lib-fix-antenna-configuration-for-RT388.patch new file mode 100644 index 0000000000..30da2cbb6e --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/518-rt2x00-rt2800lib-fix-antenna-configuration-for-RT388.patch @@ -0,0 +1,22 @@ +From fa5ad9c025610c22048add2f0ad03f62b6ca1e74 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Mon, 30 Sep 2013 16:53:33 +0200 +Subject: [PATCH] rt2x00: rt2800lib: fix antenna configuration for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -2182,7 +2182,8 @@ void rt2800_config_ant(struct rt2x00_dev + rt2800_bbp_write(rt2x00dev, 3, r3); + rt2800_bbp_write(rt2x00dev, 1, r1); + +- if (rt2x00_rt(rt2x00dev, RT3593)) { ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) { + if (ant->rx_chain_num == 1) + rt2800_bbp_write(rt2x00dev, 86, 0x00); + else diff --git a/package/kernel/mac80211/patches/rt2x00/519-rt2x00-rt2800lib-fix-LNA-gain-configuration-for-RT38.patch b/package/kernel/mac80211/patches/rt2x00/519-rt2x00-rt2800lib-fix-LNA-gain-configuration-for-RT38.patch new file mode 100644 index 0000000000..2514d824f2 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/519-rt2x00-rt2800lib-fix-LNA-gain-configuration-for-RT38.patch @@ -0,0 +1,32 @@ +From 6d668fef3a1baa60bdd715ee062ddb6333d2647c Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Mon, 30 Sep 2013 16:58:23 +0200 +Subject: [PATCH] rt2x00: rt2800lib: fix LNA gain configuration for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -2205,7 +2205,8 @@ static void rt2800_config_lna_gain(struc + eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_LNA); + lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0); + } else if (libconf->rf.channel <= 128) { +- if (rt2x00_rt(rt2x00dev, RT3593)) { ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) { + eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2); + lna_gain = rt2x00_get_field16(eeprom, + EEPROM_EXT_LNA2_A1); +@@ -2215,7 +2216,8 @@ static void rt2800_config_lna_gain(struc + EEPROM_RSSI_BG2_LNA_A1); + } + } else { +- if (rt2x00_rt(rt2x00dev, RT3593)) { ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) { + eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2); + lna_gain = rt2x00_get_field16(eeprom, + EEPROM_EXT_LNA2_A2); diff --git a/package/kernel/mac80211/patches/rt2x00/520-rt2x00-rt2800lib-fix-VGC-setup-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/520-rt2x00-rt2800lib-fix-VGC-setup-for-RT3883.patch new file mode 100644 index 0000000000..49393c2f6d --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/520-rt2x00-rt2800lib-fix-VGC-setup-for-RT3883.patch @@ -0,0 +1,44 @@ +From c49b2d829aa1c816a46a577cdec6d2ff14d9f06e Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Tue, 1 Oct 2013 15:40:08 +0200 +Subject: [PATCH] rt2x00: rt2800lib: fix VGC setup for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -5534,7 +5534,8 @@ static u8 rt2800_get_default_vgc(struct + else + vgc = 0x2e + rt2x00dev->lna_gain; + } else { /* 5GHZ band */ +- if (rt2x00_rt(rt2x00dev, RT3593)) ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) + vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3; + else if (rt2x00_rt(rt2x00dev, RT5592)) + vgc = 0x24 + (2 * rt2x00dev->lna_gain); +@@ -5554,7 +5555,8 @@ static inline void rt2800_set_vgc(struct + { + if (qual->vgc_level != vgc_level) { + if (rt2x00_rt(rt2x00dev, RT3572) || +- rt2x00_rt(rt2x00dev, RT3593)) { ++ rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) { + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, + vgc_level); + } else if (rt2x00_rt(rt2x00dev, RT5592)) { +@@ -5601,6 +5603,11 @@ void rt2800_link_tuner(struct rt2x00_dev + } + break; + ++ case RT3883: ++ if (qual->rssi > -65) ++ vgc += 0x10; ++ break; ++ + case RT5592: + if (qual->rssi > -65) + vgc += 0x20; diff --git a/package/kernel/mac80211/patches/rt2x00/521-rt2x00-rt2800lib-fix-EEPROM-LNA-validation-for-RT388.patch b/package/kernel/mac80211/patches/rt2x00/521-rt2x00-rt2800lib-fix-EEPROM-LNA-validation-for-RT388.patch new file mode 100644 index 0000000000..1e1fb6e4b5 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/521-rt2x00-rt2800lib-fix-EEPROM-LNA-validation-for-RT388.patch @@ -0,0 +1,42 @@ +From 1616650aea676541d4dc8adc6f4219856d193c8b Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Tue, 1 Oct 2013 17:27:57 +0200 +Subject: [PATCH] rt2x00: rt2800lib: fix EEPROM LNA validation for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -9269,7 +9269,8 @@ static int rt2800_validate_eeprom(struct + word = rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2); + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10) + rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0); +- if (!rt2x00_rt(rt2x00dev, RT3593)) { ++ if (!rt2x00_rt(rt2x00dev, RT3593) && ++ !rt2x00_rt(rt2x00dev, RT3883)) { + if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 || + rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff) + rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1, +@@ -9289,7 +9290,8 @@ static int rt2800_validate_eeprom(struct + word = rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2); + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10) + rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0); +- if (!rt2x00_rt(rt2x00dev, RT3593)) { ++ if (!rt2x00_rt(rt2x00dev, RT3593) && ++ !rt2x00_rt(rt2x00dev, RT3883)) { + if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 || + rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff) + rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2, +@@ -9297,7 +9299,8 @@ static int rt2800_validate_eeprom(struct + } + rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word); + +- if (rt2x00_rt(rt2x00dev, RT3593)) { ++ if (rt2x00_rt(rt2x00dev, RT3593) || ++ rt2x00_rt(rt2x00dev, RT3883)) { + word = rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2); + if (rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0x00 || + rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0xff) diff --git a/package/kernel/mac80211/patches/rt2x00/522-rt2x00-rt2800lib-fix-txpower-compensation-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/522-rt2x00-rt2800lib-fix-txpower-compensation-for-RT3883.patch new file mode 100644 index 0000000000..64dba012ec --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/522-rt2x00-rt2800lib-fix-txpower-compensation-for-RT3883.patch @@ -0,0 +1,22 @@ +From e3871034a0e7c8a95152dc3eafbcc4535398cbdc Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Wed, 2 Oct 2013 10:11:59 +0200 +Subject: [PATCH] rt2x00: rt2800lib: fix txpower compensation for RT3883 + +Signed-off-by: Gabor Juhos +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -4524,6 +4524,9 @@ static u8 rt2800_compensate_txpower(stru + if (rt2x00_rt(rt2x00dev, RT3593)) + return min_t(u8, txpower, 0xc); + ++ if (rt2x00_rt(rt2x00dev, RT3883)) ++ return min_t(u8, txpower, 0xf); ++ + if (rt2x00_has_cap_power_limit(rt2x00dev)) { + /* + * Check if eirp txpower exceed txpower_limit. diff --git a/package/kernel/mac80211/patches/rt2x00/600-01-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/600-01-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch deleted file mode 100644 index 699989baa0..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-01-rt2x00-allow-to-build-rt2800soc-module-for-RT3883.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 91094ed065f7794886b4a5490fd6de942f036bb4 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sun, 24 Mar 2013 19:26:26 +0100 -Subject: [PATCH] rt2x00: allow to build rt2800soc module for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/Kconfig | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/Kconfig -+++ b/drivers/net/wireless/ralink/rt2x00/Kconfig -@@ -210,7 +210,7 @@ endif - config RT2800SOC - tristate "Ralink WiSoC support" - depends on m -- depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 -+ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883 || SOC_MT7620 - select RT2X00_LIB_SOC - select RT2X00_LIB_MMIO - select RT2X00_LIB_CRYPTO -@@ -245,7 +245,7 @@ config RT2X00_LIB_PCI - - config RT2X00_LIB_SOC - tristate "RT2x00 SoC support" -- depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 -+ depends on SOC_RT288X || SOC_RT305X || SOC_RT3883 || SOC_MT7620 - depends on m - select RT2X00_LIB - diff --git a/package/kernel/mac80211/patches/rt2x00/600-02-rt2x00-rt2800lib-enable-support-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/600-02-rt2x00-rt2800lib-enable-support-for-RT3883.patch deleted file mode 100644 index c7927aeae0..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-02-rt2x00-rt2800lib-enable-support-for-RT3883.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 4f16582c93a71eba9d389e0f0a8aa9099a9587cd Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sun, 24 Mar 2013 19:26:26 +0100 -Subject: [PATCH] rt2x00: rt2800lib: enable support for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -9409,6 +9409,7 @@ static int rt2800_probe_rt(struct rt2x00 - case RT3390: - case RT3572: - case RT3593: -+ case RT3883: - case RT5350: - case RT5390: - case RT5392: diff --git a/package/kernel/mac80211/patches/rt2x00/600-03-rt2x00-rt2800lib-add-rf_vals-for-RF3853.patch b/package/kernel/mac80211/patches/rt2x00/600-03-rt2x00-rt2800lib-add-rf_vals-for-RF3853.patch deleted file mode 100644 index bacbf1947e..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-03-rt2x00-rt2800lib-add-rf_vals-for-RF3853.patch +++ /dev/null @@ -1,112 +0,0 @@ -From ecb394ccf248d8652c463133c4f404458a57a9c1 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sun, 24 Mar 2013 19:26:26 +0100 -Subject: [PATCH] rt2x00: rt2800lib: add rf_vals for RF3853 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800.h | 4 +- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 65 +++++++++++++++++++++++++++++++ - 2 files changed, 68 insertions(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800.h -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h -@@ -48,7 +48,8 @@ - * RF2853 2.4G/5G 3T3R - * RF3320 2.4G 1T1R(RT3350/RT3370/RT3390) - * RF3322 2.4G 2T2R(RT3352/RT3371/RT3372/RT3391/RT3392) -- * RF3053 2.4G/5G 3T3R(RT3883/RT3563/RT3573/RT3593/RT3662) -+ * RF3053 2.4G/5G 3T3R(RT3563/RT3573/RT3593) -+ * RF3853 2.4G/5G 3T3R(RT3883/RT3662) - * RF5592 2.4G/5G 2T2R - * RF3070 2.4G 1T1R - * RF5360 2.4G 1T1R -@@ -72,6 +73,7 @@ - #define RF5592 0x000f - #define RF3070 0x3070 - #define RF3290 0x3290 -+#define RF3853 0x3853 - #define RF5350 0x5350 - #define RF5360 0x5360 - #define RF5362 0x5362 ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8987,6 +8987,66 @@ static const struct rf_channel rf_vals_3 - {14, 0xF0, 2, 0x18}, - }; - -+static const struct rf_channel rf_vals_3853[] = { -+ {1, 241, 6, 2}, -+ {2, 241, 6, 7}, -+ {3, 242, 6, 2}, -+ {4, 242, 6, 7}, -+ {5, 243, 6, 2}, -+ {6, 243, 6, 7}, -+ {7, 244, 6, 2}, -+ {8, 244, 6, 7}, -+ {9, 245, 6, 2}, -+ {10, 245, 6, 7}, -+ {11, 246, 6, 2}, -+ {12, 246, 6, 7}, -+ {13, 247, 6, 2}, -+ {14, 248, 6, 4}, -+ -+ {36, 0x56, 8, 4}, -+ {38, 0x56, 8, 6}, -+ {40, 0x56, 8, 8}, -+ {44, 0x57, 8, 0}, -+ {46, 0x57, 8, 2}, -+ {48, 0x57, 8, 4}, -+ {52, 0x57, 8, 8}, -+ {54, 0x57, 8, 10}, -+ {56, 0x58, 8, 0}, -+ {60, 0x58, 8, 4}, -+ {62, 0x58, 8, 6}, -+ {64, 0x58, 8, 8}, -+ -+ {100, 0x5b, 8, 8}, -+ {102, 0x5b, 8, 10}, -+ {104, 0x5c, 8, 0}, -+ {108, 0x5c, 8, 4}, -+ {110, 0x5c, 8, 6}, -+ {112, 0x5c, 8, 8}, -+ {114, 0x5c, 8, 10}, -+ {116, 0x5d, 8, 0}, -+ {118, 0x5d, 8, 2}, -+ {120, 0x5d, 8, 4}, -+ {124, 0x5d, 8, 8}, -+ {126, 0x5d, 8, 10}, -+ {128, 0x5e, 8, 0}, -+ {132, 0x5e, 8, 4}, -+ {134, 0x5e, 8, 6}, -+ {136, 0x5e, 8, 8}, -+ {140, 0x5f, 8, 0}, -+ -+ {149, 0x5f, 8, 9}, -+ {151, 0x5f, 8, 11}, -+ {153, 0x60, 8, 1}, -+ {157, 0x60, 8, 5}, -+ {159, 0x60, 8, 7}, -+ {161, 0x60, 8, 9}, -+ {165, 0x61, 8, 1}, -+ {167, 0x61, 8, 3}, -+ {169, 0x61, 8, 5}, -+ {171, 0x61, 8, 7}, -+ {173, 0x61, 8, 9}, -+}; -+ - static const struct rf_channel rf_vals_5592_xtal20[] = { - /* Channel, N, K, mod, R */ - {1, 482, 4, 10, 3}, -@@ -9250,6 +9310,11 @@ static int rt2800_probe_hw_mode(struct r - spec->channels = rf_vals_3x; - break; - -+ case RF3853: -+ spec->num_channels = ARRAY_SIZE(rf_vals_3853); -+ spec->channels = rf_vals_3853; -+ break; -+ - case RF5592: - reg = rt2800_register_read(rt2x00dev, MAC_DEBUG_INDEX); - if (rt2x00_get_field32(reg, MAC_DEBUG_INDEX_XTAL)) { diff --git a/package/kernel/mac80211/patches/rt2x00/600-04-rt2x00-rt2800lib-enable-VCO-calibration-for-RF3853.patch b/package/kernel/mac80211/patches/rt2x00/600-04-rt2x00-rt2800lib-enable-VCO-calibration-for-RF3853.patch deleted file mode 100644 index 227c6923f5..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-04-rt2x00-rt2800lib-enable-VCO-calibration-for-RF3853.patch +++ /dev/null @@ -1,28 +0,0 @@ -From f8e3fcf18e1f2d7f9e6a9680c5452da090f33d88 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Thu, 1 Aug 2013 14:40:44 +0200 -Subject: [PATCH] rt2x00: rt2800lib: enable VCO calibration for RF3853 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -4884,6 +4884,7 @@ void rt2800_vco_calibration(struct rt2x0 - case RF3053: - case RF3070: - case RF3290: -+ case RF3853: - case RF5350: - case RF5360: - case RF5362: -@@ -9432,6 +9433,7 @@ static int rt2800_probe_hw_mode(struct r - case RF3053: - case RF3070: - case RF3290: -+ case RF3853: - case RF5350: - case RF5360: - case RF5362: diff --git a/package/kernel/mac80211/patches/rt2x00/600-05-rt2x00-rt2800lib-add-channel-configuration-function-.patch b/package/kernel/mac80211/patches/rt2x00/600-05-rt2x00-rt2800lib-add-channel-configuration-function-.patch deleted file mode 100644 index 1890b1ec16..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-05-rt2x00-rt2800lib-add-channel-configuration-function-.patch +++ /dev/null @@ -1,235 +0,0 @@ -From 6e3a17190815c6aa4dc53c2cfe9125fb1154f187 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sun, 24 Mar 2013 19:26:27 +0100 -Subject: [PATCH] rt2x00: rt2800lib: add channel configuration function for - RF3853 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 208 +++++++++++++++++++++++++++++++ - 1 file changed, 208 insertions(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -2716,6 +2716,211 @@ static void rt2800_config_channel_rf3053 - } - } - -+static void rt2800_config_channel_rf3853(struct rt2x00_dev *rt2x00dev, -+ struct ieee80211_conf *conf, -+ struct rf_channel *rf, -+ struct channel_info *info) -+{ -+ u8 rfcsr; -+ u8 bbp; -+ u8 pwr1, pwr2, pwr3; -+ -+ const bool txbf_enabled = false; /* TODO */ -+ -+ /* TODO: add band selection */ -+ -+ if (rf->channel <= 14) -+ rt2800_rfcsr_write(rt2x00dev, 6, 0x40); -+ else if (rf->channel < 132) -+ rt2800_rfcsr_write(rt2x00dev, 6, 0x80); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 6, 0x40); -+ -+ rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); -+ rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); -+ -+ if (rf->channel <= 14) -+ rt2800_rfcsr_write(rt2x00dev, 11, 0x46); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 11, 0x48); -+ -+ if (rf->channel <= 14) -+ rt2800_rfcsr_write(rt2x00dev, 12, 0x1a); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 12, 0x52); -+ -+ rt2800_rfcsr_write(rt2x00dev, 13, 0x12); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 1); -+ rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 0); -+ rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 0); -+ rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 0); -+ rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 0); -+ rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 0); -+ rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 0); -+ rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1); -+ rt2x00_set_field8(&rfcsr, RFCSR1_PLL_PD, 1); -+ -+ switch (rt2x00dev->default_ant.tx_chain_num) { -+ case 3: -+ rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 1); -+ /* fallthrough */ -+ case 2: -+ rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 1); -+ /* fallthrough */ -+ case 1: -+ rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 1); -+ break; -+ } -+ -+ switch (rt2x00dev->default_ant.rx_chain_num) { -+ case 3: -+ rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 1); -+ /* fallthrough */ -+ case 2: -+ rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 1); -+ /* fallthrough */ -+ case 1: -+ rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 1); -+ break; -+ } -+ rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); -+ -+ rt2800_freq_cal_mode1(rt2x00dev); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 30); -+ if (!conf_is_ht40(conf)) -+ rfcsr &= ~(0x06); -+ else -+ rfcsr |= 0x06; -+ rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); -+ -+ if (rf->channel <= 14) -+ rt2800_rfcsr_write(rt2x00dev, 31, 0xa0); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 31, 0x80); -+ -+ if (conf_is_ht40(conf)) -+ rt2800_rfcsr_write(rt2x00dev, 32, 0x80); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 32, 0xd8); -+ -+ if (rf->channel <= 14) -+ rt2800_rfcsr_write(rt2x00dev, 34, 0x3c); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 34, 0x20); -+ -+ /* loopback RF_BS */ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 36); -+ if (rf->channel <= 14) -+ rt2x00_set_field8(&rfcsr, RFCSR36_RF_BS, 1); -+ else -+ rt2x00_set_field8(&rfcsr, RFCSR36_RF_BS, 0); -+ rt2800_rfcsr_write(rt2x00dev, 36, rfcsr); -+ -+ if (rf->channel <= 14) -+ rfcsr = 0x23; -+ else if (rf->channel < 100) -+ rfcsr = 0x36; -+ else if (rf->channel < 132) -+ rfcsr = 0x32; -+ else -+ rfcsr = 0x30; -+ -+ if (txbf_enabled) -+ rfcsr |= 0x40; -+ -+ rt2800_rfcsr_write(rt2x00dev, 39, rfcsr); -+ -+ if (rf->channel <= 14) -+ rt2800_rfcsr_write(rt2x00dev, 44, 0x93); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 44, 0x9b); -+ -+ if (rf->channel <= 14) -+ rfcsr = 0xbb; -+ else if (rf->channel < 100) -+ rfcsr = 0xeb; -+ else if (rf->channel < 132) -+ rfcsr = 0xb3; -+ else -+ rfcsr = 0x9b; -+ rt2800_rfcsr_write(rt2x00dev, 45, rfcsr); -+ -+ if (rf->channel <= 14) -+ rfcsr = 0x8e; -+ else -+ rfcsr = 0x8a; -+ -+ if (txbf_enabled) -+ rfcsr |= 0x20; -+ -+ rt2800_rfcsr_write(rt2x00dev, 49, rfcsr); -+ -+ rt2800_rfcsr_write(rt2x00dev, 50, 0x86); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 51); -+ if (rf->channel <= 14) -+ rt2800_rfcsr_write(rt2x00dev, 51, 0x75); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 51, 0x51); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 52); -+ if (rf->channel <= 14) -+ rt2800_rfcsr_write(rt2x00dev, 52, 0x45); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 52, 0x05); -+ -+ if (rf->channel <= 14) { -+ pwr1 = info->default_power1 & 0x1f; -+ pwr2 = info->default_power2 & 0x1f; -+ pwr3 = info->default_power3 & 0x1f; -+ } else { -+ pwr1 = 0x48 | ((info->default_power1 & 0x18) << 1) | -+ (info->default_power1 & 0x7); -+ pwr2 = 0x48 | ((info->default_power2 & 0x18) << 1) | -+ (info->default_power2 & 0x7); -+ pwr3 = 0x48 | ((info->default_power3 & 0x18) << 1) | -+ (info->default_power3 & 0x7); -+ } -+ -+ rt2800_rfcsr_write(rt2x00dev, 53, pwr1); -+ rt2800_rfcsr_write(rt2x00dev, 54, pwr2); -+ rt2800_rfcsr_write(rt2x00dev, 55, pwr3); -+ -+ rt2x00_dbg(rt2x00dev, "Channel:%d, pwr1:%02x, pwr2:%02x, pwr3:%02x\n", -+ rf->channel, pwr1, pwr2, pwr3); -+ -+ bbp = (info->default_power1 >> 5) | -+ ((info->default_power2 & 0xe0) >> 1); -+ rt2800_bbp_write(rt2x00dev, 109, bbp); -+ -+ bbp = rt2800_bbp_read(rt2x00dev, 110); -+ bbp &= 0x0f; -+ bbp |= (info->default_power3 & 0xe0) >> 1; -+ rt2800_bbp_write(rt2x00dev, 110, bbp); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 57); -+ if (rf->channel <= 14) -+ rt2800_rfcsr_write(rt2x00dev, 57, 0x6e); -+ else -+ rt2800_rfcsr_write(rt2x00dev, 57, 0x3e); -+ -+ /* Enable RF tuning */ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 3); -+ rt2x00_set_field8(&rfcsr, RFCSR3_VCOCAL_EN, 1); -+ rt2800_rfcsr_write(rt2x00dev, 3, rfcsr); -+ -+ udelay(2000); -+ -+ bbp = rt2800_bbp_read(rt2x00dev, 49); -+ /* clear update flag */ -+ rt2800_bbp_write(rt2x00dev, 49, bbp & 0xfe); -+ rt2800_bbp_write(rt2x00dev, 49, bbp); -+ -+ /* TODO: add calibration for TxBF */ -+} -+ - #define POWER_BOUND 0x27 - #define POWER_BOUND_5G 0x2b - -@@ -3573,6 +3778,9 @@ static void rt2800_config_channel(struct - case RF3322: - rt2800_config_channel_rf3322(rt2x00dev, conf, rf, info); - break; -+ case RF3853: -+ rt2800_config_channel_rf3853(rt2x00dev, conf, rf, info); -+ break; - case RF3070: - case RF5350: - case RF5360: diff --git a/package/kernel/mac80211/patches/rt2x00/600-06-rt2x00-rt2800lib-enable-RF3853-support.patch b/package/kernel/mac80211/patches/rt2x00/600-06-rt2x00-rt2800lib-enable-RF3853-support.patch deleted file mode 100644 index 69ed4d7dec..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-06-rt2x00-rt2800lib-enable-RF3853-support.patch +++ /dev/null @@ -1,20 +0,0 @@ -From afd38ae82226551bf879b6c7c4b620c271fee9d2 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Thu, 1 Aug 2013 14:42:05 +0200 -Subject: [PATCH] rt2x00: rt2800lib: enable RF3853 support - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8910,6 +8910,7 @@ static int rt2800_init_eeprom(struct rt2 - case RF3290: - case RF3320: - case RF3322: -+ case RF3853: - case RF5350: - case RF5360: - case RF5362: diff --git a/package/kernel/mac80211/patches/rt2x00/600-07-rt2x00-rt2800lib-add-MAC-register-initialization-for.patch b/package/kernel/mac80211/patches/rt2x00/600-07-rt2x00-rt2800lib-add-MAC-register-initialization-for.patch deleted file mode 100644 index fc5a72cba6..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-07-rt2x00-rt2800lib-add-MAC-register-initialization-for.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 0094872a5e8e4664c6ea1b2dfa487063d39ae363 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sun, 24 Mar 2013 19:26:26 +0100 -Subject: [PATCH] rt2x00: rt2800lib: add MAC register initialization for - RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800.h | 14 ++++++++++++++ - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 19 ++++++++++++++++--- - 2 files changed, 30 insertions(+), 3 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800.h -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h -@@ -1728,6 +1728,20 @@ - #define TX_PWR_CFG_9B_STBC_MCS7 FIELD32(0x000000ff) - - /* -+ * TX_TXBF_CFG: -+ */ -+#define TX_TXBF_CFG_0 0x138c -+#define TX_TXBF_CFG_1 0x13a4 -+#define TX_TXBF_CFG_2 0x13a8 -+#define TX_TXBF_CFG_3 0x13ac -+ -+/* -+ * TX_FBK_CFG_3S: -+ */ -+#define TX_FBK_CFG_3S_0 0x13c4 -+#define TX_FBK_CFG_3S_1 0x13c8 -+ -+/* - * RX_FILTER_CFG: RX configuration register. - */ - #define RX_FILTER_CFG 0x1400 ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -5512,6 +5512,12 @@ static int rt2800_init_registers(struct - rt2800_register_write(rt2x00dev, TX_SW_CFG2, - 0x00000000); - } -+ } else if (rt2x00_rt(rt2x00dev, RT3883)) { -+ rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000402); -+ rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000); -+ rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00040000); -+ rt2800_register_write(rt2x00dev, TX_TXBF_CFG_0, 0x8000fc21); -+ rt2800_register_write(rt2x00dev, TX_TXBF_CFG_3, 0x00009c40); - } else if (rt2x00_rt(rt2x00dev, RT5390) || - rt2x00_rt(rt2x00dev, RT5392) || - rt2x00_rt(rt2x00dev, RT6352)) { -@@ -5725,6 +5731,11 @@ static int rt2800_init_registers(struct - reg = rt2x00_rt(rt2x00dev, RT5592) ? 0x00000082 : 0x00000002; - rt2800_register_write(rt2x00dev, TXOP_HLDR_ET, reg); - -+ if (rt2x00_rt(rt2x00dev, RT3883)) { -+ rt2800_register_write(rt2x00dev, TX_FBK_CFG_3S_0, 0x12111008); -+ rt2800_register_write(rt2x00dev, TX_FBK_CFG_3S_1, 0x16151413); -+ } -+ - reg = rt2800_register_read(rt2x00dev, TX_RTS_CFG); - rt2x00_set_field32(®, TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT, 7); - rt2x00_set_field32(®, TX_RTS_CFG_RTS_THRES, diff --git a/package/kernel/mac80211/patches/rt2x00/600-08-rt2x00-rt2800soc-fix-rt2800soc_disable_radio-for-RT3.patch b/package/kernel/mac80211/patches/rt2x00/600-08-rt2x00-rt2800soc-fix-rt2800soc_disable_radio-for-RT3.patch deleted file mode 100644 index d68ad50447..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-08-rt2x00-rt2800soc-fix-rt2800soc_disable_radio-for-RT3.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 6c2d32478159fffff0b85abb6817a21bb2338231 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sun, 24 Mar 2013 19:26:27 +0100 -Subject: [PATCH] rt2x00: rt2800soc: fix rt2800soc_disable_radio for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800soc.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c -@@ -51,9 +51,16 @@ static bool rt2800soc_hwcrypt_disabled(s - - static void rt2800soc_disable_radio(struct rt2x00_dev *rt2x00dev) - { -+ u32 reg; -+ - rt2800_disable_radio(rt2x00dev); - rt2x00mmio_register_write(rt2x00dev, PWR_PIN_CFG, 0); -- rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, 0); -+ -+ reg = 0; -+ if (rt2x00_rt(rt2x00dev, RT3883)) -+ rt2x00_set_field32(®, TX_PIN_CFG_RFTR_EN, 1); -+ -+ rt2x00mmio_register_write(rt2x00dev, TX_PIN_CFG, reg); - } - - static int rt2800soc_set_device_state(struct rt2x00_dev *rt2x00dev, diff --git a/package/kernel/mac80211/patches/rt2x00/600-09-rt2x00-rt2800lib-add-BBP-register-initialization-for.patch b/package/kernel/mac80211/patches/rt2x00/600-09-rt2x00-rt2800lib-add-BBP-register-initialization-for.patch deleted file mode 100644 index e53b64df7e..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-09-rt2x00-rt2800lib-add-BBP-register-initialization-for.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 84833056aa7dd25f5b097e31c78f2a0914c5160c Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sun, 24 Mar 2013 19:26:26 +0100 -Subject: [PATCH] rt2x00: rt2800lib: add BBP register initialization for - RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 44 +++++++++++++++++++++++++++++++ - 1 file changed, 44 insertions(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -6352,6 +6352,47 @@ static void rt2800_init_bbp_3593(struct - rt2800_bbp_write(rt2x00dev, 103, 0xc0); - } - -+static void rt2800_init_bbp_3883(struct rt2x00_dev *rt2x00dev) -+{ -+ rt2800_init_bbp_early(rt2x00dev); -+ -+ rt2800_bbp_write(rt2x00dev, 4, 0x50); -+ rt2800_bbp_write(rt2x00dev, 47, 0x48); -+ -+ rt2800_bbp_write(rt2x00dev, 86, 0x46); -+ rt2800_bbp_write(rt2x00dev, 88, 0x90); -+ -+ rt2800_bbp_write(rt2x00dev, 92, 0x02); -+ -+ rt2800_bbp_write(rt2x00dev, 103, 0xc0); -+ rt2800_bbp_write(rt2x00dev, 104, 0x92); -+ rt2800_bbp_write(rt2x00dev, 105, 0x34); -+ rt2800_bbp_write(rt2x00dev, 106, 0x12); -+ rt2800_bbp_write(rt2x00dev, 120, 0x50); -+ rt2800_bbp_write(rt2x00dev, 137, 0x0f); -+ rt2800_bbp_write(rt2x00dev, 163, 0x9d); -+ -+ /* Set ITxBF timeout to 0x9C40=1000msec */ -+ rt2800_bbp_write(rt2x00dev, 179, 0x02); -+ rt2800_bbp_write(rt2x00dev, 180, 0x00); -+ rt2800_bbp_write(rt2x00dev, 182, 0x40); -+ rt2800_bbp_write(rt2x00dev, 180, 0x01); -+ rt2800_bbp_write(rt2x00dev, 182, 0x9c); -+ -+ rt2800_bbp_write(rt2x00dev, 179, 0x00); -+ -+ /* Reprogram the inband interface to put right values in RXWI */ -+ rt2800_bbp_write(rt2x00dev, 142, 0x04); -+ rt2800_bbp_write(rt2x00dev, 143, 0x3b); -+ rt2800_bbp_write(rt2x00dev, 142, 0x06); -+ rt2800_bbp_write(rt2x00dev, 143, 0xa0); -+ rt2800_bbp_write(rt2x00dev, 142, 0x07); -+ rt2800_bbp_write(rt2x00dev, 143, 0xa1); -+ rt2800_bbp_write(rt2x00dev, 142, 0x08); -+ rt2800_bbp_write(rt2x00dev, 143, 0xa2); -+ rt2800_bbp_write(rt2x00dev, 148, 0xc8); -+} -+ - static void rt2800_init_bbp_53xx(struct rt2x00_dev *rt2x00dev) - { - int ant, div_mode; -@@ -6796,6 +6837,9 @@ static void rt2800_init_bbp(struct rt2x0 - case RT3593: - rt2800_init_bbp_3593(rt2x00dev); - return; -+ case RT3883: -+ rt2800_init_bbp_3883(rt2x00dev); -+ return; - case RT5390: - case RT5392: - rt2800_init_bbp_53xx(rt2x00dev); diff --git a/package/kernel/mac80211/patches/rt2x00/600-10-rt2x00-rt2800lib-add-RFCSR-initialization-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/600-10-rt2x00-rt2800lib-add-RFCSR-initialization-for-RT3883.patch deleted file mode 100644 index c16cf41019..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-10-rt2x00-rt2800lib-add-RFCSR-initialization-for-RT3883.patch +++ /dev/null @@ -1,178 +0,0 @@ -From 99c659cf345640fd0f733cbcaf4583cc2c868ec0 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Mon, 29 Apr 2013 13:21:48 +0200 -Subject: [PATCH] rt2x00: rt2800lib: add RFCSR initialization for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800.h | 1 + - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 141 +++++++++++++++++++++++++++++++ - 2 files changed, 142 insertions(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800.h -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h -@@ -2312,6 +2312,7 @@ struct mac_iveiv_entry { - /* - * RFCSR 2: - */ -+#define RFCSR2_RESCAL_BP FIELD8(0x40) - #define RFCSR2_RESCAL_EN FIELD8(0x80) - #define RFCSR2_RX2_EN_MT7620 FIELD8(0x02) - #define RFCSR2_TX2_EN_MT7620 FIELD8(0x20) ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -7711,6 +7711,144 @@ static void rt2800_init_rfcsr_5350(struc - rt2800_rfcsr_write(rt2x00dev, 63, 0x00); - } - -+static void rt2800_init_rfcsr_3883(struct rt2x00_dev *rt2x00dev) -+{ -+ u8 rfcsr; -+ -+ /* TODO: get the actual ECO value from the SoC */ -+ const unsigned int eco = 5; -+ -+ rt2800_rf_init_calibration(rt2x00dev, 2); -+ -+ rt2800_rfcsr_write(rt2x00dev, 0, 0xe0); -+ rt2800_rfcsr_write(rt2x00dev, 1, 0x03); -+ rt2800_rfcsr_write(rt2x00dev, 2, 0x50); -+ rt2800_rfcsr_write(rt2x00dev, 3, 0x20); -+ rt2800_rfcsr_write(rt2x00dev, 4, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 5, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 6, 0x40); -+ rt2800_rfcsr_write(rt2x00dev, 7, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 8, 0x5b); -+ rt2800_rfcsr_write(rt2x00dev, 9, 0x08); -+ rt2800_rfcsr_write(rt2x00dev, 10, 0xd3); -+ rt2800_rfcsr_write(rt2x00dev, 11, 0x48); -+ rt2800_rfcsr_write(rt2x00dev, 12, 0x1a); -+ rt2800_rfcsr_write(rt2x00dev, 13, 0x12); -+ rt2800_rfcsr_write(rt2x00dev, 14, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 15, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 16, 0x00); -+ -+ /* RFCSR 17 will be initialized later based on the -+ * frequency offset stored in the EEPROM -+ */ -+ -+ rt2800_rfcsr_write(rt2x00dev, 18, 0x40); -+ rt2800_rfcsr_write(rt2x00dev, 19, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 20, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 21, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 22, 0x20); -+ rt2800_rfcsr_write(rt2x00dev, 23, 0xc0); -+ rt2800_rfcsr_write(rt2x00dev, 24, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 25, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 26, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 27, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 28, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 29, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 30, 0x10); -+ rt2800_rfcsr_write(rt2x00dev, 31, 0x80); -+ rt2800_rfcsr_write(rt2x00dev, 32, 0x80); -+ rt2800_rfcsr_write(rt2x00dev, 33, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 34, 0x20); -+ rt2800_rfcsr_write(rt2x00dev, 35, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 36, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 37, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 38, 0x86); -+ rt2800_rfcsr_write(rt2x00dev, 39, 0x23); -+ rt2800_rfcsr_write(rt2x00dev, 40, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 41, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 42, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 43, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 44, 0x93); -+ rt2800_rfcsr_write(rt2x00dev, 45, 0xbb); -+ rt2800_rfcsr_write(rt2x00dev, 46, 0x60); -+ rt2800_rfcsr_write(rt2x00dev, 47, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 48, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 49, 0x8e); -+ rt2800_rfcsr_write(rt2x00dev, 50, 0x86); -+ rt2800_rfcsr_write(rt2x00dev, 51, 0x51); -+ rt2800_rfcsr_write(rt2x00dev, 52, 0x05); -+ rt2800_rfcsr_write(rt2x00dev, 53, 0x76); -+ rt2800_rfcsr_write(rt2x00dev, 54, 0x76); -+ rt2800_rfcsr_write(rt2x00dev, 55, 0x76); -+ rt2800_rfcsr_write(rt2x00dev, 56, 0xdb); -+ rt2800_rfcsr_write(rt2x00dev, 57, 0x3e); -+ rt2800_rfcsr_write(rt2x00dev, 58, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 59, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 60, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 61, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 62, 0x00); -+ rt2800_rfcsr_write(rt2x00dev, 63, 0x00); -+ -+ /* TODO: rx filter calibration? */ -+ -+ rt2800_bbp_write(rt2x00dev, 137, 0x0f); -+ -+ rt2800_bbp_write(rt2x00dev, 163, 0x9d); -+ -+ rt2800_bbp_write(rt2x00dev, 105, 0x05); -+ -+ rt2800_bbp_write(rt2x00dev, 179, 0x02); -+ rt2800_bbp_write(rt2x00dev, 180, 0x00); -+ rt2800_bbp_write(rt2x00dev, 182, 0x40); -+ rt2800_bbp_write(rt2x00dev, 180, 0x01); -+ rt2800_bbp_write(rt2x00dev, 182, 0x9c); -+ -+ rt2800_bbp_write(rt2x00dev, 179, 0x00); -+ -+ rt2800_bbp_write(rt2x00dev, 142, 0x04); -+ rt2800_bbp_write(rt2x00dev, 143, 0x3b); -+ rt2800_bbp_write(rt2x00dev, 142, 0x06); -+ rt2800_bbp_write(rt2x00dev, 143, 0xa0); -+ rt2800_bbp_write(rt2x00dev, 142, 0x07); -+ rt2800_bbp_write(rt2x00dev, 143, 0xa1); -+ rt2800_bbp_write(rt2x00dev, 142, 0x08); -+ rt2800_bbp_write(rt2x00dev, 143, 0xa2); -+ rt2800_bbp_write(rt2x00dev, 148, 0xc8); -+ -+ if (eco == 5) { -+ rt2800_rfcsr_write(rt2x00dev, 32, 0xd8); -+ rt2800_rfcsr_write(rt2x00dev, 33, 0x32); -+ } -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 2); -+ rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_BP, 0); -+ rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 1); -+ rt2800_rfcsr_write(rt2x00dev, 2, rfcsr); -+ msleep(1); -+ rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 0); -+ rt2800_rfcsr_write(rt2x00dev, 2, rfcsr); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 1); -+ rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1); -+ rt2800_rfcsr_write(rt2x00dev, 1, rfcsr); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 6); -+ rfcsr |= 0xc0; -+ rt2800_rfcsr_write(rt2x00dev, 6, rfcsr); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 22); -+ rfcsr |= 0x20; -+ rt2800_rfcsr_write(rt2x00dev, 22, rfcsr); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 46); -+ rfcsr |= 0x20; -+ rt2800_rfcsr_write(rt2x00dev, 46, rfcsr); -+ -+ rfcsr = rt2800_rfcsr_read(rt2x00dev, 20); -+ rfcsr &= ~0xee; -+ rt2800_rfcsr_write(rt2x00dev, 20, rfcsr); -+} -+ - static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev) - { - rt2800_rf_init_calibration(rt2x00dev, 2); -@@ -8553,6 +8691,9 @@ static void rt2800_init_rfcsr(struct rt2 - case RT3390: - rt2800_init_rfcsr_3390(rt2x00dev); - break; -+ case RT3883: -+ rt2800_init_rfcsr_3883(rt2x00dev); -+ break; - case RT3572: - rt2800_init_rfcsr_3572(rt2x00dev); - break; diff --git a/package/kernel/mac80211/patches/rt2x00/600-11-rt2x00-rt2800lib-use-the-extended-EEPROM-map-for-RT3.patch b/package/kernel/mac80211/patches/rt2x00/600-11-rt2x00-rt2800lib-use-the-extended-EEPROM-map-for-RT3.patch deleted file mode 100644 index e74f399e65..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-11-rt2x00-rt2800lib-use-the-extended-EEPROM-map-for-RT3.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 86022438ffeb1b87dfcd018bf477fdbb43076691 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Wed, 8 May 2013 19:35:33 +0200 -Subject: [PATCH] rt2x00: rt2800lib: use the extended EEPROM map for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -381,7 +381,8 @@ static unsigned int rt2800_eeprom_word_i - wiphy_name(rt2x00dev->hw->wiphy), word)) - return 0; - -- if (rt2x00_rt(rt2x00dev, RT3593)) -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - map = rt2800_eeprom_map_ext; - else - map = rt2800_eeprom_map; diff --git a/package/kernel/mac80211/patches/rt2x00/600-12-rt2x00-rt2800lib-force-rf-type-to-RF3853-on-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/600-12-rt2x00-rt2800lib-force-rf-type-to-RF3853-on-RT3883.patch deleted file mode 100644 index 55e703b753..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-12-rt2x00-rt2800lib-force-rf-type-to-RF3853-on-RT3883.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 4cf5403f02fa65dc2207f61d223cffa9ae50e907 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Thu, 1 Aug 2013 14:48:21 +0200 -Subject: [PATCH] rt2x00: rt2800lib: force rf type to RF3853 on RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -9087,6 +9087,8 @@ static int rt2800_init_eeprom(struct rt2 - rf = rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID); - else if (rt2x00_rt(rt2x00dev, RT3352)) - rf = RF3322; -+ else if (rt2x00_rt(rt2x00dev, RT3883)) -+ rf = RF3853; - else if (rt2x00_rt(rt2x00dev, RT5350)) - rf = RF5350; - else diff --git a/package/kernel/mac80211/patches/rt2x00/600-13-rt2x00-rt2800lib-add-channel-configuration-code-for-.patch b/package/kernel/mac80211/patches/rt2x00/600-13-rt2x00-rt2800lib-add-channel-configuration-code-for-.patch deleted file mode 100644 index 7a8d1c06b2..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-13-rt2x00-rt2800lib-add-channel-configuration-code-for-.patch +++ /dev/null @@ -1,136 +0,0 @@ -From 269f19c848a2380db03a3f207cafb88e28d71c53 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sun, 24 Mar 2013 19:26:28 +0100 -Subject: [PATCH] rt2x00: rt2800lib: add channel configuration code for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 72 +++++++++++++++++++++++++++++-- - 1 file changed, 69 insertions(+), 3 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -3741,6 +3741,36 @@ static char rt2800_txpower_to_dev(struct - return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER); - } - -+static void rt3883_bbp_adjust(struct rt2x00_dev *rt2x00dev, -+ struct rf_channel *rf) -+{ -+ u8 bbp; -+ -+ bbp = (rf->channel > 14) ? 0x48 : 0x38; -+ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); -+ -+ rt2800_bbp_write(rt2x00dev, 69, 0x12); -+ -+ if (rf->channel <= 14) { -+ rt2800_bbp_write(rt2x00dev, 70, 0x0a); -+ } else { -+ /* Disable CCK packet detection */ -+ rt2800_bbp_write(rt2x00dev, 70, 0x00); -+ } -+ -+ rt2800_bbp_write(rt2x00dev, 73, 0x10); -+ -+ if (rf->channel > 14) { -+ rt2800_bbp_write(rt2x00dev, 62, 0x1d); -+ rt2800_bbp_write(rt2x00dev, 63, 0x1d); -+ rt2800_bbp_write(rt2x00dev, 64, 0x1d); -+ } else { -+ rt2800_bbp_write(rt2x00dev, 62, 0x2d); -+ rt2800_bbp_write(rt2x00dev, 63, 0x2d); -+ rt2800_bbp_write(rt2x00dev, 64, 0x2d); -+ } -+} -+ - static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, - struct ieee80211_conf *conf, - struct rf_channel *rf, -@@ -3759,6 +3789,12 @@ static void rt2800_config_channel(struct - rt2800_txpower_to_dev(rt2x00dev, rf->channel, - info->default_power3); - -+ switch (rt2x00dev->chip.rt) { -+ case RT3883: -+ rt3883_bbp_adjust(rt2x00dev, rf); -+ break; -+ } -+ - switch (rt2x00dev->chip.rf) { - case RF2020: - case RF3020: -@@ -3863,6 +3899,15 @@ static void rt2800_config_channel(struct - rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); - rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); - rt2800_bbp_write(rt2x00dev, 77, 0x98); -+ } else if (rt2x00_rt(rt2x00dev, RT3883)) { -+ rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); -+ rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); -+ rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); -+ -+ if (rt2x00dev->default_ant.rx_chain_num > 1) -+ rt2800_bbp_write(rt2x00dev, 86, 0x46); -+ else -+ rt2800_bbp_write(rt2x00dev, 86, 0); - } else { - rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); - rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); -@@ -3876,6 +3921,7 @@ static void rt2800_config_channel(struct - !rt2x00_rt(rt2x00dev, RT6352)) { - if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { - rt2800_bbp_write(rt2x00dev, 82, 0x62); -+ rt2800_bbp_write(rt2x00dev, 82, 0x62); - rt2800_bbp_write(rt2x00dev, 75, 0x46); - } else { - if (rt2x00_rt(rt2x00dev, RT3593)) -@@ -3884,19 +3930,22 @@ static void rt2800_config_channel(struct - rt2800_bbp_write(rt2x00dev, 82, 0x84); - rt2800_bbp_write(rt2x00dev, 75, 0x50); - } -- if (rt2x00_rt(rt2x00dev, RT3593)) -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - rt2800_bbp_write(rt2x00dev, 83, 0x8a); - } - - } else { - if (rt2x00_rt(rt2x00dev, RT3572)) - rt2800_bbp_write(rt2x00dev, 82, 0x94); -- else if (rt2x00_rt(rt2x00dev, RT3593)) -+ else if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - rt2800_bbp_write(rt2x00dev, 82, 0x82); - else if (!rt2x00_rt(rt2x00dev, RT6352)) - rt2800_bbp_write(rt2x00dev, 82, 0xf2); - -- if (rt2x00_rt(rt2x00dev, RT3593)) -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - rt2800_bbp_write(rt2x00dev, 83, 0x9a); - - if (rt2x00_has_cap_external_lna_a(rt2x00dev)) -@@ -4022,6 +4071,23 @@ static void rt2800_config_channel(struct - - rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); - -+ usleep_range(1000, 1500); -+ } -+ -+ if (rt2x00_rt(rt2x00dev, RT3883)) { -+ if (!conf_is_ht40(conf)) -+ rt2800_bbp_write(rt2x00dev, 105, 0x34); -+ else -+ rt2800_bbp_write(rt2x00dev, 105, 0x04); -+ -+ /* AGC init */ -+ if (rf->channel <= 14) -+ reg = 0x2e + rt2x00dev->lna_gain; -+ else -+ reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3); -+ -+ rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); -+ - usleep_range(1000, 1500); - } - diff --git a/package/kernel/mac80211/patches/rt2x00/600-14-rt2x00-rt2800lib-fix-txpower_to_dev-function-for-RT3.patch b/package/kernel/mac80211/patches/rt2x00/600-14-rt2x00-rt2800lib-fix-txpower_to_dev-function-for-RT3.patch deleted file mode 100644 index 723f0b7698..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-14-rt2x00-rt2800lib-fix-txpower_to_dev-function-for-RT3.patch +++ /dev/null @@ -1,30 +0,0 @@ -From e37d93abaabe3ab72b0332a18092acc162307274 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Mon, 30 Sep 2013 13:57:26 +0200 -Subject: [PATCH] rt2x00: rt2800lib: fix txpower_to_dev function for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -3728,13 +3728,15 @@ static char rt2800_txpower_to_dev(struct - unsigned int channel, - char txpower) - { -- if (rt2x00_rt(rt2x00dev, RT3593)) -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - txpower = rt2x00_get_field8(txpower, EEPROM_TXPOWER_ALC); - - if (channel <= 14) - return clamp_t(char, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER); - -- if (rt2x00_rt(rt2x00dev, RT3593)) -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - return clamp_t(char, txpower, MIN_A_TXPOWER_3593, - MAX_A_TXPOWER_3593); - else diff --git a/package/kernel/mac80211/patches/rt2x00/600-15-rt2x00-rt2800lib-use-correct-txpower-calculation-fun.patch b/package/kernel/mac80211/patches/rt2x00/600-15-rt2x00-rt2800lib-use-correct-txpower-calculation-fun.patch deleted file mode 100644 index c7d37e8bdb..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-15-rt2x00-rt2800lib-use-correct-txpower-calculation-fun.patch +++ /dev/null @@ -1,23 +0,0 @@ -From c4d79e344bd580d85821390d49f92dced7d8e125 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sun, 24 Mar 2013 19:26:29 +0100 -Subject: [PATCH] rt2x00: rt2800lib: use correct txpower calculation function - for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -5114,7 +5114,8 @@ static void rt2800_config_txpower(struct - struct ieee80211_channel *chan, - int power_level) - { -- if (rt2x00_rt(rt2x00dev, RT3593)) -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - rt2800_config_txpower_rt3593(rt2x00dev, chan, power_level); - else if (rt2x00_rt(rt2x00dev, RT6352)) - rt2800_config_txpower_rt6352(rt2x00dev, chan, power_level); diff --git a/package/kernel/mac80211/patches/rt2x00/600-16-rt2x00-rt2800lib-hardcode-txmixer-gain-values-to-zer.patch b/package/kernel/mac80211/patches/rt2x00/600-16-rt2x00-rt2800lib-hardcode-txmixer-gain-values-to-zer.patch deleted file mode 100644 index d4b5f4ce05..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-16-rt2x00-rt2800lib-hardcode-txmixer-gain-values-to-zer.patch +++ /dev/null @@ -1,33 +0,0 @@ -From caea0671cd8fd9ade4f5969cbe0ee545e94ae105 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Sat, 24 Aug 2013 11:49:55 +0200 -Subject: [PATCH] rt2x00: rt2800lib: hardcode txmixer gain values to zero for - RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8969,7 +8969,8 @@ static u8 rt2800_get_txmixer_gain_24g(st - { - u16 word; - -- if (rt2x00_rt(rt2x00dev, RT3593)) -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - return 0; - - word = rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG); -@@ -8983,7 +8984,8 @@ static u8 rt2800_get_txmixer_gain_5g(str - { - u16 word; - -- if (rt2x00_rt(rt2x00dev, RT3593)) -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - return 0; - - word = rt2800_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A); diff --git a/package/kernel/mac80211/patches/rt2x00/600-17-rt2x00-rt2800lib-use-correct-RT-XWI-size-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/600-17-rt2x00-rt2800lib-use-correct-RT-XWI-size-for-RT3883.patch deleted file mode 100644 index 197aabd7bc..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-17-rt2x00-rt2800lib-use-correct-RT-XWI-size-for-RT3883.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 11c40fb47c4a4dd6ad060c2ae127ced89ffb9fe1 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Thu, 18 Apr 2013 14:33:33 +0200 -Subject: [PATCH] rt2x00: rt2800lib: use correct [RT]XWI size for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -591,6 +591,7 @@ void rt2800_get_txwi_rxwi_size(struct rt - { - switch (rt2x00dev->chip.rt) { - case RT3593: -+ case RT3883: - *txwi_size = TXWI_DESC_SIZE_4WORDS; - *rxwi_size = RXWI_DESC_SIZE_5WORDS; - break; diff --git a/package/kernel/mac80211/patches/rt2x00/600-18-rt2x00-rt2800lib-fix-antenna-configuration-for-RT388.patch b/package/kernel/mac80211/patches/rt2x00/600-18-rt2x00-rt2800lib-fix-antenna-configuration-for-RT388.patch deleted file mode 100644 index 0b5541a4f3..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-18-rt2x00-rt2800lib-fix-antenna-configuration-for-RT388.patch +++ /dev/null @@ -1,22 +0,0 @@ -From fa5ad9c025610c22048add2f0ad03f62b6ca1e74 Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Mon, 30 Sep 2013 16:53:33 +0200 -Subject: [PATCH] rt2x00: rt2800lib: fix antenna configuration for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -2020,7 +2020,8 @@ void rt2800_config_ant(struct rt2x00_dev - rt2800_bbp_write(rt2x00dev, 3, r3); - rt2800_bbp_write(rt2x00dev, 1, r1); - -- if (rt2x00_rt(rt2x00dev, RT3593)) { -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) { - if (ant->rx_chain_num == 1) - rt2800_bbp_write(rt2x00dev, 86, 0x00); - else diff --git a/package/kernel/mac80211/patches/rt2x00/600-19-rt2x00-rt2800lib-fix-LNA-gain-configuration-for-RT38.patch b/package/kernel/mac80211/patches/rt2x00/600-19-rt2x00-rt2800lib-fix-LNA-gain-configuration-for-RT38.patch deleted file mode 100644 index 4c0c88258f..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-19-rt2x00-rt2800lib-fix-LNA-gain-configuration-for-RT38.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 6d668fef3a1baa60bdd715ee062ddb6333d2647c Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Mon, 30 Sep 2013 16:58:23 +0200 -Subject: [PATCH] rt2x00: rt2800lib: fix LNA gain configuration for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -2043,7 +2043,8 @@ static void rt2800_config_lna_gain(struc - eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_LNA); - lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0); - } else if (libconf->rf.channel <= 128) { -- if (rt2x00_rt(rt2x00dev, RT3593)) { -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) { - eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2); - lna_gain = rt2x00_get_field16(eeprom, - EEPROM_EXT_LNA2_A1); -@@ -2053,7 +2054,8 @@ static void rt2800_config_lna_gain(struc - EEPROM_RSSI_BG2_LNA_A1); - } - } else { -- if (rt2x00_rt(rt2x00dev, RT3593)) { -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) { - eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2); - lna_gain = rt2x00_get_field16(eeprom, - EEPROM_EXT_LNA2_A2); diff --git a/package/kernel/mac80211/patches/rt2x00/600-20-rt2x00-rt2800lib-fix-VGC-setup-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/600-20-rt2x00-rt2800lib-fix-VGC-setup-for-RT3883.patch deleted file mode 100644 index 749d2bd627..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-20-rt2x00-rt2800lib-fix-VGC-setup-for-RT3883.patch +++ /dev/null @@ -1,44 +0,0 @@ -From c49b2d829aa1c816a46a577cdec6d2ff14d9f06e Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Tue, 1 Oct 2013 15:40:08 +0200 -Subject: [PATCH] rt2x00: rt2800lib: fix VGC setup for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -5367,7 +5367,8 @@ static u8 rt2800_get_default_vgc(struct - else - vgc = 0x2e + rt2x00dev->lna_gain; - } else { /* 5GHZ band */ -- if (rt2x00_rt(rt2x00dev, RT3593)) -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) - vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3; - else if (rt2x00_rt(rt2x00dev, RT5592)) - vgc = 0x24 + (2 * rt2x00dev->lna_gain); -@@ -5387,7 +5388,8 @@ static inline void rt2800_set_vgc(struct - { - if (qual->vgc_level != vgc_level) { - if (rt2x00_rt(rt2x00dev, RT3572) || -- rt2x00_rt(rt2x00dev, RT3593)) { -+ rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) { - rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, - vgc_level); - } else if (rt2x00_rt(rt2x00dev, RT5592)) { -@@ -5434,6 +5436,11 @@ void rt2800_link_tuner(struct rt2x00_dev - } - break; - -+ case RT3883: -+ if (qual->rssi > -65) -+ vgc += 0x10; -+ break; -+ - case RT5592: - if (qual->rssi > -65) - vgc += 0x20; diff --git a/package/kernel/mac80211/patches/rt2x00/600-21-rt2x00-rt2800lib-fix-EEPROM-LNA-validation-for-RT388.patch b/package/kernel/mac80211/patches/rt2x00/600-21-rt2x00-rt2800lib-fix-EEPROM-LNA-validation-for-RT388.patch deleted file mode 100644 index d6e9dd0c47..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-21-rt2x00-rt2800lib-fix-EEPROM-LNA-validation-for-RT388.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 1616650aea676541d4dc8adc6f4219856d193c8b Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Tue, 1 Oct 2013 17:27:57 +0200 -Subject: [PATCH] rt2x00: rt2800lib: fix EEPROM LNA validation for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -9102,7 +9102,8 @@ static int rt2800_validate_eeprom(struct - word = rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2); - if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10) - rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0); -- if (!rt2x00_rt(rt2x00dev, RT3593)) { -+ if (!rt2x00_rt(rt2x00dev, RT3593) && -+ !rt2x00_rt(rt2x00dev, RT3883)) { - if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 || - rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff) - rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1, -@@ -9122,7 +9123,8 @@ static int rt2800_validate_eeprom(struct - word = rt2800_eeprom_read(rt2x00dev, EEPROM_RSSI_A2); - if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10) - rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0); -- if (!rt2x00_rt(rt2x00dev, RT3593)) { -+ if (!rt2x00_rt(rt2x00dev, RT3593) && -+ !rt2x00_rt(rt2x00dev, RT3883)) { - if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 || - rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff) - rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2, -@@ -9130,7 +9132,8 @@ static int rt2800_validate_eeprom(struct - } - rt2800_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word); - -- if (rt2x00_rt(rt2x00dev, RT3593)) { -+ if (rt2x00_rt(rt2x00dev, RT3593) || -+ rt2x00_rt(rt2x00dev, RT3883)) { - word = rt2800_eeprom_read(rt2x00dev, EEPROM_EXT_LNA2); - if (rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0x00 || - rt2x00_get_field16(word, EEPROM_EXT_LNA2_A1) == 0xff) diff --git a/package/kernel/mac80211/patches/rt2x00/600-22-rt2x00-rt2800lib-fix-txpower-compensation-for-RT3883.patch b/package/kernel/mac80211/patches/rt2x00/600-22-rt2x00-rt2800lib-fix-txpower-compensation-for-RT3883.patch deleted file mode 100644 index 3fe503aafe..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/600-22-rt2x00-rt2800lib-fix-txpower-compensation-for-RT3883.patch +++ /dev/null @@ -1,22 +0,0 @@ -From e3871034a0e7c8a95152dc3eafbcc4535398cbdc Mon Sep 17 00:00:00 2001 -From: Gabor Juhos -Date: Wed, 2 Oct 2013 10:11:59 +0200 -Subject: [PATCH] rt2x00: rt2800lib: fix txpower compensation for RT3883 - -Signed-off-by: Gabor Juhos ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 +++ - 1 file changed, 3 insertions(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -4357,6 +4357,9 @@ static u8 rt2800_compensate_txpower(stru - if (rt2x00_rt(rt2x00dev, RT3593)) - return min_t(u8, txpower, 0xc); - -+ if (rt2x00_rt(rt2x00dev, RT3883)) -+ return min_t(u8, txpower, 0xf); -+ - if (rt2x00_has_cap_power_limit(rt2x00dev)) { - /* - * Check if eirp txpower exceed txpower_limit. diff --git a/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch b/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch index d238072b9a..ab31d8485d 100644 --- a/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch +++ b/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch @@ -105,7 +105,7 @@ .drv_init_registers = rt2800mmio_init_registers, --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h -@@ -702,6 +702,7 @@ enum rt2x00_capability_flags { +@@ -703,6 +703,7 @@ enum rt2x00_capability_flags { REQUIRE_HT_TX_DESC, REQUIRE_PS_AUTOWAKE, REQUIRE_DELAYED_RFKILL, @@ -113,7 +113,7 @@ /* * Capabilities -@@ -977,6 +978,11 @@ struct rt2x00_dev { +@@ -978,6 +979,11 @@ struct rt2x00_dev { const struct firmware *fw; /* @@ -127,7 +127,7 @@ DECLARE_KFIFO_PTR(txstatus_fifo, u32); --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c -@@ -1421,6 +1421,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de +@@ -1423,6 +1423,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup); INIT_WORK(&rt2x00dev->sleep_work, rt2x00lib_sleep); @@ -138,7 +138,7 @@ /* * Let the driver probe the device to detect the capabilities. */ -@@ -1562,6 +1566,11 @@ void rt2x00lib_remove_dev(struct rt2x00_ +@@ -1566,6 +1570,11 @@ void rt2x00lib_remove_dev(struct rt2x00_ * Free the driver data. */ kfree(rt2x00dev->drv_data); diff --git a/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch b/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch index 3d6b33518e..f0c079b62b 100644 --- a/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch +++ b/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch @@ -8,7 +8,7 @@ #include "rt2x00.h" #include "rt2800lib.h" -@@ -9291,6 +9292,17 @@ static int rt2800_init_eeprom(struct rt2 +@@ -9458,6 +9459,17 @@ static int rt2800_init_eeprom(struct rt2 rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); diff --git a/package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch index 7f80e110ab..097c071556 100644 --- a/package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch +++ b/package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch @@ -25,7 +25,7 @@ Signed-off-by: Daniel Golle * EEPROM LNA --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -4123,6 +4123,61 @@ static void rt2800_config_channel(struct +@@ -4290,6 +4290,61 @@ static void rt2800_config_channel(struct rt2800_iq_calibrate(rt2x00dev, rf->channel); } @@ -87,7 +87,7 @@ Signed-off-by: Daniel Golle bbp = rt2800_bbp_read(rt2x00dev, 4); rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * conf_is_ht40(conf)); rt2800_bbp_write(rt2x00dev, 4, bbp); -@@ -9320,7 +9375,8 @@ static int rt2800_init_eeprom(struct rt2 +@@ -9487,7 +9542,8 @@ static int rt2800_init_eeprom(struct rt2 */ eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1); @@ -97,7 +97,7 @@ Signed-off-by: Daniel Golle if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352)) __set_bit(CAPABILITY_EXTERNAL_PA_TX0, -@@ -9331,6 +9387,18 @@ static int rt2800_init_eeprom(struct rt2 +@@ -9498,6 +9554,18 @@ static int rt2800_init_eeprom(struct rt2 &rt2x00dev->cap_flags); } diff --git a/package/kernel/mac80211/patches/rt2x00/651-rt2x00-remove-unneccesary-code.patch b/package/kernel/mac80211/patches/rt2x00/651-rt2x00-remove-unneccesary-code.patch index eb49963500..7038e8e617 100644 --- a/package/kernel/mac80211/patches/rt2x00/651-rt2x00-remove-unneccesary-code.patch +++ b/package/kernel/mac80211/patches/rt2x00/651-rt2x00-remove-unneccesary-code.patch @@ -75,7 +75,7 @@ Signed-off-by: Daniel Golle --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -4136,38 +4136,22 @@ static void rt2800_config_channel(struct +@@ -4303,38 +4303,22 @@ static void rt2800_config_channel(struct reg |= 0x00000101; rt2800_register_write(rt2x00dev, RF_BYPASS3, reg); diff --git a/package/kernel/mac80211/patches/rt2x00/701-rt2800-move-usb-specific-txdone-txstatus-routines-to.patch b/package/kernel/mac80211/patches/rt2x00/701-rt2800-move-usb-specific-txdone-txstatus-routines-to.patch deleted file mode 100644 index 12abf8fdee..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/701-rt2800-move-usb-specific-txdone-txstatus-routines-to.patch +++ /dev/null @@ -1,356 +0,0 @@ -From 0381bfbc400ce4c3000b0b31c577ad9e8071e4f6 Mon Sep 17 00:00:00 2001 -From: Stanislaw Gruszka -Date: Fri, 18 May 2018 12:25:08 +0200 -Subject: [PATCH 1/5] rt2800: move usb specific txdone/txstatus routines to - rt2800lib - -In order to reuse usb txdone/txstatus routines for mmio, move them -to common rt2800lib.c file. - -Signed-off-by: Stanislaw Gruszka ---- - .../net/wireless/ralink/rt2x00/rt2800lib.c | 138 +++++++++++++++++ - .../net/wireless/ralink/rt2x00/rt2800lib.h | 3 + - .../net/wireless/ralink/rt2x00/rt2800usb.c | 143 +----------------- - 3 files changed, 145 insertions(+), 139 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -960,6 +960,47 @@ static void rt2800_rate_from_status(stru - skbdesc->tx_rate_flags = flags; - } - -+static bool rt2800_txdone_entry_check(struct queue_entry *entry, u32 reg) -+{ -+ __le32 *txwi; -+ u32 word; -+ int wcid, ack, pid; -+ int tx_wcid, tx_ack, tx_pid, is_agg; -+ -+ /* -+ * This frames has returned with an IO error, -+ * so the status report is not intended for this -+ * frame. -+ */ -+ if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) -+ return false; -+ -+ wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID); -+ ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED); -+ pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE); -+ is_agg = rt2x00_get_field32(reg, TX_STA_FIFO_TX_AGGRE); -+ -+ /* -+ * Validate if this TX status report is intended for -+ * this entry by comparing the WCID/ACK/PID fields. -+ */ -+ txwi = rt2800_drv_get_txwi(entry); -+ -+ word = rt2x00_desc_read(txwi, 1); -+ tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID); -+ tx_ack = rt2x00_get_field32(word, TXWI_W1_ACK); -+ tx_pid = rt2x00_get_field32(word, TXWI_W1_PACKETID); -+ -+ if (wcid != tx_wcid || ack != tx_ack || (!is_agg && pid != tx_pid)) { -+ rt2x00_dbg(entry->queue->rt2x00dev, -+ "TX status report missed for queue %d entry %d\n", -+ entry->queue->qid, entry->entry_idx); -+ return false; -+ } -+ -+ return true; -+} -+ - void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi, - bool match) - { -@@ -1062,6 +1103,103 @@ void rt2800_txdone_entry(struct queue_en - } - EXPORT_SYMBOL_GPL(rt2800_txdone_entry); - -+void rt2800_txdone(struct rt2x00_dev *rt2x00dev) -+{ -+ struct data_queue *queue; -+ struct queue_entry *entry; -+ u32 reg; -+ u8 qid; -+ bool match; -+ -+ while (kfifo_get(&rt2x00dev->txstatus_fifo, ®)) { -+ /* -+ * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is -+ * guaranteed to be one of the TX QIDs . -+ */ -+ qid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_QUEUE); -+ queue = rt2x00queue_get_tx_queue(rt2x00dev, qid); -+ -+ if (unlikely(rt2x00queue_empty(queue))) { -+ rt2x00_dbg(rt2x00dev, "Got TX status for an empty queue %u, dropping\n", -+ qid); -+ break; -+ } -+ -+ entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); -+ -+ if (unlikely(test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || -+ !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))) { -+ rt2x00_warn(rt2x00dev, "Data pending for entry %u in queue %u\n", -+ entry->entry_idx, qid); -+ break; -+ } -+ -+ match = rt2800_txdone_entry_check(entry, reg); -+ rt2800_txdone_entry(entry, reg, rt2800_drv_get_txwi(entry), match); -+ } -+} -+EXPORT_SYMBOL_GPL(rt2800_txdone); -+ -+static inline bool rt2800_entry_txstatus_timeout(struct queue_entry *entry) -+{ -+ bool tout; -+ -+ if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) -+ return false; -+ -+ tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500)); -+ if (unlikely(tout)) -+ rt2x00_dbg(entry->queue->rt2x00dev, -+ "TX status timeout for entry %d in queue %d\n", -+ entry->entry_idx, entry->queue->qid); -+ return tout; -+ -+} -+ -+bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev) -+{ -+ struct data_queue *queue; -+ struct queue_entry *entry; -+ -+ tx_queue_for_each(rt2x00dev, queue) { -+ entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); -+ if (rt2800_entry_txstatus_timeout(entry)) -+ return true; -+ } -+ return false; -+} -+EXPORT_SYMBOL_GPL(rt2800_txstatus_timeout); -+ -+void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev) -+{ -+ struct data_queue *queue; -+ struct queue_entry *entry; -+ -+ /* -+ * Process any trailing TX status reports for IO failures, -+ * we loop until we find the first non-IO error entry. This -+ * can either be a frame which is free, is being uploaded, -+ * or has completed the upload but didn't have an entry -+ * in the TX_STAT_FIFO register yet. -+ */ -+ tx_queue_for_each(rt2x00dev, queue) { -+ while (!rt2x00queue_empty(queue)) { -+ entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); -+ -+ if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || -+ !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) -+ break; -+ -+ if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) || -+ rt2800_entry_txstatus_timeout(entry)) -+ rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE); -+ else -+ break; -+ } -+ } -+} -+EXPORT_SYMBOL_GPL(rt2800_txdone_nostatus); -+ - static unsigned int rt2800_hw_beacon_base(struct rt2x00_dev *rt2x00dev, - unsigned int index) - { ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -@@ -206,6 +206,9 @@ void rt2800_process_rxwi(struct queue_en - - void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi, - bool match); -+void rt2800_txdone(struct rt2x00_dev *rt2x00dev); -+void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev); -+bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev); - - void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc); - void rt2800_clear_beacon(struct queue_entry *entry); ---- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c -@@ -116,35 +116,6 @@ static bool rt2800usb_txstatus_pending(s - return false; - } - --static inline bool rt2800usb_entry_txstatus_timeout(struct queue_entry *entry) --{ -- bool tout; -- -- if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) -- return false; -- -- tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500)); -- if (unlikely(tout)) -- rt2x00_dbg(entry->queue->rt2x00dev, -- "TX status timeout for entry %d in queue %d\n", -- entry->entry_idx, entry->queue->qid); -- return tout; -- --} -- --static bool rt2800usb_txstatus_timeout(struct rt2x00_dev *rt2x00dev) --{ -- struct data_queue *queue; -- struct queue_entry *entry; -- -- tx_queue_for_each(rt2x00dev, queue) { -- entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); -- if (rt2800usb_entry_txstatus_timeout(entry)) -- return true; -- } -- return false; --} -- - #define TXSTATUS_READ_INTERVAL 1000000 - - static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev, -@@ -171,7 +142,7 @@ static bool rt2800usb_tx_sta_fifo_read_c - } - - /* Check if there is any entry that timedout waiting on TX status */ -- if (rt2800usb_txstatus_timeout(rt2x00dev)) -+ if (rt2800_txstatus_timeout(rt2x00dev)) - queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work); - - if (rt2800usb_txstatus_pending(rt2x00dev)) { -@@ -501,123 +472,17 @@ static int rt2800usb_get_tx_data_len(str - /* - * TX control handlers - */ --static bool rt2800usb_txdone_entry_check(struct queue_entry *entry, u32 reg) --{ -- __le32 *txwi; -- u32 word; -- int wcid, ack, pid; -- int tx_wcid, tx_ack, tx_pid, is_agg; -- -- /* -- * This frames has returned with an IO error, -- * so the status report is not intended for this -- * frame. -- */ -- if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) -- return false; -- -- wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID); -- ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED); -- pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE); -- is_agg = rt2x00_get_field32(reg, TX_STA_FIFO_TX_AGGRE); -- -- /* -- * Validate if this TX status report is intended for -- * this entry by comparing the WCID/ACK/PID fields. -- */ -- txwi = rt2800usb_get_txwi(entry); -- -- word = rt2x00_desc_read(txwi, 1); -- tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID); -- tx_ack = rt2x00_get_field32(word, TXWI_W1_ACK); -- tx_pid = rt2x00_get_field32(word, TXWI_W1_PACKETID); -- -- if (wcid != tx_wcid || ack != tx_ack || (!is_agg && pid != tx_pid)) { -- rt2x00_dbg(entry->queue->rt2x00dev, -- "TX status report missed for queue %d entry %d\n", -- entry->queue->qid, entry->entry_idx); -- return false; -- } -- -- return true; --} -- --static void rt2800usb_txdone(struct rt2x00_dev *rt2x00dev) --{ -- struct data_queue *queue; -- struct queue_entry *entry; -- u32 reg; -- u8 qid; -- bool match; -- -- while (kfifo_get(&rt2x00dev->txstatus_fifo, ®)) { -- /* -- * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is -- * guaranteed to be one of the TX QIDs . -- */ -- qid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_QUEUE); -- queue = rt2x00queue_get_tx_queue(rt2x00dev, qid); -- -- if (unlikely(rt2x00queue_empty(queue))) { -- rt2x00_dbg(rt2x00dev, "Got TX status for an empty queue %u, dropping\n", -- qid); -- break; -- } -- -- entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); -- -- if (unlikely(test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || -- !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))) { -- rt2x00_warn(rt2x00dev, "Data pending for entry %u in queue %u\n", -- entry->entry_idx, qid); -- break; -- } -- -- match = rt2800usb_txdone_entry_check(entry, reg); -- rt2800_txdone_entry(entry, reg, rt2800usb_get_txwi(entry), match); -- } --} -- --static void rt2800usb_txdone_nostatus(struct rt2x00_dev *rt2x00dev) --{ -- struct data_queue *queue; -- struct queue_entry *entry; -- -- /* -- * Process any trailing TX status reports for IO failures, -- * we loop until we find the first non-IO error entry. This -- * can either be a frame which is free, is being uploaded, -- * or has completed the upload but didn't have an entry -- * in the TX_STAT_FIFO register yet. -- */ -- tx_queue_for_each(rt2x00dev, queue) { -- while (!rt2x00queue_empty(queue)) { -- entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); -- -- if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || -- !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) -- break; -- -- if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) || -- rt2800usb_entry_txstatus_timeout(entry)) -- rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE); -- else -- break; -- } -- } --} -- - static void rt2800usb_work_txdone(struct work_struct *work) - { - struct rt2x00_dev *rt2x00dev = - container_of(work, struct rt2x00_dev, txdone_work); - - while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) || -- rt2800usb_txstatus_timeout(rt2x00dev)) { -+ rt2800_txstatus_timeout(rt2x00dev)) { - -- rt2800usb_txdone(rt2x00dev); -+ rt2800_txdone(rt2x00dev); - -- rt2800usb_txdone_nostatus(rt2x00dev); -+ rt2800_txdone_nostatus(rt2x00dev); - - /* - * The hw may delay sending the packet after DMA complete diff --git a/package/kernel/mac80211/patches/rt2x00/702-rt2800mmio-use-txdone-txstatus-routines-from-lib.patch b/package/kernel/mac80211/patches/rt2x00/702-rt2800mmio-use-txdone-txstatus-routines-from-lib.patch deleted file mode 100644 index 9f7f65da39..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/702-rt2800mmio-use-txdone-txstatus-routines-from-lib.patch +++ /dev/null @@ -1,243 +0,0 @@ -From 7993486bbab17f8916993710a8660eb47fd991e9 Mon Sep 17 00:00:00 2001 -From: Stanislaw Gruszka -Date: Mon, 9 Jul 2018 16:07:42 +0200 -Subject: [PATCH 2/5] rt2800mmio: use txdone/txstatus routines from lib - -Use usb txdone/txstatus routines (now in rt2800libc) for mmio devices. - -Note this also change how we handle INT_SOURCE_CSR_TX_FIFO_STATUS -interrupt. Now it is disabled since IRQ routine till end of the txstatus -tasklet (the same behaviour like others interrupts). Reason to do not -disable this interrupt was not to miss any tx status from 16 entries -FIFO register. Now, since we check for tx status timeout, we can -allow to miss some tx statuses. However this will be improved in further -patch where I also implement read status FIFO register in the tasklet. - -Signed-off-by: Stanislaw Gruszka ---- - .../net/wireless/ralink/rt2x00/rt2800mmio.c | 180 +----------------- - .../net/wireless/ralink/rt2x00/rt2x00queue.c | 1 + - 2 files changed, 9 insertions(+), 172 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c -@@ -175,161 +175,6 @@ static void rt2800mmio_wakeup(struct rt2 - rt2800_config(rt2x00dev, &libconf, IEEE80211_CONF_CHANGE_PS); - } - --static bool rt2800mmio_txdone_entry_check(struct queue_entry *entry, u32 status) --{ -- __le32 *txwi; -- u32 word; -- int wcid, tx_wcid; -- -- wcid = rt2x00_get_field32(status, TX_STA_FIFO_WCID); -- -- txwi = rt2800_drv_get_txwi(entry); -- word = rt2x00_desc_read(txwi, 1); -- tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID); -- -- return (tx_wcid == wcid); --} -- --static bool rt2800mmio_txdone_find_entry(struct queue_entry *entry, void *data) --{ -- u32 status = *(u32 *)data; -- -- /* -- * rt2800pci hardware might reorder frames when exchanging traffic -- * with multiple BA enabled STAs. -- * -- * For example, a tx queue -- * [ STA1 | STA2 | STA1 | STA2 ] -- * can result in tx status reports -- * [ STA1 | STA1 | STA2 | STA2 ] -- * when the hw decides to aggregate the frames for STA1 into one AMPDU. -- * -- * To mitigate this effect, associate the tx status to the first frame -- * in the tx queue with a matching wcid. -- */ -- if (rt2800mmio_txdone_entry_check(entry, status) && -- !test_bit(ENTRY_DATA_STATUS_SET, &entry->flags)) { -- /* -- * Got a matching frame, associate the tx status with -- * the frame -- */ -- entry->status = status; -- set_bit(ENTRY_DATA_STATUS_SET, &entry->flags); -- return true; -- } -- -- /* Check the next frame */ -- return false; --} -- --static bool rt2800mmio_txdone_match_first(struct queue_entry *entry, void *data) --{ -- u32 status = *(u32 *)data; -- -- /* -- * Find the first frame without tx status and assign this status to it -- * regardless if it matches or not. -- */ -- if (!test_bit(ENTRY_DATA_STATUS_SET, &entry->flags)) { -- /* -- * Got a matching frame, associate the tx status with -- * the frame -- */ -- entry->status = status; -- set_bit(ENTRY_DATA_STATUS_SET, &entry->flags); -- return true; -- } -- -- /* Check the next frame */ -- return false; --} --static bool rt2800mmio_txdone_release_entries(struct queue_entry *entry, -- void *data) --{ -- if (test_bit(ENTRY_DATA_STATUS_SET, &entry->flags)) { -- rt2800_txdone_entry(entry, entry->status, -- rt2800mmio_get_txwi(entry), true); -- return false; -- } -- -- /* No more frames to release */ -- return true; --} -- --static bool rt2800mmio_txdone(struct rt2x00_dev *rt2x00dev) --{ -- struct data_queue *queue; -- u32 status; -- u8 qid; -- int max_tx_done = 16; -- -- while (kfifo_get(&rt2x00dev->txstatus_fifo, &status)) { -- qid = rt2x00_get_field32(status, TX_STA_FIFO_PID_QUEUE); -- if (unlikely(qid >= QID_RX)) { -- /* -- * Unknown queue, this shouldn't happen. Just drop -- * this tx status. -- */ -- rt2x00_warn(rt2x00dev, "Got TX status report with unexpected pid %u, dropping\n", -- qid); -- break; -- } -- -- queue = rt2x00queue_get_tx_queue(rt2x00dev, qid); -- if (unlikely(queue == NULL)) { -- /* -- * The queue is NULL, this shouldn't happen. Stop -- * processing here and drop the tx status -- */ -- rt2x00_warn(rt2x00dev, "Got TX status for an unavailable queue %u, dropping\n", -- qid); -- break; -- } -- -- if (unlikely(rt2x00queue_empty(queue))) { -- /* -- * The queue is empty. Stop processing here -- * and drop the tx status. -- */ -- rt2x00_warn(rt2x00dev, "Got TX status for an empty queue %u, dropping\n", -- qid); -- break; -- } -- -- /* -- * Let's associate this tx status with the first -- * matching frame. -- */ -- if (!rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, -- Q_INDEX, &status, -- rt2800mmio_txdone_find_entry)) { -- /* -- * We cannot match the tx status to any frame, so just -- * use the first one. -- */ -- if (!rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, -- Q_INDEX, &status, -- rt2800mmio_txdone_match_first)) { -- rt2x00_warn(rt2x00dev, "No frame found for TX status on queue %u, dropping\n", -- qid); -- break; -- } -- } -- -- /* -- * Release all frames with a valid tx status. -- */ -- rt2x00queue_for_each_entry(queue, Q_INDEX_DONE, -- Q_INDEX, NULL, -- rt2800mmio_txdone_release_entries); -- -- if (--max_tx_done == 0) -- break; -- } -- -- return !max_tx_done; --} -- - static inline void rt2800mmio_enable_interrupt(struct rt2x00_dev *rt2x00dev, - struct rt2x00_field32 irq_field) - { -@@ -349,14 +194,14 @@ static inline void rt2800mmio_enable_int - void rt2800mmio_txstatus_tasklet(unsigned long data) - { - struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; -- if (rt2800mmio_txdone(rt2x00dev)) -- tasklet_schedule(&rt2x00dev->txstatus_tasklet); - -- /* -- * No need to enable the tx status interrupt here as we always -- * leave it enabled to minimize the possibility of a tx status -- * register overflow. See comment in interrupt handler. -- */ -+ rt2800_txdone(rt2x00dev); -+ -+ rt2800_txdone_nostatus(rt2x00dev); -+ -+ if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) -+ rt2800mmio_enable_interrupt(rt2x00dev, -+ INT_SOURCE_CSR_TX_FIFO_STATUS); - } - EXPORT_SYMBOL_GPL(rt2800mmio_txstatus_tasklet); - -@@ -440,10 +285,6 @@ static void rt2800mmio_txstatus_interrup - * because we can schedule the tasklet multiple times (when the - * interrupt fires again during tx status processing). - * -- * Furthermore we don't disable the TX_FIFO_STATUS -- * interrupt here but leave it enabled so that the TX_STA_FIFO -- * can also be read while the tx status tasklet gets executed. -- * - * Since we have only one producer and one consumer we don't - * need to lock the kfifo. - */ -@@ -485,13 +326,8 @@ irqreturn_t rt2800mmio_interrupt(int irq - */ - mask = ~reg; - -- if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) { -+ if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) - rt2800mmio_txstatus_interrupt(rt2x00dev); -- /* -- * Never disable the TX_FIFO_STATUS interrupt. -- */ -- rt2x00_set_field32(&mask, INT_MASK_CSR_TX_FIFO_STATUS, 1); -- } - - if (rt2x00_get_field32(reg, INT_SOURCE_CSR_PRE_TBTT)) - tasklet_hi_schedule(&rt2x00dev->pretbtt_tasklet); ---- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c -@@ -113,6 +113,7 @@ int rt2x00queue_map_txskb(struct queue_e - return -ENOMEM; - - skbdesc->flags |= SKBDESC_DMA_MAPPED_TX; -+ rt2x00lib_dmadone(entry); - return 0; - } - EXPORT_SYMBOL_GPL(rt2x00queue_map_txskb); diff --git a/package/kernel/mac80211/patches/rt2x00/703-rt2x00-do-not-check-for-txstatus-timeout-every-time-.patch b/package/kernel/mac80211/patches/rt2x00/703-rt2x00-do-not-check-for-txstatus-timeout-every-time-.patch deleted file mode 100644 index 111f4c7e83..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/703-rt2x00-do-not-check-for-txstatus-timeout-every-time-.patch +++ /dev/null @@ -1,71 +0,0 @@ -From b5d6e37ea15949a126907050d8cfa4408153a0cd Mon Sep 17 00:00:00 2001 -From: Stanislaw Gruszka -Date: Fri, 18 May 2018 12:25:10 +0200 -Subject: [PATCH 3/5] rt2x00: do not check for txstatus timeout every time on - tasklet - -Do not check for tx status timeout everytime we perform txstatus tasklet. -Perform check once per half a second. - -Signed-off-by: Stanislaw Gruszka ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 7 +++++++ - drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 3 ++- - drivers/net/wireless/ralink/rt2x00/rt2x00.h | 2 ++ - drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 1 + - 4 files changed, 12 insertions(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -1161,11 +1161,18 @@ bool rt2800_txstatus_timeout(struct rt2x - struct data_queue *queue; - struct queue_entry *entry; - -+ if (time_before(jiffies, -+ rt2x00dev->last_nostatus_check + msecs_to_jiffies(500))) -+ return false; -+ -+ rt2x00dev->last_nostatus_check = jiffies; -+ - tx_queue_for_each(rt2x00dev, queue) { - entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); - if (rt2800_entry_txstatus_timeout(entry)) - return true; - } -+ - return false; - } - EXPORT_SYMBOL_GPL(rt2800_txstatus_timeout); ---- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c -@@ -197,7 +197,8 @@ void rt2800mmio_txstatus_tasklet(unsigne - - rt2800_txdone(rt2x00dev); - -- rt2800_txdone_nostatus(rt2x00dev); -+ if (rt2800_txstatus_timeout(rt2x00dev)) -+ rt2800_txdone_nostatus(rt2x00dev); - - if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) - rt2800mmio_enable_interrupt(rt2x00dev, ---- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h -+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h -@@ -988,6 +988,8 @@ struct rt2x00_dev { - */ - DECLARE_KFIFO_PTR(txstatus_fifo, u32); - -+ unsigned long last_nostatus_check; -+ - /* - * Timer to ensure tx status reports are read (rt2800usb). - */ ---- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c -@@ -1039,6 +1039,7 @@ void rt2x00queue_start_queues(struct rt2 - */ - tx_queue_for_each(rt2x00dev, queue) - rt2x00queue_start_queue(queue); -+ rt2x00dev->last_nostatus_check = jiffies; - - rt2x00queue_start_queue(rt2x00dev->rx); - } diff --git a/package/kernel/mac80211/patches/rt2x00/704-rt2x00-use-different-txstatus-timeouts-when-flushing.patch b/package/kernel/mac80211/patches/rt2x00/704-rt2x00-use-different-txstatus-timeouts-when-flushing.patch deleted file mode 100644 index 6c4d42b6f1..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/704-rt2x00-use-different-txstatus-timeouts-when-flushing.patch +++ /dev/null @@ -1,111 +0,0 @@ -From feb87977b6d251fb01a329905719e45908f6c939 Mon Sep 17 00:00:00 2001 -From: Stanislaw Gruszka -Date: Fri, 10 Aug 2018 12:31:55 +0200 -Subject: [PATCH 4/5] rt2x00: use different txstatus timeouts when flushing - -Use different tx status timeouts for normal operation and when flushing. -This increase timeout to 2s for normal operation as when there are bad -radio conditions and frames are reposted many times device can not provide -the status for quite long. With new timeout we can still get valid status -on such bad conditions. - -Signed-off-by: Stanislaw Gruszka ---- - .../net/wireless/ralink/rt2x00/rt2800lib.c | 31 +++++++++++++------ - drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 + - .../net/wireless/ralink/rt2x00/rt2x00mac.c | 4 +++ - 3 files changed, 26 insertions(+), 10 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -1140,36 +1140,47 @@ void rt2800_txdone(struct rt2x00_dev *rt - } - EXPORT_SYMBOL_GPL(rt2800_txdone); - --static inline bool rt2800_entry_txstatus_timeout(struct queue_entry *entry) -+static inline bool rt2800_entry_txstatus_timeout(struct rt2x00_dev *rt2x00dev, -+ struct queue_entry *entry) - { -- bool tout; -+ bool ret; -+ unsigned long tout; - - if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) - return false; - -- tout = time_after(jiffies, entry->last_action + msecs_to_jiffies(500)); -- if (unlikely(tout)) -+ if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) -+ tout = msecs_to_jiffies(100); -+ else -+ tout = msecs_to_jiffies(2000); -+ -+ ret = time_after(jiffies, entry->last_action + tout); -+ if (unlikely(ret)) - rt2x00_dbg(entry->queue->rt2x00dev, - "TX status timeout for entry %d in queue %d\n", - entry->entry_idx, entry->queue->qid); -- return tout; -- -+ return ret; - } - - bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev) - { - struct data_queue *queue; - struct queue_entry *entry; -+ unsigned long tout; -+ -+ if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) -+ tout = msecs_to_jiffies(50); -+ else -+ tout = msecs_to_jiffies(1000); - -- if (time_before(jiffies, -- rt2x00dev->last_nostatus_check + msecs_to_jiffies(500))) -+ if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout)) - return false; - - rt2x00dev->last_nostatus_check = jiffies; - - tx_queue_for_each(rt2x00dev, queue) { - entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE); -- if (rt2800_entry_txstatus_timeout(entry)) -+ if (rt2800_entry_txstatus_timeout(rt2x00dev, entry)) - return true; - } - -@@ -1198,7 +1209,7 @@ void rt2800_txdone_nostatus(struct rt2x0 - break; - - if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) || -- rt2800_entry_txstatus_timeout(entry)) -+ rt2800_entry_txstatus_timeout(rt2x00dev, entry)) - rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE); - else - break; ---- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h -+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h -@@ -667,6 +667,7 @@ enum rt2x00_state_flags { - DEVICE_STATE_STARTED, - DEVICE_STATE_ENABLED_RADIO, - DEVICE_STATE_SCANNING, -+ DEVICE_STATE_FLUSHING, - - /* - * Driver configuration ---- a/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00mac.c -@@ -720,8 +720,12 @@ void rt2x00mac_flush(struct ieee80211_hw - if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) - return; - -+ set_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags); -+ - tx_queue_for_each(rt2x00dev, queue) - rt2x00queue_flush_queue(queue, drop); -+ -+ clear_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags); - } - EXPORT_SYMBOL_GPL(rt2x00mac_flush); - diff --git a/package/kernel/mac80211/patches/rt2x00/705-rt2800-flush-and-txstatus-rework-for-rt2800mmio.patch b/package/kernel/mac80211/patches/rt2x00/705-rt2800-flush-and-txstatus-rework-for-rt2800mmio.patch deleted file mode 100644 index 22310185c3..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/705-rt2800-flush-and-txstatus-rework-for-rt2800mmio.patch +++ /dev/null @@ -1,239 +0,0 @@ -From 0d9fbb738a5eadc7abc8060f43ebcc71f6324c07 Mon Sep 17 00:00:00 2001 -From: Stanislaw Gruszka -Date: Tue, 14 Aug 2018 08:58:48 +0200 -Subject: [PATCH 5/5] rt2800: flush and txstatus rework for rt2800mmio - -Implement custom rt2800mmio flush routine and change txstatus -routine to read TX_STA_FIFO also in the tasklet. - -Signed-off-by: Stanislaw Gruszka ---- - .../net/wireless/ralink/rt2x00/rt2800lib.c | 14 +- - .../net/wireless/ralink/rt2x00/rt2800mmio.c | 120 +++++++++++++----- - .../net/wireless/ralink/rt2x00/rt2800mmio.h | 1 + - .../net/wireless/ralink/rt2x00/rt2800pci.c | 2 +- - 4 files changed, 99 insertions(+), 38 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -1150,7 +1150,7 @@ static inline bool rt2800_entry_txstatus - return false; - - if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) -- tout = msecs_to_jiffies(100); -+ tout = msecs_to_jiffies(50); - else - tout = msecs_to_jiffies(2000); - -@@ -1166,15 +1166,13 @@ bool rt2800_txstatus_timeout(struct rt2x - { - struct data_queue *queue; - struct queue_entry *entry; -- unsigned long tout; - -- if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) -- tout = msecs_to_jiffies(50); -- else -- tout = msecs_to_jiffies(1000); -+ if (!test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) { -+ unsigned long tout = msecs_to_jiffies(1000); - -- if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout)) -- return false; -+ if (time_before(jiffies, rt2x00dev->last_nostatus_check + tout)) -+ return false; -+ } - - rt2x00dev->last_nostatus_check = jiffies; - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c -@@ -191,21 +191,6 @@ static inline void rt2800mmio_enable_int - spin_unlock_irq(&rt2x00dev->irqmask_lock); - } - --void rt2800mmio_txstatus_tasklet(unsigned long data) --{ -- struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; -- -- rt2800_txdone(rt2x00dev); -- -- if (rt2800_txstatus_timeout(rt2x00dev)) -- rt2800_txdone_nostatus(rt2x00dev); -- -- if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) -- rt2800mmio_enable_interrupt(rt2x00dev, -- INT_SOURCE_CSR_TX_FIFO_STATUS); --} --EXPORT_SYMBOL_GPL(rt2800mmio_txstatus_tasklet); -- - void rt2800mmio_pretbtt_tasklet(unsigned long data) - { - struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; -@@ -270,12 +255,26 @@ void rt2800mmio_autowake_tasklet(unsigne - } - EXPORT_SYMBOL_GPL(rt2800mmio_autowake_tasklet); - --static void rt2800mmio_txstatus_interrupt(struct rt2x00_dev *rt2x00dev) -+static void rt2800mmio_txdone(struct rt2x00_dev *rt2x00dev) -+{ -+ bool timeout = false; -+ -+ while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) || -+ (timeout = rt2800_txstatus_timeout(rt2x00dev))) { -+ -+ rt2800_txdone(rt2x00dev); -+ -+ if (timeout) -+ rt2800_txdone_nostatus(rt2x00dev); -+ } -+} -+ -+static bool rt2800mmio_fetch_txstatus(struct rt2x00_dev *rt2x00dev) - { - u32 status; -- int i; -+ bool more = false; - -- /* -+ /* FIXEME: rewrite this comment - * The TX_FIFO_STATUS interrupt needs special care. We should - * read TX_STA_FIFO but we should do it immediately as otherwise - * the register can overflow and we would lose status reports. -@@ -286,25 +285,37 @@ static void rt2800mmio_txstatus_interrup - * because we can schedule the tasklet multiple times (when the - * interrupt fires again during tx status processing). - * -- * Since we have only one producer and one consumer we don't -+ * txstatus tasklet is called with INT_SOURCE_CSR_TX_FIFO_STATUS -+ * disabled so have only one producer and one consumer - we don't - * need to lock the kfifo. - */ -- for (i = 0; i < rt2x00dev->tx->limit; i++) { -+ while (!kfifo_is_full(&rt2x00dev->txstatus_fifo)) { - status = rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO); -- - if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID)) - break; - -- if (!kfifo_put(&rt2x00dev->txstatus_fifo, status)) { -- rt2x00_warn(rt2x00dev, "TX status FIFO overrun, drop tx status report\n"); -- break; -- } -+ kfifo_put(&rt2x00dev->txstatus_fifo, status); -+ more = true; - } - -- /* Schedule the tasklet for processing the tx status. */ -- tasklet_schedule(&rt2x00dev->txstatus_tasklet); -+ return more; - } - -+void rt2800mmio_txstatus_tasklet(unsigned long data) -+{ -+ struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data; -+ -+ do { -+ rt2800mmio_txdone(rt2x00dev); -+ -+ } while (rt2800mmio_fetch_txstatus(rt2x00dev)); -+ -+ if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) -+ rt2800mmio_enable_interrupt(rt2x00dev, -+ INT_SOURCE_CSR_TX_FIFO_STATUS); -+} -+EXPORT_SYMBOL_GPL(rt2800mmio_txstatus_tasklet); -+ - irqreturn_t rt2800mmio_interrupt(int irq, void *dev_instance) - { - struct rt2x00_dev *rt2x00dev = dev_instance; -@@ -327,8 +338,10 @@ irqreturn_t rt2800mmio_interrupt(int irq - */ - mask = ~reg; - -- if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) -- rt2800mmio_txstatus_interrupt(rt2x00dev); -+ if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) { -+ rt2800mmio_fetch_txstatus(rt2x00dev); -+ tasklet_schedule(&rt2x00dev->txstatus_tasklet); -+ } - - if (rt2x00_get_field32(reg, INT_SOURCE_CSR_PRE_TBTT)) - tasklet_hi_schedule(&rt2x00dev->pretbtt_tasklet); -@@ -453,6 +466,55 @@ void rt2800mmio_kick_queue(struct data_q - } - EXPORT_SYMBOL_GPL(rt2800mmio_kick_queue); - -+void rt2800mmio_flush_queue(struct data_queue *queue, bool drop) -+{ -+ struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; -+ bool tx_queue = false; -+ unsigned int i; -+ -+ //printk("FLUSH queue %d len %d drop %d\n", queue->qid, queue->length, drop); -+ -+ switch (queue->qid) { -+ case QID_AC_VO: -+ case QID_AC_VI: -+ case QID_AC_BE: -+ case QID_AC_BK: -+ tx_queue = true; -+ break; -+ case QID_RX: -+ break; -+ default: -+ return; -+ } -+ -+ for (i = 0; i < 5; i++) { -+ /* -+ * Check if the driver is already done, otherwise we -+ * have to sleep a little while to give the driver/hw -+ * the oppurtunity to complete interrupt process itself. -+ */ -+ if (rt2x00queue_empty(queue)) -+ break; -+ -+ /* -+ * For TX queues schedule completion tasklet to catch -+ * tx status timeouts, othewise just wait. -+ */ -+ if (tx_queue) { -+ tasklet_disable(&rt2x00dev->txstatus_tasklet); -+ rt2800mmio_txdone(rt2x00dev); -+ tasklet_enable(&rt2x00dev->txstatus_tasklet); -+ } -+ -+ /* -+ * Wait for a little while to give the driver -+ * the oppurtunity to recover itself. -+ */ -+ msleep(50); -+ } -+} -+EXPORT_SYMBOL_GPL(rt2800mmio_flush_queue); -+ - void rt2800mmio_stop_queue(struct data_queue *queue) - { - struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; ---- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.h -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.h -@@ -148,6 +148,7 @@ void rt2800mmio_toggle_irq(struct rt2x00 - /* Queue handlers */ - void rt2800mmio_start_queue(struct data_queue *queue); - void rt2800mmio_kick_queue(struct data_queue *queue); -+void rt2800mmio_flush_queue(struct data_queue *queue, bool drop); - void rt2800mmio_stop_queue(struct data_queue *queue); - void rt2800mmio_queue_init(struct data_queue *queue); - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800pci.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800pci.c -@@ -364,7 +364,7 @@ static const struct rt2x00lib_ops rt2800 - .start_queue = rt2800mmio_start_queue, - .kick_queue = rt2800mmio_kick_queue, - .stop_queue = rt2800mmio_stop_queue, -- .flush_queue = rt2x00mmio_flush_queue, -+ .flush_queue = rt2800mmio_flush_queue, - .write_tx_desc = rt2800mmio_write_tx_desc, - .write_tx_data = rt2800_write_tx_data, - .write_beacon = rt2800_write_beacon, diff --git a/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch b/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch index 639cce0886..08fd1faf01 100644 --- a/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-rf-self-txdc-calibration.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8336,6 +8336,58 @@ static void rt2800_init_rfcsr_5592(struc +@@ -8349,6 +8349,58 @@ static void rt2800_init_rfcsr_5592(struc rt2800_led_open_drain_enable(rt2x00dev); } @@ -69,7 +69,7 @@ } --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -@@ -242,6 +242,7 @@ void rt2800_link_tuner(struct rt2x00_dev +@@ -243,6 +243,7 @@ void rt2800_link_tuner(struct rt2x00_dev const u32 count); void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev); void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev); diff --git a/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch b/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch index 5bba1f2e0e..3981d8f60f 100644 --- a/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8388,6 +8388,160 @@ void rt2800_rf_self_txdc_cal(struct rt2x +@@ -8401,6 +8401,160 @@ void rt2800_rf_self_txdc_cal(struct rt2x } EXPORT_SYMBOL_GPL(rt2800_rf_self_txdc_cal); @@ -171,7 +171,7 @@ rt2800_bw_filter_calibration(rt2x00dev, false); --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -@@ -243,6 +243,8 @@ void rt2800_link_tuner(struct rt2x00_dev +@@ -244,6 +244,8 @@ void rt2800_link_tuner(struct rt2x00_dev void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev); void rt2800_vco_calibration(struct rt2x00_dev *rt2x00dev); void rt2800_rf_self_txdc_cal(struct rt2x00_dev *rt2x00dev); diff --git a/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch b/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch index 6a212c3054..4829a12ccd 100644 --- a/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-rxdcoc-calibration.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8542,6 +8542,71 @@ void rt2800_r_calibration(struct rt2x00_ +@@ -8555,6 +8555,71 @@ void rt2800_r_calibration(struct rt2x00_ } EXPORT_SYMBOL_GPL(rt2800_r_calibration); @@ -82,7 +82,7 @@ } --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -@@ -245,6 +245,7 @@ void rt2800_vco_calibration(struct rt2x0 +@@ -246,6 +246,7 @@ void rt2800_vco_calibration(struct rt2x0 void rt2800_rf_self_txdc_cal(struct rt2x00_dev *rt2x00dev); int rt2800_calcrcalibrationcode(struct rt2x00_dev *rt2x00dev, int d1, int d2); void rt2800_r_calibration(struct rt2x00_dev *rt2x00dev); diff --git a/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch b/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch index b93cdab7bb..cea099c3da 100644 --- a/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-rxiq-calibration.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8607,6 +8607,386 @@ void rt2800_rxdcoc_calibration(struct rt +@@ -8620,6 +8620,386 @@ void rt2800_rxdcoc_calibration(struct rt } EXPORT_SYMBOL_GPL(rt2800_rxdcoc_calibration); @@ -397,7 +397,7 @@ static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -@@ -246,6 +246,7 @@ void rt2800_rf_self_txdc_cal(struct rt2x +@@ -247,6 +247,7 @@ void rt2800_rf_self_txdc_cal(struct rt2x int rt2800_calcrcalibrationcode(struct rt2x00_dev *rt2x00dev, int d1, int d2); void rt2800_r_calibration(struct rt2x00_dev *rt2x00dev); void rt2800_rxdcoc_calibration(struct rt2x00_dev *rt2x00dev); diff --git a/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch b/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch index cfffd53df8..c7d7aa1f08 100644 --- a/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/986-rt2x00-add-TX-LOFT-calibration.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8987,6 +8987,957 @@ restore_value: +@@ -9000,6 +9000,957 @@ restore_value: } EXPORT_SYMBOL_GPL(rt2800_rxiq_calibration); @@ -985,7 +985,7 @@ /* RT2800 driver data structure */ struct rt2800_drv_data { -@@ -247,6 +257,7 @@ int rt2800_calcrcalibrationcode(struct r +@@ -248,6 +258,7 @@ int rt2800_calcrcalibrationcode(struct r void rt2800_r_calibration(struct rt2x00_dev *rt2x00dev); void rt2800_rxdcoc_calibration(struct rt2x00_dev *rt2x00dev); void rt2800_rxiq_calibration(struct rt2x00_dev *rt2x00dev); diff --git a/package/kernel/mac80211/patches/rt2x00/987-rt2x00-reduce-tx-power-to-nominal-level-on-RT6352.patch b/package/kernel/mac80211/patches/rt2x00/987-rt2x00-reduce-tx-power-to-nominal-level-on-RT6352.patch deleted file mode 100644 index f15fe7d817..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/987-rt2x00-reduce-tx-power-to-nominal-level-on-RT6352.patch +++ /dev/null @@ -1,114 +0,0 @@ -From patchwork Thu Dec 27 14:05:25 2018 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 8bit -X-Patchwork-Submitter: Tom Psyborg -X-Patchwork-Id: 10743705 -X-Patchwork-Delegate: kvalo@adurom.com -Return-Path: -Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org - [172.30.200.125]) - by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BC1913B5 - for ; - Thu, 27 Dec 2018 14:06:03 +0000 (UTC) -Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) - by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C758289EC - for ; - Thu, 27 Dec 2018 14:06:03 +0000 (UTC) -Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) - id 0E022289ED; Thu, 27 Dec 2018 14:06:03 +0000 (UTC) -X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on - pdx-wl-mail.web.codeaurora.org -X-Spam-Level: -X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI - autolearn=ham version=3.3.1 -Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) - by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE551289C6 - for ; - Thu, 27 Dec 2018 14:06:02 +0000 (UTC) -Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand - id S1729690AbeL0OFk (ORCPT - ); - Thu, 27 Dec 2018 09:05:40 -0500 -Received: from mail-wr1-f66.google.com ([209.85.221.66]:40863 "EHLO - mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org - with ESMTP id S1729469AbeL0OFk (ORCPT - ); - Thu, 27 Dec 2018 09:05:40 -0500 -Received: by mail-wr1-f66.google.com with SMTP id p4so18360549wrt.7 - for ; - Thu, 27 Dec 2018 06:05:39 -0800 (PST) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=gmail.com; s=20161025; - h=from:to:cc:subject:date:message-id:mime-version - :content-transfer-encoding; - bh=if95ASzOCk1n4rkrJMt0dbDI3WwTIiBNPf8RvdMIJm8=; - b=N78BHSW85OAzpxBdY2OozZyZYjAg6qKOe0l4D2qxSMPfU6K1kgB9f8YZs5Owl9wPyh - RC88Px2yQIdVDsFm3Kww1hEalZ+bN2zLqb5+mOWGMXJyEz7VHfWg6+hpYTjHMVohLkg5 - /+OqTEwl8P17YhXJ0KdEk0aHkt4uSi19pLqD+Jp6SzPPnIY+mx6ODeIAWHi3VH6alfre - plMwZa2EAMcOUCDCygy5ShCJWhXhdeL51VIfYowahUv7xowfw7o5b1+ZihX/DoKGuvHC - hNQAg9QvDOj6lqHyynD9V0pMgGYSVx2g6MPA8uH3vceV1/vgSkaWTxboyiUylHrlMdIo - xZCQ== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20161025; - h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version - :content-transfer-encoding; - bh=if95ASzOCk1n4rkrJMt0dbDI3WwTIiBNPf8RvdMIJm8=; - b=EyuukiKyMQhAsnvAdNATiSxgngxugcTEOlzcC2eOk78pzv8aNJdhWE3+cJLyh1ctj1 - Z/BoIXM298pOrkekyhEZsOnxwGO1p6mrgCBXdoANHvMk93fKtlYT8zNkMZdk6zdXSqBw - bSm8fD5pgGqoLBJH0swL1lrRkHUXSsBsQgCg1YQegfYoWCgdhAnKYmj3OJca5jqfTlJq - pL84CtNEgx9GiXNvsaTU8LeFmKU4GVoMmewsR9WRmw9zSoouDXciq0DHtAoBeElHlCjZ - /8LJQvSLqhONn5xIcFjUdsq3KcqZkCQedwF8WkwVgcA8uksMyKKH0Fj5txHAkeXIyHX3 - IhpA== -X-Gm-Message-State: AJcUukdCD27qMfzN5D3LfBblTlOINVVf3zsHMXqUaYwCxv/GoSStqEqb - ha65rhfifdjaR9/NVSakmWv3ZuEByO4= -X-Google-Smtp-Source: - ALg8bN4sgpNxIiBIAhaU8qSDeso9A0BqyR3EIwbO8UwBaShVrZZ2nAmG7p6zo63420r8KRFPizaXQA== -X-Received: by 2002:a5d:47d1:: with SMTP id - l17mr21936207wrs.319.1545919538745; - Thu, 27 Dec 2018 06:05:38 -0800 (PST) -Received: from localhost.localdomain ([31.147.208.18]) - by smtp.googlemail.com with ESMTPSA id - p6sm38219239wrx.50.2018.12.27.06.05.37 - (version=TLS1 cipher=AES128-SHA bits=128/128); - Thu, 27 Dec 2018 06:05:38 -0800 (PST) -From: =?utf-8?q?Tomislav_Po=C5=BEega?= -To: linux-wireless@vger.kernel.org -Cc: kvalo@codeaurora.org, hauke@hauke-m.de, nbd@nbd.name, - john@phrozen.org, sgruszka@redhat.com, daniel@makrotopia.org -Subject: [PATCH 1/2] rt2x00: reduce tx power to nominal level on RT6352 -Date: Thu, 27 Dec 2018 15:05:25 +0100 -Message-Id: <1545919526-4074-1-git-send-email-pozega.tomislav@gmail.com> -X-Mailer: git-send-email 1.7.0.4 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Sender: linux-wireless-owner@vger.kernel.org -Precedence: bulk -List-ID: -X-Mailing-List: linux-wireless@vger.kernel.org -X-Virus-Scanned: ClamAV using ClamSMTP - -Current implementation of RT6352 support provides too high tx power -at least on iPA/eLNA devices. Reduce amplification of variable gain -amplifier by 6dB to match board target power of 17dBm. -Transmited signal strength with this patch is similar to that of -stock firmware or pandorabox firmware. Throughput measured with iperf -improves. Device tested: Xiaomi Miwifi Mini. - -Signed-off-by: Tomislav Požega ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -5814,7 +5814,7 @@ static int rt2800_init_registers(struct - rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); - rt2800_register_write(rt2x00dev, MIMO_PS_CFG, 0x00000002); - rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0x00150F0F); -- rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x06060606); -+ rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x00000000); - rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0); - rt2800_register_write(rt2x00dev, TX1_BB_GAIN_ATTEN, 0x0); - rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C666C);