From 092e77d94847c7d8530e160106442d97404c4513 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Wed, 29 Jun 2016 17:04:05 +0200 Subject: [PATCH] rtl8xxxu: add support for rtl8188eu MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Patches by Jes Sorensen: https://git.kernel.org/cgit/linux/kernel/git/jes/linux.git/ Signed-off-by: Álvaro Fernández Rojas --- ...-definitions-for-REG_USB_SPECIAL_OPT.patch | 26 + ...itional-documentation-for-RX-DMA-reg.patch | 38 ++ ...003-rtl8xxxu-tuse-ph-to-dump-buffers.patch | 70 +++ ...rtl8xxxu-remove-unneeded-assignments.patch | 29 + ...console-noise-when-removing-the-kern.patch | 25 + ...-ieee80211_rx_status-values-in-parse.patch | 83 +++ ...b-delivery-into-parse_tx_desc-handle.patch | 164 ++++++ ...ieee80211_rx_status-within-parse_rx_.patch | 83 +++ ...rtl8xxxu-Correct-rxdesc16-definition.patch | 36 ++ ...port-for-aggregated-RX-packets-on-ge.patch | 140 +++++ ...e-larger-RX-skbs-when-aggregation-is.patch | 65 +++ ...RX-skb-size-to-include-space-for-phy.patch | 32 ++ ...xxu-Enable-aggregation-for-rtl8723au.patch | 89 +++ ...aggregation-for-rtl8192cu-rtl8188cu-.patch | 32 ++ ...A-aggregation-optional-by-setting-a-.patch | 54 ++ ...t-aggregation-timeout-REG_RXDMA_AGG_.patch | 42 ++ ...d-module-parameters-to-adjust-DMA-ag.patch | 73 +++ ...tl8xxxu-Mark-0x20f4-0x648b-as-tested.patch | 45 ++ ...tl8xxxu-Mark-0x2001-0x3308-as-tested.patch | 45 ++ ...or-handling-if-rtl8xxxu_init_device-.patch | 66 +++ ...Link-TL-WN823N-v2-to-list-of-support.patch | 38 ++ ...l8xxxu-Add-TX-page-defines-for-8723b.patch | 47 ++ ...8723a-to-use-new-rtl8xxxu_init_queue.patch | 26 + ...8192cu-8188cu-devices-to-use-rtl8xxx.patch | 26 + ...now-obsolete-rtl8xxxu_old_init_queue.patch | 60 ++ ...lify-code-setting-TX-buffer-boundary.patch | 30 + ...it-definitions-for-REG_FPGA0_TX_INFO.patch | 25 + ...errupt-bit-definitions-for-gen2-part.patch | 82 +++ ...g-to-indicate-whether-device-has-TX-.patch | 52 ++ ...-flags-in-rtl8xxxu_fileops-to-bitfla.patch | 25 + ...ce-fops-bitflag-indicating-type-of-t.patch | 58 ++ ...y-calculating-of-hw-value-used-for-s.patch | 45 ++ ...ne-the-need-for-SGI-before-handling-.patch | 52 ++ ...ne-need-for-shore-preamble-before-up.patch | 56 ++ ...illing-of-TX-descriptors-into-separa.patch | 314 +++++++++++ ...u-gen1-Fix-non-static-symbol-warning.patch | 27 + ...ke-rtl8xxxu-ampdu-action-less-chatty.patch | 37 ++ ...evice-on-module-unload-if-still-atta.patch | 27 + ...ix-spelling-mistake-firmare-firmware.patch | 29 + ...nt-8192e-specific-power-down-sequenc.patch | 191 +++++++ ...xxu-Accept-firmware-signature-0x88e0.patch | 22 + ...nitial-code-to-detect-8188eu-devices.patch | 121 ++++ ...dd-initial-code-to-part-8188eu-efuse.patch | 113 ++++ ...l8xxxu-Detect-8188eu-parts-correctly.patch | 43 ++ ...xxxu-First-stab-at-rtl8188e_power_on.patch | 102 ++++ ...ail-if-rtl8188eu_emu_to_active-fails.patch | 25 + ...tl8xxxu-Add-rtl8188e_disabled_to_emu.patch | 40 ++ ...0008-rtl8xxxu-8188e-Enable-scheduler.patch | 45 ++ ...8188e_usb_quirk-for-enabling-MAC-TX-.patch | 40 ++ ...8188e-add-REG_TXDMA_OFFSET_CHK-quirk.patch | 34 ++ ...erved-page-init-parameters-for-8188e.patch | 45 ++ ...tl8xxxu-Add-trxff_boundary-for-8188e.patch | 28 + ...specify-firmware-block-size-and-set-.patch | 26 + ...14-rtl8xxxu-Add-8188e-mac-init-table.patch | 57 ++ ...xxxu-Implement-rtl8188eu_init_phy_bb.patch | 245 ++++++++ ...xxxu-Implement-rtl8188eu_init_phy_rf.patch | 103 ++++ ...rtl8xxxu-Use-auto-LLT-init-for-8188e.patch | 24 + ...-not-set-REG_FPGA0_TX_INFO-on-8188eu.patch | 25 + ...mess-with-REG_FPGA0_XA_RF_INT_OE-eit.patch | 27 + ...xu-Set-transfer-page-size-for-8188eu.patch | 21 + ...xxu-Enable-TX-report-timer-on-8188eu.patch | 22 + ...rtl8xxxu-Setup-interrupts-for-8188eu.patch | 31 ++ ...023-rtl8xxxu-Use-rxdesc16-for-8188eu.patch | 27 + ...use-same-ADDA-on-parameters-as-8723a.patch | 25 + ...d-PHY-IQ-calibration-code-for-8188eu.patch | 521 ++++++++++++++++++ ...u-8188eu-uses-the-gen2-thermal-meter.patch | 23 + ...xu-Set-REG_USB_HRPWM-to-0-for-8188eu.patch | 23 + ...8xxxu_gen1_channel_config-for-8188eu.patch | 22 + ...xxu-Use-gen2-H2C-commands-for-8188eu.patch | 25 + ...-Initialize-GPIO-settings-for-8188eu.patch | 40 ++ ...u-Add-simple-rtl8188eu_rf_on-routine.patch | 34 ++ ...l8xxxu-Implement-rtl8188e_disable_rf.patch | 44 ++ ...u-8188eu-uses-32-byte-TX-descriptors.patch | 23 + ...xxxu-Add-dummy-rtl8188e_set_tx_power.patch | 35 ++ ...8188e-efuse-definition-for-power-val.patch | 62 +++ ...xxxu-Implement-rtl8188e_set_tx_power.patch | 84 +++ ...nt-rtl8xxxu_fill_txdesc_v3-for-8188e.patch | 128 +++++ ...e-8188eu-registers-and-update-CCK0_A.patch | 64 +++ ...-register-description-for-REG_FPGA1_.patch | 30 + ...xu-properly-detect-RTL8188EU-devices.patch | 29 + ...Correct-TX_TOTAL_PAGE_NUM-for-8188eu.patch | 24 + ...nt-8188eu-specific-8051-reset-functi.patch | 43 ++ ...ble-packet-DMA-aggregation-on-8188eu.patch | 43 ++ ...set-REG_OFDM0_XA_AGC_CORE1-to-match-.patch | 28 + ...u-Implement-rtl8188eu_config_channel.patch | 146 +++++ ...-0046-rtl8xxxu-Clean-up-llt_init-API.patch | 79 +++ ...l8xxxu-Fix-rtl8188eu-connection-fail.patch | 27 + ...not-set-auto-rate-fallback-on-8188eu.patch | 93 ++++ ...truct-rtl8xxxu_fileops-in-rtl8xxxu_i.patch | 158 ++++++ ...2-0050-rtl8xxxu-Enable-8188eu-driver.patch | 22 + ...xu-Add-rtl8188etv-to-USB-device-list.patch | 25 + ...dd-sitecom-dongle-to-USB-device-list.patch | 23 + ...xu-Implement-rtl8188eu_active_to_emu.patch | 68 +++ ...l8xxxu-Implement-rtl8188eu_power_off.patch | 178 ++++++ ...8188eu-USB-ID-for-D-Link-USB-GO-N150.patch | 25 + ...itional-rtl8188eu-shutdown-code-to-m.patch | 30 + ...ix-off-by-one-error-calculating-pubq.patch | 24 + ...ister-define-used-for-8188-IOL-magic.patch | 35 ++ ...YS_FUNC_UPLL-during-power-up-on-8188.patch | 23 + ...nable-of-WEP-TKIP-security-on-8188eu.patch | 25 + ...rrect-power-down-sequence-for-8188eu.patch | 65 +++ ...-8188eu-REG_GPIO_MUXCFG-on-power-off.patch | 21 + ...le-devices-with-a-smaller-LLT-buffer.patch | 70 +++ ...orrect-value-to-REG_CR-in-rtl8188eu_.patch | 24 + ...loading-of-driver-for-8188eu-devices.patch | 72 +++ 105 files changed, 6333 insertions(+) create mode 100644 package/kernel/mac80211/patches/650-0001-rtl8xxxu-Add-bit-definitions-for-REG_USB_SPECIAL_OPT.patch create mode 100644 package/kernel/mac80211/patches/650-0002-rtl8xxxu-Add-additional-documentation-for-RX-DMA-reg.patch create mode 100644 package/kernel/mac80211/patches/650-0003-rtl8xxxu-tuse-ph-to-dump-buffers.patch create mode 100644 package/kernel/mac80211/patches/650-0004-rtl8xxxu-remove-unneeded-assignments.patch create mode 100644 package/kernel/mac80211/patches/650-0005-rtl8xxxu-Reduce-console-noise-when-removing-the-kern.patch create mode 100644 package/kernel/mac80211/patches/650-0006-rtl8xxxu-Set-all-ieee80211_rx_status-values-in-parse.patch create mode 100644 package/kernel/mac80211/patches/650-0007-rtl8xxxu-Move-skb-delivery-into-parse_tx_desc-handle.patch create mode 100644 package/kernel/mac80211/patches/650-0008-rtl8xxxu-Obtain-ieee80211_rx_status-within-parse_rx_.patch create mode 100644 package/kernel/mac80211/patches/650-0009-rtl8xxxu-Correct-rxdesc16-definition.patch create mode 100644 package/kernel/mac80211/patches/650-0010-rtl8xxxu-Add-support-for-aggregated-RX-packets-on-ge.patch create mode 100644 package/kernel/mac80211/patches/650-0011-rtl8xxxu-Allocate-larger-RX-skbs-when-aggregation-is.patch create mode 100644 package/kernel/mac80211/patches/650-0012-rtl8xxxu-Adjust-RX-skb-size-to-include-space-for-phy.patch create mode 100644 package/kernel/mac80211/patches/650-0013-rtl8xxxu-Enable-aggregation-for-rtl8723au.patch create mode 100644 package/kernel/mac80211/patches/650-0014-rtl8xxxu-Enable-aggregation-for-rtl8192cu-rtl8188cu-.patch create mode 100644 package/kernel/mac80211/patches/650-0015-rtl8xxxu-Make-DMA-aggregation-optional-by-setting-a-.patch create mode 100644 package/kernel/mac80211/patches/650-0016-rtl8xxxu-gen1-Set-aggregation-timeout-REG_RXDMA_AGG_.patch create mode 100644 package/kernel/mac80211/patches/650-0017-rtl8xxxu-gen1-Add-module-parameters-to-adjust-DMA-ag.patch create mode 100644 package/kernel/mac80211/patches/651-0001-rtl8xxxu-Mark-0x20f4-0x648b-as-tested.patch create mode 100644 package/kernel/mac80211/patches/651-0002-rtl8xxxu-Mark-0x2001-0x3308-as-tested.patch create mode 100644 package/kernel/mac80211/patches/651-0003-rtl8xxxu-Fix-error-handling-if-rtl8xxxu_init_device-.patch create mode 100644 package/kernel/mac80211/patches/651-0004-rtl8xxxu-Add-TP-Link-TL-WN823N-v2-to-list-of-support.patch create mode 100644 package/kernel/mac80211/patches/651-0005-rtl8xxxu-Add-TX-page-defines-for-8723b.patch create mode 100644 package/kernel/mac80211/patches/651-0006-rtl8xxxu-Switch-8723a-to-use-new-rtl8xxxu_init_queue.patch create mode 100644 package/kernel/mac80211/patches/651-0007-rtl8xxxu-Switch-8192cu-8188cu-devices-to-use-rtl8xxx.patch create mode 100644 package/kernel/mac80211/patches/651-0008-rtl8xxxu-Remove-now-obsolete-rtl8xxxu_old_init_queue.patch create mode 100644 package/kernel/mac80211/patches/651-0009-rtl8xxxu-Simplify-code-setting-TX-buffer-boundary.patch create mode 100644 package/kernel/mac80211/patches/651-0010-rtl8xxxu-Add-bit-definitions-for-REG_FPGA0_TX_INFO.patch create mode 100644 package/kernel/mac80211/patches/651-0011-rtl8xxxu-Add-interrupt-bit-definitions-for-gen2-part.patch create mode 100644 package/kernel/mac80211/patches/651-0012-rtl8xxxu-Use-flag-to-indicate-whether-device-has-TX-.patch create mode 100644 package/kernel/mac80211/patches/651-0013-rtl8xxxu-Convert-flags-in-rtl8xxxu_fileops-to-bitfla.patch create mode 100644 package/kernel/mac80211/patches/651-0014-rtl8xxxu-Introduce-fops-bitflag-indicating-type-of-t.patch create mode 100644 package/kernel/mac80211/patches/651-0015-rtl8xxxu-Simplify-calculating-of-hw-value-used-for-s.patch create mode 100644 package/kernel/mac80211/patches/651-0016-rtl8xxxu-Determine-the-need-for-SGI-before-handling-.patch create mode 100644 package/kernel/mac80211/patches/651-0017-rtl8xxxu-Determine-need-for-shore-preamble-before-up.patch create mode 100644 package/kernel/mac80211/patches/651-0018-rtl8xxxu-Split-filling-of-TX-descriptors-into-separa.patch create mode 100644 package/kernel/mac80211/patches/651-0019-rtl8xxxu-gen1-Fix-non-static-symbol-warning.patch create mode 100644 package/kernel/mac80211/patches/651-0020-net-wireless-rtl8xxxu-make-rtl8xxxu-ampdu-action-less-chatty.patch create mode 100644 package/kernel/mac80211/patches/651-0021-rtl8xxxu-Reset-device-on-module-unload-if-still-atta.patch create mode 100644 package/kernel/mac80211/patches/651-0022-rtl8xxxu-fix-spelling-mistake-firmare-firmware.patch create mode 100644 package/kernel/mac80211/patches/651-0023-rtl8xxxu-Implement-8192e-specific-power-down-sequenc.patch create mode 100644 package/kernel/mac80211/patches/652-0001-rtl8xxxu-Accept-firmware-signature-0x88e0.patch create mode 100644 package/kernel/mac80211/patches/652-0002-rtl8xxxu-Add-initial-code-to-detect-8188eu-devices.patch create mode 100644 package/kernel/mac80211/patches/652-0003-rtl8xxxu-Add-initial-code-to-part-8188eu-efuse.patch create mode 100644 package/kernel/mac80211/patches/652-0004-rtl8xxxu-Detect-8188eu-parts-correctly.patch create mode 100644 package/kernel/mac80211/patches/652-0005-rtl8xxxu-First-stab-at-rtl8188e_power_on.patch create mode 100644 package/kernel/mac80211/patches/652-0006-rtl8xxxu-8188e-bail-if-rtl8188eu_emu_to_active-fails.patch create mode 100644 package/kernel/mac80211/patches/652-0007-rtl8xxxu-Add-rtl8188e_disabled_to_emu.patch create mode 100644 package/kernel/mac80211/patches/652-0008-rtl8xxxu-8188e-Enable-scheduler.patch create mode 100644 package/kernel/mac80211/patches/652-0009-rtl8xxxu-Add-rtl8188e_usb_quirk-for-enabling-MAC-TX-.patch create mode 100644 package/kernel/mac80211/patches/652-0010-rtl8xxxu-8188e-add-REG_TXDMA_OFFSET_CHK-quirk.patch create mode 100644 package/kernel/mac80211/patches/652-0011-rtl8xxxu-Add-reserved-page-init-parameters-for-8188e.patch create mode 100644 package/kernel/mac80211/patches/652-0012-rtl8xxxu-Add-trxff_boundary-for-8188e.patch create mode 100644 package/kernel/mac80211/patches/652-0013-rtl8xxxu-8188eu-specify-firmware-block-size-and-set-.patch create mode 100644 package/kernel/mac80211/patches/652-0014-rtl8xxxu-Add-8188e-mac-init-table.patch create mode 100644 package/kernel/mac80211/patches/652-0015-rtl8xxxu-Implement-rtl8188eu_init_phy_bb.patch create mode 100644 package/kernel/mac80211/patches/652-0016-rtl8xxxu-Implement-rtl8188eu_init_phy_rf.patch create mode 100644 package/kernel/mac80211/patches/652-0017-rtl8xxxu-Use-auto-LLT-init-for-8188e.patch create mode 100644 package/kernel/mac80211/patches/652-0018-rtl8xxxu-Do-not-set-REG_FPGA0_TX_INFO-on-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0019-rtl8xxxu-Do-not-mess-with-REG_FPGA0_XA_RF_INT_OE-eit.patch create mode 100644 package/kernel/mac80211/patches/652-0020-rtl8xxxu-Set-transfer-page-size-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0021-rtl8xxxu-Enable-TX-report-timer-on-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0022-rtl8xxxu-Setup-interrupts-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0023-rtl8xxxu-Use-rxdesc16-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0024-rtl8xxxu-8188eu-use-same-ADDA-on-parameters-as-8723a.patch create mode 100644 package/kernel/mac80211/patches/652-0025-rtl8xxxu-Add-PHY-IQ-calibration-code-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0026-rtl8xxxu-8188eu-uses-the-gen2-thermal-meter.patch create mode 100644 package/kernel/mac80211/patches/652-0027-rtl8xxxu-Set-REG_USB_HRPWM-to-0-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0028-rtl8xxxu-Use-rtl8xxxu_gen1_channel_config-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0029-rtl8xxxu-Use-gen2-H2C-commands-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0030-rtl8xxxu-Initialize-GPIO-settings-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0031-rtl8xxxu-Add-simple-rtl8188eu_rf_on-routine.patch create mode 100644 package/kernel/mac80211/patches/652-0032-rtl8xxxu-Implement-rtl8188e_disable_rf.patch create mode 100644 package/kernel/mac80211/patches/652-0033-rtl8xxxu-8188eu-uses-32-byte-TX-descriptors.patch create mode 100644 package/kernel/mac80211/patches/652-0034-rtl8xxxu-Add-dummy-rtl8188e_set_tx_power.patch create mode 100644 package/kernel/mac80211/patches/652-0035-rtl8xxxu-Update-8188e-efuse-definition-for-power-val.patch create mode 100644 package/kernel/mac80211/patches/652-0036-rtl8xxxu-Implement-rtl8188e_set_tx_power.patch create mode 100644 package/kernel/mac80211/patches/652-0037-rtl8xxxu-Implement-rtl8xxxu_fill_txdesc_v3-for-8188e.patch create mode 100644 package/kernel/mac80211/patches/652-0038-rtl8xxxu-Add-some-8188eu-registers-and-update-CCK0_A.patch create mode 100644 package/kernel/mac80211/patches/652-0039-rtl8xxxu-Improve-register-description-for-REG_FPGA1_.patch create mode 100644 package/kernel/mac80211/patches/652-0040-rtl8xxxu-properly-detect-RTL8188EU-devices.patch create mode 100644 package/kernel/mac80211/patches/652-0041-rtl8xxxu-Correct-TX_TOTAL_PAGE_NUM-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0042-rtl8xxxu-Implement-8188eu-specific-8051-reset-functi.patch create mode 100644 package/kernel/mac80211/patches/652-0043-rtl8xxxu-Disable-packet-DMA-aggregation-on-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0044-rtl8xxxu-8188eu-set-REG_OFDM0_XA_AGC_CORE1-to-match-.patch create mode 100644 package/kernel/mac80211/patches/652-0045-rtl8xxxu-Implement-rtl8188eu_config_channel.patch create mode 100644 package/kernel/mac80211/patches/652-0046-rtl8xxxu-Clean-up-llt_init-API.patch create mode 100644 package/kernel/mac80211/patches/652-0047-rtl8xxxu-Fix-rtl8188eu-connection-fail.patch create mode 100644 package/kernel/mac80211/patches/652-0048-rtl8xxxu-Do-not-set-auto-rate-fallback-on-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0049-rtl8xxxu-Use-a-struct-rtl8xxxu_fileops-in-rtl8xxxu_i.patch create mode 100644 package/kernel/mac80211/patches/652-0050-rtl8xxxu-Enable-8188eu-driver.patch create mode 100644 package/kernel/mac80211/patches/652-0051-rtl8xxxu-Add-rtl8188etv-to-USB-device-list.patch create mode 100644 package/kernel/mac80211/patches/652-0052-rtl8xxxu-Add-sitecom-dongle-to-USB-device-list.patch create mode 100644 package/kernel/mac80211/patches/652-0053-rtl8xxxu-Implement-rtl8188eu_active_to_emu.patch create mode 100644 package/kernel/mac80211/patches/652-0054-rtl8xxxu-Implement-rtl8188eu_power_off.patch create mode 100644 package/kernel/mac80211/patches/652-0055-rtl8xxxu-Add-rtl8188eu-USB-ID-for-D-Link-USB-GO-N150.patch create mode 100644 package/kernel/mac80211/patches/652-0056-rtl8xxxu-Add-additional-rtl8188eu-shutdown-code-to-m.patch create mode 100644 package/kernel/mac80211/patches/652-0057-rtl8xxxu-Fix-off-by-one-error-calculating-pubq.patch create mode 100644 package/kernel/mac80211/patches/652-0058-rtl8xxxu-Add-register-define-used-for-8188-IOL-magic.patch create mode 100644 package/kernel/mac80211/patches/652-0059-rtl8xxxu-Clear-SYS_FUNC_UPLL-during-power-up-on-8188.patch create mode 100644 package/kernel/mac80211/patches/652-0060-rtl8xxxu-Early-enable-of-WEP-TKIP-security-on-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0061-rtl8xxxu-Correct-power-down-sequence-for-8188eu.patch create mode 100644 package/kernel/mac80211/patches/652-0062-rtl8xxxu-Reset-8188eu-REG_GPIO_MUXCFG-on-power-off.patch create mode 100644 package/kernel/mac80211/patches/652-0063-rtl8xxxu-Handle-devices-with-a-smaller-LLT-buffer.patch create mode 100644 package/kernel/mac80211/patches/652-0064-rtl8xxxu-Write-correct-value-to-REG_CR-in-rtl8188eu_.patch create mode 100644 package/kernel/mac80211/patches/652-0065-rtl8xxxu-Fix-reloading-of-driver-for-8188eu-devices.patch diff --git a/package/kernel/mac80211/patches/650-0001-rtl8xxxu-Add-bit-definitions-for-REG_USB_SPECIAL_OPT.patch b/package/kernel/mac80211/patches/650-0001-rtl8xxxu-Add-bit-definitions-for-REG_USB_SPECIAL_OPT.patch new file mode 100644 index 0000000000..047a33827d --- /dev/null +++ b/package/kernel/mac80211/patches/650-0001-rtl8xxxu-Add-bit-definitions-for-REG_USB_SPECIAL_OPT.patch @@ -0,0 +1,26 @@ +From 0931604ba1483850cd69de30ee5d52d251e15418 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 2 May 2016 15:25:22 -0400 +Subject: [PATCH] rtl8xxxu: Add bit definitions for REG_USB_SPECIAL_OPTION + +Documentation for enabling USB aggregation and whether to select +interrupt or bulk delivery of interrupt events. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -1052,6 +1052,10 @@ + #define USB_HIMR_ROK BIT(0) /* Receive DMA OK Interrupt */ + + #define REG_USB_SPECIAL_OPTION 0xfe55 ++#define USB_SPEC_USB_AGG_ENABLE BIT(3) /* Enable USB aggregation */ ++#define USB_SPEC_INT_BULK_SELECT BIT(4) /* Use interrupt endpoint to ++ deliver interrupt packet. ++ 0: Use int, 1: use bulk */ + #define REG_USB_HRPWM 0xfe58 + #define REG_USB_DMA_AGG_TO 0xfe5b + #define REG_USB_AGG_TO 0xfe5c diff --git a/package/kernel/mac80211/patches/650-0002-rtl8xxxu-Add-additional-documentation-for-RX-DMA-reg.patch b/package/kernel/mac80211/patches/650-0002-rtl8xxxu-Add-additional-documentation-for-RX-DMA-reg.patch new file mode 100644 index 0000000000..a3a5ebdebb --- /dev/null +++ b/package/kernel/mac80211/patches/650-0002-rtl8xxxu-Add-additional-documentation-for-RX-DMA-reg.patch @@ -0,0 +1,38 @@ +From 479bd5f91ac89837def3fe2b31ae8ee720d6ff94 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 2 May 2016 15:59:00 -0400 +Subject: [PATCH] rtl8xxxu: Add additional documentation for RX DMA registers + +This also renames REG_USB_AGG_{TO,TH} to REG_USB_AGG_{TIMEOUT,THRESH} + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -405,7 +405,11 @@ + #define REG_DWBCN1_CTRL_8723B 0x0228 + + /* 0x0280 ~ 0x02FF RXDMA Configuration */ +-#define REG_RXDMA_AGG_PG_TH 0x0280 ++#define REG_RXDMA_AGG_PG_TH 0x0280 /* 0-7 : USB DMA size bits ++ 8-14: USB DMA timeout ++ 15 : Aggregation enable ++ Only seems to be used ++ on 8723bu/8192eu */ + #define RXDMA_USB_AGG_ENABLE BIT(31) + #define REG_RXPKT_NUM 0x0284 + #define RXPKT_NUM_RXDMA_IDLE BIT(17) +@@ -1058,8 +1062,8 @@ + 0: Use int, 1: use bulk */ + #define REG_USB_HRPWM 0xfe58 + #define REG_USB_DMA_AGG_TO 0xfe5b +-#define REG_USB_AGG_TO 0xfe5c +-#define REG_USB_AGG_TH 0xfe5d ++#define REG_USB_AGG_TIMEOUT 0xfe5c ++#define REG_USB_AGG_THRESH 0xfe5d + + #define REG_NORMAL_SIE_VID 0xfe60 /* 0xfe60 - 0xfe61 */ + #define REG_NORMAL_SIE_PID 0xfe62 /* 0xfe62 - 0xfe63 */ diff --git a/package/kernel/mac80211/patches/650-0003-rtl8xxxu-tuse-ph-to-dump-buffers.patch b/package/kernel/mac80211/patches/650-0003-rtl8xxxu-tuse-ph-to-dump-buffers.patch new file mode 100644 index 0000000000..88963fb299 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0003-rtl8xxxu-tuse-ph-to-dump-buffers.patch @@ -0,0 +1,70 @@ +From da21652f72bbdcec7dd8fe61ae32f28608f90c85 Mon Sep 17 00:00:00 2001 +From: Andy Shevchenko +Date: Thu, 26 May 2016 17:52:19 +0300 +Subject: [PATCH] rtl8xxxu: tuse %*ph to dump buffers + +Use %*ph specifier to dump small buffers in hex format instead of doing this +byte-by-byte. + +Signed-off-by: Andy Shevchenko +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 9 ++------- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 9 ++------- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 9 ++------- + 3 files changed, 6 insertions(+), 21 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +@@ -413,13 +413,8 @@ static int rtl8192cu_parse_efuse(struct + dev_info(&priv->udev->dev, + "%s: dumping efuse (0x%02zx bytes):\n", + __func__, sizeof(struct rtl8192cu_efuse)); +- for (i = 0; i < sizeof(struct rtl8192cu_efuse); i += 8) { +- dev_info(&priv->udev->dev, "%02x: " +- "%02x %02x %02x %02x %02x %02x %02x %02x\n", i, +- raw[i], raw[i + 1], raw[i + 2], +- raw[i + 3], raw[i + 4], raw[i + 5], +- raw[i + 6], raw[i + 7]); +- } ++ for (i = 0; i < sizeof(struct rtl8192cu_efuse); i += 8) ++ dev_info(&priv->udev->dev, "%02x: %8ph\n", i, &raw[i]); + } + return 0; + } +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +@@ -622,13 +622,8 @@ static int rtl8192eu_parse_efuse(struct + dev_info(&priv->udev->dev, + "%s: dumping efuse (0x%02zx bytes):\n", + __func__, sizeof(struct rtl8192eu_efuse)); +- for (i = 0; i < sizeof(struct rtl8192eu_efuse); i += 8) { +- dev_info(&priv->udev->dev, "%02x: " +- "%02x %02x %02x %02x %02x %02x %02x %02x\n", i, +- raw[i], raw[i + 1], raw[i + 2], +- raw[i + 3], raw[i + 4], raw[i + 5], +- raw[i + 6], raw[i + 7]); +- } ++ for (i = 0; i < sizeof(struct rtl8192eu_efuse); i += 8) ++ dev_info(&priv->udev->dev, "%02x: %8ph\n", i, &raw[i]); + } + return 0; + } +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +@@ -466,13 +466,8 @@ static int rtl8723bu_parse_efuse(struct + dev_info(&priv->udev->dev, + "%s: dumping efuse (0x%02zx bytes):\n", + __func__, sizeof(struct rtl8723bu_efuse)); +- for (i = 0; i < sizeof(struct rtl8723bu_efuse); i += 8) { +- dev_info(&priv->udev->dev, "%02x: " +- "%02x %02x %02x %02x %02x %02x %02x %02x\n", i, +- raw[i], raw[i + 1], raw[i + 2], +- raw[i + 3], raw[i + 4], raw[i + 5], +- raw[i + 6], raw[i + 7]); +- } ++ for (i = 0; i < sizeof(struct rtl8723bu_efuse); i += 8) ++ dev_info(&priv->udev->dev, "%02x: %8ph\n", i, &raw[i]); + } + + return 0; diff --git a/package/kernel/mac80211/patches/650-0004-rtl8xxxu-remove-unneeded-assignments.patch b/package/kernel/mac80211/patches/650-0004-rtl8xxxu-remove-unneeded-assignments.patch new file mode 100644 index 0000000000..43c633934b --- /dev/null +++ b/package/kernel/mac80211/patches/650-0004-rtl8xxxu-remove-unneeded-assignments.patch @@ -0,0 +1,29 @@ +From 650902b7a7e02064fc295eed9ac4c86cf7435f3b Mon Sep 17 00:00:00 2001 +From: Luis de Bethencourt +Date: Fri, 10 Jun 2016 14:57:34 +0100 +Subject: [PATCH] rtl8xxxu: remove unneeded assignments + +reg_eac and reg_ecc are only used if candidate is bigger than 0, and in +that case new values will be given to them. Removing the unused +assignments. + +Signed-off-by: Luis de Bethencourt +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 2 -- + 1 file changed, 2 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +@@ -1244,11 +1244,9 @@ static void rtl8192eu_phy_iq_calibrate(s + reg_e94 = result[i][0]; + reg_e9c = result[i][1]; + reg_ea4 = result[i][2]; +- reg_eac = result[i][3]; + reg_eb4 = result[i][4]; + reg_ebc = result[i][5]; + reg_ec4 = result[i][6]; +- reg_ecc = result[i][7]; + } + + if (candidate >= 0) { diff --git a/package/kernel/mac80211/patches/650-0005-rtl8xxxu-Reduce-console-noise-when-removing-the-kern.patch b/package/kernel/mac80211/patches/650-0005-rtl8xxxu-Reduce-console-noise-when-removing-the-kern.patch new file mode 100644 index 0000000000..d27bc6399f --- /dev/null +++ b/package/kernel/mac80211/patches/650-0005-rtl8xxxu-Reduce-console-noise-when-removing-the-kern.patch @@ -0,0 +1,25 @@ +From d39e7f8bbab83a2a4145fb8b4701882ef8ba0eeb Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 23 Jun 2016 12:37:38 -0400 +Subject: [PATCH] rtl8xxxu: Reduce console noise when removing the kernel + module + +USB urbs will return with a status != 0 when rmmod'ing the driver. No +need to fill the log with messages from rtl8xxxu_int_complete() + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5267,7 +5267,7 @@ static void rtl8xxxu_int_complete(struct + if (ret) + usb_unanchor_urb(urb); + } else { +- dev_info(dev, "%s: Error %i\n", __func__, urb->status); ++ dev_dbg(dev, "%s: Error %i\n", __func__, urb->status); + } + } + diff --git a/package/kernel/mac80211/patches/650-0006-rtl8xxxu-Set-all-ieee80211_rx_status-values-in-parse.patch b/package/kernel/mac80211/patches/650-0006-rtl8xxxu-Set-all-ieee80211_rx_status-values-in-parse.patch new file mode 100644 index 0000000000..8de6ac4c7a --- /dev/null +++ b/package/kernel/mac80211/patches/650-0006-rtl8xxxu-Set-all-ieee80211_rx_status-values-in-parse.patch @@ -0,0 +1,83 @@ +From be5bf7d23ac03bcfa2e6875248f7d45165589d4f Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 16 May 2016 21:57:25 -0400 +Subject: [PATCH] rtl8xxxu: Set all ieee80211_rx_status values in + parse_rx_desc() + +This needs to be handled locally in the parse_rx_desc() function in +order to be able to handle aggregated packets in the future. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5048,6 +5048,7 @@ static void rtl8xxxu_rx_urb_work(struct + int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb, + struct ieee80211_rx_status *rx_status) + { ++ struct ieee80211_hw *hw = priv->hw; + struct rtl8xxxu_rxdesc16 *rx_desc = + (struct rtl8xxxu_rxdesc16 *)skb->data; + struct rtl8723au_phy_stats *phy_stats; +@@ -5059,6 +5060,8 @@ int rtl8xxxu_parse_rxdesc16(struct rtl8x + for (i = 0; i < (sizeof(struct rtl8xxxu_rxdesc16) / sizeof(u32)); i++) + _rx_desc[i] = le32_to_cpu(_rx_desc_le[i]); + ++ memset(rx_status, 0, sizeof(struct ieee80211_rx_status)); ++ + skb_pull(skb, sizeof(struct rtl8xxxu_rxdesc16)); + + phy_stats = (struct rtl8723au_phy_stats *)skb->data; +@@ -5088,12 +5091,16 @@ int rtl8xxxu_parse_rxdesc16(struct rtl8x + rx_status->rate_idx = rx_desc->rxmcs; + } + ++ rx_status->freq = hw->conf.chandef.chan->center_freq; ++ rx_status->band = hw->conf.chandef.chan->band; ++ + return RX_TYPE_DATA_PKT; + } + + int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb, + struct ieee80211_rx_status *rx_status) + { ++ struct ieee80211_hw *hw = priv->hw; + struct rtl8xxxu_rxdesc24 *rx_desc = + (struct rtl8xxxu_rxdesc24 *)skb->data; + struct rtl8723au_phy_stats *phy_stats; +@@ -5105,6 +5112,8 @@ int rtl8xxxu_parse_rxdesc24(struct rtl8x + for (i = 0; i < (sizeof(struct rtl8xxxu_rxdesc24) / sizeof(u32)); i++) + _rx_desc[i] = le32_to_cpu(_rx_desc_le[i]); + ++ memset(rx_status, 0, sizeof(struct ieee80211_rx_status)); ++ + skb_pull(skb, sizeof(struct rtl8xxxu_rxdesc24)); + + phy_stats = (struct rtl8723au_phy_stats *)skb->data; +@@ -5140,6 +5149,9 @@ int rtl8xxxu_parse_rxdesc24(struct rtl8x + rx_status->rate_idx = rx_desc->rxmcs; + } + ++ rx_status->freq = hw->conf.chandef.chan->center_freq; ++ rx_status->band = hw->conf.chandef.chan->band; ++ + return RX_TYPE_DATA_PKT; + } + +@@ -5202,13 +5214,8 @@ static void rtl8xxxu_rx_complete(struct + skb_put(skb, urb->actual_length); + + if (urb->status == 0) { +- memset(rx_status, 0, sizeof(struct ieee80211_rx_status)); +- + rx_type = priv->fops->parse_rx_desc(priv, skb, rx_status); + +- rx_status->freq = hw->conf.chandef.chan->center_freq; +- rx_status->band = hw->conf.chandef.chan->band; +- + if (rx_type == RX_TYPE_DATA_PKT) + ieee80211_rx_irqsafe(hw, skb); + else { diff --git a/package/kernel/mac80211/patches/650-0007-rtl8xxxu-Move-skb-delivery-into-parse_tx_desc-handle.patch b/package/kernel/mac80211/patches/650-0007-rtl8xxxu-Move-skb-delivery-into-parse_tx_desc-handle.patch new file mode 100644 index 0000000000..4d9bd43b18 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0007-rtl8xxxu-Move-skb-delivery-into-parse_tx_desc-handle.patch @@ -0,0 +1,164 @@ +From 83bb21c65c73a5250504e6056e29683339fb15d2 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 16 May 2016 22:03:04 -0400 +Subject: [PATCH] rtl8xxxu: Move skb delivery into parse_tx_desc() handler + +This is another prepatory patch to be able to handle aggregated RX +packets. + +In order to avoid adding a prototype, this also moves the +rtl8723bu_handle_c2h() function. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 104 ++++++++++----------- + 1 file changed, 50 insertions(+), 54 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5045,6 +5045,51 @@ static void rtl8xxxu_rx_urb_work(struct + } + } + ++static void rtl8723bu_handle_c2h(struct rtl8xxxu_priv *priv, ++ struct sk_buff *skb) ++{ ++ struct rtl8723bu_c2h *c2h = (struct rtl8723bu_c2h *)skb->data; ++ struct device *dev = &priv->udev->dev; ++ int len; ++ ++ len = skb->len - 2; ++ ++ dev_dbg(dev, "C2H ID %02x seq %02x, len %02x source %02x\n", ++ c2h->id, c2h->seq, len, c2h->bt_info.response_source); ++ ++ switch(c2h->id) { ++ case C2H_8723B_BT_INFO: ++ if (c2h->bt_info.response_source > ++ BT_INFO_SRC_8723B_BT_ACTIVE_SEND) ++ dev_dbg(dev, "C2H_BT_INFO WiFi only firmware\n"); ++ else ++ dev_dbg(dev, "C2H_BT_INFO BT/WiFi coexist firmware\n"); ++ ++ if (c2h->bt_info.bt_has_reset) ++ dev_dbg(dev, "BT has been reset\n"); ++ if (c2h->bt_info.tx_rx_mask) ++ dev_dbg(dev, "BT TRx mask\n"); ++ ++ break; ++ case C2H_8723B_BT_MP_INFO: ++ dev_dbg(dev, "C2H_MP_INFO ext ID %02x, status %02x\n", ++ c2h->bt_mp_info.ext_id, c2h->bt_mp_info.status); ++ break; ++ case C2H_8723B_RA_REPORT: ++ dev_dbg(dev, ++ "C2H RA RPT: rate %02x, unk %i, macid %02x, noise %i\n", ++ c2h->ra_report.rate, c2h->ra_report.dummy0_0, ++ c2h->ra_report.macid, c2h->ra_report.noisy_state); ++ break; ++ default: ++ dev_info(dev, "Unhandled C2H event %02x seq %02x\n", ++ c2h->id, c2h->seq); ++ print_hex_dump(KERN_INFO, "C2H content: ", DUMP_PREFIX_NONE, ++ 16, 1, c2h->raw.payload, len, false); ++ break; ++ } ++} ++ + int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb, + struct ieee80211_rx_status *rx_status) + { +@@ -5094,6 +5139,7 @@ int rtl8xxxu_parse_rxdesc16(struct rtl8x + rx_status->freq = hw->conf.chandef.chan->center_freq; + rx_status->band = hw->conf.chandef.chan->band; + ++ ieee80211_rx_irqsafe(hw, skb); + return RX_TYPE_DATA_PKT; + } + +@@ -5125,6 +5171,8 @@ int rtl8xxxu_parse_rxdesc24(struct rtl8x + if (rx_desc->rpt_sel) { + struct device *dev = &priv->udev->dev; + dev_dbg(dev, "%s: C2H packet\n", __func__); ++ rtl8723bu_handle_c2h(priv, skb); ++ dev_kfree_skb(skb); + return RX_TYPE_C2H; + } + +@@ -5152,54 +5200,10 @@ int rtl8xxxu_parse_rxdesc24(struct rtl8x + rx_status->freq = hw->conf.chandef.chan->center_freq; + rx_status->band = hw->conf.chandef.chan->band; + ++ ieee80211_rx_irqsafe(hw, skb); + return RX_TYPE_DATA_PKT; + } + +-static void rtl8723bu_handle_c2h(struct rtl8xxxu_priv *priv, +- struct sk_buff *skb) +-{ +- struct rtl8723bu_c2h *c2h = (struct rtl8723bu_c2h *)skb->data; +- struct device *dev = &priv->udev->dev; +- int len; +- +- len = skb->len - 2; +- +- dev_dbg(dev, "C2H ID %02x seq %02x, len %02x source %02x\n", +- c2h->id, c2h->seq, len, c2h->bt_info.response_source); +- +- switch(c2h->id) { +- case C2H_8723B_BT_INFO: +- if (c2h->bt_info.response_source > +- BT_INFO_SRC_8723B_BT_ACTIVE_SEND) +- dev_dbg(dev, "C2H_BT_INFO WiFi only firmware\n"); +- else +- dev_dbg(dev, "C2H_BT_INFO BT/WiFi coexist firmware\n"); +- +- if (c2h->bt_info.bt_has_reset) +- dev_dbg(dev, "BT has been reset\n"); +- if (c2h->bt_info.tx_rx_mask) +- dev_dbg(dev, "BT TRx mask\n"); +- +- break; +- case C2H_8723B_BT_MP_INFO: +- dev_dbg(dev, "C2H_MP_INFO ext ID %02x, status %02x\n", +- c2h->bt_mp_info.ext_id, c2h->bt_mp_info.status); +- break; +- case C2H_8723B_RA_REPORT: +- dev_dbg(dev, +- "C2H RA RPT: rate %02x, unk %i, macid %02x, noise %i\n", +- c2h->ra_report.rate, c2h->ra_report.dummy0_0, +- c2h->ra_report.macid, c2h->ra_report.noisy_state); +- break; +- default: +- dev_info(dev, "Unhandled C2H event %02x seq %02x\n", +- c2h->id, c2h->seq); +- print_hex_dump(KERN_INFO, "C2H content: ", DUMP_PREFIX_NONE, +- 16, 1, c2h->raw.payload, len, false); +- break; +- } +-} +- + static void rtl8xxxu_rx_complete(struct urb *urb) + { + struct rtl8xxxu_rx_urb *rx_urb = +@@ -5209,19 +5213,11 @@ static void rtl8xxxu_rx_complete(struct + struct sk_buff *skb = (struct sk_buff *)urb->context; + struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); + struct device *dev = &priv->udev->dev; +- int rx_type; + + skb_put(skb, urb->actual_length); + + if (urb->status == 0) { +- rx_type = priv->fops->parse_rx_desc(priv, skb, rx_status); +- +- if (rx_type == RX_TYPE_DATA_PKT) +- ieee80211_rx_irqsafe(hw, skb); +- else { +- rtl8723bu_handle_c2h(priv, skb); +- dev_kfree_skb(skb); +- } ++ priv->fops->parse_rx_desc(priv, skb, rx_status); + + skb = NULL; + rx_urb->urb.context = NULL; diff --git a/package/kernel/mac80211/patches/650-0008-rtl8xxxu-Obtain-ieee80211_rx_status-within-parse_rx_.patch b/package/kernel/mac80211/patches/650-0008-rtl8xxxu-Obtain-ieee80211_rx_status-within-parse_rx_.patch new file mode 100644 index 0000000000..a91282fcb5 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0008-rtl8xxxu-Obtain-ieee80211_rx_status-within-parse_rx_.patch @@ -0,0 +1,83 @@ +From d6e54e5f7c011c2396c4cec56ca8e8e5cf1c89da Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 16 May 2016 22:13:22 -0400 +Subject: [PATCH] rtl8xxxu: Obtain ieee80211_rx_status within parse_rx_desc() + +When handling aggregated packets, we'll get a new ieee80211_rx_status +for each cloned skb, so passing in the pointer from the outside +doesn't make sense. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 9 +++------ + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 +++++------ + 2 files changed, 8 insertions(+), 12 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1315,8 +1315,7 @@ struct rtl8xxxu_fileops { + void (*phy_init_antenna_selection) (struct rtl8xxxu_priv *priv); + void (*phy_iq_calibrate) (struct rtl8xxxu_priv *priv); + void (*config_channel) (struct ieee80211_hw *hw); +- int (*parse_rx_desc) (struct rtl8xxxu_priv *priv, struct sk_buff *skb, +- struct ieee80211_rx_status *rx_status); ++ int (*parse_rx_desc) (struct rtl8xxxu_priv *priv, struct sk_buff *skb); + void (*init_aggregation) (struct rtl8xxxu_priv *priv); + void (*init_statistics) (struct rtl8xxxu_priv *priv); + void (*enable_rf) (struct rtl8xxxu_priv *priv); +@@ -1412,10 +1411,8 @@ void rtl8xxxu_gen2_report_connect(struct + void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv *priv); + void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv *priv); + void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv); +-int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb, +- struct ieee80211_rx_status *rx_status); +-int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb, +- struct ieee80211_rx_status *rx_status); ++int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb); ++int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb); + int rtl8xxxu_gen2_channel_to_group(int channel); + bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv, + int result[][8], int c1, int c2); +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5090,10 +5090,10 @@ static void rtl8723bu_handle_c2h(struct + } + } + +-int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb, +- struct ieee80211_rx_status *rx_status) ++int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb) + { + struct ieee80211_hw *hw = priv->hw; ++ struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); + struct rtl8xxxu_rxdesc16 *rx_desc = + (struct rtl8xxxu_rxdesc16 *)skb->data; + struct rtl8723au_phy_stats *phy_stats; +@@ -5143,10 +5143,10 @@ int rtl8xxxu_parse_rxdesc16(struct rtl8x + return RX_TYPE_DATA_PKT; + } + +-int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb, +- struct ieee80211_rx_status *rx_status) ++int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb) + { + struct ieee80211_hw *hw = priv->hw; ++ struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); + struct rtl8xxxu_rxdesc24 *rx_desc = + (struct rtl8xxxu_rxdesc24 *)skb->data; + struct rtl8723au_phy_stats *phy_stats; +@@ -5211,13 +5211,12 @@ static void rtl8xxxu_rx_complete(struct + struct ieee80211_hw *hw = rx_urb->hw; + struct rtl8xxxu_priv *priv = hw->priv; + struct sk_buff *skb = (struct sk_buff *)urb->context; +- struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); + struct device *dev = &priv->udev->dev; + + skb_put(skb, urb->actual_length); + + if (urb->status == 0) { +- priv->fops->parse_rx_desc(priv, skb, rx_status); ++ priv->fops->parse_rx_desc(priv, skb); + + skb = NULL; + rx_urb->urb.context = NULL; diff --git a/package/kernel/mac80211/patches/650-0009-rtl8xxxu-Correct-rxdesc16-definition.patch b/package/kernel/mac80211/patches/650-0009-rtl8xxxu-Correct-rxdesc16-definition.patch new file mode 100644 index 0000000000..a0c5500ad6 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0009-rtl8xxxu-Correct-rxdesc16-definition.patch @@ -0,0 +1,36 @@ +From 5af9037975b20c64faa6e4829971b9a039342352 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 19 May 2016 20:29:01 -0400 +Subject: [PATCH] rtl8xxxu: Correct rxdesc16 definition + +This corrects the definition of rxdesc16 to correctly specify pkt_cnt +for aggregated packets. This is based on the code of the vendor +rtl8723au driver, as opposed to the struct definitions they use. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -135,7 +135,8 @@ struct rtl8xxxu_rxdesc16 { + + u32 seq:12; + u32 frag:4; +- u32 nextpktlen:14; ++ u32 pkt_cnt:8; ++ u32 reserved:6; + u32 nextind:1; + u32 reserved0:1; + +@@ -198,7 +199,8 @@ struct rtl8xxxu_rxdesc16 { + + u32 reserved0:1; + u32 nextind:1; +- u32 nextpktlen:14; ++ u32 reserved:6; ++ u32 pkt_cnt:8; + u32 frag:4; + u32 seq:12; + diff --git a/package/kernel/mac80211/patches/650-0010-rtl8xxxu-Add-support-for-aggregated-RX-packets-on-ge.patch b/package/kernel/mac80211/patches/650-0010-rtl8xxxu-Add-support-for-aggregated-RX-packets-on-ge.patch new file mode 100644 index 0000000000..6a6da06404 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0010-rtl8xxxu-Add-support-for-aggregated-RX-packets-on-ge.patch @@ -0,0 +1,140 @@ +From 6cee81e9411abb9fc538308b06e75b4f2cdbde1c Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 20 May 2016 00:15:47 -0400 +Subject: [PATCH] rtl8xxxu: Add support for aggregated RX packets on gen1 parts + +This implements support for demuxing aggregated RX packets on gen1 +devices, using the rxdesc16 format. + +So far this has only been tested with rtl8723au devices. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 103 ++++++++++++++------- + 1 file changed, 69 insertions(+), 34 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5093,53 +5093,88 @@ static void rtl8723bu_handle_c2h(struct + int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb) + { + struct ieee80211_hw *hw = priv->hw; +- struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); +- struct rtl8xxxu_rxdesc16 *rx_desc = +- (struct rtl8xxxu_rxdesc16 *)skb->data; ++ struct ieee80211_rx_status *rx_status; ++ struct rtl8xxxu_rxdesc16 *rx_desc; + struct rtl8723au_phy_stats *phy_stats; +- __le32 *_rx_desc_le = (__le32 *)skb->data; +- u32 *_rx_desc = (u32 *)skb->data; ++ struct sk_buff *next_skb = NULL; ++ __le32 *_rx_desc_le; ++ u32 *_rx_desc; + int drvinfo_sz, desc_shift; +- int i; ++ int i, pkt_cnt, pkt_len, urb_len, pkt_offset; + +- for (i = 0; i < (sizeof(struct rtl8xxxu_rxdesc16) / sizeof(u32)); i++) +- _rx_desc[i] = le32_to_cpu(_rx_desc_le[i]); ++ urb_len = skb->len; ++ pkt_cnt = 0; + +- memset(rx_status, 0, sizeof(struct ieee80211_rx_status)); ++ do { ++ rx_desc = (struct rtl8xxxu_rxdesc16 *)skb->data; ++ _rx_desc_le = (__le32 *)skb->data; ++ _rx_desc = (u32 *)skb->data; + +- skb_pull(skb, sizeof(struct rtl8xxxu_rxdesc16)); ++ for (i = 0; ++ i < (sizeof(struct rtl8xxxu_rxdesc16) / sizeof(u32)); i++) ++ _rx_desc[i] = le32_to_cpu(_rx_desc_le[i]); + +- phy_stats = (struct rtl8723au_phy_stats *)skb->data; ++ /* ++ * Only read pkt_cnt from the header if we're parsing the ++ * first packet ++ */ ++ if (!pkt_cnt) ++ pkt_cnt = rx_desc->pkt_cnt; ++ pkt_len = rx_desc->pktlen; + +- drvinfo_sz = rx_desc->drvinfo_sz * 8; +- desc_shift = rx_desc->shift; +- skb_pull(skb, drvinfo_sz + desc_shift); ++ drvinfo_sz = rx_desc->drvinfo_sz * 8; ++ desc_shift = rx_desc->shift; ++ pkt_offset = roundup(pkt_len + drvinfo_sz + desc_shift + ++ sizeof(struct rtl8xxxu_rxdesc16), 128); + +- if (rx_desc->phy_stats) +- rtl8xxxu_rx_parse_phystats(priv, rx_status, phy_stats, +- rx_desc->rxmcs); ++ if (pkt_cnt > 1) ++ next_skb = skb_clone(skb, GFP_ATOMIC); + +- rx_status->mactime = le32_to_cpu(rx_desc->tsfl); +- rx_status->flag |= RX_FLAG_MACTIME_START; ++ rx_status = IEEE80211_SKB_RXCB(skb); ++ memset(rx_status, 0, sizeof(struct ieee80211_rx_status)); + +- if (!rx_desc->swdec) +- rx_status->flag |= RX_FLAG_DECRYPTED; +- if (rx_desc->crc32) +- rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; +- if (rx_desc->bw) +- rx_status->flag |= RX_FLAG_40MHZ; ++ skb_pull(skb, sizeof(struct rtl8xxxu_rxdesc16)); + +- if (rx_desc->rxht) { +- rx_status->flag |= RX_FLAG_HT; +- rx_status->rate_idx = rx_desc->rxmcs - DESC_RATE_MCS0; +- } else { +- rx_status->rate_idx = rx_desc->rxmcs; +- } ++ phy_stats = (struct rtl8723au_phy_stats *)skb->data; + +- rx_status->freq = hw->conf.chandef.chan->center_freq; +- rx_status->band = hw->conf.chandef.chan->band; ++ skb_pull(skb, drvinfo_sz + desc_shift); ++ ++ skb_trim(skb, pkt_len); ++ ++ if (rx_desc->phy_stats) ++ rtl8xxxu_rx_parse_phystats(priv, rx_status, phy_stats, ++ rx_desc->rxmcs); ++ ++ rx_status->mactime = le32_to_cpu(rx_desc->tsfl); ++ rx_status->flag |= RX_FLAG_MACTIME_START; ++ ++ if (!rx_desc->swdec) ++ rx_status->flag |= RX_FLAG_DECRYPTED; ++ if (rx_desc->crc32) ++ rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; ++ if (rx_desc->bw) ++ rx_status->flag |= RX_FLAG_40MHZ; ++ ++ if (rx_desc->rxht) { ++ rx_status->flag |= RX_FLAG_HT; ++ rx_status->rate_idx = rx_desc->rxmcs - DESC_RATE_MCS0; ++ } else { ++ rx_status->rate_idx = rx_desc->rxmcs; ++ } ++ ++ rx_status->freq = hw->conf.chandef.chan->center_freq; ++ rx_status->band = hw->conf.chandef.chan->band; ++ ++ ieee80211_rx_irqsafe(hw, skb); ++ ++ skb = next_skb; ++ if (skb) ++ skb_pull(next_skb, pkt_offset); ++ ++ pkt_cnt--; ++ urb_len -= pkt_offset; ++ } while (skb && urb_len > 0 && pkt_cnt > 0); + +- ieee80211_rx_irqsafe(hw, skb); + return RX_TYPE_DATA_PKT; + } + diff --git a/package/kernel/mac80211/patches/650-0011-rtl8xxxu-Allocate-larger-RX-skbs-when-aggregation-is.patch b/package/kernel/mac80211/patches/650-0011-rtl8xxxu-Allocate-larger-RX-skbs-when-aggregation-is.patch new file mode 100644 index 0000000000..ccd68ec792 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0011-rtl8xxxu-Allocate-larger-RX-skbs-when-aggregation-is.patch @@ -0,0 +1,65 @@ +From 48c31d0cdbadc082abfcf88c2bd161fab4000bb4 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Sat, 21 May 2016 13:43:51 -0400 +Subject: [PATCH] rtl8xxxu: Allocate larger RX skbs when aggregation is enabled + +This adds support for allocating larger skbs for devices which +indicate they support it. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 2 ++ + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 13 +++++++++---- + 2 files changed, 11 insertions(+), 4 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1247,6 +1247,7 @@ struct rtl8xxxu_priv { + u32 ep_tx_normal_queue:1; + u32 ep_tx_low_queue:1; + u32 has_xtalk:1; ++ u32 rx_buf_aggregation:1; + u8 xtalk; + unsigned int pipe_interrupt; + unsigned int pipe_in; +@@ -1330,6 +1331,7 @@ struct rtl8xxxu_fileops { + void (*report_connect) (struct rtl8xxxu_priv *priv, + u8 macid, bool connect); + int writeN_block_size; ++ int rx_agg_buf_size; + char tx_desc_size; + char rx_desc_size; + char has_s0s1; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -64,8 +64,6 @@ module_param_named(ht40_2g, rtl8xxxu_ht4 + MODULE_PARM_DESC(ht40_2g, "Enable HT40 support on the 2.4GHz band"); + + #define USB_VENDOR_ID_REALTEK 0x0bda +-/* Minimum IEEE80211_MAX_FRAME_LEN */ +-#define RTL_RX_BUFFER_SIZE IEEE80211_MAX_FRAME_LEN + #define RTL8XXXU_RX_URBS 32 + #define RTL8XXXU_RX_URB_PENDING_WATER 8 + #define RTL8XXXU_TX_URBS 64 +@@ -5271,12 +5269,19 @@ cleanup: + static int rtl8xxxu_submit_rx_urb(struct rtl8xxxu_priv *priv, + struct rtl8xxxu_rx_urb *rx_urb) + { ++ struct rtl8xxxu_fileops *fops = priv->fops; + struct sk_buff *skb; + int skb_size; + int ret, rx_desc_sz; + +- rx_desc_sz = priv->fops->rx_desc_size; +- skb_size = rx_desc_sz + RTL_RX_BUFFER_SIZE; ++ rx_desc_sz = fops->rx_desc_size; ++ ++ if (priv->rx_buf_aggregation && fops->rx_agg_buf_size) ++ skb_size = fops->rx_agg_buf_size; ++ else ++ skb_size = IEEE80211_MAX_FRAME_LEN; ++ skb_size += rx_desc_sz; ++ + skb = __netdev_alloc_skb(NULL, skb_size, GFP_KERNEL); + if (!skb) + return -ENOMEM; diff --git a/package/kernel/mac80211/patches/650-0012-rtl8xxxu-Adjust-RX-skb-size-to-include-space-for-phy.patch b/package/kernel/mac80211/patches/650-0012-rtl8xxxu-Adjust-RX-skb-size-to-include-space-for-phy.patch new file mode 100644 index 0000000000..70c27f2329 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0012-rtl8xxxu-Adjust-RX-skb-size-to-include-space-for-phy.patch @@ -0,0 +1,32 @@ +From e9f4ede33cf1cd0bc705de6cd9c150fb3677ed74 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Sat, 21 May 2016 13:45:37 -0400 +Subject: [PATCH] rtl8xxxu: Adjust RX skb size to include space for phystats + +The old allocation didn't leave space for phystats in the buffer, +allowing the packet to be rejected if a frame size of size +IEEE80211_MAX_FRAME_LEN was received. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5276,11 +5276,12 @@ static int rtl8xxxu_submit_rx_urb(struct + + rx_desc_sz = fops->rx_desc_size; + +- if (priv->rx_buf_aggregation && fops->rx_agg_buf_size) ++ if (priv->rx_buf_aggregation && fops->rx_agg_buf_size) { + skb_size = fops->rx_agg_buf_size; +- else ++ skb_size += (rx_desc_sz + sizeof(struct rtl8723au_phy_stats)); ++ } else { + skb_size = IEEE80211_MAX_FRAME_LEN; +- skb_size += rx_desc_sz; ++ } + + skb = __netdev_alloc_skb(NULL, skb_size, GFP_KERNEL); + if (!skb) diff --git a/package/kernel/mac80211/patches/650-0013-rtl8xxxu-Enable-aggregation-for-rtl8723au.patch b/package/kernel/mac80211/patches/650-0013-rtl8xxxu-Enable-aggregation-for-rtl8723au.patch new file mode 100644 index 0000000000..a8f151b6d8 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0013-rtl8xxxu-Enable-aggregation-for-rtl8723au.patch @@ -0,0 +1,89 @@ +From 7e9f37893c874ff2a01dfbf73d31d3de37359fc7 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 16 May 2016 21:50:57 -0400 +Subject: [PATCH] rtl8xxxu: Enable aggregation for rtl8723au + +Implement rtl8xxxu_gen1_init_aggregation(). Aggregation should be the +same for all gen1 parts. We may want to allow for tuning parameters in +the fileopes struct. For now this is based allocating 16KB RX buffers, +leaving 16000 bytes for actual packets, and the rest for the skb +overhead. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 2 ++ + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 34 ++++++++++++++++++++++ + 3 files changed, 37 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1412,6 +1412,7 @@ void rtl8xxxu_gen1_report_connect(struct + u8 macid, bool connect); + void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv, + u8 macid, bool connect); ++void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv); + void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv *priv); + void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv *priv); + void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv); +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +@@ -377,6 +377,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = + .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, + .config_channel = rtl8xxxu_gen1_config_channel, + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, ++ .init_aggregation = rtl8xxxu_gen1_init_aggregation, + .enable_rf = rtl8xxxu_gen1_enable_rf, + .disable_rf = rtl8xxxu_gen1_disable_rf, + .usb_quirks = rtl8xxxu_gen1_usb_quirks, +@@ -384,6 +385,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = + .update_rate_mask = rtl8xxxu_update_rate_mask, + .report_connect = rtl8xxxu_gen1_report_connect, + .writeN_block_size = 1024, ++ .rx_agg_buf_size = 16000, + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), + .adda_1t_init = 0x0b1b25a0, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4405,6 +4405,40 @@ void rtl8xxxu_gen2_report_connect(struct + rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt)); + } + ++void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv) ++{ ++ u8 agg_ctrl, usb_spec, page_thresh; ++ ++ usb_spec = rtl8xxxu_read8(priv, REG_USB_SPECIAL_OPTION); ++ usb_spec &= ~USB_SPEC_USB_AGG_ENABLE; ++ ++ agg_ctrl = rtl8xxxu_read8(priv, REG_TRXDMA_CTRL); ++ agg_ctrl &= ~TRXDMA_CTRL_RXDMA_AGG_EN; ++ ++ agg_ctrl |= TRXDMA_CTRL_RXDMA_AGG_EN; ++ ++ rtl8xxxu_write8(priv, REG_TRXDMA_CTRL, agg_ctrl); ++ rtl8xxxu_write8(priv, REG_USB_SPECIAL_OPTION, usb_spec); ++ ++ /* ++ * The number of packets we can take looks to be buffer size / 512 ++ * which matches the 512 byte rounding we have to do when de-muxing ++ * the packets. ++ * ++ * Sample numbers from the vendor driver: ++ * USB High-Speed mode values: ++ * RxAggBlockCount = 8 : 512 byte unit ++ * RxAggBlockTimeout = 6 ++ * RxAggPageCount = 48 : 128 byte unit ++ * RxAggPageTimeout = 4 or 6 (absolute time 34ms/(2^6)) ++ */ ++ ++ page_thresh = (priv->fops->rx_agg_buf_size / 512); ++ rtl8xxxu_write8(priv, REG_RXDMA_AGG_PG_TH, page_thresh); ++ rtl8xxxu_write8(priv, REG_USB_DMA_AGG_TO, 4); ++ priv->rx_buf_aggregation = 1; ++} ++ + static void rtl8xxxu_set_basic_rates(struct rtl8xxxu_priv *priv, u32 rate_cfg) + { + u32 val32; diff --git a/package/kernel/mac80211/patches/650-0014-rtl8xxxu-Enable-aggregation-for-rtl8192cu-rtl8188cu-.patch b/package/kernel/mac80211/patches/650-0014-rtl8xxxu-Enable-aggregation-for-rtl8192cu-rtl8188cu-.patch new file mode 100644 index 0000000000..e0053b9c01 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0014-rtl8xxxu-Enable-aggregation-for-rtl8192cu-rtl8188cu-.patch @@ -0,0 +1,32 @@ +From 02d7c11e9b66e38806b73dcb5de319bb64710367 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Sun, 22 May 2016 13:45:30 -0400 +Subject: [PATCH] rtl8xxxu: Enable aggregation for + rtl8192cu/rtl8188cu/rtl8188ru + +This enables aggregation on rtl8192cu and derivative parts. This uses +the same parameters as for rtl8723au. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +@@ -560,6 +560,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = + .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate, + .config_channel = rtl8xxxu_gen1_config_channel, + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, ++ .init_aggregation = rtl8xxxu_gen1_init_aggregation, + .enable_rf = rtl8xxxu_gen1_enable_rf, + .disable_rf = rtl8xxxu_gen1_disable_rf, + .usb_quirks = rtl8xxxu_gen1_usb_quirks, +@@ -567,6 +568,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = + .update_rate_mask = rtl8xxxu_update_rate_mask, + .report_connect = rtl8xxxu_gen1_report_connect, + .writeN_block_size = 128, ++ .rx_agg_buf_size = 16000, + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), + .adda_1t_init = 0x0b1b25a0, diff --git a/package/kernel/mac80211/patches/650-0015-rtl8xxxu-Make-DMA-aggregation-optional-by-setting-a-.patch b/package/kernel/mac80211/patches/650-0015-rtl8xxxu-Make-DMA-aggregation-optional-by-setting-a-.patch new file mode 100644 index 0000000000..878cb62383 --- /dev/null +++ b/package/kernel/mac80211/patches/650-0015-rtl8xxxu-Make-DMA-aggregation-optional-by-setting-a-.patch @@ -0,0 +1,54 @@ +From 0640e5cd53bc004be1a9a1af6d340baab44d9351 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 16 Jun 2016 14:46:05 -0400 +Subject: [PATCH] rtl8xxxu: Make DMA aggregation optional by setting a module + parameter + +Let the default to off until we have more data on the right default +tuning values. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -44,6 +44,7 @@ + + int rtl8xxxu_debug = RTL8XXXU_DEBUG_EFUSE; + static bool rtl8xxxu_ht40_2g; ++static bool rtl8xxxu_dma_aggregation; + + MODULE_AUTHOR("Jes Sorensen "); + MODULE_DESCRIPTION("RTL8XXXu USB mac80211 Wireless LAN Driver"); +@@ -62,6 +63,8 @@ module_param_named(debug, rtl8xxxu_debug + MODULE_PARM_DESC(debug, "Set debug mask"); + module_param_named(ht40_2g, rtl8xxxu_ht40_2g, bool, 0600); + MODULE_PARM_DESC(ht40_2g, "Enable HT40 support on the 2.4GHz band"); ++module_param_named(dma_aggregation, rtl8xxxu_dma_aggregation, bool, 0600); ++MODULE_PARM_DESC(dma_aggregation, "Enable DMA packet aggregation"); + + #define USB_VENDOR_ID_REALTEK 0x0bda + #define RTL8XXXU_RX_URBS 32 +@@ -4411,14 +4414,18 @@ void rtl8xxxu_gen1_init_aggregation(stru + + usb_spec = rtl8xxxu_read8(priv, REG_USB_SPECIAL_OPTION); + usb_spec &= ~USB_SPEC_USB_AGG_ENABLE; ++ rtl8xxxu_write8(priv, REG_USB_SPECIAL_OPTION, usb_spec); + + agg_ctrl = rtl8xxxu_read8(priv, REG_TRXDMA_CTRL); + agg_ctrl &= ~TRXDMA_CTRL_RXDMA_AGG_EN; + +- agg_ctrl |= TRXDMA_CTRL_RXDMA_AGG_EN; ++ if (!rtl8xxxu_dma_aggregation) { ++ rtl8xxxu_write8(priv, REG_TRXDMA_CTRL, agg_ctrl); ++ return; ++ } + ++ agg_ctrl |= TRXDMA_CTRL_RXDMA_AGG_EN; + rtl8xxxu_write8(priv, REG_TRXDMA_CTRL, agg_ctrl); +- rtl8xxxu_write8(priv, REG_USB_SPECIAL_OPTION, usb_spec); + + /* + * The number of packets we can take looks to be buffer size / 512 diff --git a/package/kernel/mac80211/patches/650-0016-rtl8xxxu-gen1-Set-aggregation-timeout-REG_RXDMA_AGG_.patch b/package/kernel/mac80211/patches/650-0016-rtl8xxxu-gen1-Set-aggregation-timeout-REG_RXDMA_AGG_.patch new file mode 100644 index 0000000000..9f0edb2dba --- /dev/null +++ b/package/kernel/mac80211/patches/650-0016-rtl8xxxu-gen1-Set-aggregation-timeout-REG_RXDMA_AGG_.patch @@ -0,0 +1,42 @@ +From 0338642c5eeaaf03cd4a63e211b94596c559e6e5 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 22 Jun 2016 22:09:35 -0400 +Subject: [PATCH] rtl8xxxu: gen1: Set aggregation timeout (REG_RXDMA_AGG_PG_TH + + 1) as well + +gen2 chips as well as 8188eu seems to use this register for setting +DMA timeout threshold values, however the 8192cu is using +REG_USB_DMA_AGG_TO. Set both to be on the safe side. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4410,7 +4410,7 @@ void rtl8xxxu_gen2_report_connect(struct + + void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv) + { +- u8 agg_ctrl, usb_spec, page_thresh; ++ u8 agg_ctrl, usb_spec, page_thresh, timeout; + + usb_spec = rtl8xxxu_read8(priv, REG_USB_SPECIAL_OPTION); + usb_spec &= ~USB_SPEC_USB_AGG_ENABLE; +@@ -4442,7 +4442,14 @@ void rtl8xxxu_gen1_init_aggregation(stru + + page_thresh = (priv->fops->rx_agg_buf_size / 512); + rtl8xxxu_write8(priv, REG_RXDMA_AGG_PG_TH, page_thresh); +- rtl8xxxu_write8(priv, REG_USB_DMA_AGG_TO, 4); ++ /* ++ * REG_RXDMA_AGG_PG_TH + 1 seems to be the timeout register on ++ * gen2 chips and rtl8188eu. The rtl8723au seems unhappy if we ++ * don't set it, so better set both. ++ */ ++ timeout = 4; ++ rtl8xxxu_write8(priv, REG_RXDMA_AGG_PG_TH + 1, timeout); ++ rtl8xxxu_write8(priv, REG_USB_DMA_AGG_TO, timeout); + priv->rx_buf_aggregation = 1; + } + diff --git a/package/kernel/mac80211/patches/650-0017-rtl8xxxu-gen1-Add-module-parameters-to-adjust-DMA-ag.patch b/package/kernel/mac80211/patches/650-0017-rtl8xxxu-gen1-Add-module-parameters-to-adjust-DMA-ag.patch new file mode 100644 index 0000000000..465ea4b16b --- /dev/null +++ b/package/kernel/mac80211/patches/650-0017-rtl8xxxu-gen1-Add-module-parameters-to-adjust-DMA-ag.patch @@ -0,0 +1,73 @@ +From 3dc0c72274876ad9612b12ab9fce553ec7e21d20 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 22 Jun 2016 23:17:37 -0400 +Subject: [PATCH] rtl8xxxu: gen1: Add module parameters to adjust DMA + aggregation parameters + +This allows the user to specify DMA aggregation timout and block +count. Blocks are presumably always 512 bytes, so the minimum block +count is 6 for 802.11 packets. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 28 ++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -45,6 +45,8 @@ + int rtl8xxxu_debug = RTL8XXXU_DEBUG_EFUSE; + static bool rtl8xxxu_ht40_2g; + static bool rtl8xxxu_dma_aggregation; ++static int rtl8xxxu_dma_agg_timeout = -1; ++static int rtl8xxxu_dma_agg_pages = -1; + + MODULE_AUTHOR("Jes Sorensen "); + MODULE_DESCRIPTION("RTL8XXXu USB mac80211 Wireless LAN Driver"); +@@ -65,6 +67,10 @@ module_param_named(ht40_2g, rtl8xxxu_ht4 + MODULE_PARM_DESC(ht40_2g, "Enable HT40 support on the 2.4GHz band"); + module_param_named(dma_aggregation, rtl8xxxu_dma_aggregation, bool, 0600); + MODULE_PARM_DESC(dma_aggregation, "Enable DMA packet aggregation"); ++module_param_named(dma_agg_timeout, rtl8xxxu_dma_agg_timeout, int, 0600); ++MODULE_PARM_DESC(dma_agg_timeout, "Set DMA aggregation timeout (range 1-127)"); ++module_param_named(dma_agg_pages, rtl8xxxu_dma_agg_pages, int, 0600); ++MODULE_PARM_DESC(dma_agg_pages, "Set DMA aggregation pages (range 1-127, 0 to disable)"); + + #define USB_VENDOR_ID_REALTEK 0x0bda + #define RTL8XXXU_RX_URBS 32 +@@ -4441,6 +4447,18 @@ void rtl8xxxu_gen1_init_aggregation(stru + */ + + page_thresh = (priv->fops->rx_agg_buf_size / 512); ++ if (rtl8xxxu_dma_agg_pages >= 0) { ++ if (rtl8xxxu_dma_agg_pages <= page_thresh) ++ timeout = page_thresh; ++ else if (rtl8xxxu_dma_agg_pages <= 6) ++ dev_err(&priv->udev->dev, ++ "%s: dma_agg_pages=%i too small, minium is 6\n", ++ __func__, rtl8xxxu_dma_agg_pages); ++ else ++ dev_err(&priv->udev->dev, ++ "%s: dma_agg_pages=%i larger than limit %i\n", ++ __func__, rtl8xxxu_dma_agg_pages, page_thresh); ++ } + rtl8xxxu_write8(priv, REG_RXDMA_AGG_PG_TH, page_thresh); + /* + * REG_RXDMA_AGG_PG_TH + 1 seems to be the timeout register on +@@ -4448,6 +4466,16 @@ void rtl8xxxu_gen1_init_aggregation(stru + * don't set it, so better set both. + */ + timeout = 4; ++ ++ if (rtl8xxxu_dma_agg_timeout >= 0) { ++ if (rtl8xxxu_dma_agg_timeout <= 127) ++ timeout = rtl8xxxu_dma_agg_timeout; ++ else ++ dev_err(&priv->udev->dev, ++ "%s: Invalid dma_agg_timeout: %i\n", ++ __func__, rtl8xxxu_dma_agg_timeout); ++ } ++ + rtl8xxxu_write8(priv, REG_RXDMA_AGG_PG_TH + 1, timeout); + rtl8xxxu_write8(priv, REG_USB_DMA_AGG_TO, timeout); + priv->rx_buf_aggregation = 1; diff --git a/package/kernel/mac80211/patches/651-0001-rtl8xxxu-Mark-0x20f4-0x648b-as-tested.patch b/package/kernel/mac80211/patches/651-0001-rtl8xxxu-Mark-0x20f4-0x648b-as-tested.patch new file mode 100644 index 0000000000..3a6435f07f --- /dev/null +++ b/package/kernel/mac80211/patches/651-0001-rtl8xxxu-Mark-0x20f4-0x648b-as-tested.patch @@ -0,0 +1,45 @@ +From cd0355d9889f6843a0fac0a160cfb42b482cbcf7 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 23 Jun 2016 12:47:17 -0400 +Subject: [PATCH] rtl8xxxu: Mark 0x20f4:0x648b as tested + +Successfully tested by Jocelyn Mayer + +Reported-by: J. Mayer +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5971,6 +5971,10 @@ static int rtl8xxxu_probe(struct usb_int + if (id->idProduct == 0x1004) + untested = 0; + break; ++ case 0x20f4: ++ if (id->idProduct == 0x648b) ++ untested = 0; ++ break; + default: + break; + } +@@ -6140,6 +6144,9 @@ static struct usb_device_id dev_table[] + /* Tested by Andrea Merello */ + {USB_DEVICE_AND_INTERFACE_INFO(0x050d, 0x1004, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, ++/* Tested by Jocelyn Mayer */ ++{USB_DEVICE_AND_INTERFACE_INFO(0x20f4, 0x648b, 0xff, 0xff, 0xff), ++ .driver_info = (unsigned long)&rtl8192cu_fops}, + /* Currently untested 8188 series devices */ + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8191, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, +@@ -6199,8 +6206,6 @@ static struct usb_device_id dev_table[] + .driver_info = (unsigned long)&rtl8192cu_fops}, + {USB_DEVICE_AND_INTERFACE_INFO(0x2019, 0xed17, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, +-{USB_DEVICE_AND_INTERFACE_INFO(0x20f4, 0x648b, 0xff, 0xff, 0xff), +- .driver_info = (unsigned long)&rtl8192cu_fops}, + {USB_DEVICE_AND_INTERFACE_INFO(0x4855, 0x0090, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, + {USB_DEVICE_AND_INTERFACE_INFO(0x4856, 0x0091, 0xff, 0xff, 0xff), diff --git a/package/kernel/mac80211/patches/651-0002-rtl8xxxu-Mark-0x2001-0x3308-as-tested.patch b/package/kernel/mac80211/patches/651-0002-rtl8xxxu-Mark-0x2001-0x3308-as-tested.patch new file mode 100644 index 0000000000..54d4ad6828 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0002-rtl8xxxu-Mark-0x2001-0x3308-as-tested.patch @@ -0,0 +1,45 @@ +From 7aff76bb819f3d7936c88fdf519619efab64e6c2 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 23 Jun 2016 12:56:20 -0400 +Subject: [PATCH] rtl8xxxu: Mark 0x2001:0x3308 as tested + +D-Link DWA-121 is reported as working. + +Reported-by: Stefano Bravi +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5975,6 +5975,10 @@ static int rtl8xxxu_probe(struct usb_int + if (id->idProduct == 0x648b) + untested = 0; + break; ++ case 0x2001: ++ if (id->idProduct == 0x3308) ++ untested = 0; ++ break; + default: + break; + } +@@ -6147,6 +6151,9 @@ static struct usb_device_id dev_table[] + /* Tested by Jocelyn Mayer */ + {USB_DEVICE_AND_INTERFACE_INFO(0x20f4, 0x648b, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, ++/* Tested by Stefano Bravi */ ++{USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x3308, 0xff, 0xff, 0xff), ++ .driver_info = (unsigned long)&rtl8192cu_fops}, + /* Currently untested 8188 series devices */ + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8191, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, +@@ -6194,8 +6201,6 @@ static struct usb_device_id dev_table[] + .driver_info = (unsigned long)&rtl8192cu_fops}, + {USB_DEVICE_AND_INTERFACE_INFO(0x13d3, 0x3357, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, +-{USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x3308, 0xff, 0xff, 0xff), +- .driver_info = (unsigned long)&rtl8192cu_fops}, + {USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x330b, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, + {USB_DEVICE_AND_INTERFACE_INFO(0x2019, 0x4902, 0xff, 0xff, 0xff), diff --git a/package/kernel/mac80211/patches/651-0003-rtl8xxxu-Fix-error-handling-if-rtl8xxxu_init_device-.patch b/package/kernel/mac80211/patches/651-0003-rtl8xxxu-Fix-error-handling-if-rtl8xxxu_init_device-.patch new file mode 100644 index 0000000000..5f6b698dc6 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0003-rtl8xxxu-Fix-error-handling-if-rtl8xxxu_init_device-.patch @@ -0,0 +1,66 @@ +From 70a3605d6d1922411b8a78499d58f140565353f7 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 29 Jun 2016 14:42:18 -0400 +Subject: [PATCH] rtl8xxxu: Fix error handling if rtl8xxxu_init_device() fails + +For some reason we lost the code bailing if rtl8xxxu_init_device() +returned an error. + +This catches the error and also cleans up the error handling. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5947,7 +5947,7 @@ static int rtl8xxxu_probe(struct usb_int + struct ieee80211_hw *hw; + struct usb_device *udev; + struct ieee80211_supported_band *sband; +- int ret = 0; ++ int ret; + int untested = 1; + + udev = usb_get_dev(interface_to_usbdev(interface)); +@@ -5995,6 +5995,7 @@ static int rtl8xxxu_probe(struct usb_int + hw = ieee80211_alloc_hw(sizeof(struct rtl8xxxu_priv), &rtl8xxxu_ops); + if (!hw) { + ret = -ENOMEM; ++ priv = NULL; + goto exit; + } + +@@ -6043,6 +6044,8 @@ static int rtl8xxxu_probe(struct usb_int + } + + ret = rtl8xxxu_init_device(hw); ++ if (ret) ++ goto exit; + + hw->wiphy->max_scan_ssids = 1; + hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; +@@ -6093,9 +6096,20 @@ static int rtl8xxxu_probe(struct usb_int + goto exit; + } + ++ return 0; ++ + exit: +- if (ret < 0) +- usb_put_dev(udev); ++ usb_set_intfdata(interface, NULL); ++ ++ if (priv) { ++ kfree(priv->fw_data); ++ mutex_destroy(&priv->usb_buf_mutex); ++ mutex_destroy(&priv->h2c_mutex); ++ } ++ usb_put_dev(udev); ++ ++ ieee80211_free_hw(hw); ++ + return ret; + } + diff --git a/package/kernel/mac80211/patches/651-0004-rtl8xxxu-Add-TP-Link-TL-WN823N-v2-to-list-of-support.patch b/package/kernel/mac80211/patches/651-0004-rtl8xxxu-Add-TP-Link-TL-WN823N-v2-to-list-of-support.patch new file mode 100644 index 0000000000..4d17e0c6f9 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0004-rtl8xxxu-Add-TP-Link-TL-WN823N-v2-to-list-of-support.patch @@ -0,0 +1,38 @@ +From 32e8292a3222036b934aeebe5dbf13c729dc3dfe Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 13:18:39 -0400 +Subject: [PATCH] rtl8xxxu: Add TP-Link TL-WN823N v2 to list of supported + devices + +This is an rtl8192eu based dongle (the v1 is an rtl8192cu). Reported +and tested by Myckel Habets. + +Reported-by: Myckel Habets +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5979,6 +5979,10 @@ static int rtl8xxxu_probe(struct usb_int + if (id->idProduct == 0x3308) + untested = 0; + break; ++ case 0x2357: ++ if (id->idProduct == 0x0109) ++ untested = 0; ++ break; + default: + break; + } +@@ -6146,6 +6150,9 @@ static struct usb_device_id dev_table[] + .driver_info = (unsigned long)&rtl8723au_fops}, + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x818b, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192eu_fops}, ++/* Tested by Myckel Habets */ ++{USB_DEVICE_AND_INTERFACE_INFO(0x2357, 0x0109, 0xff, 0xff, 0xff), ++ .driver_info = (unsigned long)&rtl8192eu_fops}, + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0xb720, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8723bu_fops}, + #ifdef CPTCFG_RTL8XXXU_UNTESTED diff --git a/package/kernel/mac80211/patches/651-0005-rtl8xxxu-Add-TX-page-defines-for-8723b.patch b/package/kernel/mac80211/patches/651-0005-rtl8xxxu-Add-TX-page-defines-for-8723b.patch new file mode 100644 index 0000000000..7f0e4246e3 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0005-rtl8xxxu-Add-TX-page-defines-for-8723b.patch @@ -0,0 +1,47 @@ +From 36bbcb566a806b96e397cb882272373bbbed83c8 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 15:02:20 -0400 +Subject: [PATCH] rtl8xxxu: Add TX page defines for 8723b + +This switches the 8723b driver to use the new +rtl8xxxu_init_queue_reserved_page() function. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 6 ++++++ + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 4 ++++ + 2 files changed, 10 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -43,6 +43,7 @@ + + #define TX_TOTAL_PAGE_NUM 0xf8 + #define TX_TOTAL_PAGE_NUM_8192E 0xf3 ++#define TX_TOTAL_PAGE_NUM_8723B 0xf7 + /* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */ + #define TX_PAGE_NUM_PUBQ 0xe7 + #define TX_PAGE_NUM_HI_PQ 0x0c +@@ -54,6 +55,11 @@ + #define TX_PAGE_NUM_LO_PQ_8192E 0x0c + #define TX_PAGE_NUM_NORM_PQ_8192E 0x00 + ++#define TX_PAGE_NUM_PUBQ_8723B 0xe7 ++#define TX_PAGE_NUM_HI_PQ_8723B 0x0c ++#define TX_PAGE_NUM_LO_PQ_8723B 0x02 ++#define TX_PAGE_NUM_NORM_PQ_8723B 0x02 ++ + #define RTL_FW_PAGE_SIZE 4096 + #define RTL8XXXU_FIRMWARE_POLL_MAX 1000 + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +@@ -1674,4 +1674,8 @@ struct rtl8xxxu_fileops rtl8723bu_fops = + .pbp_rx = PBP_PAGE_SIZE_256, + .pbp_tx = PBP_PAGE_SIZE_256, + .mactable = rtl8723b_mac_init_table, ++ .total_page_num = TX_TOTAL_PAGE_NUM_8723B, ++ .page_num_hi = TX_PAGE_NUM_HI_PQ_8723B, ++ .page_num_lo = TX_PAGE_NUM_LO_PQ_8723B, ++ .page_num_norm = TX_PAGE_NUM_NORM_PQ_8723B, + }; diff --git a/package/kernel/mac80211/patches/651-0006-rtl8xxxu-Switch-8723a-to-use-new-rtl8xxxu_init_queue.patch b/package/kernel/mac80211/patches/651-0006-rtl8xxxu-Switch-8723a-to-use-new-rtl8xxxu_init_queue.patch new file mode 100644 index 0000000000..1c15acc54b --- /dev/null +++ b/package/kernel/mac80211/patches/651-0006-rtl8xxxu-Switch-8723a-to-use-new-rtl8xxxu_init_queue.patch @@ -0,0 +1,26 @@ +From 0ee0d2f7f6442d5e3ae76ce1626eb018582ba4d1 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 15:18:39 -0400 +Subject: [PATCH] rtl8xxxu: Switch 8723a to use new + rtl8xxxu_init_queue_reserved_page() routine + +This changes the pub-queue value written to REQ_RQPN, however the old +code used a hard coded minimum value assuming there would always be an +active lo-queue, even when no USB EP was found for it. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +@@ -396,4 +396,8 @@ struct rtl8xxxu_fileops rtl8723au_fops = + .pbp_rx = PBP_PAGE_SIZE_128, + .pbp_tx = PBP_PAGE_SIZE_128, + .mactable = rtl8xxxu_gen1_mac_init_table, ++ .total_page_num = TX_TOTAL_PAGE_NUM, ++ .page_num_hi = TX_PAGE_NUM_HI_PQ, ++ .page_num_lo = TX_PAGE_NUM_LO_PQ, ++ .page_num_norm = TX_PAGE_NUM_NORM_PQ, + }; diff --git a/package/kernel/mac80211/patches/651-0007-rtl8xxxu-Switch-8192cu-8188cu-devices-to-use-rtl8xxx.patch b/package/kernel/mac80211/patches/651-0007-rtl8xxxu-Switch-8192cu-8188cu-devices-to-use-rtl8xxx.patch new file mode 100644 index 0000000000..c4f1031cf8 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0007-rtl8xxxu-Switch-8192cu-8188cu-devices-to-use-rtl8xxx.patch @@ -0,0 +1,26 @@ +From e37da0657a3d57d6a98198f6ed730b42fca6bae7 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 15:28:50 -0400 +Subject: [PATCH] rtl8xxxu: Switch 8192cu/8188cu devices to use + rtl8xxxu_init_queue_reserved_page() + +This was the last user of the old +rtl8xxxu_old_init_queue_reserved_page() which can now be removed. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +@@ -579,5 +579,9 @@ struct rtl8xxxu_fileops rtl8192cu_fops = + .pbp_rx = PBP_PAGE_SIZE_128, + .pbp_tx = PBP_PAGE_SIZE_128, + .mactable = rtl8xxxu_gen1_mac_init_table, ++ .total_page_num = TX_TOTAL_PAGE_NUM, ++ .page_num_hi = TX_PAGE_NUM_HI_PQ, ++ .page_num_lo = TX_PAGE_NUM_LO_PQ, ++ .page_num_norm = TX_PAGE_NUM_NORM_PQ, + }; + #endif diff --git a/package/kernel/mac80211/patches/651-0008-rtl8xxxu-Remove-now-obsolete-rtl8xxxu_old_init_queue.patch b/package/kernel/mac80211/patches/651-0008-rtl8xxxu-Remove-now-obsolete-rtl8xxxu_old_init_queue.patch new file mode 100644 index 0000000000..41b1bed434 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0008-rtl8xxxu-Remove-now-obsolete-rtl8xxxu_old_init_queue.patch @@ -0,0 +1,60 @@ +From d9de1941802e3887251f8f6d519ff17d5fafc516 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 15:34:59 -0400 +Subject: [PATCH] rtl8xxxu: Remove now obsolete + rtl8xxxu_old_init_queue_reserved_page() + +Switching over the old devices to use the new function allows us to +get rid of this legacy. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 30 ++-------------------- + 1 file changed, 2 insertions(+), 28 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -3847,28 +3847,6 @@ void rtl8xxxu_gen2_disable_rf(struct rtl + rtl8xxxu_write32(priv, REG_RX_WAIT_CCA, val32); + } + +-static void rtl8xxxu_old_init_queue_reserved_page(struct rtl8xxxu_priv *priv) +-{ +- u8 val8; +- u32 val32; +- +- if (priv->ep_tx_normal_queue) +- val8 = TX_PAGE_NUM_NORM_PQ; +- else +- val8 = 0; +- +- rtl8xxxu_write8(priv, REG_RQPN_NPQ, val8); +- +- val32 = (TX_PAGE_NUM_PUBQ << RQPN_PUB_PQ_SHIFT) | RQPN_LOAD; +- +- if (priv->ep_tx_high_queue) +- val32 |= (TX_PAGE_NUM_HI_PQ << RQPN_HI_PQ_SHIFT); +- if (priv->ep_tx_low_queue) +- val32 |= (TX_PAGE_NUM_LO_PQ << RQPN_LO_PQ_SHIFT); +- +- rtl8xxxu_write32(priv, REG_RQPN, val32); +-} +- + static void rtl8xxxu_init_queue_reserved_page(struct rtl8xxxu_priv *priv) + { + struct rtl8xxxu_fileops *fops = priv->fops; +@@ -3929,12 +3907,8 @@ static int rtl8xxxu_init_device(struct i + goto exit; + } + +- if (!macpower) { +- if (priv->fops->total_page_num) +- rtl8xxxu_init_queue_reserved_page(priv); +- else +- rtl8xxxu_old_init_queue_reserved_page(priv); +- } ++ if (!macpower) ++ rtl8xxxu_init_queue_reserved_page(priv); + + ret = rtl8xxxu_init_queue_priority(priv); + dev_dbg(dev, "%s: init_queue_priority %i\n", __func__, ret); diff --git a/package/kernel/mac80211/patches/651-0009-rtl8xxxu-Simplify-code-setting-TX-buffer-boundary.patch b/package/kernel/mac80211/patches/651-0009-rtl8xxxu-Simplify-code-setting-TX-buffer-boundary.patch new file mode 100644 index 0000000000..475063b9d7 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0009-rtl8xxxu-Simplify-code-setting-TX-buffer-boundary.patch @@ -0,0 +1,30 @@ +From 031c086dcd5e17bb1e792ba215c997adcb570844 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 15:39:09 -0400 +Subject: [PATCH] rtl8xxxu: Simplify code setting TX buffer boundary + +With all devices now offering fops->total_page_num, get rid of the +if mess for setting the TX buffer boundary. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -3968,13 +3968,7 @@ static int rtl8xxxu_init_device(struct i + /* + * Set TX buffer boundary + */ +- if (priv->rtl_chip == RTL8192E) +- val8 = TX_TOTAL_PAGE_NUM_8192E + 1; +- else +- val8 = TX_TOTAL_PAGE_NUM + 1; +- +- if (priv->rtl_chip == RTL8723B) +- val8 -= 1; ++ val8 = priv->fops->total_page_num + 1; + + rtl8xxxu_write8(priv, REG_TXPKTBUF_BCNQ_BDNY, val8); + rtl8xxxu_write8(priv, REG_TXPKTBUF_MGQ_BDNY, val8); diff --git a/package/kernel/mac80211/patches/651-0010-rtl8xxxu-Add-bit-definitions-for-REG_FPGA0_TX_INFO.patch b/package/kernel/mac80211/patches/651-0010-rtl8xxxu-Add-bit-definitions-for-REG_FPGA0_TX_INFO.patch new file mode 100644 index 0000000000..87bf9ac51c --- /dev/null +++ b/package/kernel/mac80211/patches/651-0010-rtl8xxxu-Add-bit-definitions-for-REG_FPGA0_TX_INFO.patch @@ -0,0 +1,25 @@ +From e3aee53b23762f47ad233591090640c6df3db3c0 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 14:31:08 -0400 +Subject: [PATCH] rtl8xxxu: Add bit definitions for REG_FPGA0_TX_INFO + +This adds TX antenna selection bit defines for OFDM mode. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -780,6 +780,10 @@ + #define FPGA_RF_MODE_OFDM BIT(25) + + #define REG_FPGA0_TX_INFO 0x0804 ++#define FPGA0_TX_INFO_OFDM_PATH_A BIT(0) ++#define FPGA0_TX_INFO_OFDM_PATH_B BIT(1) ++#define FPGA0_TX_INFO_OFDM_PATH_C BIT(2) ++#define FPGA0_TX_INFO_OFDM_PATH_D BIT(3) + #define REG_FPGA0_PSD_FUNC 0x0808 + #define REG_FPGA0_TX_GAIN 0x080c + #define REG_FPGA0_RF_TIMING1 0x0810 diff --git a/package/kernel/mac80211/patches/651-0011-rtl8xxxu-Add-interrupt-bit-definitions-for-gen2-part.patch b/package/kernel/mac80211/patches/651-0011-rtl8xxxu-Add-interrupt-bit-definitions-for-gen2-part.patch new file mode 100644 index 0000000000..d8ca286678 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0011-rtl8xxxu-Add-interrupt-bit-definitions-for-gen2-part.patch @@ -0,0 +1,82 @@ +From b11b4053e28ebcd35fca0b81448ee91ef88a6fed Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 16:52:13 -0400 +Subject: [PATCH] rtl8xxxu: Add interrupt bit definitions for gen2 parts + +These are primarily needed for SDIO/PCI parts, but the vendor driver +still sets them for some USB devices. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 56 ++++++++++++++++++++++ + 1 file changed, 56 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -213,10 +213,66 @@ + #define REG_HMBOX_EXT_1 0x008a + #define REG_HMBOX_EXT_2 0x008c + #define REG_HMBOX_EXT_3 0x008e ++ + /* Interrupt registers for 8192e/8723bu/8812 */ + #define REG_HIMR0 0x00b0 ++#define IMR0_TXCCK BIT(30) /* TXRPT interrupt when CCX bit ++ of the packet is set */ ++#define IMR0_PSTIMEOUT BIT(29) /* Power Save Time Out Int */ ++#define IMR0_GTINT4 BIT(28) /* Set when GTIMER4 expires */ ++#define IMR0_GTINT3 BIT(27) /* Set when GTIMER3 expires */ ++#define IMR0_TBDER BIT(26) /* Transmit Beacon0 Error */ ++#define IMR0_TBDOK BIT(25) /* Transmit Beacon0 OK */ ++#define IMR0_TSF_BIT32_TOGGLE BIT(24) /* TSF Timer BIT32 toggle ++ indication interrupt */ ++#define IMR0_BCNDMAINT0 BIT(20) /* Beacon DMA Interrupt 0 */ ++#define IMR0_BCNDERR0 BIT(16) /* Beacon Queue DMA Error 0 */ ++#define IMR0_HSISR_IND_ON_INT BIT(15) /* HSISR Indicator (HSIMR & ++ HSISR is true) */ ++#define IMR0_BCNDMAINT_E BIT(14) /* Beacon DMA Interrupt ++ Extension for Win7 */ ++#define IMR0_ATIMEND BIT(12) /* CTWidnow End or ++ ATIM Window End */ ++#define IMR0_HISR1_IND_INT BIT(11) /* HISR1 Indicator ++ (HISR1 & HIMR1 is true) */ ++#define IMR0_C2HCMD BIT(10) /* CPU to Host Command INT ++ Status, Write 1 to clear */ ++#define IMR0_CPWM2 BIT(9) /* CPU power Mode exchange INT ++ Status, Write 1 to clear */ ++#define IMR0_CPWM BIT(8) /* CPU power Mode exchange INT ++ Status, Write 1 to clear */ ++#define IMR0_HIGHDOK BIT(7) /* High Queue DMA OK */ ++#define IMR0_MGNTDOK BIT(6) /* Management Queue DMA OK */ ++#define IMR0_BKDOK BIT(5) /* AC_BK DMA OK */ ++#define IMR0_BEDOK BIT(4) /* AC_BE DMA OK */ ++#define IMR0_VIDOK BIT(3) /* AC_VI DMA OK */ ++#define IMR0_VODOK BIT(2) /* AC_VO DMA OK */ ++#define IMR0_RDU BIT(1) /* Rx Descriptor Unavailable */ ++#define IMR0_ROK BIT(0) /* Receive DMA OK */ + #define REG_HISR0 0x00b4 + #define REG_HIMR1 0x00b8 ++#define IMR1_BCNDMAINT7 BIT(27) /* Beacon DMA Interrupt 7 */ ++#define IMR1_BCNDMAINT6 BIT(26) /* Beacon DMA Interrupt 6 */ ++#define IMR1_BCNDMAINT5 BIT(25) /* Beacon DMA Interrupt 5 */ ++#define IMR1_BCNDMAINT4 BIT(24) /* Beacon DMA Interrupt 4 */ ++#define IMR1_BCNDMAINT3 BIT(23) /* Beacon DMA Interrupt 3 */ ++#define IMR1_BCNDMAINT2 BIT(22) /* Beacon DMA Interrupt 2 */ ++#define IMR1_BCNDMAINT1 BIT(21) /* Beacon DMA Interrupt 1 */ ++#define IMR1_BCNDERR7 BIT(20) /* Beacon Queue DMA Err Int 7 */ ++#define IMR1_BCNDERR6 BIT(19) /* Beacon Queue DMA Err Int 6 */ ++#define IMR1_BCNDERR5 BIT(18) /* Beacon Queue DMA Err Int 5 */ ++#define IMR1_BCNDERR4 BIT(17) /* Beacon Queue DMA Err Int 4 */ ++#define IMR1_BCNDERR3 BIT(16) /* Beacon Queue DMA Err Int 3 */ ++#define IMR1_BCNDERR2 BIT(15) /* Beacon Queue DMA Err Int 2 */ ++#define IMR1_BCNDERR1 BIT(14) /* Beacon Queue DMA Err Int 1 */ ++#define IMR1_ATIMEND_E BIT(13) /* ATIM Window End Extension ++ for Win7 */ ++#define IMR1_TXERR BIT(11) /* Tx Error Flag Int Status, ++ write 1 to clear */ ++#define IMR1_RXERR BIT(10) /* Rx Error Flag Int Status, ++ write 1 to clear */ ++#define IMR1_TXFOVW BIT(9) /* Transmit FIFO Overflow */ ++#define IMR1_RXFOVW BIT(8) /* Receive FIFO Overflow */ + #define REG_HISR1 0x00bc + + /* Host suspend counter on FPGA platform */ diff --git a/package/kernel/mac80211/patches/651-0012-rtl8xxxu-Use-flag-to-indicate-whether-device-has-TX-.patch b/package/kernel/mac80211/patches/651-0012-rtl8xxxu-Use-flag-to-indicate-whether-device-has-TX-.patch new file mode 100644 index 0000000000..c87d91143d --- /dev/null +++ b/package/kernel/mac80211/patches/651-0012-rtl8xxxu-Use-flag-to-indicate-whether-device-has-TX-.patch @@ -0,0 +1,52 @@ +From 37949932b4c8854d8122ac385bfcab725440625c Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 16:13:06 -0400 +Subject: [PATCH] rtl8xxxu: Use flag to indicate whether device has TX report + timer support + +Use a fileops flag to indicate whether the device has TX report timer +support. This will make it easier to include future devices such as +8188eu to use the TX report timer. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 5 ++--- + 3 files changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1341,6 +1341,7 @@ struct rtl8xxxu_fileops { + char tx_desc_size; + char rx_desc_size; + char has_s0s1; ++ char has_tx_report; + u32 adda_1t_init; + u32 adda_1t_path_on; + u32 adda_2t_path_on_a; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +@@ -1666,6 +1666,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), + .has_s0s1 = 1, ++ .has_tx_report = 1, + .adda_1t_init = 0x01c00014, + .adda_1t_path_on = 0x01c00014, + .adda_2t_path_on_a = 0x01c00014, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4000,10 +4000,9 @@ static int rtl8xxxu_init_device(struct i + priv->fops->usb_quirks(priv); + + /* +- * Presumably this is for 8188EU as well +- * Enable TX report and TX report timer ++ * Enable TX report and TX report timer for 8723bu/8188eu/... + */ +- if (priv->rtl_chip == RTL8723B) { ++ if (priv->fops->has_tx_report) { + val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL); + val8 |= TX_REPORT_CTRL_TIMER_ENABLE; + rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8); diff --git a/package/kernel/mac80211/patches/651-0013-rtl8xxxu-Convert-flags-in-rtl8xxxu_fileops-to-bitfla.patch b/package/kernel/mac80211/patches/651-0013-rtl8xxxu-Convert-flags-in-rtl8xxxu_fileops-to-bitfla.patch new file mode 100644 index 0000000000..04dfc993ad --- /dev/null +++ b/package/kernel/mac80211/patches/651-0013-rtl8xxxu-Convert-flags-in-rtl8xxxu_fileops-to-bitfla.patch @@ -0,0 +1,25 @@ +From 2edfdaa9d373a12582647ab06b9f09e43853c602 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 11:15:15 -0400 +Subject: [PATCH] rtl8xxxu: Convert flags in rtl8xxxu_fileops to bitflags + +This leaves space for a few more flags within the same space. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1340,8 +1340,8 @@ struct rtl8xxxu_fileops { + int rx_agg_buf_size; + char tx_desc_size; + char rx_desc_size; +- char has_s0s1; +- char has_tx_report; ++ u8 has_s0s1:1; ++ u8 has_tx_report:1; + u32 adda_1t_init; + u32 adda_1t_path_on; + u32 adda_2t_path_on_a; diff --git a/package/kernel/mac80211/patches/651-0014-rtl8xxxu-Introduce-fops-bitflag-indicating-type-of-t.patch b/package/kernel/mac80211/patches/651-0014-rtl8xxxu-Introduce-fops-bitflag-indicating-type-of-t.patch new file mode 100644 index 0000000000..9f7edcb7df --- /dev/null +++ b/package/kernel/mac80211/patches/651-0014-rtl8xxxu-Introduce-fops-bitflag-indicating-type-of-t.patch @@ -0,0 +1,58 @@ +From 99919affd249419a20984f96c7876fc6ec3759a8 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 11:18:36 -0400 +Subject: [PATCH] rtl8xxxu: Introduce fops bitflag indicating type of thermal + meter + +Do not rely on TX descriptor size to determine the thermal meter +type. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- + 4 files changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1342,6 +1342,7 @@ struct rtl8xxxu_fileops { + char rx_desc_size; + u8 has_s0s1:1; + u8 has_tx_report:1; ++ u8 gen2_thermal_meter:1; + u32 adda_1t_init; + u32 adda_1t_path_on; + u32 adda_2t_path_on_a; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +@@ -1505,6 +1505,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), + .has_s0s1 = 0, ++ .gen2_thermal_meter = 1, + .adda_1t_init = 0x0fc01616, + .adda_1t_path_on = 0x0fc01616, + .adda_2t_path_on_a = 0x0fc01616, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +@@ -1667,6 +1667,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), + .has_s0s1 = 1, + .has_tx_report = 1, ++ .gen2_thermal_meter = 1, + .adda_1t_init = 0x01c00014, + .adda_1t_path_on = 0x01c00014, + .adda_2t_path_on_a = 0x01c00014, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4195,7 +4195,7 @@ static int rtl8xxxu_init_device(struct i + /* + * This should enable thermal meter + */ +- if (priv->fops->tx_desc_size == sizeof(struct rtl8xxxu_txdesc40)) ++ if (priv->fops->gen2_thermal_meter) + rtl8xxxu_write_rfreg(priv, + RF_A, RF6052_REG_T_METER_8723B, 0x37cf8); + else diff --git a/package/kernel/mac80211/patches/651-0015-rtl8xxxu-Simplify-calculating-of-hw-value-used-for-s.patch b/package/kernel/mac80211/patches/651-0015-rtl8xxxu-Simplify-calculating-of-hw-value-used-for-s.patch new file mode 100644 index 0000000000..243eeb8053 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0015-rtl8xxxu-Simplify-calculating-of-hw-value-used-for-s.patch @@ -0,0 +1,45 @@ +From dae8758ca00ceaf71253471dc79de6a2749cb722 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 25 Jul 2016 13:06:24 -0400 +Subject: [PATCH] rtl8xxxu: Simplify calculating of hw value used for setting + TX rate + +Calculating the value in one place rather than using one calculation +in one place and a different one for management frames in another +location makes little sense. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4848,7 +4848,8 @@ static void rtl8xxxu_tx(struct ieee80211 + } + } + +- if (rate_flag & IEEE80211_TX_RC_MCS) ++ if (rate_flag & IEEE80211_TX_RC_MCS && ++ !ieee80211_is_mgmt(hdr->frame_control)) + rate = tx_info->control.rates[0].idx + DESC_RATE_MCS0; + else + rate = tx_rate->hw_value; +@@ -4869,7 +4870,7 @@ static void rtl8xxxu_tx(struct ieee80211 + tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK); + + if (ieee80211_is_mgmt(hdr->frame_control)) { +- tx_desc->txdw5 = cpu_to_le32(tx_rate->hw_value); ++ tx_desc->txdw5 = cpu_to_le32(rate); + tx_desc->txdw4 |= + cpu_to_le32(TXDESC32_USE_DRIVER_RATE); + tx_desc->txdw5 |= +@@ -4923,7 +4924,7 @@ static void rtl8xxxu_tx(struct ieee80211 + tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK); + + if (ieee80211_is_mgmt(hdr->frame_control)) { +- tx_desc40->txdw4 = cpu_to_le32(tx_rate->hw_value); ++ tx_desc40->txdw4 = cpu_to_le32(rate); + tx_desc40->txdw3 |= + cpu_to_le32(TXDESC40_USE_DRIVER_RATE); + tx_desc40->txdw4 |= diff --git a/package/kernel/mac80211/patches/651-0016-rtl8xxxu-Determine-the-need-for-SGI-before-handling-.patch b/package/kernel/mac80211/patches/651-0016-rtl8xxxu-Determine-the-need-for-SGI-before-handling-.patch new file mode 100644 index 0000000000..fd89360c30 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0016-rtl8xxxu-Determine-the-need-for-SGI-before-handling-.patch @@ -0,0 +1,52 @@ +From 20296682e77606561c3899e6f2f4f881974472f3 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 25 Jul 2016 13:14:02 -0400 +Subject: [PATCH] rtl8xxxu: Determine the need for SGI before handling specific + TX desc formats + +In order to be able to split out the TX descriptor handling code, +determine in advance the need to mark SGI. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4770,7 +4770,7 @@ static void rtl8xxxu_tx(struct ieee80211 + u16 rate_flag = tx_info->control.rates[0].flags; + int tx_desc_size = priv->fops->tx_desc_size; + int ret; +- bool usedesc40, ampdu_enable; ++ bool usedesc40, ampdu_enable, sgi = false; + + if (skb_headroom(skb) < tx_desc_size) { + dev_warn(dev, +@@ -4854,6 +4854,12 @@ static void rtl8xxxu_tx(struct ieee80211 + else + rate = tx_rate->hw_value; + ++ if (rate_flag & IEEE80211_TX_RC_SHORT_GI || ++ (ieee80211_is_data_qos(hdr->frame_control) && ++ sta && sta->ht_cap.cap & ++ (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20))) ++ sgi = true; ++ + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); + if (!usedesc40) { + tx_desc->txdw5 = cpu_to_le32(rate); +@@ -4886,12 +4892,8 @@ static void rtl8xxxu_tx(struct ieee80211 + (sta && vif && vif->bss_conf.use_short_preamble)) + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE); + +- if (rate_flag & IEEE80211_TX_RC_SHORT_GI || +- (ieee80211_is_data_qos(hdr->frame_control) && +- sta && sta->ht_cap.cap & +- (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20))) { ++ if (sgi) + tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI); +- } + + if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) { + /* diff --git a/package/kernel/mac80211/patches/651-0017-rtl8xxxu-Determine-need-for-shore-preamble-before-up.patch b/package/kernel/mac80211/patches/651-0017-rtl8xxxu-Determine-need-for-shore-preamble-before-up.patch new file mode 100644 index 0000000000..f3c97d1b3c --- /dev/null +++ b/package/kernel/mac80211/patches/651-0017-rtl8xxxu-Determine-need-for-shore-preamble-before-up.patch @@ -0,0 +1,56 @@ +From 36109f7398a02f07a32051d1483e3e9ae7a4ad4b Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 25 Jul 2016 13:17:42 -0400 +Subject: [PATCH] rtl8xxxu: Determine need for shore preamble before updating + TX descriptors + +Another patch to move this detection out of the code handling the TX +descriptor update. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4770,7 +4770,7 @@ static void rtl8xxxu_tx(struct ieee80211 + u16 rate_flag = tx_info->control.rates[0].flags; + int tx_desc_size = priv->fops->tx_desc_size; + int ret; +- bool usedesc40, ampdu_enable, sgi = false; ++ bool usedesc40, ampdu_enable, sgi = false, short_preamble = false; + + if (skb_headroom(skb) < tx_desc_size) { + dev_warn(dev, +@@ -4860,6 +4860,10 @@ static void rtl8xxxu_tx(struct ieee80211 + (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20))) + sgi = true; + ++ if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE || ++ (sta && vif && vif->bss_conf.use_short_preamble)) ++ short_preamble = true; ++ + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); + if (!usedesc40) { + tx_desc->txdw5 = cpu_to_le32(rate); +@@ -4888,8 +4892,7 @@ static void rtl8xxxu_tx(struct ieee80211 + if (ieee80211_is_data_qos(hdr->frame_control)) + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS); + +- if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE || +- (sta && vif && vif->bss_conf.use_short_preamble)) ++ if (short_preamble) + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE); + + if (sgi) +@@ -4935,8 +4938,7 @@ static void rtl8xxxu_tx(struct ieee80211 + cpu_to_le32(TXDESC40_RETRY_LIMIT_ENABLE); + } + +- if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE || +- (sta && vif && vif->bss_conf.use_short_preamble)) ++ if (short_preamble) + tx_desc40->txdw5 |= + cpu_to_le32(TXDESC40_SHORT_PREAMBLE); + diff --git a/package/kernel/mac80211/patches/651-0018-rtl8xxxu-Split-filling-of-TX-descriptors-into-separa.patch b/package/kernel/mac80211/patches/651-0018-rtl8xxxu-Split-filling-of-TX-descriptors-into-separa.patch new file mode 100644 index 0000000000..b503c95d87 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0018-rtl8xxxu-Split-filling-of-TX-descriptors-into-separa.patch @@ -0,0 +1,314 @@ +From 57a46cf908c7a9dfa871494fb45ad914905c991a Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 25 Jul 2016 14:21:21 -0400 +Subject: [PATCH] rtl8xxxu: Split filling of TX descriptors into separate + functions + +Split the filling of TX descriptors into a generic portion used on all +devices, and format specific helper functions provided in the fops +structure. + +This also cleaned up some mess, even if non harmful, in the handling +of txdesc40 descriptors, where the code randomly would switch between +the pointer to tx_desc and tx_desc40. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 12 ++ + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 1 + + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 1 + + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 1 + + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 1 + + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 198 ++++++++++++--------- + 6 files changed, 125 insertions(+), 89 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1336,6 +1336,10 @@ struct rtl8xxxu_fileops { + u32 ramask, int sgi); + void (*report_connect) (struct rtl8xxxu_priv *priv, + u8 macid, bool connect); ++ void (*fill_txdesc) (struct ieee80211_hdr *hdr, ++ struct rtl8xxxu_txdesc32 *tx_desc, u32 rate, ++ u16 rate_flag, bool sgi, bool short_preamble, ++ bool ampdu_enable); + int writeN_block_size; + int rx_agg_buf_size; + char tx_desc_size; +@@ -1429,6 +1433,14 @@ int rtl8xxxu_parse_rxdesc24(struct rtl8x + int rtl8xxxu_gen2_channel_to_group(int channel); + bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv, + int result[][8], int c1, int c2); ++void rtl8xxxu_fill_txdesc_v1(struct ieee80211_hdr *hdr, ++ struct rtl8xxxu_txdesc32 *tx_desc, u32 rate, ++ u16 rate_flag, bool sgi, bool short_preamble, ++ bool ampdu_enable); ++void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hdr *hdr, ++ struct rtl8xxxu_txdesc32 *tx_desc32, u32 rate, ++ u16 rate_flag, bool sgi, bool short_preamble, ++ bool ampdu_enable); + + extern struct rtl8xxxu_fileops rtl8192cu_fops; + extern struct rtl8xxxu_fileops rtl8192eu_fops; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +@@ -567,6 +567,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = + .set_tx_power = rtl8xxxu_gen1_set_tx_power, + .update_rate_mask = rtl8xxxu_update_rate_mask, + .report_connect = rtl8xxxu_gen1_report_connect, ++ .fill_txdesc = rtl8xxxu_fill_txdesc_v1, + .writeN_block_size = 128, + .rx_agg_buf_size = 16000, + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +@@ -1501,6 +1501,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = + .set_tx_power = rtl8192e_set_tx_power, + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, + .report_connect = rtl8xxxu_gen2_report_connect, ++ .fill_txdesc = rtl8xxxu_fill_txdesc_v2, + .writeN_block_size = 128, + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +@@ -384,6 +384,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = + .set_tx_power = rtl8xxxu_gen1_set_tx_power, + .update_rate_mask = rtl8xxxu_update_rate_mask, + .report_connect = rtl8xxxu_gen1_report_connect, ++ .fill_txdesc = rtl8xxxu_fill_txdesc_v1, + .writeN_block_size = 1024, + .rx_agg_buf_size = 16000, + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +@@ -1662,6 +1662,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = + .set_tx_power = rtl8723b_set_tx_power, + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, + .report_connect = rtl8xxxu_gen2_report_connect, ++ .fill_txdesc = rtl8xxxu_fill_txdesc_v2, + .writeN_block_size = 1024, + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40), + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4750,6 +4750,113 @@ static void rtl8xxxu_dump_action(struct + } + } + ++/* ++ * Fill in v1 (gen1) specific TX descriptor bits. ++ * This format is used on 8188cu/8192cu/8723au ++ */ ++void ++rtl8xxxu_fill_txdesc_v1(struct ieee80211_hdr *hdr, ++ struct rtl8xxxu_txdesc32 *tx_desc, u32 rate, ++ u16 rate_flag, bool sgi, bool short_preamble, ++ bool ampdu_enable) ++{ ++ u16 seq_number; ++ ++ seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); ++ ++ tx_desc->txdw5 = cpu_to_le32(rate); ++ ++ if (ieee80211_is_data(hdr->frame_control)) ++ tx_desc->txdw5 |= cpu_to_le32(0x0001ff00); ++ ++ tx_desc->txdw3 = cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT); ++ ++ if (ampdu_enable) ++ tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE); ++ else ++ tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK); ++ ++ if (ieee80211_is_mgmt(hdr->frame_control)) { ++ tx_desc->txdw5 = cpu_to_le32(rate); ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_USE_DRIVER_RATE); ++ tx_desc->txdw5 |= cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT); ++ tx_desc->txdw5 |= cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE); ++ } ++ ++ if (ieee80211_is_data_qos(hdr->frame_control)) ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS); ++ ++ if (short_preamble) ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE); ++ ++ if (sgi) ++ tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI); ++ ++ if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) { ++ /* ++ * Use RTS rate 24M - does the mac80211 tell ++ * us which to use? ++ */ ++ tx_desc->txdw4 |= cpu_to_le32(DESC_RATE_24M << ++ TXDESC32_RTS_RATE_SHIFT); ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_RTS_CTS_ENABLE); ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE); ++ } ++} ++ ++/* ++ * Fill in v2 (gen2) specific TX descriptor bits. ++ * This format is used on 8192eu/8723bu ++ */ ++void ++rtl8xxxu_fill_txdesc_v2(struct ieee80211_hdr *hdr, ++ struct rtl8xxxu_txdesc32 *tx_desc32, u32 rate, ++ u16 rate_flag, bool sgi, bool short_preamble, ++ bool ampdu_enable) ++{ ++ struct rtl8xxxu_txdesc40 *tx_desc40; ++ u16 seq_number; ++ ++ tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc32; ++ ++ seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); ++ ++ tx_desc40->txdw4 = cpu_to_le32(rate); ++ if (ieee80211_is_data(hdr->frame_control)) { ++ tx_desc40->txdw4 |= cpu_to_le32(0x1f << ++ TXDESC40_DATA_RATE_FB_SHIFT); ++ } ++ ++ tx_desc40->txdw9 = cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT); ++ ++ if (ampdu_enable) ++ tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE); ++ else ++ tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK); ++ ++ if (ieee80211_is_mgmt(hdr->frame_control)) { ++ tx_desc40->txdw4 = cpu_to_le32(rate); ++ tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_USE_DRIVER_RATE); ++ tx_desc40->txdw4 |= ++ cpu_to_le32(6 << TXDESC40_RETRY_LIMIT_SHIFT); ++ tx_desc40->txdw4 |= cpu_to_le32(TXDESC40_RETRY_LIMIT_ENABLE); ++ } ++ ++ if (short_preamble) ++ tx_desc40->txdw5 |= cpu_to_le32(TXDESC40_SHORT_PREAMBLE); ++ ++ if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) { ++ /* ++ * Use RTS rate 24M - does the mac80211 tell ++ * us which to use? ++ */ ++ tx_desc40->txdw4 |= cpu_to_le32(DESC_RATE_24M << ++ TXDESC40_RTS_RATE_SHIFT); ++ tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_RTS_CTS_ENABLE); ++ tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_HW_RTS_ENABLE); ++ } ++} ++ + static void rtl8xxxu_tx(struct ieee80211_hw *hw, + struct ieee80211_tx_control *control, + struct sk_buff *skb) +@@ -4759,7 +4866,6 @@ static void rtl8xxxu_tx(struct ieee80211 + struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info); + struct rtl8xxxu_priv *priv = hw->priv; + struct rtl8xxxu_txdesc32 *tx_desc; +- struct rtl8xxxu_txdesc40 *tx_desc40; + struct rtl8xxxu_tx_urb *tx_urb; + struct ieee80211_sta *sta = NULL; + struct ieee80211_vif *vif = tx_info->control.vif; +@@ -4865,95 +4971,9 @@ static void rtl8xxxu_tx(struct ieee80211 + short_preamble = true; + + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); +- if (!usedesc40) { +- tx_desc->txdw5 = cpu_to_le32(rate); +- +- if (ieee80211_is_data(hdr->frame_control)) +- tx_desc->txdw5 |= cpu_to_le32(0x0001ff00); +- +- tx_desc->txdw3 = +- cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT); +- +- if (ampdu_enable) +- tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE); +- else +- tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK); +- +- if (ieee80211_is_mgmt(hdr->frame_control)) { +- tx_desc->txdw5 = cpu_to_le32(rate); +- tx_desc->txdw4 |= +- cpu_to_le32(TXDESC32_USE_DRIVER_RATE); +- tx_desc->txdw5 |= +- cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT); +- tx_desc->txdw5 |= +- cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE); +- } +- +- if (ieee80211_is_data_qos(hdr->frame_control)) +- tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS); + +- if (short_preamble) +- tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE); +- +- if (sgi) +- tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI); +- +- if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) { +- /* +- * Use RTS rate 24M - does the mac80211 tell +- * us which to use? +- */ +- tx_desc->txdw4 |= +- cpu_to_le32(DESC_RATE_24M << +- TXDESC32_RTS_RATE_SHIFT); +- tx_desc->txdw4 |= +- cpu_to_le32(TXDESC32_RTS_CTS_ENABLE); +- tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE); +- } +- } else { +- tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc; +- +- tx_desc40->txdw4 = cpu_to_le32(rate); +- if (ieee80211_is_data(hdr->frame_control)) { +- tx_desc->txdw4 |= +- cpu_to_le32(0x1f << +- TXDESC40_DATA_RATE_FB_SHIFT); +- } +- +- tx_desc40->txdw9 = +- cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT); +- +- if (ampdu_enable) +- tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE); +- else +- tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK); +- +- if (ieee80211_is_mgmt(hdr->frame_control)) { +- tx_desc40->txdw4 = cpu_to_le32(rate); +- tx_desc40->txdw3 |= +- cpu_to_le32(TXDESC40_USE_DRIVER_RATE); +- tx_desc40->txdw4 |= +- cpu_to_le32(6 << TXDESC40_RETRY_LIMIT_SHIFT); +- tx_desc40->txdw4 |= +- cpu_to_le32(TXDESC40_RETRY_LIMIT_ENABLE); +- } +- +- if (short_preamble) +- tx_desc40->txdw5 |= +- cpu_to_le32(TXDESC40_SHORT_PREAMBLE); +- +- if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) { +- /* +- * Use RTS rate 24M - does the mac80211 tell +- * us which to use? +- */ +- tx_desc->txdw4 |= +- cpu_to_le32(DESC_RATE_24M << +- TXDESC40_RTS_RATE_SHIFT); +- tx_desc->txdw3 |= cpu_to_le32(TXDESC40_RTS_CTS_ENABLE); +- tx_desc->txdw3 |= cpu_to_le32(TXDESC40_HW_RTS_ENABLE); +- } +- } ++ priv->fops->fill_txdesc(hdr, tx_desc, rate, rate_flag, ++ sgi, short_preamble, ampdu_enable); + + rtl8xxxu_calc_tx_desc_csum(tx_desc); + diff --git a/package/kernel/mac80211/patches/651-0019-rtl8xxxu-gen1-Fix-non-static-symbol-warning.patch b/package/kernel/mac80211/patches/651-0019-rtl8xxxu-gen1-Fix-non-static-symbol-warning.patch new file mode 100644 index 0000000000..c6ccb8cf73 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0019-rtl8xxxu-gen1-Fix-non-static-symbol-warning.patch @@ -0,0 +1,27 @@ +From 455c72dcc58c79885888c3a45043c5d80c8372d1 Mon Sep 17 00:00:00 2001 +From: Wei Yongjun +Date: Tue, 12 Jul 2016 14:33:34 +0000 +Subject: [PATCH] rtl8xxxu: gen1: Fix non static symbol warning + +Fixes the following sparse warning: + +drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c:898:1: warning: + symbol 'rtl8xxxu_gen1_h2c_cmd' was not declared. Should it be static? + +Signed-off-by: Wei Yongjun +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -894,7 +894,7 @@ int rtl8xxxu_write_rfreg(struct rtl8xxxu + return retval; + } + +-int ++static int + rtl8xxxu_gen1_h2c_cmd(struct rtl8xxxu_priv *priv, struct h2c_cmd *h2c, int len) + { + struct device *dev = &priv->udev->dev; diff --git a/package/kernel/mac80211/patches/651-0020-net-wireless-rtl8xxxu-make-rtl8xxxu-ampdu-action-less-chatty.patch b/package/kernel/mac80211/patches/651-0020-net-wireless-rtl8xxxu-make-rtl8xxxu-ampdu-action-less-chatty.patch new file mode 100644 index 0000000000..8adc471fa9 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0020-net-wireless-rtl8xxxu-make-rtl8xxxu-ampdu-action-less-chatty.patch @@ -0,0 +1,37 @@ +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5696,7 +5696,7 @@ rtl8xxxu_ampdu_action(struct ieee80211_h + + switch (action) { + case IEEE80211_AMPDU_TX_START: +- dev_info(dev, "%s: IEEE80211_AMPDU_TX_START\n", __func__); ++ dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_START\n", __func__); + ampdu_factor = sta->ht_cap.ampdu_factor; + ampdu_density = sta->ht_cap.ampdu_density; + rtl8xxxu_set_ampdu_factor(priv, ampdu_factor); +@@ -5706,21 +5706,21 @@ rtl8xxxu_ampdu_action(struct ieee80211_h + ampdu_factor, ampdu_density); + break; + case IEEE80211_AMPDU_TX_STOP_FLUSH: +- dev_info(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH\n", __func__); ++ dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH\n", __func__); + rtl8xxxu_set_ampdu_factor(priv, 0); + rtl8xxxu_set_ampdu_min_space(priv, 0); + break; + case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: +- dev_info(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH_CONT\n", ++ dev_dbg(dev, "%s: IEEE80211_AMPDU_TX_STOP_FLUSH_CONT\n", + __func__); + rtl8xxxu_set_ampdu_factor(priv, 0); + rtl8xxxu_set_ampdu_min_space(priv, 0); + break; + case IEEE80211_AMPDU_RX_START: +- dev_info(dev, "%s: IEEE80211_AMPDU_RX_START\n", __func__); ++ dev_dbg(dev, "%s: IEEE80211_AMPDU_RX_START\n", __func__); + break; + case IEEE80211_AMPDU_RX_STOP: +- dev_info(dev, "%s: IEEE80211_AMPDU_RX_STOP\n", __func__); ++ dev_dbg(dev, "%s: IEEE80211_AMPDU_RX_STOP\n", __func__); + break; + default: + break; diff --git a/package/kernel/mac80211/patches/651-0021-rtl8xxxu-Reset-device-on-module-unload-if-still-atta.patch b/package/kernel/mac80211/patches/651-0021-rtl8xxxu-Reset-device-on-module-unload-if-still-atta.patch new file mode 100644 index 0000000000..6b33533faa --- /dev/null +++ b/package/kernel/mac80211/patches/651-0021-rtl8xxxu-Reset-device-on-module-unload-if-still-atta.patch @@ -0,0 +1,27 @@ +From dc8f9f320eada9b516a347f34e9e02dae93334ca Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 1 Sep 2016 15:08:57 -0400 +Subject: [PATCH] rtl8xxxu: Reset device on module unload if still attached + +If the USB dongle is still attached, reset it on module unload to +avoid scans failing when reloading the driver. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -6129,6 +6129,11 @@ static void rtl8xxxu_disconnect(struct u + mutex_destroy(&priv->usb_buf_mutex); + mutex_destroy(&priv->h2c_mutex); + ++ if (priv->udev->state != USB_STATE_NOTATTACHED) { ++ dev_info(&priv->udev->dev, ++ "Device still attached, trying to reset\n"); ++ usb_reset_device(priv->udev); ++ } + usb_put_dev(priv->udev); + ieee80211_free_hw(hw); + } diff --git a/package/kernel/mac80211/patches/651-0022-rtl8xxxu-fix-spelling-mistake-firmare-firmware.patch b/package/kernel/mac80211/patches/651-0022-rtl8xxxu-fix-spelling-mistake-firmare-firmware.patch new file mode 100644 index 0000000000..4b740d3927 --- /dev/null +++ b/package/kernel/mac80211/patches/651-0022-rtl8xxxu-fix-spelling-mistake-firmare-firmware.patch @@ -0,0 +1,29 @@ +From 398103a0c2c48445e11855c693877126aed23c6e Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Sat, 3 Sep 2016 17:43:54 +0100 +Subject: [PATCH] rtl8xxxu: fix spelling mistake "firmare" -> "firmware" + +Trivial fix to spelling mistakes in dev_dbg message. + +Signed-off-by: Colin Ian King +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -3921,11 +3921,11 @@ static int rtl8xxxu_init_device(struct i + rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, priv->fops->trxff_boundary); + + ret = rtl8xxxu_download_firmware(priv); +- dev_dbg(dev, "%s: download_fiwmare %i\n", __func__, ret); ++ dev_dbg(dev, "%s: download_firmware %i\n", __func__, ret); + if (ret) + goto exit; + ret = rtl8xxxu_start_firmware(priv); +- dev_dbg(dev, "%s: start_fiwmare %i\n", __func__, ret); ++ dev_dbg(dev, "%s: start_firmware %i\n", __func__, ret); + if (ret) + goto exit; + diff --git a/package/kernel/mac80211/patches/651-0023-rtl8xxxu-Implement-8192e-specific-power-down-sequenc.patch b/package/kernel/mac80211/patches/651-0023-rtl8xxxu-Implement-8192e-specific-power-down-sequenc.patch new file mode 100644 index 0000000000..611997a7ef --- /dev/null +++ b/package/kernel/mac80211/patches/651-0023-rtl8xxxu-Implement-8192e-specific-power-down-sequenc.patch @@ -0,0 +1,191 @@ +From c37241da2ccb981598ed4bf243f86228aca292b6 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 13 Sep 2016 14:51:43 -0400 +Subject: [PATCH] rtl8xxxu: Implement 8192e specific power down sequence + +This powers down the 8192e correctly, or at least to the point where +the firmware will load again, when reloading the driver module. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 144 ++++++++++++++++++++- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 1 + + 2 files changed, 144 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +@@ -1396,6 +1396,114 @@ exit: + return ret; + } + ++static int rtl8192eu_active_to_lps(struct rtl8xxxu_priv *priv) ++{ ++ struct device *dev = &priv->udev->dev; ++ u8 val8; ++ u16 val16; ++ u32 val32; ++ int retry, retval; ++ ++ rtl8xxxu_write8(priv, REG_TXPAUSE, 0xff); ++ ++ retry = 100; ++ retval = -EBUSY; ++ /* ++ * Poll 32 bit wide 0x05f8 for 0x00000000 to ensure no TX is pending. ++ */ ++ do { ++ val32 = rtl8xxxu_read32(priv, REG_SCH_TX_CMD); ++ if (!val32) { ++ retval = 0; ++ break; ++ } ++ } while (retry--); ++ ++ if (!retry) { ++ dev_warn(dev, "Failed to flush TX queue\n"); ++ retval = -EBUSY; ++ goto out; ++ } ++ ++ /* Disable CCK and OFDM, clock gated */ ++ val8 = rtl8xxxu_read8(priv, REG_SYS_FUNC); ++ val8 &= ~SYS_FUNC_BBRSTB; ++ rtl8xxxu_write8(priv, REG_SYS_FUNC, val8); ++ ++ udelay(2); ++ ++ /* Reset whole BB */ ++ val8 = rtl8xxxu_read8(priv, REG_SYS_FUNC); ++ val8 &= ~SYS_FUNC_BB_GLB_RSTN; ++ rtl8xxxu_write8(priv, REG_SYS_FUNC, val8); ++ ++ /* Reset MAC TRX */ ++ val16 = rtl8xxxu_read16(priv, REG_CR); ++ val16 &= 0xff00; ++ val16 |= (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE); ++ rtl8xxxu_write16(priv, REG_CR, val16); ++ ++ val16 = rtl8xxxu_read16(priv, REG_CR); ++ val16 &= ~CR_SECURITY_ENABLE; ++ rtl8xxxu_write16(priv, REG_CR, val16); ++ ++ val8 = rtl8xxxu_read8(priv, REG_DUAL_TSF_RST); ++ val8 |= DUAL_TSF_TX_OK; ++ rtl8xxxu_write8(priv, REG_DUAL_TSF_RST, val8); ++ ++out: ++ return retval; ++} ++ ++static int rtl8192eu_active_to_emu(struct rtl8xxxu_priv *priv) ++{ ++ u8 val8; ++ int count, ret = 0; ++ ++ /* Turn off RF */ ++ rtl8xxxu_write8(priv, REG_RF_CTRL, 0); ++ ++ /* Switch DPDT_SEL_P output from register 0x65[2] */ ++ val8 = rtl8xxxu_read8(priv, REG_LEDCFG2); ++ val8 &= ~LEDCFG2_DPDT_SELECT; ++ rtl8xxxu_write8(priv, REG_LEDCFG2, val8); ++ ++ /* 0x0005[1] = 1 turn off MAC by HW state machine*/ ++ val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); ++ val8 |= BIT(1); ++ rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); ++ ++ for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { ++ val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); ++ if ((val8 & BIT(1)) == 0) ++ break; ++ udelay(10); ++ } ++ ++ if (!count) { ++ dev_warn(&priv->udev->dev, "%s: Disabling MAC timed out\n", ++ __func__); ++ ret = -EBUSY; ++ goto exit; ++ } ++ ++exit: ++ return ret; ++} ++ ++static int rtl8192eu_emu_to_disabled(struct rtl8xxxu_priv *priv) ++{ ++ u8 val8; ++ ++ /* 0x04[12:11] = 01 enable WL suspend */ ++ val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); ++ val8 &= ~(BIT(3) | BIT(4)); ++ val8 |= BIT(3); ++ rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); ++ ++ return 0; ++} ++ + static int rtl8192eu_power_on(struct rtl8xxxu_priv *priv) + { + u16 val16; +@@ -1446,6 +1554,40 @@ exit: + return ret; + } + ++void rtl8192eu_power_off(struct rtl8xxxu_priv *priv) ++{ ++ u8 val8; ++ u16 val16; ++ ++ rtl8xxxu_flush_fifo(priv); ++ ++ val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL); ++ val8 &= ~TX_REPORT_CTRL_TIMER_ENABLE; ++ rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8); ++ ++ /* Turn off RF */ ++ rtl8xxxu_write8(priv, REG_RF_CTRL, 0x00); ++ ++ rtl8192eu_active_to_lps(priv); ++ ++ /* Reset Firmware if running in RAM */ ++ if (rtl8xxxu_read8(priv, REG_MCU_FW_DL) & MCU_FW_RAM_SEL) ++ rtl8xxxu_firmware_self_reset(priv); ++ ++ /* Reset MCU */ ++ val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); ++ val16 &= ~SYS_FUNC_CPU_ENABLE; ++ rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); ++ ++ /* Reset MCU ready status */ ++ rtl8xxxu_write8(priv, REG_MCU_FW_DL, 0x00); ++ ++ rtl8xxxu_reset_8051(priv); ++ ++ rtl8192eu_active_to_emu(priv); ++ rtl8192eu_emu_to_disabled(priv); ++} ++ + static void rtl8192e_enable_rf(struct rtl8xxxu_priv *priv) + { + u32 val32; +@@ -1487,7 +1629,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = + .parse_efuse = rtl8192eu_parse_efuse, + .load_firmware = rtl8192eu_load_firmware, + .power_on = rtl8192eu_power_on, +- .power_off = rtl8xxxu_power_off, ++ .power_off = rtl8192eu_power_off, + .reset_8051 = rtl8xxxu_reset_8051, + .llt_init = rtl8xxxu_auto_llt_table, + .init_phy_bb = rtl8192eu_init_phy_bb, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -676,6 +676,7 @@ + #define REG_SCH_TXCMD 0x05d0 + + /* define REG_FW_TSF_SYNC_CNT 0x04a0 */ ++#define REG_SCH_TX_CMD 0x05f8 + #define REG_FW_RESET_TSF_CNT_1 0x05fc + #define REG_FW_RESET_TSF_CNT_0 0x05fd + #define REG_FW_BCN_DIS_CNT 0x05fe diff --git a/package/kernel/mac80211/patches/652-0001-rtl8xxxu-Accept-firmware-signature-0x88e0.patch b/package/kernel/mac80211/patches/652-0001-rtl8xxxu-Accept-firmware-signature-0x88e0.patch new file mode 100644 index 0000000000..65fb3aa5e8 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0001-rtl8xxxu-Accept-firmware-signature-0x88e0.patch @@ -0,0 +1,22 @@ +From 738e72f09accebe95513ff7201e1b12427b4a80f Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 27 Jun 2016 14:08:47 -0400 +Subject: [PATCH] rtl8xxxu: Accept firmware signature 0x88e0 + +rtl8188eu uses firmware signature 0x88e0 + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -2097,6 +2097,7 @@ int rtl8xxxu_load_firmware(struct rtl8xx + switch (signature & 0xfff0) { + case 0x92e0: + case 0x92c0: ++ case 0x88e0: + case 0x88c0: + case 0x5300: + case 0x2300: diff --git a/package/kernel/mac80211/patches/652-0002-rtl8xxxu-Add-initial-code-to-detect-8188eu-devices.patch b/package/kernel/mac80211/patches/652-0002-rtl8xxxu-Add-initial-code-to-detect-8188eu-devices.patch new file mode 100644 index 0000000000..f90c7f4355 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0002-rtl8xxxu-Add-initial-code-to-detect-8188eu-devices.patch @@ -0,0 +1,121 @@ +From d62628f1e4245a28921f6d326440387c33c23bc2 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 27 Jun 2016 14:23:44 -0400 +Subject: [PATCH] rtl8xxxu: Add initial code to detect 8188eu devices + +So far this just detects the device and tries to load firmware. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/Makefile | 2 +- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 65 ++++++++++++++++++++++ + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 + + 4 files changed, 70 insertions(+), 1 deletion(-) + create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c + +--- a/drivers/net/wireless/realtek/rtl8xxxu/Makefile ++++ b/drivers/net/wireless/realtek/rtl8xxxu/Makefile +@@ -1,4 +1,4 @@ + obj-$(CPTCFG_RTL8XXXU) += rtl8xxxu.o + + rtl8xxxu-y := rtl8xxxu_core.o rtl8xxxu_8192e.o rtl8xxxu_8723b.o \ +- rtl8xxxu_8723a.o rtl8xxxu_8192c.o ++ rtl8xxxu_8723a.o rtl8xxxu_8192c.o rtl8xxxu_8188e.o +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1442,6 +1442,7 @@ void rtl8xxxu_fill_txdesc_v2(struct ieee + u16 rate_flag, bool sgi, bool short_preamble, + bool ampdu_enable); + ++extern struct rtl8xxxu_fileops rtl8188eu_fops; + extern struct rtl8xxxu_fileops rtl8192cu_fops; + extern struct rtl8xxxu_fileops rtl8192eu_fops; + extern struct rtl8xxxu_fileops rtl8723au_fops; +--- /dev/null ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -0,0 +1,65 @@ ++/* ++ * RTL8XXXU mac80211 USB driver - 8188e specific subdriver ++ * ++ * Copyright (c) 2014 - 2016 Jes Sorensen ++ * ++ * Portions, notably calibration code: ++ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. ++ * ++ * This driver was written as a replacement for the vendor provided ++ * rtl8723au driver. As the Realtek 8xxx chips are very similar in ++ * their programming interface, I have started adding support for ++ * additional 8xxx chips like the 8192cu, 8188cus, etc. ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of version 2 of the GNU General Public License as ++ * published by the Free Software Foundation. ++ * ++ * This program is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for ++ * more details. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "rtl8xxxu.h" ++#include "rtl8xxxu_regs.h" ++ ++static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv) ++{ ++ return 0; ++} ++ ++static int rtl8188eu_load_firmware(struct rtl8xxxu_priv *priv) ++{ ++ char *fw_name; ++ int ret; ++ ++ fw_name = "rtlwifi/rtl8188eufw.bin"; ++ ++ ret = rtl8xxxu_load_firmware(priv, fw_name); ++ ++ return -EINVAL; ++ return ret; ++} ++ ++struct rtl8xxxu_fileops rtl8188eu_fops = { ++ .parse_efuse = rtl8188eu_parse_efuse, ++ .load_firmware = rtl8188eu_load_firmware, ++ .reset_8051 = rtl8xxxu_reset_8051, ++}; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -54,6 +54,7 @@ MODULE_LICENSE("GPL"); + MODULE_FIRMWARE("rtlwifi/rtl8723aufw_A.bin"); + MODULE_FIRMWARE("rtlwifi/rtl8723aufw_B.bin"); + MODULE_FIRMWARE("rtlwifi/rtl8723aufw_B_NoBT.bin"); ++MODULE_FIRMWARE("rtlwifi/rtl8188eufw.bin"); + MODULE_FIRMWARE("rtlwifi/rtl8192cufw_A.bin"); + MODULE_FIRMWARE("rtlwifi/rtl8192cufw_B.bin"); + MODULE_FIRMWARE("rtlwifi/rtl8192cufw_TMSC.bin"); +@@ -6154,6 +6155,8 @@ static struct usb_device_id dev_table[] + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0xb720, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8723bu_fops}, + #ifdef CPTCFG_RTL8XXXU_UNTESTED ++{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8179, 0xff, 0xff, 0xff), ++ .driver_info = (unsigned long)&rtl8188eu_fops}, + /* Still supported by rtlwifi */ + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8176, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, diff --git a/package/kernel/mac80211/patches/652-0003-rtl8xxxu-Add-initial-code-to-part-8188eu-efuse.patch b/package/kernel/mac80211/patches/652-0003-rtl8xxxu-Add-initial-code-to-part-8188eu-efuse.patch new file mode 100644 index 0000000000..e664fa0b30 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0003-rtl8xxxu-Add-initial-code-to-part-8188eu-efuse.patch @@ -0,0 +1,113 @@ +From 0acca96b150f2ebd6883689ddfe62babea1a0fc1 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 27 Jun 2016 15:19:04 -0400 +Subject: [PATCH] rtl8xxxu: Add initial code to part 8188eu efuse + +This obtains the MAC address, but work is still needed to handle TX +power settings. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 40 ++++++++++++++++++++++ + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 34 ++++++++++++++++++ + 2 files changed, 74 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -871,6 +871,45 @@ struct rtl8192eu_efuse { + u8 res14[0xc3]; + }; + ++struct rtl8188eu_efuse { ++ __le16 rtl_id; ++ u8 res0[0x0e]; ++ u8 cck_tx_power_index_A[3]; /* 0x10 */ ++ u8 cck_tx_power_index_B[3]; ++ u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */ ++ u8 ht40_1s_tx_power_index_B[3]; ++ u8 res1[0x9c]; ++ u8 channel_plan; /* 0xb8 */ ++ u8 xtal_k; ++ u8 thermal_meter; ++ u8 iqk_lck; ++ u8 res2[5]; ++ u8 rf_board_option; ++ u8 rf_feature_option; ++ u8 rf_bt_setting; ++ u8 eeprom_version; ++ u8 eeprom_customer_id; ++ u8 res3[3]; ++ u8 rf_antenna_option; /* 0xc9 */ ++ u8 res4[6]; ++ u8 vid; /* 0xd0 */ ++ u8 res5[1]; ++ u8 pid; /* 0xd2 */ ++ u8 res6[1]; ++ u8 usb_optional_function; ++ u8 res7[2]; ++ u8 mac_addr[ETH_ALEN]; /* 0xd7 */ ++ u8 res8[2]; ++ u8 vendor_name[7]; ++ u8 res9[2]; ++ u8 device_name[0x0b]; /* 0xe8 */ ++ u8 res10[2]; ++ u8 serial[0x0b]; /* 0xf5 */ ++ u8 res11[0x30]; ++ u8 unknown[0x0d]; /* 0x130 */ ++ u8 res12[0xc3]; ++}; ++ + struct rtl8xxxu_reg8val { + u16 reg; + u8 val; +@@ -1289,6 +1328,7 @@ struct rtl8xxxu_priv { + struct rtl8723bu_efuse efuse8723bu; + struct rtl8192cu_efuse efuse8192; + struct rtl8192eu_efuse efuse8192eu; ++ struct rtl8188eu_efuse efuse8188eu; + } efuse_wifi; + u32 adda_backup[RTL8XXXU_ADDA_REGS]; + u32 mac_backup[RTL8XXXU_MAC_REGS]; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -42,6 +42,40 @@ + + static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv) + { ++ struct rtl8188eu_efuse *efuse = &priv->efuse_wifi.efuse8188eu; ++ int i; ++ ++ if (efuse->rtl_id != cpu_to_le16(0x8129)) ++ return -EINVAL; ++ ++ ether_addr_copy(priv->mac_addr, efuse->mac_addr); ++ ++ memcpy(priv->cck_tx_power_index_A, efuse->cck_tx_power_index_A, ++ sizeof(efuse->cck_tx_power_index_A)); ++ memcpy(priv->cck_tx_power_index_B, efuse->cck_tx_power_index_B, ++ sizeof(efuse->cck_tx_power_index_B)); ++ ++ memcpy(priv->ht40_1s_tx_power_index_A, ++ priv->efuse_wifi.efuse8188eu.ht40_1s_tx_power_index_A, ++ sizeof(priv->ht40_1s_tx_power_index_A)); ++ memcpy(priv->ht40_1s_tx_power_index_B, ++ priv->efuse_wifi.efuse8188eu.ht40_1s_tx_power_index_B, ++ sizeof(priv->ht40_1s_tx_power_index_B)); ++ ++ dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name); ++ dev_info(&priv->udev->dev, "Product: %.11s\n", efuse->device_name); ++ dev_info(&priv->udev->dev, "Serial: %.11s\n", efuse->serial); ++ ++ if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) { ++ unsigned char *raw = priv->efuse_wifi.raw; ++ ++ dev_info(&priv->udev->dev, ++ "%s: dumping efuse (0x%02zx bytes):\n", ++ __func__, sizeof(struct rtl8188eu_efuse)); ++ for (i = 0; i < sizeof(struct rtl8188eu_efuse); i += 8) ++ dev_info(&priv->udev->dev, "%02x: %8ph\n", i, &raw[i]); ++ } ++ + return 0; + } + diff --git a/package/kernel/mac80211/patches/652-0004-rtl8xxxu-Detect-8188eu-parts-correctly.patch b/package/kernel/mac80211/patches/652-0004-rtl8xxxu-Detect-8188eu-parts-correctly.patch new file mode 100644 index 0000000000..291f45e788 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0004-rtl8xxxu-Detect-8188eu-parts-correctly.patch @@ -0,0 +1,43 @@ +From 27f6f980c393532dd0145314e8403fd9c1b680b7 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 27 Jun 2016 15:34:00 -0400 +Subject: [PATCH] rtl8xxxu: Detect 8188eu parts correctly + +8188 parts with chip_cut >= 2 are assumed to be 8188eu. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 22 +++++++++++++++------- + 1 file changed, 15 insertions(+), 7 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -1683,13 +1683,21 @@ static int rtl8xxxu_identify_chip(struct + } + priv->has_wifi = 1; + } else { +- sprintf(priv->chip_name, "8188CU"); +- priv->rf_paths = 1; +- priv->rx_paths = 1; +- priv->tx_paths = 1; +- priv->rtl_chip = RTL8188C; +- priv->usb_interrupts = 1; +- priv->has_wifi = 1; ++ if (priv->chip_cut >= 2) { ++ sprintf(priv->chip_name, "8188EU"); ++ priv->rf_paths = 1; ++ priv->rx_paths = 1; ++ priv->tx_paths = 1; ++ priv->rtl_chip = RTL8188E; ++ } else { ++ sprintf(priv->chip_name, "8188CU"); ++ priv->rf_paths = 1; ++ priv->rx_paths = 1; ++ priv->tx_paths = 1; ++ priv->rtl_chip = RTL8188C; ++ priv->usb_interrupts = 1; ++ priv->has_wifi = 1; ++ } + } + + switch (priv->rtl_chip) { diff --git a/package/kernel/mac80211/patches/652-0005-rtl8xxxu-First-stab-at-rtl8188e_power_on.patch b/package/kernel/mac80211/patches/652-0005-rtl8xxxu-First-stab-at-rtl8188e_power_on.patch new file mode 100644 index 0000000000..1027d41a81 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0005-rtl8xxxu-First-stab-at-rtl8188e_power_on.patch @@ -0,0 +1,102 @@ +From 7016570c33d1f135f60b38461a3b7ed161911157 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 27 Jun 2016 17:08:30 -0400 +Subject: [PATCH] rtl8xxxu: First stab at rtl8188e_power_on() + +Code based on code from Andrea Merello. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 79 ++++++++++++++++++++++ + 1 file changed, 79 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -92,8 +92,87 @@ static int rtl8188eu_load_firmware(struc + return ret; + } + ++static int rtl8188e_emu_to_active(struct rtl8xxxu_priv *priv) ++{ ++ u8 val8; ++ u32 val32; ++ u16 val16; ++ int count, ret = 0; ++ ++ /* wait till 0x04[17] = 1 power ready*/ ++ for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { ++ val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); ++ if (val32 & BIT(17)) ++ break; ++ ++ udelay(10); ++ } ++ ++ if (!count) { ++ ret = -EBUSY; ++ goto exit; ++ } ++ ++ /* reset baseband */ ++ val8 = rtl8xxxu_read8(priv, REG_SYS_FUNC); ++ val8 &= ~(SYS_FUNC_BBRSTB | SYS_FUNC_BB_GLB_RSTN); ++ rtl8xxxu_write8(priv, REG_SYS_FUNC, val8); ++ ++ /*0x24[23] = 2b'01 schmit trigger */ ++ val32 = rtl8xxxu_read32(priv, REG_AFE_XTAL_CTRL); ++ val32 |= BIT(23); ++ rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, val32); ++ ++ /* 0x04[15] = 0 disable HWPDN (control by DRV)*/ ++ val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); ++ val16 &= ~APS_FSMCO_HW_POWERDOWN; ++ rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); ++ ++ /*0x04[12:11] = 2b'00 disable WL suspend*/ ++ val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); ++ val16 &= ~(APS_FSMCO_HW_SUSPEND | APS_FSMCO_PCIE); ++ rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); ++ ++ /* set, then poll until 0 */ ++ val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); ++ val32 |= APS_FSMCO_MAC_ENABLE; ++ rtl8xxxu_write32(priv, REG_APS_FSMCO, val32); ++ ++ for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { ++ val32 = rtl8xxxu_read32(priv, REG_APS_FSMCO); ++ if ((val32 & APS_FSMCO_MAC_ENABLE) == 0) { ++ ret = 0; ++ break; ++ } ++ udelay(10); ++ } ++ ++ if (!count) { ++ ret = -EBUSY; ++ goto exit; ++ } ++ ++ /* LDO normal mode*/ ++ val8 = rtl8xxxu_read8(priv, REG_LPLDO_CTRL); ++ val8 &= ~BIT(4); ++ rtl8xxxu_write8(priv, REG_LPLDO_CTRL, val8); ++ ++exit: ++ return ret; ++} ++ ++static int rtl8188eu_power_on(struct rtl8xxxu_priv *priv) ++{ ++ int ret; ++ ++ ret = rtl8188e_emu_to_active(priv); ++ ++ return ret; ++} ++ + struct rtl8xxxu_fileops rtl8188eu_fops = { + .parse_efuse = rtl8188eu_parse_efuse, + .load_firmware = rtl8188eu_load_firmware, ++ .power_on = rtl8188eu_power_on, + .reset_8051 = rtl8xxxu_reset_8051, + }; diff --git a/package/kernel/mac80211/patches/652-0006-rtl8xxxu-8188e-bail-if-rtl8188eu_emu_to_active-fails.patch b/package/kernel/mac80211/patches/652-0006-rtl8xxxu-8188e-bail-if-rtl8188eu_emu_to_active-fails.patch new file mode 100644 index 0000000000..1756bacc8e --- /dev/null +++ b/package/kernel/mac80211/patches/652-0006-rtl8xxxu-8188e-bail-if-rtl8188eu_emu_to_active-fails.patch @@ -0,0 +1,25 @@ +From d4c94e8fc13fdc241b3070476736eefe12726553 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 29 Jun 2016 10:24:39 -0400 +Subject: [PATCH] rtl8xxxu: 8188e - bail if rtl8188eu_emu_to_active() fails + +If emu_to_active() fails, don't try to enable anything else. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -166,7 +166,10 @@ static int rtl8188eu_power_on(struct rtl + int ret; + + ret = rtl8188e_emu_to_active(priv); ++ if (ret) ++ goto exit; + ++exit: + return ret; + } + diff --git a/package/kernel/mac80211/patches/652-0007-rtl8xxxu-Add-rtl8188e_disabled_to_emu.patch b/package/kernel/mac80211/patches/652-0007-rtl8xxxu-Add-rtl8188e_disabled_to_emu.patch new file mode 100644 index 0000000000..509cc87f33 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0007-rtl8xxxu-Add-rtl8188e_disabled_to_emu.patch @@ -0,0 +1,40 @@ +From f24a42f020ff56f587e8c66363af2d7e3ca90790 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 29 Jun 2016 10:38:52 -0400 +Subject: [PATCH] rtl8xxxu: Add rtl8188e_disabled_to_emu() + +This sequence is found in the vendor driver, but never actually +called. It's unclear if we need it. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -92,6 +92,15 @@ static int rtl8188eu_load_firmware(struc + return ret; + } + ++static void rtl8188e_disabled_to_emu(struct rtl8xxxu_priv *priv) ++{ ++ u16 val16; ++ ++ val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); ++ val16 &= ~(APS_FSMCO_PFM_WOWL | APS_FSMCO_ENABLE_POWERDOWN); ++ rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); ++} ++ + static int rtl8188e_emu_to_active(struct rtl8xxxu_priv *priv) + { + u8 val8; +@@ -165,6 +174,8 @@ static int rtl8188eu_power_on(struct rtl + { + int ret; + ++ rtl8188e_disabled_to_emu(priv); ++ + ret = rtl8188e_emu_to_active(priv); + if (ret) + goto exit; diff --git a/package/kernel/mac80211/patches/652-0008-rtl8xxxu-8188e-Enable-scheduler.patch b/package/kernel/mac80211/patches/652-0008-rtl8xxxu-8188e-Enable-scheduler.patch new file mode 100644 index 0000000000..bcf8061ef0 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0008-rtl8xxxu-8188e-Enable-scheduler.patch @@ -0,0 +1,45 @@ +From 2eaadaf2f65a2856f3e9d4522d582eb2ce6800ec Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 29 Jun 2016 11:07:13 -0400 +Subject: [PATCH] rtl8xxxu: 8188e: Enable scheduler + +This enables the schduler, DMA, etc, except for MAC RX/TX which has to +be set after REG_TRXFF_BNDY due to a hardware bug in the 8188e + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -172,6 +172,7 @@ exit: + + static int rtl8188eu_power_on(struct rtl8xxxu_priv *priv) + { ++ u16 val16; + int ret; + + rtl8188e_disabled_to_emu(priv); +@@ -180,6 +181,21 @@ static int rtl8188eu_power_on(struct rtl + if (ret) + goto exit; + ++ /* ++ * Enable MAC DMA/WMAC/SCHEDULE/SEC block ++ * Set CR bit10 to enable 32k calibration. ++ * We do not set CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE here ++ * due to a hardware bug in the 88E, requiring those to be ++ * set after REG_TRXFF_BNDY is set. If not the RXFF bundary ++ * will get set to a larger buffer size than the real buffer ++ * size. ++ */ ++ val16 = (CR_HCI_TXDMA_ENABLE | CR_HCI_RXDMA_ENABLE | ++ CR_TXDMA_ENABLE | CR_RXDMA_ENABLE | ++ CR_PROTOCOL_ENABLE | CR_SCHEDULE_ENABLE | ++ CR_SECURITY_ENABLE | CR_CALTIMER_ENABLE); ++ rtl8xxxu_write16(priv, REG_CR, val16); ++ + exit: + return ret; + } diff --git a/package/kernel/mac80211/patches/652-0009-rtl8xxxu-Add-rtl8188e_usb_quirk-for-enabling-MAC-TX-.patch b/package/kernel/mac80211/patches/652-0009-rtl8xxxu-Add-rtl8188e_usb_quirk-for-enabling-MAC-TX-.patch new file mode 100644 index 0000000000..e4cf61559b --- /dev/null +++ b/package/kernel/mac80211/patches/652-0009-rtl8xxxu-Add-rtl8188e_usb_quirk-for-enabling-MAC-TX-.patch @@ -0,0 +1,40 @@ +From 281b44d1c35792946e2a2373c60e543cd5d71c03 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 29 Jun 2016 11:47:10 -0400 +Subject: [PATCH] rtl8xxxu: Add rtl8188e_usb_quirk() for enabling MAC TX/RX + +Due to a bug in the 8188e chips, this has to be done after setting +REG_TRXFF_BNDY. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -200,9 +200,24 @@ exit: + return ret; + } + ++static void rtl8188e_usb_quirks(struct rtl8xxxu_priv *priv) ++{ ++ u16 val16; ++ ++ /* ++ * Technically this is not a USB quirk, but a chip quirk. ++ * This has to be done after REG_TRXFF_BNDY is set, see ++ * rtl8188eu_power_on() for details. ++ */ ++ val16 = rtl8xxxu_read16(priv, REG_CR); ++ val16 |= (CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE); ++ rtl8xxxu_write16(priv, REG_CR, val16); ++} ++ + struct rtl8xxxu_fileops rtl8188eu_fops = { + .parse_efuse = rtl8188eu_parse_efuse, + .load_firmware = rtl8188eu_load_firmware, + .power_on = rtl8188eu_power_on, + .reset_8051 = rtl8xxxu_reset_8051, ++ .usb_quirks = rtl8188e_usb_quirks, + }; diff --git a/package/kernel/mac80211/patches/652-0010-rtl8xxxu-8188e-add-REG_TXDMA_OFFSET_CHK-quirk.patch b/package/kernel/mac80211/patches/652-0010-rtl8xxxu-8188e-add-REG_TXDMA_OFFSET_CHK-quirk.patch new file mode 100644 index 0000000000..7ff1e8a317 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0010-rtl8xxxu-8188e-add-REG_TXDMA_OFFSET_CHK-quirk.patch @@ -0,0 +1,34 @@ +From 19a9f0c2c5912dc0eb9c1d7a04808509ac3a99a5 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 29 Jun 2016 11:53:31 -0400 +Subject: [PATCH] rtl8xxxu: 8188e add REG_TXDMA_OFFSET_CHK quirk + +Enable quirk allowing TX DMA to drop redundant data of packet. This is +the same quirk enabled on gen2 parts. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -203,6 +203,7 @@ exit: + static void rtl8188e_usb_quirks(struct rtl8xxxu_priv *priv) + { + u16 val16; ++ u32 val32; + + /* + * Technically this is not a USB quirk, but a chip quirk. +@@ -212,6 +213,10 @@ static void rtl8188e_usb_quirks(struct r + val16 = rtl8xxxu_read16(priv, REG_CR); + val16 |= (CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE); + rtl8xxxu_write16(priv, REG_CR, val16); ++ ++ val32 = rtl8xxxu_read32(priv, REG_TXDMA_OFFSET_CHK); ++ val32 |= TXDMA_OFFSET_DROP_DATA_EN; ++ rtl8xxxu_write32(priv, REG_TXDMA_OFFSET_CHK, val32); + } + + struct rtl8xxxu_fileops rtl8188eu_fops = { diff --git a/package/kernel/mac80211/patches/652-0011-rtl8xxxu-Add-reserved-page-init-parameters-for-8188e.patch b/package/kernel/mac80211/patches/652-0011-rtl8xxxu-Add-reserved-page-init-parameters-for-8188e.patch new file mode 100644 index 0000000000..b77d98fcec --- /dev/null +++ b/package/kernel/mac80211/patches/652-0011-rtl8xxxu-Add-reserved-page-init-parameters-for-8188e.patch @@ -0,0 +1,45 @@ +From 60f7f109456f2bcdd69504bdf63c55e57ae0c64b Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 29 Jun 2016 12:02:18 -0400 +Subject: [PATCH] rtl8xxxu: Add reserved page init parameters for 8188e + +Signed-off-by: Andrea Merello +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 6 ++++++ + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 4 ++++ + 2 files changed, 10 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -42,6 +42,7 @@ + #define REALTEK_USB_CMD_IDX 0x00 + + #define TX_TOTAL_PAGE_NUM 0xf8 ++#define TX_TOTAL_PAGE_NUM_8188E 0xa8 + #define TX_TOTAL_PAGE_NUM_8192E 0xf3 + #define TX_TOTAL_PAGE_NUM_8723B 0xf7 + /* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */ +@@ -50,6 +51,11 @@ + #define TX_PAGE_NUM_LO_PQ 0x02 + #define TX_PAGE_NUM_NORM_PQ 0x02 + ++#define TX_PAGE_NUM_PUBQ_8188E 0x47 ++#define TX_PAGE_NUM_HI_PQ_8188E 0x29 ++#define TX_PAGE_NUM_LO_PQ_8188E 0x1c ++#define TX_PAGE_NUM_NORM_PQ_8188E 0x1c ++ + #define TX_PAGE_NUM_PUBQ_8192E 0xe7 + #define TX_PAGE_NUM_HI_PQ_8192E 0x08 + #define TX_PAGE_NUM_LO_PQ_8192E 0x0c +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -225,4 +225,8 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .power_on = rtl8188eu_power_on, + .reset_8051 = rtl8xxxu_reset_8051, + .usb_quirks = rtl8188e_usb_quirks, ++ .total_page_num = TX_TOTAL_PAGE_NUM_8188E, ++ .page_num_hi = TX_PAGE_NUM_HI_PQ_8188E, ++ .page_num_lo = TX_PAGE_NUM_LO_PQ_8188E, ++ .page_num_norm = TX_PAGE_NUM_NORM_PQ_8188E, + }; diff --git a/package/kernel/mac80211/patches/652-0012-rtl8xxxu-Add-trxff_boundary-for-8188e.patch b/package/kernel/mac80211/patches/652-0012-rtl8xxxu-Add-trxff_boundary-for-8188e.patch new file mode 100644 index 0000000000..9c57d8ca86 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0012-rtl8xxxu-Add-trxff_boundary-for-8188e.patch @@ -0,0 +1,28 @@ +From 5bbaf33b2500b9f1ca1137663924a722e00aad57 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 29 Jun 2016 12:08:31 -0400 +Subject: [PATCH] rtl8xxxu: Add trxff_boundary for 8188e + +The 8188e presumably has a 10K buffer, but leave space for TX report +or WOL pattern. + +Signed-off-by: Andrea Merello +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -225,6 +225,11 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .power_on = rtl8188eu_power_on, + .reset_8051 = rtl8xxxu_reset_8051, + .usb_quirks = rtl8188e_usb_quirks, ++ /* ++ * Use 9K for 8188e normal chip ++ * Max RX buffer = 10K - max(TxReportSize(64*8), WOLPattern(16*24)) ++ */ ++ .trxff_boundary = 0x23ff, + .total_page_num = TX_TOTAL_PAGE_NUM_8188E, + .page_num_hi = TX_PAGE_NUM_HI_PQ_8188E, + .page_num_lo = TX_PAGE_NUM_LO_PQ_8188E, diff --git a/package/kernel/mac80211/patches/652-0013-rtl8xxxu-8188eu-specify-firmware-block-size-and-set-.patch b/package/kernel/mac80211/patches/652-0013-rtl8xxxu-8188eu-specify-firmware-block-size-and-set-.patch new file mode 100644 index 0000000000..7d864028af --- /dev/null +++ b/package/kernel/mac80211/patches/652-0013-rtl8xxxu-8188eu-specify-firmware-block-size-and-set-.patch @@ -0,0 +1,26 @@ +From f8f72624491a011686c3ddc213c4eef6bac95665 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 29 Jun 2016 15:03:54 -0400 +Subject: [PATCH] rtl8xxxu: 8188eu specify firmware block size and set + power_off function + +This uses a conservative firmware block size for now. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -223,8 +223,10 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .parse_efuse = rtl8188eu_parse_efuse, + .load_firmware = rtl8188eu_load_firmware, + .power_on = rtl8188eu_power_on, ++ .power_off = rtl8xxxu_power_off, + .reset_8051 = rtl8xxxu_reset_8051, + .usb_quirks = rtl8188e_usb_quirks, ++ .writeN_block_size = 128, + /* + * Use 9K for 8188e normal chip + * Max RX buffer = 10K - max(TxReportSize(64*8), WOLPattern(16*24)) diff --git a/package/kernel/mac80211/patches/652-0014-rtl8xxxu-Add-8188e-mac-init-table.patch b/package/kernel/mac80211/patches/652-0014-rtl8xxxu-Add-8188e-mac-init-table.patch new file mode 100644 index 0000000000..796c619513 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0014-rtl8xxxu-Add-8188e-mac-init-table.patch @@ -0,0 +1,57 @@ +From 3490eb08d944df4605aefae95a8ff46982b29a79 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 19 Jul 2016 15:04:24 -0400 +Subject: [PATCH] rtl8xxxu: Add 8188e mac init table + +This table was pulled from the vendor driver. + +Signed-off-by: Andrea Merello +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 28 ++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -40,6 +40,33 @@ + #include "rtl8xxxu.h" + #include "rtl8xxxu_regs.h" + ++static struct rtl8xxxu_reg8val rtl8188e_mac_init_table[] = { ++ {0x026, 0x41}, {0x027, 0x35}, {0x428, 0x0a}, {0x429, 0x10}, ++ {0x430, 0x00}, {0x431, 0x01}, {0x432, 0x02}, {0x433, 0x04}, ++ {0x434, 0x05}, {0x435, 0x06}, {0x436, 0x07}, {0x437, 0x08}, ++ {0x438, 0x00}, {0x439, 0x00}, {0x43a, 0x01}, {0x43b, 0x02}, ++ {0x43c, 0x04}, {0x43d, 0x05}, {0x43e, 0x06}, {0x43f, 0x07}, ++ {0x440, 0x5d}, {0x441, 0x01}, {0x442, 0x00}, {0x444, 0x15}, ++ {0x445, 0xf0}, {0x446, 0x0f}, {0x447, 0x00}, {0x458, 0x41}, ++ {0x459, 0xa8}, {0x45a, 0x72}, {0x45b, 0xb9}, {0x460, 0x66}, ++ {0x461, 0x66}, {0x480, 0x08}, {0x4c8, 0xff}, {0x4c9, 0x08}, ++ {0x4cc, 0xff}, {0x4cd, 0xff}, {0x4ce, 0x01}, {0x4d3, 0x01}, ++ {0x500, 0x26}, {0x501, 0xa2}, {0x502, 0x2f}, {0x503, 0x00}, ++ {0x504, 0x28}, {0x505, 0xa3}, {0x506, 0x5e}, {0x507, 0x00}, ++ {0x508, 0x2b}, {0x509, 0xa4}, {0x50a, 0x5e}, {0x50b, 0x00}, ++ {0x50c, 0x4f}, {0x50d, 0xa4}, {0x50e, 0x00}, {0x50f, 0x00}, ++ {0x512, 0x1c}, {0x514, 0x0a}, {0x516, 0x0a}, {0x525, 0x4f}, ++ {0x550, 0x10}, {0x551, 0x10}, {0x559, 0x02}, {0x55d, 0xff}, ++ {0x605, 0x30}, {0x608, 0x0e}, {0x609, 0x2a}, {0x620, 0xff}, ++ {0x621, 0xff}, {0x622, 0xff}, {0x623, 0xff}, {0x624, 0xff}, ++ {0x625, 0xff}, {0x626, 0xff}, {0x627, 0xff}, {0x652, 0x20}, ++ {0x63c, 0x0a}, {0x63d, 0x0a}, {0x63e, 0x0e}, {0x63f, 0x0e}, ++ {0x640, 0x40}, {0x66e, 0x05}, {0x700, 0x21}, {0x701, 0x43}, ++ {0x702, 0x65}, {0x703, 0x87}, {0x708, 0x21}, {0x709, 0x43}, ++ {0x70a, 0x65}, {0x70b, 0x87}, ++ {0xffff, 0xff}, ++}; ++ + static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv) + { + struct rtl8188eu_efuse *efuse = &priv->efuse_wifi.efuse8188eu; +@@ -232,6 +259,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + * Max RX buffer = 10K - max(TxReportSize(64*8), WOLPattern(16*24)) + */ + .trxff_boundary = 0x23ff, ++ .mactable = rtl8188e_mac_init_table, + .total_page_num = TX_TOTAL_PAGE_NUM_8188E, + .page_num_hi = TX_PAGE_NUM_HI_PQ_8188E, + .page_num_lo = TX_PAGE_NUM_LO_PQ_8188E, diff --git a/package/kernel/mac80211/patches/652-0015-rtl8xxxu-Implement-rtl8188eu_init_phy_bb.patch b/package/kernel/mac80211/patches/652-0015-rtl8xxxu-Implement-rtl8188eu_init_phy_bb.patch new file mode 100644 index 0000000000..104a2874b1 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0015-rtl8xxxu-Implement-rtl8188eu_init_phy_bb.patch @@ -0,0 +1,245 @@ +From 08e1167540ad5de6fdc1814fcfbce545b4c10c41 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 19 Jul 2016 16:19:30 -0400 +Subject: [PATCH] rtl8xxxu: Implement rtl8188eu_init_phy_bb() + +This includes adding rtl8188eu_phy_init_table rtl8188e_agc_table, both +extracted from the vendor driver. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 202 +++++++++++++++++++++ + 1 file changed, 202 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -67,6 +67,174 @@ static struct rtl8xxxu_reg8val rtl8188e_ + {0xffff, 0xff}, + }; + ++static struct rtl8xxxu_reg32val rtl8188eu_phy_init_table[] = { ++ {0x800, 0x80040000}, {0x804, 0x00000003}, ++ {0x808, 0x0000fc00}, {0x80c, 0x0000000a}, ++ {0x810, 0x10001331}, {0x814, 0x020c3d10}, ++ {0x818, 0x02200385}, {0x81c, 0x00000000}, ++ {0x820, 0x01000100}, {0x824, 0x00390204}, ++ {0x828, 0x00000000}, {0x82c, 0x00000000}, ++ {0x830, 0x00000000}, {0x834, 0x00000000}, ++ {0x838, 0x00000000}, {0x83c, 0x00000000}, ++ {0x840, 0x00010000}, {0x844, 0x00000000}, ++ {0x848, 0x00000000}, {0x84c, 0x00000000}, ++ {0x850, 0x00000000}, {0x854, 0x00000000}, ++ {0x858, 0x569a11a9}, {0x85c, 0x01000014}, ++ {0x860, 0x66f60110}, {0x864, 0x061f0649}, ++ {0x868, 0x00000000}, {0x86c, 0x27272700}, ++ {0x870, 0x07000760}, {0x874, 0x25004000}, ++ {0x878, 0x00000808}, {0x87c, 0x00000000}, ++ {0x880, 0xb0000c1c}, {0x884, 0x00000001}, ++ {0x888, 0x00000000}, {0x88c, 0xccc000c0}, ++ {0x890, 0x00000800}, {0x894, 0xfffffffe}, ++ {0x898, 0x40302010}, {0x89c, 0x00706050}, ++ {0x900, 0x00000000}, {0x904, 0x00000023}, ++ {0x908, 0x00000000}, {0x90c, 0x81121111}, ++ {0x910, 0x00000002}, {0x914, 0x00000201}, ++ {0xa00, 0x00d047c8}, {0xa04, 0x80ff000c}, ++ {0xa08, 0x8c838300}, {0xa0c, 0x2e7f120f}, ++ {0xa10, 0x9500bb78}, {0xa14, 0x1114d028}, ++ {0xa18, 0x00881117}, {0xa1c, 0x89140f00}, ++ {0xa20, 0x1a1b0000}, {0xa24, 0x090e1317}, ++ {0xa28, 0x00000204}, {0xa2c, 0x00d30000}, ++ {0xa70, 0x101fbf00}, {0xa74, 0x00000007}, ++ {0xa78, 0x00000900}, {0xa7c, 0x225b0606}, ++ {0xa80, 0x218075b1}, {0xb2c, 0x80000000}, ++ {0xc00, 0x48071d40}, {0xc04, 0x03a05611}, ++ {0xc08, 0x000000e4}, {0xc0c, 0x6c6c6c6c}, ++ {0xc10, 0x08800000}, {0xc14, 0x40000100}, ++ {0xc18, 0x08800000}, {0xc1c, 0x40000100}, ++ {0xc20, 0x00000000}, {0xc24, 0x00000000}, ++ {0xc28, 0x00000000}, {0xc2c, 0x00000000}, ++ {0xc30, 0x69e9ac47}, {0xc34, 0x469652af}, ++ {0xc38, 0x49795994}, {0xc3c, 0x0a97971c}, ++ {0xc40, 0x1f7c403f}, {0xc44, 0x000100b7}, ++ {0xc48, 0xec020107}, {0xc4c, 0x007f037f}, ++ {0xc50, 0x69553420}, {0xc54, 0x43bc0094}, ++ {0xc58, 0x00013169}, {0xc5c, 0x00250492}, ++ {0xc60, 0x00000000}, {0xc64, 0x7112848b}, ++ {0xc68, 0x47c00bff}, {0xc6c, 0x00000036}, ++ {0xc70, 0x2c7f000d}, {0xc74, 0x020610db}, ++ {0xc78, 0x0000001f}, {0xc7c, 0x00b91612}, ++ {0xc80, 0x390000e4}, {0xc84, 0x20f60000}, ++ {0xc88, 0x40000100}, {0xc8c, 0x20200000}, ++ {0xc90, 0x00091521}, {0xc94, 0x00000000}, ++ {0xc98, 0x00121820}, {0xc9c, 0x00007f7f}, ++ {0xca0, 0x00000000}, {0xca4, 0x000300a0}, ++ {0xca8, 0x00000000}, {0xcac, 0x00000000}, ++ {0xcb0, 0x00000000}, {0xcb4, 0x00000000}, ++ {0xcb8, 0x00000000}, {0xcbc, 0x28000000}, ++ {0xcc0, 0x00000000}, {0xcc4, 0x00000000}, ++ {0xcc8, 0x00000000}, {0xccc, 0x00000000}, ++ {0xcd0, 0x00000000}, {0xcd4, 0x00000000}, ++ {0xcd8, 0x64b22427}, {0xcdc, 0x00766932}, ++ {0xce0, 0x00222222}, {0xce4, 0x00000000}, ++ {0xce8, 0x37644302}, {0xcec, 0x2f97d40c}, ++ {0xd00, 0x00000740}, {0xd04, 0x00020401}, ++ {0xd08, 0x0000907f}, {0xd0c, 0x20010201}, ++ {0xd10, 0xa0633333}, {0xd14, 0x3333bc43}, ++ {0xd18, 0x7a8f5b6f}, {0xd2c, 0xcc979975}, ++ {0xd30, 0x00000000}, {0xd34, 0x80608000}, ++ {0xd38, 0x00000000}, {0xd3c, 0x00127353}, ++ {0xd40, 0x00000000}, {0xd44, 0x00000000}, ++ {0xd48, 0x00000000}, {0xd4c, 0x00000000}, ++ {0xd50, 0x6437140a}, {0xd54, 0x00000000}, ++ {0xd58, 0x00000282}, {0xd5c, 0x30032064}, ++ {0xd60, 0x4653de68}, {0xd64, 0x04518a3c}, ++ {0xd68, 0x00002101}, {0xd6c, 0x2a201c16}, ++ {0xd70, 0x1812362e}, {0xd74, 0x322c2220}, ++ {0xd78, 0x000e3c24}, {0xe00, 0x2d2d2d2d}, ++ {0xe04, 0x2d2d2d2d}, {0xe08, 0x0390272d}, ++ {0xe10, 0x2d2d2d2d}, {0xe14, 0x2d2d2d2d}, ++ {0xe18, 0x2d2d2d2d}, {0xe1c, 0x2d2d2d2d}, ++ {0xe28, 0x00000000}, {0xe30, 0x1000dc1f}, ++ {0xe34, 0x10008c1f}, {0xe38, 0x02140102}, ++ {0xe3c, 0x681604c2}, {0xe40, 0x01007c00}, ++ {0xe44, 0x01004800}, {0xe48, 0xfb000000}, ++ {0xe4c, 0x000028d1}, {0xe50, 0x1000dc1f}, ++ {0xe54, 0x10008c1f}, {0xe58, 0x02140102}, ++ {0xe5c, 0x28160d05}, {0xe60, 0x00000008}, ++ {0xe68, 0x001b25a4}, {0xe6c, 0x00c00014}, ++ {0xe70, 0x00c00014}, {0xe74, 0x01000014}, ++ {0xe78, 0x01000014}, {0xe7c, 0x01000014}, ++ {0xe80, 0x01000014}, {0xe84, 0x00c00014}, ++ {0xe88, 0x01000014}, {0xe8c, 0x00c00014}, ++ {0xed0, 0x00c00014}, {0xed4, 0x00c00014}, ++ {0xed8, 0x00c00014}, {0xedc, 0x00000014}, ++ {0xee0, 0x00000014}, {0xeec, 0x01c00014}, ++ {0xf14, 0x00000003}, {0xf4c, 0x00000000}, ++ {0xf00, 0x00000300}, ++ {0xffff, 0xffffffff}, ++}; ++ ++static struct rtl8xxxu_reg32val rtl8188e_agc_table[] = { ++ {0xc78, 0xfb000001}, {0xc78, 0xfb010001}, ++ {0xc78, 0xfb020001}, {0xc78, 0xfb030001}, ++ {0xc78, 0xfb040001}, {0xc78, 0xfb050001}, ++ {0xc78, 0xfa060001}, {0xc78, 0xf9070001}, ++ {0xc78, 0xf8080001}, {0xc78, 0xf7090001}, ++ {0xc78, 0xf60a0001}, {0xc78, 0xf50b0001}, ++ {0xc78, 0xf40c0001}, {0xc78, 0xf30d0001}, ++ {0xc78, 0xf20e0001}, {0xc78, 0xf10f0001}, ++ {0xc78, 0xf0100001}, {0xc78, 0xef110001}, ++ {0xc78, 0xee120001}, {0xc78, 0xed130001}, ++ {0xc78, 0xec140001}, {0xc78, 0xeb150001}, ++ {0xc78, 0xea160001}, {0xc78, 0xe9170001}, ++ {0xc78, 0xe8180001}, {0xc78, 0xe7190001}, ++ {0xc78, 0xe61a0001}, {0xc78, 0xe51b0001}, ++ {0xc78, 0xe41c0001}, {0xc78, 0xe31d0001}, ++ {0xc78, 0xe21e0001}, {0xc78, 0xe11f0001}, ++ {0xc78, 0x8a200001}, {0xc78, 0x89210001}, ++ {0xc78, 0x88220001}, {0xc78, 0x87230001}, ++ {0xc78, 0x86240001}, {0xc78, 0x85250001}, ++ {0xc78, 0x84260001}, {0xc78, 0x83270001}, ++ {0xc78, 0x82280001}, {0xc78, 0x6b290001}, ++ {0xc78, 0x6a2a0001}, {0xc78, 0x692b0001}, ++ {0xc78, 0x682c0001}, {0xc78, 0x672d0001}, ++ {0xc78, 0x662e0001}, {0xc78, 0x652f0001}, ++ {0xc78, 0x64300001}, {0xc78, 0x63310001}, ++ {0xc78, 0x62320001}, {0xc78, 0x61330001}, ++ {0xc78, 0x46340001}, {0xc78, 0x45350001}, ++ {0xc78, 0x44360001}, {0xc78, 0x43370001}, ++ {0xc78, 0x42380001}, {0xc78, 0x41390001}, ++ {0xc78, 0x403a0001}, {0xc78, 0x403b0001}, ++ {0xc78, 0x403c0001}, {0xc78, 0x403d0001}, ++ {0xc78, 0x403e0001}, {0xc78, 0x403f0001}, ++ {0xc78, 0xfb400001}, {0xc78, 0xfb410001}, ++ {0xc78, 0xfb420001}, {0xc78, 0xfb430001}, ++ {0xc78, 0xfb440001}, {0xc78, 0xfb450001}, ++ {0xc78, 0xfb460001}, {0xc78, 0xfb470001}, ++ {0xc78, 0xfb480001}, {0xc78, 0xfa490001}, ++ {0xc78, 0xf94a0001}, {0xc78, 0xf84b0001}, ++ {0xc78, 0xf74c0001}, {0xc78, 0xf64d0001}, ++ {0xc78, 0xf54e0001}, {0xc78, 0xf44f0001}, ++ {0xc78, 0xf3500001}, {0xc78, 0xf2510001}, ++ {0xc78, 0xf1520001}, {0xc78, 0xf0530001}, ++ {0xc78, 0xef540001}, {0xc78, 0xee550001}, ++ {0xc78, 0xed560001}, {0xc78, 0xec570001}, ++ {0xc78, 0xeb580001}, {0xc78, 0xea590001}, ++ {0xc78, 0xe95a0001}, {0xc78, 0xe85b0001}, ++ {0xc78, 0xe75c0001}, {0xc78, 0xe65d0001}, ++ {0xc78, 0xe55e0001}, {0xc78, 0xe45f0001}, ++ {0xc78, 0xe3600001}, {0xc78, 0xe2610001}, ++ {0xc78, 0xc3620001}, {0xc78, 0xc2630001}, ++ {0xc78, 0xc1640001}, {0xc78, 0x8b650001}, ++ {0xc78, 0x8a660001}, {0xc78, 0x89670001}, ++ {0xc78, 0x88680001}, {0xc78, 0x87690001}, ++ {0xc78, 0x866a0001}, {0xc78, 0x856b0001}, ++ {0xc78, 0x846c0001}, {0xc78, 0x676d0001}, ++ {0xc78, 0x666e0001}, {0xc78, 0x656f0001}, ++ {0xc78, 0x64700001}, {0xc78, 0x63710001}, ++ {0xc78, 0x62720001}, {0xc78, 0x61730001}, ++ {0xc78, 0x60740001}, {0xc78, 0x46750001}, ++ {0xc78, 0x45760001}, {0xc78, 0x44770001}, ++ {0xc78, 0x43780001}, {0xc78, 0x42790001}, ++ {0xc78, 0x417a0001}, {0xc78, 0x407b0001}, ++ {0xc78, 0x407c0001}, {0xc78, 0x407d0001}, ++ {0xc78, 0x407e0001}, {0xc78, 0x407f0001}, ++ {0xffff, 0xffffffff} ++}; ++ + static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv) + { + struct rtl8188eu_efuse *efuse = &priv->efuse_wifi.efuse8188eu; +@@ -89,6 +257,8 @@ static int rtl8188eu_parse_efuse(struct + priv->efuse_wifi.efuse8188eu.ht40_1s_tx_power_index_B, + sizeof(priv->ht40_1s_tx_power_index_B)); + ++ priv->xtalk = priv->efuse_wifi.efuse8188eu.xtal_k & 0x3f; ++ + dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name); + dev_info(&priv->udev->dev, "Product: %.11s\n", efuse->device_name); + dev_info(&priv->udev->dev, "Serial: %.11s\n", efuse->serial); +@@ -119,6 +289,37 @@ static int rtl8188eu_load_firmware(struc + return ret; + } + ++static void rtl8188eu_init_phy_bb(struct rtl8xxxu_priv *priv) ++{ ++ u8 val8; ++ u16 val16; ++ u32 val32; ++ ++ val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); ++ val16 |= SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB | SYS_FUNC_DIO_RF; ++ rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); ++ ++ /* ++ * Per vendor driver, run power sequence before init of RF ++ */ ++ val8 = RF_ENABLE | RF_RSTB | RF_SDMRSTB; ++ rtl8xxxu_write8(priv, REG_RF_CTRL, val8); ++ ++ val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); ++ val16 |= (SYS_FUNC_USBA | SYS_FUNC_USBD | ++ SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB); ++ rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); ++ ++ rtl8xxxu_init_phy_regs(priv, rtl8188eu_phy_init_table); ++ rtl8xxxu_init_phy_regs(priv, rtl8188e_agc_table); ++ ++ val32 = rtl8xxxu_read32(priv, REG_AFE_XTAL_CTRL); ++ val8 = priv->xtalk; ++ val32 &= 0xff8007ff; ++ val32 |= ((val8 | (val8 << 6)) << 11); ++ rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, val32); ++} ++ + static void rtl8188e_disabled_to_emu(struct rtl8xxxu_priv *priv) + { + u16 val16; +@@ -252,6 +453,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .power_on = rtl8188eu_power_on, + .power_off = rtl8xxxu_power_off, + .reset_8051 = rtl8xxxu_reset_8051, ++ .init_phy_bb = rtl8188eu_init_phy_bb, + .usb_quirks = rtl8188e_usb_quirks, + .writeN_block_size = 128, + /* diff --git a/package/kernel/mac80211/patches/652-0016-rtl8xxxu-Implement-rtl8188eu_init_phy_rf.patch b/package/kernel/mac80211/patches/652-0016-rtl8xxxu-Implement-rtl8188eu_init_phy_rf.patch new file mode 100644 index 0000000000..9095b1b179 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0016-rtl8xxxu-Implement-rtl8188eu_init_phy_rf.patch @@ -0,0 +1,103 @@ +From d538ef459e4d8edea4968a2c0012fbab5d8c70f5 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 19 Jul 2016 17:12:42 -0400 +Subject: [PATCH] rtl8xxxu: Implement rtl8188eu_init_phy_rf() + +Include the table rtl8188eu_radioa_init_table derived from vendor +driver. The vendor table relies on a hack setting RF6052_REG_RCK1 + +RF6052_REG_RCK2 with delays. This workaround is open coded here +instead of modifying the table parsing code. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 65 ++++++++++++++++++++++ + 1 file changed, 65 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -235,6 +235,54 @@ static struct rtl8xxxu_reg32val rtl8188e + {0xffff, 0xffffffff} + }; + ++static struct rtl8xxxu_rfregval rtl8188eu_radioa_init_table[] = { ++ {0x00, 0x00030000}, {0x08, 0x00084000}, ++ {0x18, 0x00000407}, {0x19, 0x00000012}, ++ {0x1e, 0x00080009}, {0x1f, 0x00000880}, ++ {0x2f, 0x0001a060}, {0x3f, 0x00000000}, ++ {0x42, 0x000060c0}, {0x57, 0x000d0000}, ++ {0x58, 0x000be180}, {0x67, 0x00001552}, ++ {0x83, 0x00000000}, {0xb0, 0x000ff8fc}, ++ {0xb1, 0x00054400}, {0xb2, 0x000ccc19}, ++ {0xb4, 0x00043003}, {0xb6, 0x0004953e}, ++ {0xb7, 0x0001c718}, {0xb8, 0x000060ff}, ++ {0xb9, 0x00080001}, {0xba, 0x00040000}, ++ {0xbb, 0x00000400}, {0xbf, 0x000c0000}, ++ {0xc2, 0x00002400}, {0xc3, 0x00000009}, ++ {0xc4, 0x00040c91}, {0xc5, 0x00099999}, ++ {0xc6, 0x000000a3}, {0xc7, 0x00088820}, ++ {0xc8, 0x00076c06}, {0xc9, 0x00000000}, ++ {0xca, 0x00080000}, {0xdf, 0x00000180}, ++ {0xef, 0x000001a0}, {0x51, 0x0006b27d}, ++ {0x52, 0x0007e49d}, /* Set to 0x0007e4dd for SDIO */ ++ {0x53, 0x00000073}, {0x56, 0x00051ff3}, ++ {0x35, 0x00000086}, {0x35, 0x00000186}, ++ {0x35, 0x00000286}, {0x36, 0x00001c25}, ++ {0x36, 0x00009c25}, {0x36, 0x00011c25}, ++ {0x36, 0x00019c25}, {0xb6, 0x00048538}, ++ {0x18, 0x00000c07}, {0x5a, 0x0004bd00}, ++ {0x19, 0x000739d0}, {0x34, 0x0000adf3}, ++ {0x34, 0x00009df0}, {0x34, 0x00008ded}, ++ {0x34, 0x00007dea}, {0x34, 0x00006de7}, ++ {0x34, 0x000054ee}, {0x34, 0x000044eb}, ++ {0x34, 0x000034e8}, {0x34, 0x0000246b}, ++ {0x34, 0x00001468}, {0x34, 0x0000006d}, ++ {0x00, 0x00030159}, {0x84, 0x00068200}, ++ {0x86, 0x000000ce}, {0x87, 0x00048a00}, ++ {0x8e, 0x00065540}, {0x8f, 0x00088000}, ++ {0xef, 0x000020a0}, {0x3b, 0x000f02b0}, ++ {0x3b, 0x000ef7b0}, {0x3b, 0x000d4fb0}, ++ {0x3b, 0x000cf060}, {0x3b, 0x000b0090}, ++ {0x3b, 0x000a0080}, {0x3b, 0x00090080}, ++ {0x3b, 0x0008f780}, {0x3b, 0x000722b0}, ++ {0x3b, 0x0006f7b0}, {0x3b, 0x00054fb0}, ++ {0x3b, 0x0004f060}, {0x3b, 0x00030090}, ++ {0x3b, 0x00020080}, {0x3b, 0x00010080}, ++ {0x3b, 0x0000f780}, {0xef, 0x000000a0}, ++ {0x00, 0x00010159}, {0x18, 0x0000f407}, ++ {0xff, 0xffffffff} ++}; ++ + static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv) + { + struct rtl8188eu_efuse *efuse = &priv->efuse_wifi.efuse8188eu; +@@ -320,6 +368,22 @@ static void rtl8188eu_init_phy_bb(struct + rtl8xxxu_write32(priv, REG_AFE_XTAL_CTRL, val32); + } + ++static int rtl8188eu_init_phy_rf(struct rtl8xxxu_priv *priv) ++{ ++ int ret; ++ ++ ret = rtl8xxxu_init_phy_rf(priv, rtl8188eu_radioa_init_table, RF_A); ++ ++ msleep(100); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK2, 0x80003); ++ msleep(100); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK1, 0x00001); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK2, 0x80000); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0x33e60); ++ ++ return ret; ++} ++ + static void rtl8188e_disabled_to_emu(struct rtl8xxxu_priv *priv) + { + u16 val16; +@@ -454,6 +518,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .power_off = rtl8xxxu_power_off, + .reset_8051 = rtl8xxxu_reset_8051, + .init_phy_bb = rtl8188eu_init_phy_bb, ++ .init_phy_rf = rtl8188eu_init_phy_rf, + .usb_quirks = rtl8188e_usb_quirks, + .writeN_block_size = 128, + /* diff --git a/package/kernel/mac80211/patches/652-0017-rtl8xxxu-Use-auto-LLT-init-for-8188e.patch b/package/kernel/mac80211/patches/652-0017-rtl8xxxu-Use-auto-LLT-init-for-8188e.patch new file mode 100644 index 0000000000..a2dd472d01 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0017-rtl8xxxu-Use-auto-LLT-init-for-8188e.patch @@ -0,0 +1,24 @@ +From ada071c5bd6d58ca46d71956456d339b64a48551 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 19 Jul 2016 17:27:48 -0400 +Subject: [PATCH] rtl8xxxu: Use auto LLT init for 8188e + +The vendor driver uses IOL to init the LLT table for 8188e. Since we +are trying to avoid dealing with IOL for now, gamble that auto LLT +will work. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -517,6 +517,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .power_on = rtl8188eu_power_on, + .power_off = rtl8xxxu_power_off, + .reset_8051 = rtl8xxxu_reset_8051, ++ .llt_init = rtl8xxxu_auto_llt_table, + .init_phy_bb = rtl8188eu_init_phy_bb, + .init_phy_rf = rtl8188eu_init_phy_rf, + .usb_quirks = rtl8188e_usb_quirks, diff --git a/package/kernel/mac80211/patches/652-0018-rtl8xxxu-Do-not-set-REG_FPGA0_TX_INFO-on-8188eu.patch b/package/kernel/mac80211/patches/652-0018-rtl8xxxu-Do-not-set-REG_FPGA0_TX_INFO-on-8188eu.patch new file mode 100644 index 0000000000..c9d70c7583 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0018-rtl8xxxu-Do-not-set-REG_FPGA0_TX_INFO-on-8188eu.patch @@ -0,0 +1,25 @@ +From 1c55be6db2ed7e19a24ece3c1eea0e7a14ea9a6a Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 14:32:46 -0400 +Subject: [PATCH] rtl8xxxu: Do not set REG_FPGA0_TX_INFO on 8188eu + +The vendor driver doesn't set this for 8188eu either. It is unclear if +this is only relevant for gen1 parts. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -3958,7 +3958,8 @@ static int rtl8xxxu_init_device(struct i + goto exit; + + /* RFSW Control - clear bit 14 ?? */ +- if (priv->rtl_chip != RTL8723B && priv->rtl_chip != RTL8192E) ++ if (priv->rtl_chip != RTL8723B && priv->rtl_chip != RTL8192E && ++ priv->rtl_chip != RTL8188E) + rtl8xxxu_write32(priv, REG_FPGA0_TX_INFO, 0x00000003); + + val32 = FPGA0_RF_TRSW | FPGA0_RF_TRSWB | FPGA0_RF_ANTSW | diff --git a/package/kernel/mac80211/patches/652-0019-rtl8xxxu-Do-not-mess-with-REG_FPGA0_XA_RF_INT_OE-eit.patch b/package/kernel/mac80211/patches/652-0019-rtl8xxxu-Do-not-mess-with-REG_FPGA0_XA_RF_INT_OE-eit.patch new file mode 100644 index 0000000000..7ab6513273 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0019-rtl8xxxu-Do-not-mess-with-REG_FPGA0_XA_RF_INT_OE-eit.patch @@ -0,0 +1,27 @@ +From 66f8eac46264726a71fc264289d8168028db0d32 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 14:38:23 -0400 +Subject: [PATCH] rtl8xxxu: Do not mess with REG_FPGA0_XA_RF_INT_OE either on + 8188eu + +On older devices the vendor driver hard codes a value into +REG_FPGA0_XA_RF_INT_OE for antenna selection. This probably shouldn't +be done in the first place, but more investigation needs to be done to +figure out how this really works. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -3972,7 +3972,7 @@ static int rtl8xxxu_init_device(struct i + rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); + + /* 0x860[6:5]= 00 - why? - this sets antenna B */ +- if (priv->rtl_chip != RTL8192E) ++ if (priv->rtl_chip != RTL8192E && priv->rtl_chip != RTL8188E) + rtl8xxxu_write32(priv, REG_FPGA0_XA_RF_INT_OE, 0x66f60210); + + if (!macpower) { diff --git a/package/kernel/mac80211/patches/652-0020-rtl8xxxu-Set-transfer-page-size-for-8188eu.patch b/package/kernel/mac80211/patches/652-0020-rtl8xxxu-Set-transfer-page-size-for-8188eu.patch new file mode 100644 index 0000000000..48be64cecb --- /dev/null +++ b/package/kernel/mac80211/patches/652-0020-rtl8xxxu-Set-transfer-page-size-for-8188eu.patch @@ -0,0 +1,21 @@ +From ae67e9c34a9ab0624f76401330940b5a4b39fd97 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 15:59:31 -0400 +Subject: [PATCH] rtl8xxxu: Set transfer page size for 8188eu + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -527,6 +527,8 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + * Max RX buffer = 10K - max(TxReportSize(64*8), WOLPattern(16*24)) + */ + .trxff_boundary = 0x23ff, ++ .pbp_rx = PBP_PAGE_SIZE_128, ++ .pbp_tx = PBP_PAGE_SIZE_128, + .mactable = rtl8188e_mac_init_table, + .total_page_num = TX_TOTAL_PAGE_NUM_8188E, + .page_num_hi = TX_PAGE_NUM_HI_PQ_8188E, diff --git a/package/kernel/mac80211/patches/652-0021-rtl8xxxu-Enable-TX-report-timer-on-8188eu.patch b/package/kernel/mac80211/patches/652-0021-rtl8xxxu-Enable-TX-report-timer-on-8188eu.patch new file mode 100644 index 0000000000..f983e5ce87 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0021-rtl8xxxu-Enable-TX-report-timer-on-8188eu.patch @@ -0,0 +1,22 @@ +From d20ce683065f086727704d4ea22073fac6db8f47 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 16:13:06 -0400 +Subject: [PATCH] rtl8xxxu: Enable TX report timer on 8188eu + +The 8188eu uses the same TX report timer as found on the 8723b. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -522,6 +522,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .init_phy_rf = rtl8188eu_init_phy_rf, + .usb_quirks = rtl8188e_usb_quirks, + .writeN_block_size = 128, ++ .has_tx_report = 1, + /* + * Use 9K for 8188e normal chip + * Max RX buffer = 10K - max(TxReportSize(64*8), WOLPattern(16*24)) diff --git a/package/kernel/mac80211/patches/652-0022-rtl8xxxu-Setup-interrupts-for-8188eu.patch b/package/kernel/mac80211/patches/652-0022-rtl8xxxu-Setup-interrupts-for-8188eu.patch new file mode 100644 index 0000000000..5684df26fc --- /dev/null +++ b/package/kernel/mac80211/patches/652-0022-rtl8xxxu-Setup-interrupts-for-8188eu.patch @@ -0,0 +1,31 @@ +From 90361ade5a709877dee37f5cb091886117c815f4 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 20 Jul 2016 16:59:18 -0400 +Subject: [PATCH] rtl8xxxu: Setup interrupts for 8188eu + +This sets up interrupts for 8188eu, but per vendor driver, it's not +obvious this is really needed for USB devices. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4037,6 +4037,15 @@ static int rtl8xxxu_init_device(struct i + if (priv->rtl_chip == RTL8192E) { + rtl8xxxu_write32(priv, REG_HIMR0, 0x00); + rtl8xxxu_write32(priv, REG_HIMR1, 0x00); ++ } else if (priv->rtl_chip == RTL8188E) { ++ rtl8xxxu_write32(priv, REG_HISR0, 0xffffffff); ++ val32 = IMR0_PSTIMEOUT | IMR0_TBDER | IMR0_CPWM | IMR0_CPWM2; ++ rtl8xxxu_write32(priv, REG_HIMR0, val32); ++ val32 = IMR1_TXERR | IMR1_RXERR | IMR1_TXFOVW | IMR1_RXFOVW; ++ rtl8xxxu_write32(priv, REG_HIMR1, val32); ++ val8 = rtl8xxxu_read8(priv, REG_USB_SPECIAL_OPTION); ++ val8 |= USB_SPEC_INT_BULK_SELECT; ++ rtl8xxxu_write8(priv, REG_USB_SPECIAL_OPTION, val8); + } else { + /* + * Enable all interrupts - not obvious USB needs to do this diff --git a/package/kernel/mac80211/patches/652-0023-rtl8xxxu-Use-rxdesc16-for-8188eu.patch b/package/kernel/mac80211/patches/652-0023-rtl8xxxu-Use-rxdesc16-for-8188eu.patch new file mode 100644 index 0000000000..9a46233d92 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0023-rtl8xxxu-Use-rxdesc16-for-8188eu.patch @@ -0,0 +1,27 @@ +From f89604d87636dfd156d3ea417fb0af72c4f51e46 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 21 Jul 2016 14:52:49 -0400 +Subject: [PATCH] rtl8xxxu: Use rxdesc16 for 8188eu + +The RX descriptor format looks like the gen1 RX descriptor format, so +use that for now. On the other hand the TX descriptor format looks +like a hybrid. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -520,8 +520,10 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .llt_init = rtl8xxxu_auto_llt_table, + .init_phy_bb = rtl8188eu_init_phy_bb, + .init_phy_rf = rtl8188eu_init_phy_rf, ++ .parse_rx_desc = rtl8xxxu_parse_rxdesc16, + .usb_quirks = rtl8188e_usb_quirks, + .writeN_block_size = 128, ++ .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), + .has_tx_report = 1, + /* + * Use 9K for 8188e normal chip diff --git a/package/kernel/mac80211/patches/652-0024-rtl8xxxu-8188eu-use-same-ADDA-on-parameters-as-8723a.patch b/package/kernel/mac80211/patches/652-0024-rtl8xxxu-8188eu-use-same-ADDA-on-parameters-as-8723a.patch new file mode 100644 index 0000000000..5b4a8c7216 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0024-rtl8xxxu-8188eu-use-same-ADDA-on-parameters-as-8723a.patch @@ -0,0 +1,25 @@ +From be3bb0c98c94596874f4261413f7c188f400ac18 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 21 Jul 2016 15:23:16 -0400 +Subject: [PATCH] rtl8xxxu: 8188eu use same ADDA on parameters as 8723au/8192cu + +For ADDA setup the 8188eu looks to match the gen1 parts. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -525,6 +525,10 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .writeN_block_size = 128, + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), + .has_tx_report = 1, ++ .adda_1t_init = 0x0b1b25a0, ++ .adda_1t_path_on = 0x0bdb25a0, ++ .adda_2t_path_on_a = 0x04db25a4, ++ .adda_2t_path_on_b = 0x0b1b25a4, + /* + * Use 9K for 8188e normal chip + * Max RX buffer = 10K - max(TxReportSize(64*8), WOLPattern(16*24)) diff --git a/package/kernel/mac80211/patches/652-0025-rtl8xxxu-Add-PHY-IQ-calibration-code-for-8188eu.patch b/package/kernel/mac80211/patches/652-0025-rtl8xxxu-Add-PHY-IQ-calibration-code-for-8188eu.patch new file mode 100644 index 0000000000..07e2432720 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0025-rtl8xxxu-Add-PHY-IQ-calibration-code-for-8188eu.patch @@ -0,0 +1,521 @@ +From 9e90e4617f5e6549825baa88ef4a310f34a5f0bc Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 21 Jul 2016 17:25:56 -0400 +Subject: [PATCH] rtl8xxxu: Add PHY IQ calibration code for 8188eu + +The vendor driver for 8188eu is a bizarre modern style code for path A +and old-style code for path B. Most likely because the 8188eu is a +1T1R part which never gets to the path B code. + +Eventually we should look into unifying all the IQ calibration code. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 489 +++++++++++++++++++++ + 1 file changed, 489 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -384,6 +384,494 @@ static int rtl8188eu_init_phy_rf(struct + return ret; + } + ++static int rtl8188eu_iqk_path_a(struct rtl8xxxu_priv *priv) ++{ ++ u32 reg_eac, reg_e94, reg_e9c; ++ int result = 0; ++ ++ /* Path A IQK setting */ ++ rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x10008c1c); ++ rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x30008c1c); ++ ++ rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x8214032a); ++ rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160000); ++ ++ /* LO calibration setting */ ++ rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x00462911); ++ ++ /* One shot, path A LOK & IQK */ ++ rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); ++ rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); ++ ++ mdelay(10); ++ ++ /* Check failed */ ++ reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); ++ reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); ++ reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); ++ ++ if (!(reg_eac & BIT(28)) && ++ ((reg_e94 & 0x03ff0000) != 0x01420000) && ++ ((reg_e9c & 0x03ff0000) != 0x00420000)) ++ result |= 0x01; ++ ++ return result; ++} ++ ++static int rtl8188eu_rx_iqk_path_a(struct rtl8xxxu_priv *priv) ++{ ++ u32 reg_ea4, reg_eac, reg_e94, reg_e9c, val32; ++ int result = 0; ++ ++ /* Leave IQK mode */ ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00); ++ ++ /* Enable path A PA in TX IQK mode */ ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf117b); ++ ++ /* PA/PAD control by 0x56, and set = 0x0 */ ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x00980); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_56, 0x51000); ++ ++ /* Enter IQK mode */ ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); ++ ++ /* TX IQK setting */ ++ rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); ++ rtl8xxxu_write32(priv, REG_RX_IQK, 0x81004800); ++ ++ /* path-A IQK setting */ ++ rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x10008c1c); ++ rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x30008c1c); ++ ++ rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c1f); ++ rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160000); ++ ++ /* LO calibration setting */ ++ rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); ++ ++ /* One shot, path A LOK & IQK */ ++ rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); ++ rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); ++ ++ mdelay(10); ++ ++ /* Check failed */ ++ reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); ++ reg_e94 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_A); ++ reg_e9c = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_A); ++ ++ if (!(reg_eac & BIT(28)) && ++ ((reg_e94 & 0x03ff0000) != 0x01420000) && ++ ((reg_e9c & 0x03ff0000) != 0x00420000)) { ++ result |= 0x01; ++ } else { ++ /* PA/PAD controlled by 0x0 */ ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); ++ goto out; ++ } ++ ++ val32 = 0x80007c00 | ++ (reg_e94 & 0x03ff0000) | ((reg_e9c >> 16) & 0x03ff); ++ rtl8xxxu_write32(priv, REG_TX_IQK, val32); ++ ++ /* Modify RX IQK mode table */ ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); ++ ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_WE_LUT, 0x800a0); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_RCK_OS, 0x30000); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G1, 0x0000f); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_TXPA_G2, 0xf7ffa); ++ ++ /* Enter IQK mode */ ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); ++ ++ /* IQK setting */ ++ rtl8xxxu_write32(priv, REG_RX_IQK, 0x01004800); ++ ++ /* Path A IQK setting */ ++ rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x38008c1c); ++ rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x18008c1c); ++ ++ rtl8xxxu_write32(priv, REG_TX_IQK_PI_A, 0x82160c05); ++ rtl8xxxu_write32(priv, REG_RX_IQK_PI_A, 0x28160c1f); ++ ++ /* LO calibration setting */ ++ rtl8xxxu_write32(priv, REG_IQK_AGC_RSP, 0x0046a911); ++ ++ /* One shot, path A LOK & IQK */ ++ rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf9000000); ++ rtl8xxxu_write32(priv, REG_IQK_AGC_PTS, 0xf8000000); ++ ++ mdelay(10); ++ ++ reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); ++ reg_ea4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_A_2); ++ ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x00000000); ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_UNKNOWN_DF, 0x180); ++ ++ if (!(reg_eac & BIT(27)) && ++ ((reg_ea4 & 0x03ff0000) != 0x01320000) && ++ ((reg_eac & 0x03ff0000) != 0x00360000)) ++ result |= 0x02; ++ else ++ dev_warn(&priv->udev->dev, "%s: Path A RX IQK failed!\n", ++ __func__); ++ ++out: ++ return result; ++} ++ ++static int rtl8188eu_iqk_path_b(struct rtl8xxxu_priv *priv) ++{ ++ u32 reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc; ++ int result = 0; ++ ++ rtl8xxxu_write32(priv, REG_IQK_AGC_CONT, 0x00000002); ++ rtl8xxxu_write32(priv, REG_IQK_AGC_CONT, 0x00000000); ++ ++ mdelay(1); ++ ++ /* Check failed */ ++ reg_eac = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_A_2); ++ reg_eb4 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); ++ reg_ebc = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); ++ reg_ec4 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_B_2); ++ reg_ecc = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_B_2); ++ ++ if (!(reg_eac & BIT(31)) && ++ ((reg_eb4 & 0x03ff0000) != 0x01420000) && ++ ((reg_ebc & 0x03ff0000) != 0x00420000)) ++ result |= 0x01; ++ else ++ dev_warn(&priv->udev->dev, "%s: Path B IQK failed!\n", ++ __func__); ++ ++ if (!(reg_eac & BIT(30)) && ++ ((reg_ec4 & 0x03ff0000) != 0x01320000) && ++ ((reg_ecc & 0x03ff0000) != 0x00360000)) ++ result |= 0x01; ++ else ++ dev_warn(&priv->udev->dev, "%s: Path B RX IQK failed!\n", ++ __func__); ++ ++ return result; ++} ++ ++static void rtl8188eu_phy_iqcalibrate(struct rtl8xxxu_priv *priv, ++ int result[][8], int t) ++{ ++ struct device *dev = &priv->udev->dev; ++ u32 i, val32; ++ int path_a_ok, path_b_ok; ++ int retry = 2; ++ const u32 adda_regs[RTL8XXXU_ADDA_REGS] = { ++ REG_FPGA0_XCD_SWITCH_CTRL, REG_BLUETOOTH, ++ REG_RX_WAIT_CCA, REG_TX_CCK_RFON, ++ REG_TX_CCK_BBON, REG_TX_OFDM_RFON, ++ REG_TX_OFDM_BBON, REG_TX_TO_RX, ++ REG_TX_TO_TX, REG_RX_CCK, ++ REG_RX_OFDM, REG_RX_WAIT_RIFS, ++ REG_RX_TO_RX, REG_STANDBY, ++ REG_SLEEP, REG_PMPD_ANAEN ++ }; ++ const u32 iqk_mac_regs[RTL8XXXU_MAC_REGS] = { ++ REG_TXPAUSE, REG_BEACON_CTRL, ++ REG_BEACON_CTRL_1, REG_GPIO_MUXCFG ++ }; ++ const u32 iqk_bb_regs[RTL8XXXU_BB_REGS] = { ++ REG_OFDM0_TRX_PATH_ENABLE, REG_OFDM0_TR_MUX_PAR, ++ REG_FPGA0_XCD_RF_SW_CTRL, REG_CONFIG_ANT_A, REG_CONFIG_ANT_B, ++ REG_FPGA0_XAB_RF_SW_CTRL, REG_FPGA0_XA_RF_INT_OE, ++ REG_FPGA0_XB_RF_INT_OE, REG_FPGA0_RF_MODE ++ }; ++ ++ /* ++ * Note: IQ calibration must be performed after loading ++ * PHY_REG.txt , and radio_a, radio_b.txt ++ */ ++ ++ if (t == 0) { ++ /* Save ADDA parameters, turn Path A ADDA on */ ++ rtl8xxxu_save_regs(priv, adda_regs, priv->adda_backup, ++ RTL8XXXU_ADDA_REGS); ++ rtl8xxxu_save_mac_regs(priv, iqk_mac_regs, priv->mac_backup); ++ rtl8xxxu_save_regs(priv, iqk_bb_regs, ++ priv->bb_backup, RTL8XXXU_BB_REGS); ++ } ++ ++ rtl8xxxu_path_adda_on(priv, adda_regs, true); ++ ++ if (t == 0) { ++ val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_HSSI_PARM1); ++ if (val32 & FPGA0_HSSI_PARM1_PI) ++ priv->pi_enabled = 1; ++ } ++ ++ if (!priv->pi_enabled) { ++ /* Switch BB to PI mode to do IQ Calibration. */ ++ rtl8xxxu_write32(priv, REG_FPGA0_XA_HSSI_PARM1, 0x01000100); ++ rtl8xxxu_write32(priv, REG_FPGA0_XB_HSSI_PARM1, 0x01000100); ++ } ++ ++ val32 = rtl8xxxu_read32(priv, REG_FPGA0_RF_MODE); ++ val32 &= ~FPGA_RF_MODE_CCK; ++ rtl8xxxu_write32(priv, REG_FPGA0_RF_MODE, val32); ++ ++ rtl8xxxu_write32(priv, REG_OFDM0_TRX_PATH_ENABLE, 0x03a05600); ++ rtl8xxxu_write32(priv, REG_OFDM0_TR_MUX_PAR, 0x000800e4); ++ rtl8xxxu_write32(priv, REG_FPGA0_XCD_RF_SW_CTRL, 0x22204000); ++ ++ if (!priv->no_pape) { ++ val32 = rtl8xxxu_read32(priv, REG_FPGA0_XAB_RF_SW_CTRL); ++ val32 |= (FPGA0_RF_PAPE | ++ (FPGA0_RF_PAPE << FPGA0_RF_BD_CTRL_SHIFT)); ++ rtl8xxxu_write32(priv, REG_FPGA0_XAB_RF_SW_CTRL, val32); ++ } ++ ++ val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_RF_INT_OE); ++ val32 &= ~BIT(10); ++ rtl8xxxu_write32(priv, REG_FPGA0_XA_RF_INT_OE, val32); ++ val32 = rtl8xxxu_read32(priv, REG_FPGA0_XB_RF_INT_OE); ++ val32 &= ~BIT(10); ++ rtl8xxxu_write32(priv, REG_FPGA0_XB_RF_INT_OE, val32); ++ ++ if (priv->tx_paths > 1) { ++ rtl8xxxu_write32(priv, REG_FPGA0_XA_LSSI_PARM, 0x00010000); ++ rtl8xxxu_write32(priv, REG_FPGA0_XB_LSSI_PARM, 0x00010000); ++ } ++ ++ /* MAC settings */ ++ rtl8xxxu_mac_calibration(priv, iqk_mac_regs, priv->mac_backup); ++ ++ /* Page B init */ ++ rtl8xxxu_write32(priv, REG_CONFIG_ANT_A, 0x0f600000); ++ ++ if (priv->tx_paths > 1) ++ rtl8xxxu_write32(priv, REG_CONFIG_ANT_B, 0x0f600000); ++ ++ /* IQ calibration setting */ ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); ++ rtl8xxxu_write32(priv, REG_TX_IQK, 0x01007c00); ++ rtl8xxxu_write32(priv, REG_RX_IQK, 0x81004800); ++ ++ for (i = 0; i < retry; i++) { ++ path_a_ok = rtl8188eu_iqk_path_a(priv); ++ if (path_a_ok == 0x01) { ++ val32 = rtl8xxxu_read32(priv, ++ REG_TX_POWER_BEFORE_IQK_A); ++ result[t][0] = (val32 >> 16) & 0x3ff; ++ val32 = rtl8xxxu_read32(priv, ++ REG_TX_POWER_AFTER_IQK_A); ++ result[t][1] = (val32 >> 16) & 0x3ff; ++ break; ++ } ++ } ++ ++ if (!path_a_ok) ++ dev_dbg(dev, "%s: Path A TX IQK failed!\n", __func__); ++ ++ for (i = 0; i < retry; i++) { ++ path_a_ok = rtl8188eu_rx_iqk_path_a(priv); ++ if (path_a_ok == 0x03) { ++ val32 = rtl8xxxu_read32(priv, ++ REG_RX_POWER_BEFORE_IQK_A_2); ++ result[t][2] = (val32 >> 16) & 0x3ff; ++ val32 = rtl8xxxu_read32(priv, ++ REG_RX_POWER_AFTER_IQK_A_2); ++ result[t][3] = (val32 >> 16) & 0x3ff; ++ ++ break; ++ } ++ } ++ ++ if (!path_a_ok) ++ dev_dbg(dev, "%s: Path A RX IQK failed!\n", __func__); ++ ++ /* ++ * Path B calibration code in the vendor driver seems to be ++ * old style and not updated for the 8188eu since it's a 1T1R ++ * part. Keeping the code here in sync with the vendor code ++ * to not divert unncessarily, but probably would be good to ++ * look into modernizing all the code including that for the ++ * old gen1 devices ++ */ ++ if (priv->tx_paths > 1) { ++ /* ++ * Path A into standby ++ */ ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x0); ++ rtl8xxxu_write32(priv, REG_FPGA0_XA_LSSI_PARM, 0x00010000); ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0x80800000); ++ ++ /* Turn Path B ADDA on */ ++ rtl8xxxu_path_adda_on(priv, adda_regs, false); ++ ++ for (i = 0; i < retry; i++) { ++ path_b_ok = rtl8188eu_iqk_path_b(priv); ++ if (path_b_ok == 0x03) { ++ val32 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); ++ result[t][4] = (val32 >> 16) & 0x3ff; ++ val32 = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); ++ result[t][5] = (val32 >> 16) & 0x3ff; ++ val32 = rtl8xxxu_read32(priv, REG_RX_POWER_BEFORE_IQK_B_2); ++ result[t][6] = (val32 >> 16) & 0x3ff; ++ val32 = rtl8xxxu_read32(priv, REG_RX_POWER_AFTER_IQK_B_2); ++ result[t][7] = (val32 >> 16) & 0x3ff; ++ break; ++ } else if (i == (retry - 1) && path_b_ok == 0x01) { ++ /* TX IQK OK */ ++ val32 = rtl8xxxu_read32(priv, REG_TX_POWER_BEFORE_IQK_B); ++ result[t][4] = (val32 >> 16) & 0x3ff; ++ val32 = rtl8xxxu_read32(priv, REG_TX_POWER_AFTER_IQK_B); ++ result[t][5] = (val32 >> 16) & 0x3ff; ++ } ++ } ++ ++ if (!path_b_ok) ++ dev_dbg(dev, "%s: Path B IQK failed!\n", __func__); ++ } ++ ++ /* Back to BB mode, load original value */ ++ rtl8xxxu_write32(priv, REG_FPGA0_IQK, 0); ++ ++ if (t) { ++ if (!priv->pi_enabled) { ++ /* ++ * Switch back BB to SI mode after finishing ++ * IQ Calibration ++ */ ++ val32 = 0x01000000; ++ rtl8xxxu_write32(priv, REG_FPGA0_XA_HSSI_PARM1, val32); ++ rtl8xxxu_write32(priv, REG_FPGA0_XB_HSSI_PARM1, val32); ++ } ++ ++ /* Reload ADDA power saving parameters */ ++ rtl8xxxu_restore_regs(priv, adda_regs, priv->adda_backup, ++ RTL8XXXU_ADDA_REGS); ++ ++ /* Reload MAC parameters */ ++ rtl8xxxu_restore_mac_regs(priv, iqk_mac_regs, priv->mac_backup); ++ ++ /* Reload BB parameters */ ++ rtl8xxxu_restore_regs(priv, iqk_bb_regs, ++ priv->bb_backup, RTL8XXXU_BB_REGS); ++ ++ /* Restore RX initial gain */ ++ rtl8xxxu_write32(priv, REG_FPGA0_XA_LSSI_PARM, 0x00032ed3); ++ ++ if (priv->tx_paths > 1) { ++ rtl8xxxu_write32(priv, REG_FPGA0_XB_LSSI_PARM, ++ 0x00032ed3); ++ } ++ ++ /* Load 0xe30 IQC default value */ ++ rtl8xxxu_write32(priv, REG_TX_IQK_TONE_A, 0x01008c00); ++ rtl8xxxu_write32(priv, REG_RX_IQK_TONE_A, 0x01008c00); ++ } ++} ++ ++static void rtl8188eu_phy_iq_calibrate(struct rtl8xxxu_priv *priv) ++{ ++ struct device *dev = &priv->udev->dev; ++ int result[4][8]; /* last is final result */ ++ int i, candidate; ++ bool path_a_ok, path_b_ok; ++ u32 reg_e94, reg_e9c, reg_ea4, reg_eac; ++ u32 reg_eb4, reg_ebc, reg_ec4, reg_ecc; ++ bool simu; ++ ++ memset(result, 0, sizeof(result)); ++ result[3][0] = 0x100; ++ result[3][2] = 0x100; ++ result[3][4] = 0x100; ++ result[3][6] = 0x100; ++ ++ candidate = -1; ++ ++ path_a_ok = false; ++ path_b_ok = false; ++ ++ for (i = 0; i < 3; i++) { ++ rtl8188eu_phy_iqcalibrate(priv, result, i); ++ ++ if (i == 1) { ++ simu = rtl8xxxu_gen2_simularity_compare(priv, ++ result, 0, 1); ++ if (simu) { ++ candidate = 0; ++ break; ++ } ++ } ++ ++ if (i == 2) { ++ simu = rtl8xxxu_gen2_simularity_compare(priv, ++ result, 0, 2); ++ if (simu) { ++ candidate = 0; ++ break; ++ } ++ ++ simu = rtl8xxxu_gen2_simularity_compare(priv, ++ result, 1, 2); ++ if (simu) ++ candidate = 1; ++ else ++ candidate = 3; ++ } ++ } ++ ++ for (i = 0; i < 4; i++) { ++ reg_e94 = result[i][0]; ++ reg_e9c = result[i][1]; ++ reg_ea4 = result[i][2]; ++ reg_eb4 = result[i][4]; ++ reg_ebc = result[i][5]; ++ reg_ec4 = result[i][6]; ++ } ++ ++ if (candidate >= 0) { ++ reg_e94 = result[candidate][0]; ++ priv->rege94 = reg_e94; ++ reg_e9c = result[candidate][1]; ++ priv->rege9c = reg_e9c; ++ reg_ea4 = result[candidate][2]; ++ reg_eac = result[candidate][3]; ++ reg_eb4 = result[candidate][4]; ++ priv->regeb4 = reg_eb4; ++ reg_ebc = result[candidate][5]; ++ priv->regebc = reg_ebc; ++ reg_ec4 = result[candidate][6]; ++ reg_ecc = result[candidate][7]; ++ dev_dbg(dev, "%s: candidate is %x\n", __func__, candidate); ++ dev_dbg(dev, ++ "%s: e94 =%x e9c=%x ea4=%x eac=%x eb4=%x ebc=%x ec4=%x " ++ "ecc=%x\n ", __func__, reg_e94, reg_e9c, ++ reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, reg_ecc); ++ path_a_ok = true; ++ path_b_ok = true; ++ } else { ++ reg_e94 = reg_eb4 = priv->rege94 = priv->regeb4 = 0x100; ++ reg_e9c = reg_ebc = priv->rege9c = priv->regebc = 0x0; ++ } ++ ++ if (reg_e94 && candidate >= 0) ++ rtl8xxxu_fill_iqk_matrix_a(priv, path_a_ok, result, ++ candidate, (reg_ea4 == 0)); ++ ++ if (priv->rf_paths > 1 && reg_eb4) ++ rtl8xxxu_fill_iqk_matrix_b(priv, path_b_ok, result, ++ candidate, (reg_ec4 == 0)); ++ ++ rtl8xxxu_save_regs(priv, rtl8xxxu_iqk_phy_iq_bb_reg, ++ priv->bb_recovery_backup, RTL8XXXU_BB_REGS); ++} ++ + static void rtl8188e_disabled_to_emu(struct rtl8xxxu_priv *priv) + { + u16 val16; +@@ -520,6 +1008,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .llt_init = rtl8xxxu_auto_llt_table, + .init_phy_bb = rtl8188eu_init_phy_bb, + .init_phy_rf = rtl8188eu_init_phy_rf, ++ .phy_iq_calibrate = rtl8188eu_phy_iq_calibrate, + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, + .usb_quirks = rtl8188e_usb_quirks, + .writeN_block_size = 128, diff --git a/package/kernel/mac80211/patches/652-0026-rtl8xxxu-8188eu-uses-the-gen2-thermal-meter.patch b/package/kernel/mac80211/patches/652-0026-rtl8xxxu-8188eu-uses-the-gen2-thermal-meter.patch new file mode 100644 index 0000000000..5a445edfc9 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0026-rtl8xxxu-8188eu-uses-the-gen2-thermal-meter.patch @@ -0,0 +1,23 @@ +From 720e57cf9ea8c3121063bc2340be536b3260663e Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 11:20:00 -0400 +Subject: [PATCH] rtl8xxxu: 8188eu uses the gen2 thermal meter + +Vendor driver writes thermal meter setup to RF register 0x42, hence +the gen2 setup. However the driver doesn't do much with it. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1014,6 +1014,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .writeN_block_size = 128, + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), + .has_tx_report = 1, ++ .gen2_thermal_meter = 1, + .adda_1t_init = 0x0b1b25a0, + .adda_1t_path_on = 0x0bdb25a0, + .adda_2t_path_on_a = 0x04db25a4, diff --git a/package/kernel/mac80211/patches/652-0027-rtl8xxxu-Set-REG_USB_HRPWM-to-0-for-8188eu.patch b/package/kernel/mac80211/patches/652-0027-rtl8xxxu-Set-REG_USB_HRPWM-to-0-for-8188eu.patch new file mode 100644 index 0000000000..4655e4a684 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0027-rtl8xxxu-Set-REG_USB_HRPWM-to-0-for-8188eu.patch @@ -0,0 +1,23 @@ +From 95df0a5e0bdb67c6efd14dbccd1eab59fdfd0be2 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 11:33:29 -0400 +Subject: [PATCH] rtl8xxxu: Set REG_USB_HRPWM to 0 for 8188eu + +This matches what 8192eu does + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4236,7 +4236,7 @@ static int rtl8xxxu_init_device(struct i + val32 |= FPGA_RF_MODE_CCK; + rtl8xxxu_write32(priv, REG_FPGA0_RF_MODE, val32); + } +- } else if (priv->rtl_chip == RTL8192E) { ++ } else if (priv->rtl_chip == RTL8192E || priv->rtl_chip == RTL8188E) { + rtl8xxxu_write8(priv, REG_USB_HRPWM, 0x00); + } + diff --git a/package/kernel/mac80211/patches/652-0028-rtl8xxxu-Use-rtl8xxxu_gen1_channel_config-for-8188eu.patch b/package/kernel/mac80211/patches/652-0028-rtl8xxxu-Use-rtl8xxxu_gen1_channel_config-for-8188eu.patch new file mode 100644 index 0000000000..5594b7e55a --- /dev/null +++ b/package/kernel/mac80211/patches/652-0028-rtl8xxxu-Use-rtl8xxxu_gen1_channel_config-for-8188eu.patch @@ -0,0 +1,22 @@ +From 2ce9d067424ab287a1193330ee1c3607995cfbf4 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 11:40:13 -0400 +Subject: [PATCH] rtl8xxxu: Use rtl8xxxu_gen1_channel_config() for 8188eu + +Channel configuration looks to be using the old gen1 style API + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1009,6 +1009,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .init_phy_bb = rtl8188eu_init_phy_bb, + .init_phy_rf = rtl8188eu_init_phy_rf, + .phy_iq_calibrate = rtl8188eu_phy_iq_calibrate, ++ .config_channel = rtl8xxxu_gen1_config_channel, + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, + .usb_quirks = rtl8188e_usb_quirks, + .writeN_block_size = 128, diff --git a/package/kernel/mac80211/patches/652-0029-rtl8xxxu-Use-gen2-H2C-commands-for-8188eu.patch b/package/kernel/mac80211/patches/652-0029-rtl8xxxu-Use-gen2-H2C-commands-for-8188eu.patch new file mode 100644 index 0000000000..da8c11862d --- /dev/null +++ b/package/kernel/mac80211/patches/652-0029-rtl8xxxu-Use-gen2-H2C-commands-for-8188eu.patch @@ -0,0 +1,25 @@ +From ce938ec0ff5764c535cf19ee6dd52482e0b6ebbb Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 11:44:12 -0400 +Subject: [PATCH] rtl8xxxu: Use gen2 H2C commands for 8188eu + +The 8188eu is a weird hybrid between the old gen1 and newer gen2 +APIs. It uses the newer API for H2C commands, hence use +rtl8xxxu_gen2_update_rate_mask() and rtl8xxxu_gen2_report_connect(). + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1012,6 +1012,8 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .config_channel = rtl8xxxu_gen1_config_channel, + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, + .usb_quirks = rtl8188e_usb_quirks, ++ .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, ++ .report_connect = rtl8xxxu_gen2_report_connect, + .writeN_block_size = 128, + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), + .has_tx_report = 1, diff --git a/package/kernel/mac80211/patches/652-0030-rtl8xxxu-Initialize-GPIO-settings-for-8188eu.patch b/package/kernel/mac80211/patches/652-0030-rtl8xxxu-Initialize-GPIO-settings-for-8188eu.patch new file mode 100644 index 0000000000..c8692316d4 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0030-rtl8xxxu-Initialize-GPIO-settings-for-8188eu.patch @@ -0,0 +1,40 @@ +From b7472848032d36e227711d0381a58cc3114f1b33 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 12:56:30 -0400 +Subject: [PATCH] rtl8xxxu: Initialize GPIO settings for 8188eu + +This matches what the vendor driver does, but is actually opposite of +what it does for 8192eu. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 +++++++ + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 1 + + 2 files changed, 8 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4206,6 +4206,13 @@ static int rtl8xxxu_init_device(struct i + * Reset USB mode switch setting + */ + rtl8xxxu_write8(priv, REG_ACLK_MON, 0x00); ++ } else if (priv->rtl_chip == RTL8188E) { ++ /* ++ * Init GPIO settings for 8188e ++ */ ++ val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG); ++ val8 &= ~GPIO_MUXCFG_IO_SEL_ENBT; ++ rtl8xxxu_write8(priv, REG_GPIO_MUXCFG, val8); + } + + rtl8723a_phy_lc_calibrate(priv); +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -143,6 +143,7 @@ + #define REG_CAL_TIMER 0x003c + #define REG_ACLK_MON 0x003e + #define REG_GPIO_MUXCFG 0x0040 ++#define GPIO_MUXCFG_IO_SEL_ENBT BIT(5) + #define REG_GPIO_IO_SEL 0x0042 + #define REG_MAC_PINMUX_CFG 0x0043 + #define REG_GPIO_PIN_CTRL 0x0044 diff --git a/package/kernel/mac80211/patches/652-0031-rtl8xxxu-Add-simple-rtl8188eu_rf_on-routine.patch b/package/kernel/mac80211/patches/652-0031-rtl8xxxu-Add-simple-rtl8188eu_rf_on-routine.patch new file mode 100644 index 0000000000..e9bfd9f101 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0031-rtl8xxxu-Add-simple-rtl8188eu_rf_on-routine.patch @@ -0,0 +1,34 @@ +From 3bb9c23b43cc4cc37a06c20c62266128040cd5d7 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 13:10:02 -0400 +Subject: [PATCH] rtl8xxxu: Add simple rtl8188eu_rf_on() routine + +It is not obvious from the vendor driver if we need more than this. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -980,6 +980,11 @@ exit: + return ret; + } + ++static void rtl8188e_enable_rf(struct rtl8xxxu_priv *priv) ++{ ++ rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00); ++} ++ + static void rtl8188e_usb_quirks(struct rtl8xxxu_priv *priv) + { + u16 val16; +@@ -1011,6 +1016,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .phy_iq_calibrate = rtl8188eu_phy_iq_calibrate, + .config_channel = rtl8xxxu_gen1_config_channel, + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, ++ .enable_rf = rtl8188e_enable_rf, + .usb_quirks = rtl8188e_usb_quirks, + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, + .report_connect = rtl8xxxu_gen2_report_connect, diff --git a/package/kernel/mac80211/patches/652-0032-rtl8xxxu-Implement-rtl8188e_disable_rf.patch b/package/kernel/mac80211/patches/652-0032-rtl8xxxu-Implement-rtl8188e_disable_rf.patch new file mode 100644 index 0000000000..c2a7d70e4d --- /dev/null +++ b/package/kernel/mac80211/patches/652-0032-rtl8xxxu-Implement-rtl8188e_disable_rf.patch @@ -0,0 +1,44 @@ +From c1619fa7cc81439fa3a791e5462e161ccc5536e5 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 13:17:36 -0400 +Subject: [PATCH] rtl8xxxu: Implement rtl8188e_disable_rf() + +This is partly guessware as there is no straight forward disable RF +routine in the vendor driver. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -985,6 +985,20 @@ static void rtl8188e_enable_rf(struct rt + rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00); + } + ++static void rtl8188e_disable_rf(struct rtl8xxxu_priv *priv) ++{ ++ u32 val32; ++ ++ val32 = rtl8xxxu_read32(priv, REG_OFDM0_TRX_PATH_ENABLE); ++ val32 &= ~OFDM_RF_PATH_TX_MASK; ++ rtl8xxxu_write32(priv, REG_OFDM0_TRX_PATH_ENABLE, val32); ++ ++ /* Power down RF module */ ++ rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0); ++ if (priv->rf_paths == 2) ++ rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_AC, 0); ++} ++ + static void rtl8188e_usb_quirks(struct rtl8xxxu_priv *priv) + { + u16 val16; +@@ -1017,6 +1031,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .config_channel = rtl8xxxu_gen1_config_channel, + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, + .enable_rf = rtl8188e_enable_rf, ++ .disable_rf = rtl8188e_disable_rf, + .usb_quirks = rtl8188e_usb_quirks, + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, + .report_connect = rtl8xxxu_gen2_report_connect, diff --git a/package/kernel/mac80211/patches/652-0033-rtl8xxxu-8188eu-uses-32-byte-TX-descriptors.patch b/package/kernel/mac80211/patches/652-0033-rtl8xxxu-8188eu-uses-32-byte-TX-descriptors.patch new file mode 100644 index 0000000000..cbc33922fc --- /dev/null +++ b/package/kernel/mac80211/patches/652-0033-rtl8xxxu-8188eu-uses-32-byte-TX-descriptors.patch @@ -0,0 +1,23 @@ +From acd23916afbf214c7e40fec769361d8e46a6886a Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 13:40:55 -0400 +Subject: [PATCH] rtl8xxxu: 8188eu uses 32 byte TX descriptors + +Note the format is different and looks to be some bizarre hybrid of +the gen1 and gen2 formats. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1037,6 +1037,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .report_connect = rtl8xxxu_gen2_report_connect, + .writeN_block_size = 128, + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), ++ .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), + .has_tx_report = 1, + .gen2_thermal_meter = 1, + .adda_1t_init = 0x0b1b25a0, diff --git a/package/kernel/mac80211/patches/652-0034-rtl8xxxu-Add-dummy-rtl8188e_set_tx_power.patch b/package/kernel/mac80211/patches/652-0034-rtl8xxxu-Add-dummy-rtl8188e_set_tx_power.patch new file mode 100644 index 0000000000..3826362693 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0034-rtl8xxxu-Add-dummy-rtl8188e_set_tx_power.patch @@ -0,0 +1,35 @@ +From d83a65b58e8626c9fab83e45bb7ec5aea9176504 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 13:55:24 -0400 +Subject: [PATCH] rtl8xxxu: Add dummy rtl8188e_set_tx_power() + +To avoid crashing on launch, add a dummy set_tx_power() function for +8188e. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -283,6 +283,11 @@ static struct rtl8xxxu_rfregval rtl8188e + {0xff, 0xffffffff} + }; + ++static void ++rtl8188e_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) ++{ ++} ++ + static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv) + { + struct rtl8188eu_efuse *efuse = &priv->efuse_wifi.efuse8188eu; +@@ -1033,6 +1038,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .enable_rf = rtl8188e_enable_rf, + .disable_rf = rtl8188e_disable_rf, + .usb_quirks = rtl8188e_usb_quirks, ++ .set_tx_power = rtl8188e_set_tx_power, + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, + .report_connect = rtl8xxxu_gen2_report_connect, + .writeN_block_size = 128, diff --git a/package/kernel/mac80211/patches/652-0035-rtl8xxxu-Update-8188e-efuse-definition-for-power-val.patch b/package/kernel/mac80211/patches/652-0035-rtl8xxxu-Update-8188e-efuse-definition-for-power-val.patch new file mode 100644 index 0000000000..3503915387 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0035-rtl8xxxu-Update-8188e-efuse-definition-for-power-val.patch @@ -0,0 +1,62 @@ +From 3c3fae09952723763d87cbd2a02be667a46a040a Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 16:46:11 -0400 +Subject: [PATCH] rtl8xxxu: Update 8188e efuse definition for power values + +The 8188e uses a similar layout as the 8192e, however it does not have +values for path B. Update struct rtl8188eu_efuse to reflect this and +copy over path A values for path B. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 7 ++----- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 19 +++++++++++-------- + 2 files changed, 13 insertions(+), 13 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -880,11 +880,8 @@ struct rtl8192eu_efuse { + struct rtl8188eu_efuse { + __le16 rtl_id; + u8 res0[0x0e]; +- u8 cck_tx_power_index_A[3]; /* 0x10 */ +- u8 cck_tx_power_index_B[3]; +- u8 ht40_1s_tx_power_index_A[3]; /* 0x16 */ +- u8 ht40_1s_tx_power_index_B[3]; +- u8 res1[0x9c]; ++ struct rtl8192eu_efuse_tx_power tx_power_index_A; /* 0x10 */ ++ u8 res1[0x7e]; /* 0x3a */ + u8 channel_plan; /* 0xb8 */ + u8 xtal_k; + u8 thermal_meter; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -298,17 +298,20 @@ static int rtl8188eu_parse_efuse(struct + + ether_addr_copy(priv->mac_addr, efuse->mac_addr); + +- memcpy(priv->cck_tx_power_index_A, efuse->cck_tx_power_index_A, +- sizeof(efuse->cck_tx_power_index_A)); +- memcpy(priv->cck_tx_power_index_B, efuse->cck_tx_power_index_B, +- sizeof(efuse->cck_tx_power_index_B)); ++ memcpy(priv->cck_tx_power_index_A, efuse->tx_power_index_A.cck_base, ++ sizeof(efuse->tx_power_index_A.cck_base)); ++ /* ++ * Efuse is empty for path B, so copy in values from path A ++ */ ++ memcpy(priv->cck_tx_power_index_B, efuse->tx_power_index_A.cck_base, ++ sizeof(efuse->tx_power_index_A.cck_base)); + + memcpy(priv->ht40_1s_tx_power_index_A, +- priv->efuse_wifi.efuse8188eu.ht40_1s_tx_power_index_A, +- sizeof(priv->ht40_1s_tx_power_index_A)); ++ efuse->tx_power_index_A.ht40_base, ++ sizeof(efuse->tx_power_index_A.ht40_base)); + memcpy(priv->ht40_1s_tx_power_index_B, +- priv->efuse_wifi.efuse8188eu.ht40_1s_tx_power_index_B, +- sizeof(priv->ht40_1s_tx_power_index_B)); ++ efuse->tx_power_index_A.ht40_base, ++ sizeof(efuse->tx_power_index_A.ht40_base)); + + priv->xtalk = priv->efuse_wifi.efuse8188eu.xtal_k & 0x3f; + diff --git a/package/kernel/mac80211/patches/652-0036-rtl8xxxu-Implement-rtl8188e_set_tx_power.patch b/package/kernel/mac80211/patches/652-0036-rtl8xxxu-Implement-rtl8188e_set_tx_power.patch new file mode 100644 index 0000000000..b386715e43 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0036-rtl8xxxu-Implement-rtl8188e_set_tx_power.patch @@ -0,0 +1,84 @@ +From cf02f3fe981c1f11a41cf885d7c5a0298378b0d6 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 22 Jul 2016 16:50:59 -0400 +Subject: [PATCH] rtl8xxxu: Implement rtl8188e_set_tx_power() + +This matches the code used to set TX power on 8192eu, except it only +handles path A. + +We should be able to consolidate this code. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 57 ++++++++++++++++++++++ + 1 file changed, 57 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -283,9 +283,66 @@ static struct rtl8xxxu_rfregval rtl8188e + {0xff, 0xffffffff} + }; + ++int rtl8xxxu_8188e_channel_to_group(int channel) ++{ ++ int group; ++ ++ if (channel < 3) ++ group = 0; ++ else if (channel < 6) ++ group = 1; ++ else if (channel < 9) ++ group = 2; ++ else if (channel < 12) ++ group = 3; ++ else if (channel < 14) ++ group = 4; ++ else ++ group = 5; ++ ++ return group; ++} ++ + static void + rtl8188e_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) + { ++ u32 val32, ofdm, mcs; ++ u8 cck, ofdmbase, mcsbase; ++ int group, tx_idx; ++ ++ tx_idx = 0; ++ group = rtl8xxxu_8188e_channel_to_group(channel); ++ ++ cck = priv->cck_tx_power_index_A[group]; ++ ++ val32 = rtl8xxxu_read32(priv, REG_TX_AGC_A_CCK1_MCS32); ++ val32 &= 0xffff00ff; ++ val32 |= (cck << 8); ++ rtl8xxxu_write32(priv, REG_TX_AGC_A_CCK1_MCS32, val32); ++ ++ val32 = rtl8xxxu_read32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11); ++ val32 &= 0xff; ++ val32 |= ((cck << 8) | (cck << 16) | (cck << 24)); ++ rtl8xxxu_write32(priv, REG_TX_AGC_B_CCK11_A_CCK2_11, val32); ++ ++ ofdmbase = priv->ht40_1s_tx_power_index_A[group]; ++ ofdmbase += priv->ofdm_tx_power_diff[tx_idx].a; ++ ofdm = ofdmbase | ofdmbase << 8 | ofdmbase << 16 | ofdmbase << 24; ++ ++ rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE18_06, ofdm); ++ rtl8xxxu_write32(priv, REG_TX_AGC_A_RATE54_24, ofdm); ++ ++ mcsbase = priv->ht40_1s_tx_power_index_A[group]; ++ if (ht40) ++ mcsbase += priv->ht40_tx_power_diff[tx_idx++].a; ++ else ++ mcsbase += priv->ht20_tx_power_diff[tx_idx++].a; ++ mcs = mcsbase | mcsbase << 8 | mcsbase << 16 | mcsbase << 24; ++ ++ rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS03_MCS00, mcs); ++ rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS07_MCS04, mcs); ++ rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS11_MCS08, mcs); ++ rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, mcs); + } + + static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv) diff --git a/package/kernel/mac80211/patches/652-0037-rtl8xxxu-Implement-rtl8xxxu_fill_txdesc_v3-for-8188e.patch b/package/kernel/mac80211/patches/652-0037-rtl8xxxu-Implement-rtl8xxxu_fill_txdesc_v3-for-8188e.patch new file mode 100644 index 0000000000..8c63e2e50d --- /dev/null +++ b/package/kernel/mac80211/patches/652-0037-rtl8xxxu-Implement-rtl8xxxu_fill_txdesc_v3-for-8188e.patch @@ -0,0 +1,128 @@ +From cea78f97a74d9e5e3a8cb701e89c3e5c656f5c64 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 26 Jul 2016 14:01:14 -0400 +Subject: [PATCH] rtl8xxxu: Implement rtl8xxxu_fill_txdesc_v3() for 8188eu + +Getting closer but still no cigar. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 10 ++++ + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 + + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 62 ++++++++++++++++++++++ + 3 files changed, 73 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -509,6 +509,8 @@ struct rtl8xxxu_txdesc40 { + #define TXDESC_AMPDU_DENSITY_SHIFT 20 + #define TXDESC40_BT_INT BIT(23) + #define TXDESC40_GID_SHIFT 24 ++#define TXDESC_ANTENNA_SELECT_A BIT(24) ++#define TXDESC_ANTENNA_SELECT_B BIT(25) + + /* Word 3 */ + #define TXDESC40_USE_DRIVER_RATE BIT(8) +@@ -553,6 +555,10 @@ struct rtl8xxxu_txdesc40 { + + /* Word 6 */ + #define TXDESC_MAX_AGG_SHIFT 11 ++#define TXDESC_USB_TX_AGG_SHIT 24 ++ ++/* Word 7 */ ++#define TXDESC_ANTENNA_SELECT_C BIT(29) + + /* Word 8 */ + #define TXDESC40_HW_SEQ_ENABLE BIT(15) +@@ -1484,6 +1490,10 @@ void rtl8xxxu_fill_txdesc_v2(struct ieee + struct rtl8xxxu_txdesc32 *tx_desc32, u32 rate, + u16 rate_flag, bool sgi, bool short_preamble, + bool ampdu_enable); ++void rtl8xxxu_fill_txdesc_v3(struct ieee80211_hdr *hdr, ++ struct rtl8xxxu_txdesc32 *tx_desc32, u32 rate, ++ u16 rate_flag, bool sgi, bool short_preamble, ++ bool ampdu_enable); + + extern struct rtl8xxxu_fileops rtl8188eu_fops; + extern struct rtl8xxxu_fileops rtl8192cu_fops; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1101,6 +1101,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .set_tx_power = rtl8188e_set_tx_power, + .update_rate_mask = rtl8xxxu_gen2_update_rate_mask, + .report_connect = rtl8xxxu_gen2_report_connect, ++ .fill_txdesc = rtl8xxxu_fill_txdesc_v3, + .writeN_block_size = 128, + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4884,6 +4884,68 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211 + } + } + ++/* ++ * Fill in v3 (gen1) specific TX descriptor bits. ++ * This format is a hybrid between the v1 and v2 formats, only seen ++ * on 8188eu devices so far. ++ */ ++void ++rtl8xxxu_fill_txdesc_v3(struct ieee80211_hdr *hdr, ++ struct rtl8xxxu_txdesc32 *tx_desc, u32 rate, ++ u16 rate_flag, bool sgi, bool short_preamble, ++ bool ampdu_enable) ++{ ++ u16 seq_number; ++ ++ seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); ++ ++ tx_desc->txdw5 = cpu_to_le32(rate); ++ ++ /* ++ * Data/RTS rate FB limit ++ */ ++ if (ieee80211_is_data(hdr->frame_control)) ++ tx_desc->txdw5 |= cpu_to_le32(0x0001ff00); ++ ++ tx_desc->txdw3 = cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT); ++ ++ if (ampdu_enable) ++ tx_desc->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE); ++ else ++ tx_desc->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK); ++ ++ if (ieee80211_is_mgmt(hdr->frame_control)) { ++ tx_desc->txdw5 = cpu_to_le32(rate); ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_USE_DRIVER_RATE); ++ tx_desc->txdw5 |= cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT); ++ tx_desc->txdw5 |= cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE); ++ } ++ ++ if (ieee80211_is_data_qos(hdr->frame_control)) ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS); ++ ++ if (short_preamble) ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE); ++ ++ if (sgi) ++ tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI); ++ ++ if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) { ++ /* ++ * Use RTS rate 24M - does the mac80211 tell ++ * us which to use? ++ */ ++ tx_desc->txdw4 |= cpu_to_le32(DESC_RATE_24M << ++ TXDESC32_RTS_RATE_SHIFT); ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_RTS_CTS_ENABLE); ++ tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE); ++ } ++ ++ tx_desc->txdw2 |= cpu_to_le32(TXDESC_ANTENNA_SELECT_A | ++ TXDESC_ANTENNA_SELECT_B); ++ tx_desc->txdw7 |= cpu_to_le32(TXDESC_ANTENNA_SELECT_C); ++} ++ + static void rtl8xxxu_tx(struct ieee80211_hw *hw, + struct ieee80211_tx_control *control, + struct sk_buff *skb) diff --git a/package/kernel/mac80211/patches/652-0038-rtl8xxxu-Add-some-8188eu-registers-and-update-CCK0_A.patch b/package/kernel/mac80211/patches/652-0038-rtl8xxxu-Add-some-8188eu-registers-and-update-CCK0_A.patch new file mode 100644 index 0000000000..468022f250 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0038-rtl8xxxu-Add-some-8188eu-registers-and-update-CCK0_A.patch @@ -0,0 +1,64 @@ +From cbbf4d6e0a8d8230aff7c4088cf1ed593e6002dd Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 29 Jul 2016 15:25:34 -0400 +Subject: [PATCH] rtl8xxxu: Add some 8188eu registers and update + CCK0_AFE_SETTING bit defines + +CCK0_AFE_SETTING is particular, it has the notion of primary RX antenna +and optional RX antenna. When configuring RX for single antenna, setup +should use the same antenna for default and optional. For AB setup, +use antenna A as default and B as optional. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 24 ++++++++++++++++++++-- + 1 file changed, 22 insertions(+), 2 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -938,6 +938,7 @@ + #define REG_FPGA1_RF_MODE 0x0900 + + #define REG_FPGA1_TX_INFO 0x090c ++#define REG_ANT_MAPPING1 0x0914 + #define REG_DPDT_CTRL 0x092c /* 8723BU */ + #define REG_RFE_CTRL_ANTA_SRC 0x0930 /* 8723BU */ + #define REG_RFE_PATH_SELECT 0x0940 /* 8723BU */ +@@ -949,9 +950,25 @@ + + #define REG_CCK0_AFE_SETTING 0x0a04 + #define CCK0_AFE_RX_MASK 0x0f000000 +-#define CCK0_AFE_RX_ANT_AB BIT(24) ++#define CCK0_AFE_TX_MASK 0xf0000000 + #define CCK0_AFE_RX_ANT_A 0 +-#define CCK0_AFE_RX_ANT_B (BIT(24) | BIT(26)) ++#define CCK0_AFE_RX_ANT_B BIT(26) ++#define CCK0_AFE_RX_ANT_C BIT(27) ++#define CCK0_AFE_RX_ANT_D (BIT(26) | BIT(27)) ++#define CCK0_AFE_RX_ANT_OPTION_A 0 ++#define CCK0_AFE_RX_ANT_OPTION_B BIT(24) ++#define CCK0_AFE_RX_ANT_OPTION_C BIT(25) ++#define CCK0_AFE_RX_ANT_OPTION_D (BIT(24) | BIT(25)) ++#define CCK0_AFE_TX_ANT_A BIT(31) ++#define CCK0_AFE_TX_ANT_B BIT(30) ++ ++#define REG_CCK_ANTDIV_PARA2 0x0a04 ++#define REG_BB_POWER_SAVE4 0x0a74 ++ ++/* 8188eu */ ++#define REG_LNA_SWITCH 0x0b2c ++#define LNA_SWITCH_DISABLE_CSCG BIT(22) ++#define LNA_SWITCH_OUTPUT_CG BIT(31) + + #define REG_CONFIG_ANT_A 0x0b68 + #define REG_CONFIG_ANT_B 0x0b6c +@@ -1004,6 +1021,9 @@ + + #define REG_OFDM0_RX_IQ_EXT_ANTA 0x0ca0 + ++/* 8188eu */ ++#define REG_ANTDIV_PARA1 0x0ca4 ++ + /* 8723bu */ + #define REG_OFDM0_TX_PSDO_NOISE_WEIGHT 0x0ce4 + diff --git a/package/kernel/mac80211/patches/652-0039-rtl8xxxu-Improve-register-description-for-REG_FPGA1_.patch b/package/kernel/mac80211/patches/652-0039-rtl8xxxu-Improve-register-description-for-REG_FPGA1_.patch new file mode 100644 index 0000000000..e5d7788643 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0039-rtl8xxxu-Improve-register-description-for-REG_FPGA1_.patch @@ -0,0 +1,30 @@ +From ebf1c90b91cd40052552dd4efa1a54bbbd43ca5f Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 29 Jul 2016 15:57:19 -0400 +Subject: [PATCH] rtl8xxxu: Improve register description for REG_FPGA1_TX_INFO + +This is based on Hal_SetAntenna() from the 8188eu driver + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -938,6 +938,15 @@ + #define REG_FPGA1_RF_MODE 0x0900 + + #define REG_FPGA1_TX_INFO 0x090c ++#define FPGA1_TX_ANT_MASK 0x0000000f ++#define FPGA1_TX_ANT_L_MASK 0x000000f0 ++#define FPGA1_TX_ANT_NON_HT_MASK 0x00000f00 ++#define FPGA1_TX_ANT_HT1_MASK 0x0000f000 ++#define FPGA1_TX_ANT_HT2_MASK 0x000f0000 ++#define FPGA1_TX_ANT_HT_S1_MASK 0x00f00000 ++#define FPGA1_TX_ANT_NON_HT_S1_MASK 0x0f000000 ++#define FPGA1_TX_OFDM_TXSC_MASK 0x30000000 ++ + #define REG_ANT_MAPPING1 0x0914 + #define REG_DPDT_CTRL 0x092c /* 8723BU */ + #define REG_RFE_CTRL_ANTA_SRC 0x0930 /* 8723BU */ diff --git a/package/kernel/mac80211/patches/652-0040-rtl8xxxu-properly-detect-RTL8188EU-devices.patch b/package/kernel/mac80211/patches/652-0040-rtl8xxxu-properly-detect-RTL8188EU-devices.patch new file mode 100644 index 0000000000..13c82c06b3 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0040-rtl8xxxu-properly-detect-RTL8188EU-devices.patch @@ -0,0 +1,29 @@ +From 9df5d333304264856465094f9529b414c4c279fb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Fri, 29 Jul 2016 18:22:37 +0200 +Subject: [PATCH] rtl8xxxu: properly detect RTL8188EU devices +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The assumption that all RTL8188EU have chip cut >= C is wrong. +However, RTL8188EU devices can be easily differentiated from RTL8188CU devices +relying on TX report capbility. + +Signed-off-by: Álvaro Fernández Rojas +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -1683,7 +1683,7 @@ static int rtl8xxxu_identify_chip(struct + } + priv->has_wifi = 1; + } else { +- if (priv->chip_cut >= 2) { ++ if (priv->fops->has_tx_report) { + sprintf(priv->chip_name, "8188EU"); + priv->rf_paths = 1; + priv->rx_paths = 1; diff --git a/package/kernel/mac80211/patches/652-0041-rtl8xxxu-Correct-TX_TOTAL_PAGE_NUM-for-8188eu.patch b/package/kernel/mac80211/patches/652-0041-rtl8xxxu-Correct-TX_TOTAL_PAGE_NUM-for-8188eu.patch new file mode 100644 index 0000000000..fc913fc98c --- /dev/null +++ b/package/kernel/mac80211/patches/652-0041-rtl8xxxu-Correct-TX_TOTAL_PAGE_NUM-for-8188eu.patch @@ -0,0 +1,24 @@ +From 8cacc26a9247d1d661b887ac77d88c73b2b9ec1d Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 8 Aug 2016 15:04:36 -0400 +Subject: [PATCH] rtl8xxxu: Correct TX_TOTAL_PAGE_NUM for 8188eu + +For some reason I had gotten this off-by-one when pulling them number +from the vendor driver. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -42,7 +42,7 @@ + #define REALTEK_USB_CMD_IDX 0x00 + + #define TX_TOTAL_PAGE_NUM 0xf8 +-#define TX_TOTAL_PAGE_NUM_8188E 0xa8 ++#define TX_TOTAL_PAGE_NUM_8188E 0xa9 + #define TX_TOTAL_PAGE_NUM_8192E 0xf3 + #define TX_TOTAL_PAGE_NUM_8723B 0xf7 + /* (HPQ + LPQ + NPQ + PUBQ) = TX_TOTAL_PAGE_NUM */ diff --git a/package/kernel/mac80211/patches/652-0042-rtl8xxxu-Implement-8188eu-specific-8051-reset-functi.patch b/package/kernel/mac80211/patches/652-0042-rtl8xxxu-Implement-8188eu-specific-8051-reset-functi.patch new file mode 100644 index 0000000000..047cb381fc --- /dev/null +++ b/package/kernel/mac80211/patches/652-0042-rtl8xxxu-Implement-8188eu-specific-8051-reset-functi.patch @@ -0,0 +1,43 @@ +From 763213d99c4d9c20cf69848fc6784d38597ab0ff Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 10 Aug 2016 15:40:30 -0400 +Subject: [PATCH] rtl8xxxu: Implement 8188eu specific 8051 reset function + +The 8188eu doesn't seem to require the additional hacks used on some +other chips. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -389,6 +389,18 @@ static int rtl8188eu_parse_efuse(struct + return 0; + } + ++void rtl8188eu_reset_8051(struct rtl8xxxu_priv *priv) ++{ ++ u16 sys_func; ++ ++ sys_func = rtl8xxxu_read16(priv, REG_SYS_FUNC); ++ sys_func &= ~SYS_FUNC_CPU_ENABLE; ++ rtl8xxxu_write16(priv, REG_SYS_FUNC, sys_func); ++ ++ sys_func |= SYS_FUNC_CPU_ENABLE; ++ rtl8xxxu_write16(priv, REG_SYS_FUNC, sys_func); ++} ++ + static int rtl8188eu_load_firmware(struct rtl8xxxu_priv *priv) + { + char *fw_name; +@@ -1088,7 +1100,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .load_firmware = rtl8188eu_load_firmware, + .power_on = rtl8188eu_power_on, + .power_off = rtl8xxxu_power_off, +- .reset_8051 = rtl8xxxu_reset_8051, ++ .reset_8051 = rtl8188eu_reset_8051, + .llt_init = rtl8xxxu_auto_llt_table, + .init_phy_bb = rtl8188eu_init_phy_bb, + .init_phy_rf = rtl8188eu_init_phy_rf, diff --git a/package/kernel/mac80211/patches/652-0043-rtl8xxxu-Disable-packet-DMA-aggregation-on-8188eu.patch b/package/kernel/mac80211/patches/652-0043-rtl8xxxu-Disable-packet-DMA-aggregation-on-8188eu.patch new file mode 100644 index 0000000000..268b30dcfc --- /dev/null +++ b/package/kernel/mac80211/patches/652-0043-rtl8xxxu-Disable-packet-DMA-aggregation-on-8188eu.patch @@ -0,0 +1,43 @@ +From 17cb73ae89e15b60276f0b6583d4ed30b6bdeb4f Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 10 Aug 2016 15:41:13 -0400 +Subject: [PATCH] rtl8xxxu: Disable packet DMA aggregation on 8188eu + +For now disable packet DMA aggregation on the 8188eu, rather then +risking the feature being left on by the init tables. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -345,6 +345,19 @@ rtl8188e_set_tx_power(struct rtl8xxxu_pr + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, mcs); + } + ++void rtl8188eu_init_aggregation(struct rtl8xxxu_priv *priv) ++{ ++ u8 agg_ctrl, usb_spec; ++ ++ usb_spec = rtl8xxxu_read8(priv, REG_USB_SPECIAL_OPTION); ++ usb_spec &= ~USB_SPEC_USB_AGG_ENABLE; ++ rtl8xxxu_write8(priv, REG_USB_SPECIAL_OPTION, usb_spec); ++ ++ agg_ctrl = rtl8xxxu_read8(priv, REG_TRXDMA_CTRL); ++ agg_ctrl &= ~TRXDMA_CTRL_RXDMA_AGG_EN; ++ rtl8xxxu_write8(priv, REG_TRXDMA_CTRL, agg_ctrl); ++} ++ + static int rtl8188eu_parse_efuse(struct rtl8xxxu_priv *priv) + { + struct rtl8188eu_efuse *efuse = &priv->efuse_wifi.efuse8188eu; +@@ -1107,6 +1120,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .phy_iq_calibrate = rtl8188eu_phy_iq_calibrate, + .config_channel = rtl8xxxu_gen1_config_channel, + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, ++ .init_aggregation = rtl8188eu_init_aggregation, + .enable_rf = rtl8188e_enable_rf, + .disable_rf = rtl8188e_disable_rf, + .usb_quirks = rtl8188e_usb_quirks, diff --git a/package/kernel/mac80211/patches/652-0044-rtl8xxxu-8188eu-set-REG_OFDM0_XA_AGC_CORE1-to-match-.patch b/package/kernel/mac80211/patches/652-0044-rtl8xxxu-8188eu-set-REG_OFDM0_XA_AGC_CORE1-to-match-.patch new file mode 100644 index 0000000000..49eb28d178 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0044-rtl8xxxu-8188eu-set-REG_OFDM0_XA_AGC_CORE1-to-match-.patch @@ -0,0 +1,28 @@ +From af4fefead371c6ab89b323ff4b10881369bf4170 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 10 Aug 2016 16:06:37 -0400 +Subject: [PATCH] rtl8xxxu: 8188eu set REG_OFDM0_XA_AGC_CORE1 to match vendor + driver + +We have no description of this register, so not sure why this differs +from say 8723au. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5880,7 +5880,10 @@ exit: + rtl8xxxu_write16(priv, REG_RXFLTMAP2, 0xffff); + rtl8xxxu_write16(priv, REG_RXFLTMAP0, 0xffff); + +- rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, 0x6954341e); ++ if (priv->rtl_chip == RTL8188E) ++ rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, 0x6955341e); ++ else ++ rtl8xxxu_write32(priv, REG_OFDM0_XA_AGC_CORE1, 0x6954341e); + + return ret; + diff --git a/package/kernel/mac80211/patches/652-0045-rtl8xxxu-Implement-rtl8188eu_config_channel.patch b/package/kernel/mac80211/patches/652-0045-rtl8xxxu-Implement-rtl8188eu_config_channel.patch new file mode 100644 index 0000000000..9431d6e4bc --- /dev/null +++ b/package/kernel/mac80211/patches/652-0045-rtl8xxxu-Implement-rtl8188eu_config_channel.patch @@ -0,0 +1,146 @@ +From b3ce6298eb09b26c5abbc5dca8c8dfa18f41ea12 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Thu, 18 Aug 2016 12:20:31 -0400 +Subject: [PATCH] rtl8xxxu: Implement rtl8188eu_config_channel() + +The 8188eu doesn't seem to have REG_FPGA0_ANALOG2 + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 118 ++++++++++++++++++++- + 1 file changed, 117 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -345,6 +345,122 @@ rtl8188e_set_tx_power(struct rtl8xxxu_pr + rtl8xxxu_write32(priv, REG_TX_AGC_A_MCS15_MCS12, mcs); + } + ++void rtl8188eu_config_channel(struct ieee80211_hw *hw) ++{ ++ struct rtl8xxxu_priv *priv = hw->priv; ++ u32 val32, rsr; ++ u8 val8, opmode; ++ bool ht = true; ++ int sec_ch_above, channel; ++ int i; ++ ++ opmode = rtl8xxxu_read8(priv, REG_BW_OPMODE); ++ rsr = rtl8xxxu_read32(priv, REG_RESPONSE_RATE_SET); ++ channel = hw->conf.chandef.chan->hw_value; ++ ++ switch (hw->conf.chandef.width) { ++ case NL80211_CHAN_WIDTH_20_NOHT: ++ ht = false; ++ case NL80211_CHAN_WIDTH_20: ++ opmode |= BW_OPMODE_20MHZ; ++ rtl8xxxu_write8(priv, REG_BW_OPMODE, opmode); ++ ++ val32 = rtl8xxxu_read32(priv, REG_FPGA0_RF_MODE); ++ val32 &= ~FPGA_RF_MODE; ++ rtl8xxxu_write32(priv, REG_FPGA0_RF_MODE, val32); ++ ++ val32 = rtl8xxxu_read32(priv, REG_FPGA1_RF_MODE); ++ val32 &= ~FPGA_RF_MODE; ++ rtl8xxxu_write32(priv, REG_FPGA1_RF_MODE, val32); ++ break; ++ case NL80211_CHAN_WIDTH_40: ++ if (hw->conf.chandef.center_freq1 > ++ hw->conf.chandef.chan->center_freq) { ++ sec_ch_above = 1; ++ channel += 2; ++ } else { ++ sec_ch_above = 0; ++ channel -= 2; ++ } ++ ++ opmode &= ~BW_OPMODE_20MHZ; ++ rtl8xxxu_write8(priv, REG_BW_OPMODE, opmode); ++ rsr &= ~RSR_RSC_BANDWIDTH_40M; ++ if (sec_ch_above) ++ rsr |= RSR_RSC_UPPER_SUB_CHANNEL; ++ else ++ rsr |= RSR_RSC_LOWER_SUB_CHANNEL; ++ rtl8xxxu_write32(priv, REG_RESPONSE_RATE_SET, rsr); ++ ++ val32 = rtl8xxxu_read32(priv, REG_FPGA0_RF_MODE); ++ val32 |= FPGA_RF_MODE; ++ rtl8xxxu_write32(priv, REG_FPGA0_RF_MODE, val32); ++ ++ val32 = rtl8xxxu_read32(priv, REG_FPGA1_RF_MODE); ++ val32 |= FPGA_RF_MODE; ++ rtl8xxxu_write32(priv, REG_FPGA1_RF_MODE, val32); ++ ++ /* ++ * Set Control channel to upper or lower. These settings ++ * are required only for 40MHz ++ */ ++ val32 = rtl8xxxu_read32(priv, REG_CCK0_SYSTEM); ++ val32 &= ~CCK0_SIDEBAND; ++ if (!sec_ch_above) ++ val32 |= CCK0_SIDEBAND; ++ rtl8xxxu_write32(priv, REG_CCK0_SYSTEM, val32); ++ ++ val32 = rtl8xxxu_read32(priv, REG_OFDM1_LSTF); ++ val32 &= ~OFDM_LSTF_PRIME_CH_MASK; /* 0xc00 */ ++ if (sec_ch_above) ++ val32 |= OFDM_LSTF_PRIME_CH_LOW; ++ else ++ val32 |= OFDM_LSTF_PRIME_CH_HIGH; ++ rtl8xxxu_write32(priv, REG_OFDM1_LSTF, val32); ++ ++ val32 = rtl8xxxu_read32(priv, REG_FPGA0_POWER_SAVE); ++ val32 &= ~(FPGA0_PS_LOWER_CHANNEL | FPGA0_PS_UPPER_CHANNEL); ++ if (sec_ch_above) ++ val32 |= FPGA0_PS_UPPER_CHANNEL; ++ else ++ val32 |= FPGA0_PS_LOWER_CHANNEL; ++ rtl8xxxu_write32(priv, REG_FPGA0_POWER_SAVE, val32); ++ break; ++ ++ default: ++ break; ++ } ++ ++ for (i = RF_A; i < priv->rf_paths; i++) { ++ val32 = rtl8xxxu_read_rfreg(priv, i, RF6052_REG_MODE_AG); ++ val32 &= ~MODE_AG_CHANNEL_MASK; ++ val32 |= channel; ++ rtl8xxxu_write_rfreg(priv, i, RF6052_REG_MODE_AG, val32); ++ } ++ ++ if (ht) ++ val8 = 0x0e; ++ else ++ val8 = 0x0a; ++ ++#if 0 ++ rtl8xxxu_write8(priv, REG_SIFS_CCK + 1, val8); ++ rtl8xxxu_write8(priv, REG_SIFS_OFDM + 1, val8); ++ ++ rtl8xxxu_write16(priv, REG_R2T_SIFS, 0x0808); ++ rtl8xxxu_write16(priv, REG_T2T_SIFS, 0x0a0a); ++#endif ++ ++ for (i = RF_A; i < priv->rf_paths; i++) { ++ val32 = rtl8xxxu_read_rfreg(priv, i, RF6052_REG_MODE_AG); ++ if (hw->conf.chandef.width == NL80211_CHAN_WIDTH_40) ++ val32 &= ~MODE_AG_CHANNEL_20MHZ; ++ else ++ val32 |= MODE_AG_CHANNEL_20MHZ; ++ rtl8xxxu_write_rfreg(priv, i, RF6052_REG_MODE_AG, val32); ++ } ++} ++ + void rtl8188eu_init_aggregation(struct rtl8xxxu_priv *priv) + { + u8 agg_ctrl, usb_spec; +@@ -1118,7 +1234,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .init_phy_bb = rtl8188eu_init_phy_bb, + .init_phy_rf = rtl8188eu_init_phy_rf, + .phy_iq_calibrate = rtl8188eu_phy_iq_calibrate, +- .config_channel = rtl8xxxu_gen1_config_channel, ++ .config_channel = rtl8188eu_config_channel, + .parse_rx_desc = rtl8xxxu_parse_rxdesc16, + .init_aggregation = rtl8188eu_init_aggregation, + .enable_rf = rtl8188e_enable_rf, diff --git a/package/kernel/mac80211/patches/652-0046-rtl8xxxu-Clean-up-llt_init-API.patch b/package/kernel/mac80211/patches/652-0046-rtl8xxxu-Clean-up-llt_init-API.patch new file mode 100644 index 0000000000..ca804a1665 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0046-rtl8xxxu-Clean-up-llt_init-API.patch @@ -0,0 +1,79 @@ +From 533293085b6c331f20c36fa09fe3cf1e904ce259 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 24 Aug 2016 11:31:38 -0400 +Subject: [PATCH] rtl8xxxu: Clean up llt_init() API + +Remove last_tx_page argument from the llt_init() function. The +rtl8xxxu_fileops structure contains the correct TX_TOTAL_PAGE_NUM +value for the device, and rtl8xxxu_auto_llt_table() doesn't need to +know the value in the first place. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 6 +++--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 9 ++++++--- + 2 files changed, 9 insertions(+), 6 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1367,7 +1367,7 @@ struct rtl8xxxu_fileops { + int (*power_on) (struct rtl8xxxu_priv *priv); + void (*power_off) (struct rtl8xxxu_priv *priv); + void (*reset_8051) (struct rtl8xxxu_priv *priv); +- int (*llt_init) (struct rtl8xxxu_priv *priv, u8 last_tx_page); ++ int (*llt_init) (struct rtl8xxxu_priv *priv); + void (*init_phy_bb) (struct rtl8xxxu_priv *priv); + int (*init_phy_rf) (struct rtl8xxxu_priv *priv); + void (*phy_init_antenna_selection) (struct rtl8xxxu_priv *priv); +@@ -1449,14 +1449,14 @@ int rtl8xxxu_load_firmware(struct rtl8xx + void rtl8xxxu_firmware_self_reset(struct rtl8xxxu_priv *priv); + void rtl8xxxu_power_off(struct rtl8xxxu_priv *priv); + void rtl8xxxu_reset_8051(struct rtl8xxxu_priv *priv); +-int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page); ++int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv); + void rtl8xxxu_gen2_prepare_calibrate(struct rtl8xxxu_priv *priv, u8 start); + int rtl8xxxu_flush_fifo(struct rtl8xxxu_priv *priv); + int rtl8xxxu_gen2_h2c_cmd(struct rtl8xxxu_priv *priv, + struct h2c_cmd *h2c, int len); + int rtl8xxxu_active_to_lps(struct rtl8xxxu_priv *priv); + void rtl8xxxu_disabled_to_emu(struct rtl8xxxu_priv *priv); +-int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page); ++int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv); + void rtl8xxxu_gen1_phy_iq_calibrate(struct rtl8xxxu_priv *priv); + void rtl8xxxu_gen1_init_phy_bb(struct rtl8xxxu_priv *priv); + void rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -2482,10 +2482,13 @@ static int rtl8xxxu_llt_write(struct rtl + return ret; + } + +-int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page) ++int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv) + { + int ret; + int i; ++ u8 last_tx_page; ++ ++ last_tx_page = priv->fops->total_page_num; + + for (i = 0; i < last_tx_page; i++) { + ret = rtl8xxxu_llt_write(priv, i, i + 1); +@@ -2513,7 +2516,7 @@ exit: + return ret; + } + +-int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv, u8 last_tx_page) ++int rtl8xxxu_auto_llt_table(struct rtl8xxxu_priv *priv) + { + u32 val32; + int ret = 0; +@@ -3999,7 +4002,7 @@ static int rtl8xxxu_init_device(struct i + + dev_dbg(dev, "%s: macpower %i\n", __func__, macpower); + if (!macpower) { +- ret = priv->fops->llt_init(priv, TX_TOTAL_PAGE_NUM); ++ ret = priv->fops->llt_init(priv); + if (ret) { + dev_warn(dev, "%s: LLT table init failed\n", __func__); + goto exit; diff --git a/package/kernel/mac80211/patches/652-0047-rtl8xxxu-Fix-rtl8188eu-connection-fail.patch b/package/kernel/mac80211/patches/652-0047-rtl8xxxu-Fix-rtl8188eu-connection-fail.patch new file mode 100644 index 0000000000..78f248cd13 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0047-rtl8xxxu-Fix-rtl8188eu-connection-fail.patch @@ -0,0 +1,27 @@ +From 2c6b2e7aadc24a58bac9321bcf15262519f903a8 Mon Sep 17 00:00:00 2001 +From: Taehee Yoo +Date: Sun, 21 Aug 2016 20:38:22 +0900 +Subject: [PATCH] rtl8xxxu : Fix rtl8188eu connection fail + +rtl8188eu vendor driver's LLT init routine is similar +rtl8xxxu_init_llt_table() than rtl8xxxu_auto_llt_table(). + +So now, rtl8188eu can connect to AP. + +Signed-off-by: Taehee Yoo +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1230,7 +1230,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .power_on = rtl8188eu_power_on, + .power_off = rtl8xxxu_power_off, + .reset_8051 = rtl8188eu_reset_8051, +- .llt_init = rtl8xxxu_auto_llt_table, ++ .llt_init = rtl8xxxu_init_llt_table, + .init_phy_bb = rtl8188eu_init_phy_bb, + .init_phy_rf = rtl8188eu_init_phy_rf, + .phy_iq_calibrate = rtl8188eu_phy_iq_calibrate, diff --git a/package/kernel/mac80211/patches/652-0048-rtl8xxxu-Do-not-set-auto-rate-fallback-on-8188eu.patch b/package/kernel/mac80211/patches/652-0048-rtl8xxxu-Do-not-set-auto-rate-fallback-on-8188eu.patch new file mode 100644 index 0000000000..76023f9358 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0048-rtl8xxxu-Do-not-set-auto-rate-fallback-on-8188eu.patch @@ -0,0 +1,93 @@ +From 4bc5ab6c3655cead3401c85e9dd174c7453c94eb Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 24 Aug 2016 13:54:00 -0400 +Subject: [PATCH] rtl8xxxu: Do not set auto rate fallback on 8188eu + +Introduce a fileops flag to indicate whether the device has this +feature. + +Reported-by: Taehee Yoo +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 15 ++++++++++----- + 6 files changed, 15 insertions(+), 5 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1396,6 +1396,7 @@ struct rtl8xxxu_fileops { + u8 has_s0s1:1; + u8 has_tx_report:1; + u8 gen2_thermal_meter:1; ++ u8 has_darfrc:1; + u32 adda_1t_init; + u32 adda_1t_path_on; + u32 adda_2t_path_on_a; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +@@ -572,6 +572,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = + .rx_agg_buf_size = 16000, + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), ++ .has_darfrc = 1, + .adda_1t_init = 0x0b1b25a0, + .adda_1t_path_on = 0x0bdb25a0, + .adda_2t_path_on_a = 0x04db25a4, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +@@ -1649,6 +1649,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), + .has_s0s1 = 0, + .gen2_thermal_meter = 1, ++ .has_darfrc = 1, + .adda_1t_init = 0x0fc01616, + .adda_1t_path_on = 0x0fc01616, + .adda_2t_path_on_a = 0x0fc01616, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +@@ -389,6 +389,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = + .rx_agg_buf_size = 16000, + .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32), + .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16), ++ .has_darfrc = 1, + .adda_1t_init = 0x0b1b25a0, + .adda_1t_path_on = 0x0bdb25a0, + .adda_2t_path_on_a = 0x04db25a4, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +@@ -1669,6 +1669,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = + .has_s0s1 = 1, + .has_tx_report = 1, + .gen2_thermal_meter = 1, ++ .has_darfrc = 1, + .adda_1t_init = 0x01c00014, + .adda_1t_path_on = 0x01c00014, + .adda_2t_path_on_a = 0x01c00014, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -4104,11 +4104,16 @@ static int rtl8xxxu_init_device(struct i + rtl8xxxu_write32(priv, REG_EDCA_VI_PARAM, 0x005ea324); + rtl8xxxu_write32(priv, REG_EDCA_VO_PARAM, 0x002fa226); + +- /* Set data auto rate fallback retry count */ +- rtl8xxxu_write32(priv, REG_DARFRC, 0x00000000); +- rtl8xxxu_write32(priv, REG_DARFRC + 4, 0x10080404); +- rtl8xxxu_write32(priv, REG_RARFRC, 0x04030201); +- rtl8xxxu_write32(priv, REG_RARFRC + 4, 0x08070605); ++ /* ++ * Set data auto rate fallback retry count. ++ * Notably the 8188eu doesn't seem to use this ++ */ ++ if (priv->fops->has_darfrc) { ++ rtl8xxxu_write32(priv, REG_DARFRC, 0x00000000); ++ rtl8xxxu_write32(priv, REG_DARFRC + 4, 0x10080404); ++ rtl8xxxu_write32(priv, REG_RARFRC, 0x04030201); ++ rtl8xxxu_write32(priv, REG_RARFRC + 4, 0x08070605); ++ } + + val8 = rtl8xxxu_read8(priv, REG_FWHW_TXQ_CTRL); + val8 |= FWHW_TXQ_CTRL_AMPDU_RETRY; diff --git a/package/kernel/mac80211/patches/652-0049-rtl8xxxu-Use-a-struct-rtl8xxxu_fileops-in-rtl8xxxu_i.patch b/package/kernel/mac80211/patches/652-0049-rtl8xxxu-Use-a-struct-rtl8xxxu_fileops-in-rtl8xxxu_i.patch new file mode 100644 index 0000000000..5e46c29adb --- /dev/null +++ b/package/kernel/mac80211/patches/652-0049-rtl8xxxu-Use-a-struct-rtl8xxxu_fileops-in-rtl8xxxu_i.patch @@ -0,0 +1,158 @@ +From e3c6694ed9367142704930754f3d6bff6c25f7e7 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 24 Aug 2016 14:06:04 -0400 +Subject: [PATCH] rtl8xxxu: Use a struct rtl8xxxu_fileops * in + rtl8xxxu_init_device() + +This saves some 217, or about, derefences of priv->fops. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 39 +++++++++++----------- + 1 file changed, 20 insertions(+), 19 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -3896,6 +3896,7 @@ static int rtl8xxxu_init_device(struct i + { + struct rtl8xxxu_priv *priv = hw->priv; + struct device *dev = &priv->udev->dev; ++ struct rtl8xxxu_fileops *fops = priv->fops; + bool macpower; + int ret; + u8 val8; +@@ -3914,7 +3915,7 @@ static int rtl8xxxu_init_device(struct i + else + macpower = true; + +- ret = priv->fops->power_on(priv); ++ ret = fops->power_on(priv); + if (ret < 0) { + dev_warn(dev, "%s: Failed power on\n", __func__); + goto exit; +@@ -3931,7 +3932,7 @@ static int rtl8xxxu_init_device(struct i + /* + * Set RX page boundary + */ +- rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, priv->fops->trxff_boundary); ++ rtl8xxxu_write16(priv, REG_TRXFF_BNDY + 2, fops->trxff_boundary); + + ret = rtl8xxxu_download_firmware(priv); + dev_dbg(dev, "%s: download_firmware %i\n", __func__, ret); +@@ -3942,8 +3943,8 @@ static int rtl8xxxu_init_device(struct i + if (ret) + goto exit; + +- if (priv->fops->phy_init_antenna_selection) +- priv->fops->phy_init_antenna_selection(priv); ++ if (fops->phy_init_antenna_selection) ++ fops->phy_init_antenna_selection(priv); + + ret = rtl8xxxu_init_mac(priv); + +@@ -3956,7 +3957,7 @@ static int rtl8xxxu_init_device(struct i + if (ret) + goto exit; + +- ret = priv->fops->init_phy_rf(priv); ++ ret = fops->init_phy_rf(priv); + if (ret) + goto exit; + +@@ -3982,7 +3983,7 @@ static int rtl8xxxu_init_device(struct i + /* + * Set TX buffer boundary + */ +- val8 = priv->fops->total_page_num + 1; ++ val8 = fops->total_page_num + 1; + + rtl8xxxu_write8(priv, REG_TXPKTBUF_BCNQ_BDNY, val8); + rtl8xxxu_write8(priv, REG_TXPKTBUF_MGQ_BDNY, val8); +@@ -3995,14 +3996,14 @@ static int rtl8xxxu_init_device(struct i + * The vendor drivers set PBP for all devices, except 8192e. + * There is no explanation for this in any of the sources. + */ +- val8 = (priv->fops->pbp_rx << PBP_PAGE_SIZE_RX_SHIFT) | +- (priv->fops->pbp_tx << PBP_PAGE_SIZE_TX_SHIFT); ++ val8 = (fops->pbp_rx << PBP_PAGE_SIZE_RX_SHIFT) | ++ (fops->pbp_tx << PBP_PAGE_SIZE_TX_SHIFT); + if (priv->rtl_chip != RTL8192E) + rtl8xxxu_write8(priv, REG_PBP, val8); + + dev_dbg(dev, "%s: macpower %i\n", __func__, macpower); + if (!macpower) { +- ret = priv->fops->llt_init(priv); ++ ret = fops->llt_init(priv); + if (ret) { + dev_warn(dev, "%s: LLT table init failed\n", __func__); + goto exit; +@@ -4011,12 +4012,12 @@ static int rtl8xxxu_init_device(struct i + /* + * Chip specific quirks + */ +- priv->fops->usb_quirks(priv); ++ fops->usb_quirks(priv); + + /* + * Enable TX report and TX report timer for 8723bu/8188eu/... + */ +- if (priv->fops->has_tx_report) { ++ if (fops->has_tx_report) { + val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL); + val8 |= TX_REPORT_CTRL_TIMER_ENABLE; + rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8); +@@ -4108,7 +4109,7 @@ static int rtl8xxxu_init_device(struct i + * Set data auto rate fallback retry count. + * Notably the 8188eu doesn't seem to use this + */ +- if (priv->fops->has_darfrc) { ++ if (fops->has_darfrc) { + rtl8xxxu_write32(priv, REG_DARFRC, 0x00000000); + rtl8xxxu_write32(priv, REG_DARFRC + 4, 0x10080404); + rtl8xxxu_write32(priv, REG_RARFRC, 0x04030201); +@@ -4165,8 +4166,8 @@ static int rtl8xxxu_init_device(struct i + rtl8xxxu_write8(priv, REG_RSV_CTRL, val8); + } + +- if (priv->fops->init_aggregation) +- priv->fops->init_aggregation(priv); ++ if (fops->init_aggregation) ++ fops->init_aggregation(priv); + + /* + * Enable CCK and OFDM block +@@ -4183,7 +4184,7 @@ static int rtl8xxxu_init_device(struct i + /* + * Start out with default power levels for channel 6, 20MHz + */ +- priv->fops->set_tx_power(priv, 1, false); ++ fops->set_tx_power(priv, 1, false); + + /* Let the 8051 take control of antenna setting */ + if (priv->rtl_chip != RTL8192E) { +@@ -4199,8 +4200,8 @@ static int rtl8xxxu_init_device(struct i + + rtl8xxxu_write16(priv, REG_FAST_EDCA_CTRL, 0); + +- if (priv->fops->init_statistics) +- priv->fops->init_statistics(priv); ++ if (fops->init_statistics) ++ fops->init_statistics(priv); + + if (priv->rtl_chip == RTL8192E) { + /* +@@ -4225,12 +4226,12 @@ static int rtl8xxxu_init_device(struct i + + rtl8723a_phy_lc_calibrate(priv); + +- priv->fops->phy_iq_calibrate(priv); ++ fops->phy_iq_calibrate(priv); + + /* + * This should enable thermal meter + */ +- if (priv->fops->gen2_thermal_meter) ++ if (fops->gen2_thermal_meter) + rtl8xxxu_write_rfreg(priv, + RF_A, RF6052_REG_T_METER_8723B, 0x37cf8); + else diff --git a/package/kernel/mac80211/patches/652-0050-rtl8xxxu-Enable-8188eu-driver.patch b/package/kernel/mac80211/patches/652-0050-rtl8xxxu-Enable-8188eu-driver.patch new file mode 100644 index 0000000000..3966ec3c6d --- /dev/null +++ b/package/kernel/mac80211/patches/652-0050-rtl8xxxu-Enable-8188eu-driver.patch @@ -0,0 +1,22 @@ +From c62a97a358ce2ba090efe1b447fa61a7104520ef Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 25 Jul 2016 12:32:02 -0400 +Subject: [PATCH] rtl8xxxu: Enable 8188eu driver + +This enables the 8188eu driver - this should work by now. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -539,7 +539,6 @@ static int rtl8188eu_load_firmware(struc + + ret = rtl8xxxu_load_firmware(priv, fw_name); + +- return -EINVAL; + return ret; + } + diff --git a/package/kernel/mac80211/patches/652-0051-rtl8xxxu-Add-rtl8188etv-to-USB-device-list.patch b/package/kernel/mac80211/patches/652-0051-rtl8xxxu-Add-rtl8188etv-to-USB-device-list.patch new file mode 100644 index 0000000000..a15be5e4ec --- /dev/null +++ b/package/kernel/mac80211/patches/652-0051-rtl8xxxu-Add-rtl8188etv-to-USB-device-list.patch @@ -0,0 +1,25 @@ +From e234d016528d2c22cca59faf87e675f8b72b8a83 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 26 Aug 2016 10:28:45 -0400 +Subject: [PATCH] rtl8xxxu: Add rtl8188etv to USB device list + +Hans de Goede reported this works for him with two different tablets. + +Reported-by: Hans de Goede +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -6256,6 +6256,9 @@ static struct usb_device_id dev_table[] + #ifdef CPTCFG_RTL8XXXU_UNTESTED + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8179, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8188eu_fops}, ++/* Tested by Hans de Goede - rtl8188etv */ ++{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x0179, 0xff, 0xff, 0xff), ++ .driver_info = (unsigned long)&rtl8188eu_fops}, + /* Still supported by rtlwifi */ + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8176, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, diff --git a/package/kernel/mac80211/patches/652-0052-rtl8xxxu-Add-sitecom-dongle-to-USB-device-list.patch b/package/kernel/mac80211/patches/652-0052-rtl8xxxu-Add-sitecom-dongle-to-USB-device-list.patch new file mode 100644 index 0000000000..8fb65e960e --- /dev/null +++ b/package/kernel/mac80211/patches/652-0052-rtl8xxxu-Add-sitecom-dongle-to-USB-device-list.patch @@ -0,0 +1,23 @@ +From cdf2dd45b570739953d1ed37b92536a85a94f2c1 Mon Sep 17 00:00:00 2001 +From: Andrea Merello +Date: Fri, 26 Aug 2016 19:18:17 +0200 +Subject: [PATCH] rtl8xxxu: Add sitecom dongle to USB device list + +Signed-off-by: Andrea Merello +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -6259,6 +6259,9 @@ static struct usb_device_id dev_table[] + /* Tested by Hans de Goede - rtl8188etv */ + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x0179, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8188eu_fops}, ++/* Sitecom rtl8188eus */ ++{USB_DEVICE_AND_INTERFACE_INFO(0x0df6, 0x0076, 0xff, 0xff, 0xff), ++ .driver_info = (unsigned long)&rtl8188eu_fops}, + /* Still supported by rtlwifi */ + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8176, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, diff --git a/package/kernel/mac80211/patches/652-0053-rtl8xxxu-Implement-rtl8188eu_active_to_emu.patch b/package/kernel/mac80211/patches/652-0053-rtl8xxxu-Implement-rtl8188eu_active_to_emu.patch new file mode 100644 index 0000000000..0beaa91437 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0053-rtl8xxxu-Implement-rtl8188eu_active_to_emu.patch @@ -0,0 +1,68 @@ +From ed9fac53f69189d25affa6baf2e921235724d668 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 26 Aug 2016 15:16:32 -0400 +Subject: [PATCH] rtl8xxxu: Implement rtl8188eu_active_to_emu() + +Per the vendor driver's sequence table, this seems to be the correct +way to disable RF on the 8188eu, even if the driver doesn't actually +call the sequence by itself. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 38 ++++++++++++++++++++++ + 1 file changed, 38 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1155,6 +1155,42 @@ exit: + return ret; + } + ++static int rtl8188eu_active_to_emu(struct rtl8xxxu_priv *priv) ++{ ++ u8 val8; ++ int count, ret = 0; ++ ++ /* Turn off RF */ ++ rtl8xxxu_write8(priv, REG_RF_CTRL, 0); ++ ++ /* LDO Sleep mode */ ++ val8 = rtl8xxxu_read8(priv, REG_LPLDO_CTRL); ++ val8 |= BIT(4); ++ rtl8xxxu_write8(priv, REG_LPLDO_CTRL, val8); ++ ++ /* 0x0005[1] = 1 turn off MAC by HW state machine*/ ++ val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); ++ val8 |= BIT(1); ++ rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); ++ ++ for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { ++ val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); ++ if ((val8 & BIT(1)) == 0) ++ break; ++ udelay(10); ++ } ++ ++ if (!count) { ++ dev_warn(&priv->udev->dev, "%s: Disabling MAC timed out\n", ++ __func__); ++ ret = -EBUSY; ++ goto exit; ++ } ++ ++exit: ++ return ret; ++} ++ + static int rtl8188eu_power_on(struct rtl8xxxu_priv *priv) + { + u16 val16; +@@ -1202,6 +1238,8 @@ static void rtl8188e_disable_rf(struct r + rtl8xxxu_write_rfreg(priv, RF_A, RF6052_REG_AC, 0); + if (priv->rf_paths == 2) + rtl8xxxu_write_rfreg(priv, RF_B, RF6052_REG_AC, 0); ++ ++ rtl8188eu_active_to_emu(priv); + } + + static void rtl8188e_usb_quirks(struct rtl8xxxu_priv *priv) diff --git a/package/kernel/mac80211/patches/652-0054-rtl8xxxu-Implement-rtl8188eu_power_off.patch b/package/kernel/mac80211/patches/652-0054-rtl8xxxu-Implement-rtl8188eu_power_off.patch new file mode 100644 index 0000000000..efbb88fd35 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0054-rtl8xxxu-Implement-rtl8188eu_power_off.patch @@ -0,0 +1,178 @@ +From 034fb94799289990283082eef61934f5eb9e939f Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Fri, 26 Aug 2016 16:09:00 -0400 +Subject: [PATCH] rtl8xxxu: Implement rtl8188eu_power_off() + +This allows the firmware to reload correctly upon rmmod/insmod. +However the device still doesn't receive data upon reloading. + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 130 ++++++++++++++++++++- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 2 + + 2 files changed, 131 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1191,6 +1191,71 @@ exit: + return ret; + } + ++static int rtl8188eu_emu_to_disabled(struct rtl8xxxu_priv *priv) ++{ ++ u8 val8; ++ ++ /* 0x04[12:11] = 01 enable WL suspend */ ++ val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 2); ++ val8 &= ~BIT(0); ++ rtl8xxxu_write8(priv, REG_APS_FSMCO + 2, val8); ++ ++ val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); ++ val8 |= BIT(7); ++ rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); ++ ++ return 0; ++} ++ ++static int rtl8188eu_active_to_lps(struct rtl8xxxu_priv *priv) ++{ ++ struct device *dev = &priv->udev->dev; ++ u8 val8; ++ u16 val16; ++ u32 val32; ++ int retry, retval; ++ ++ rtl8xxxu_write8(priv, REG_TXPAUSE, 0x7f); ++ ++ retry = 100; ++ retval = -EBUSY; ++ /* ++ * Poll 32 bit wide 0x05f8 for 0x00000000 to ensure no TX is pending. ++ */ ++ do { ++ val32 = rtl8xxxu_read32(priv, 0x05f8); ++ if (!val32) { ++ retval = 0; ++ break; ++ } ++ } while (retry--); ++ ++ if (!retry) { ++ dev_warn(dev, "Failed to flush TX queue\n"); ++ retval = -EBUSY; ++ goto out; ++ } ++ ++ /* Disable CCK and OFDM, clock gated */ ++ val8 = rtl8xxxu_read8(priv, REG_SYS_FUNC); ++ val8 &= ~SYS_FUNC_BBRSTB; ++ rtl8xxxu_write8(priv, REG_SYS_FUNC, val8); ++ ++ udelay(2); ++ ++ /* Reset MAC TRX */ ++ val16 = rtl8xxxu_read16(priv, REG_CR); ++ val16 &= ~(CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE | CR_SECURITY_ENABLE); ++ rtl8xxxu_write16(priv, REG_CR, val8); ++ ++ val8 = rtl8xxxu_read8(priv, REG_DUAL_TSF_RST); ++ val8 |= DUAL_TSF_TX_OK; ++ rtl8xxxu_write8(priv, REG_DUAL_TSF_RST, val8); ++ ++out: ++ return retval; ++} ++ + static int rtl8188eu_power_on(struct rtl8xxxu_priv *priv) + { + u16 val16; +@@ -1221,6 +1286,69 @@ exit: + return ret; + } + ++void rtl8188eu_power_off(struct rtl8xxxu_priv *priv) ++{ ++ u8 val8; ++ u16 val16; ++ ++ rtl8xxxu_flush_fifo(priv); ++ ++ val8 = rtl8xxxu_read8(priv, REG_TX_REPORT_CTRL); ++ val8 &= ~TX_REPORT_CTRL_TIMER_ENABLE; ++ rtl8xxxu_write8(priv, REG_TX_REPORT_CTRL, val8); ++ ++ /* Turn off RF */ ++ rtl8xxxu_write8(priv, REG_RF_CTRL, 0x00); ++ ++ rtl8188eu_active_to_lps(priv); ++ ++ /* Reset Firmware if running in RAM */ ++ if (rtl8xxxu_read8(priv, REG_MCU_FW_DL) & MCU_FW_RAM_SEL) ++ rtl8xxxu_firmware_self_reset(priv); ++ ++ /* Reset MCU */ ++ val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); ++ val16 &= ~SYS_FUNC_CPU_ENABLE; ++ rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); ++ ++ /* Reset MCU ready status */ ++ rtl8xxxu_write8(priv, REG_MCU_FW_DL, 0x00); ++ ++ /* 32K_CTRL looks to be very 8188e specific */ ++ val8 = rtl8xxxu_read8(priv, REG_32K_CTRL); ++ val8 &= ~BIT(0); ++ rtl8xxxu_write8(priv, REG_32K_CTRL, val8); ++ ++ rtl8188eu_active_to_emu(priv); ++ rtl8188eu_emu_to_disabled(priv); ++ ++ /* Reset MCU IO Wrapper */ ++ val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL + 1); ++ val8 &= ~BIT(3); ++ rtl8xxxu_write8(priv, REG_RSV_CTRL + 1, val8); ++ ++ val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL + 1); ++ val8 |= BIT(3); ++ rtl8xxxu_write8(priv, REG_RSV_CTRL + 1, val8); ++ ++ /* Vendor driver refers to GPIO_IN */ ++ val8 = rtl8xxxu_read8(priv, REG_GPIO_PIN_CTRL); ++ /* Vendor driver refers to GPIO_OUT */ ++ rtl8xxxu_write8(priv, REG_GPIO_PIN_CTRL + 1, val8); ++ rtl8xxxu_write8(priv, REG_GPIO_PIN_CTRL + 2, 0xff); ++ ++ val8 = rtl8xxxu_read8(priv, REG_GPIO_IO_SEL); ++ rtl8xxxu_write8(priv, REG_GPIO_IO_SEL + 1, val8 << 4); ++ val8 = rtl8xxxu_read8(priv, REG_GPIO_IO_SEL + 1); ++ rtl8xxxu_write8(priv, REG_GPIO_IO_SEL + 1, val8 | 0x0f); ++ ++ /* ++ * Set LNA, TRSW, EX_PA Pin to output mode ++ * Referred to as REG_BB_PAD_CTRL in 8188eu vendor driver ++ */ ++ rtl8xxxu_write32(priv, REG_PAD_CTRL1, 0x00080808); ++} ++ + static void rtl8188e_enable_rf(struct rtl8xxxu_priv *priv) + { + rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00); +@@ -1265,7 +1393,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .parse_efuse = rtl8188eu_parse_efuse, + .load_firmware = rtl8188eu_load_firmware, + .power_on = rtl8188eu_power_on, +- .power_off = rtl8xxxu_power_off, ++ .power_off = rtl8188eu_power_off, + .reset_8051 = rtl8188eu_reset_8051, + .llt_init = rtl8xxxu_init_llt_table, + .init_phy_bb = rtl8188eu_init_phy_bb, +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -413,6 +413,8 @@ + #define REG_MBIST_START 0x0174 + #define REG_MBIST_DONE 0x0178 + #define REG_MBIST_FAIL 0x017c ++/* 8188EU */ ++#define REG_32K_CTRL 0x0194 + #define REG_C2HEVT_MSG_NORMAL 0x01a0 + /* 8192EU/8723BU/8812 */ + #define REG_C2HEVT_CMD_ID_8723B 0x01ae diff --git a/package/kernel/mac80211/patches/652-0055-rtl8xxxu-Add-rtl8188eu-USB-ID-for-D-Link-USB-GO-N150.patch b/package/kernel/mac80211/patches/652-0055-rtl8xxxu-Add-rtl8188eu-USB-ID-for-D-Link-USB-GO-N150.patch new file mode 100644 index 0000000000..6281d16539 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0055-rtl8xxxu-Add-rtl8188eu-USB-ID-for-D-Link-USB-GO-N150.patch @@ -0,0 +1,25 @@ +From 3f58ab0fbda16f70e9011089e87474756cf9c329 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 29 Aug 2016 12:55:37 -0400 +Subject: [PATCH] rtl8xxxu: Add rtl8188eu USB ID for D-Link USB-GO-N150 + +Received one in the mail yesterday, seems to work like all the other +8188eu dongles I have. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -6262,6 +6262,9 @@ static struct usb_device_id dev_table[] + /* Sitecom rtl8188eus */ + {USB_DEVICE_AND_INTERFACE_INFO(0x0df6, 0x0076, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8188eu_fops}, ++/* D-Link USB-GO-N150 */ ++{USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x3311, 0xff, 0xff, 0xff), ++ .driver_info = (unsigned long)&rtl8188eu_fops}, + /* Still supported by rtlwifi */ + {USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_REALTEK, 0x8176, 0xff, 0xff, 0xff), + .driver_info = (unsigned long)&rtl8192cu_fops}, diff --git a/package/kernel/mac80211/patches/652-0056-rtl8xxxu-Add-additional-rtl8188eu-shutdown-code-to-m.patch b/package/kernel/mac80211/patches/652-0056-rtl8xxxu-Add-additional-rtl8188eu-shutdown-code-to-m.patch new file mode 100644 index 0000000000..c2ff0f94cb --- /dev/null +++ b/package/kernel/mac80211/patches/652-0056-rtl8xxxu-Add-additional-rtl8188eu-shutdown-code-to-m.patch @@ -0,0 +1,30 @@ +From 33b19d32ae77eee805170a5a28220899f76f6ca4 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Mon, 29 Aug 2016 14:27:19 -0400 +Subject: [PATCH] rtl8xxxu: Add additional rtl8188eu shutdown code to match + vendor driver + +This makes the driver match the poweroff sequence of the vendor driver +further. However it still doesn't work correctly when reloading the +driver. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1347,6 +1347,12 @@ void rtl8188eu_power_off(struct rtl8xxxu + * Referred to as REG_BB_PAD_CTRL in 8188eu vendor driver + */ + rtl8xxxu_write32(priv, REG_PAD_CTRL1, 0x00080808); ++ ++ rtl8xxxu_write8(priv, REG_RSV_CTRL, 0x00); ++ ++ val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); ++ val16 |= APS_FSMCO_ENABLE_POWERDOWN | APS_FSMCO_HW_POWERDOWN; ++ rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); + } + + static void rtl8188e_enable_rf(struct rtl8xxxu_priv *priv) diff --git a/package/kernel/mac80211/patches/652-0057-rtl8xxxu-Fix-off-by-one-error-calculating-pubq.patch b/package/kernel/mac80211/patches/652-0057-rtl8xxxu-Fix-off-by-one-error-calculating-pubq.patch new file mode 100644 index 0000000000..e70502c97b --- /dev/null +++ b/package/kernel/mac80211/patches/652-0057-rtl8xxxu-Fix-off-by-one-error-calculating-pubq.patch @@ -0,0 +1,24 @@ +From c563d5e11eb6d90d6375b0ab7bce0ff1fdc53d1b Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 30 Aug 2016 13:49:04 -0400 +Subject: [PATCH] rtl8xxxu: Fix off by one error calculating pubq + +This was detected tracing the 8188eu driver, but doesn't seem to make +any difference when using it. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -3882,7 +3882,7 @@ static void rtl8xxxu_init_queue_reserved + val32 = (nq << RQPN_NPQ_SHIFT) | (eq << RQPN_EPQ_SHIFT); + rtl8xxxu_write32(priv, REG_RQPN_NPQ, val32); + +- pubq = fops->total_page_num - hq - lq - nq; ++ pubq = fops->total_page_num - hq - lq - nq - 1; + + val32 = RQPN_LOAD; + val32 |= (hq << RQPN_HI_PQ_SHIFT); diff --git a/package/kernel/mac80211/patches/652-0058-rtl8xxxu-Add-register-define-used-for-8188-IOL-magic.patch b/package/kernel/mac80211/patches/652-0058-rtl8xxxu-Add-register-define-used-for-8188-IOL-magic.patch new file mode 100644 index 0000000000..86f327b829 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0058-rtl8xxxu-Add-register-define-used-for-8188-IOL-magic.patch @@ -0,0 +1,35 @@ +From 023b13832fdaeff6d7945036e769f1f16167348f Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 30 Aug 2016 13:59:01 -0400 +Subject: [PATCH] rtl8xxxu: Add register define used for 8188 IOL magic + +This interface seems to be used to send firmware and register init +files to the firmware. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +@@ -378,6 +378,11 @@ + #define PBP_PAGE_SIZE_512 0x3 + #define PBP_PAGE_SIZE_1024 0x4 + ++/* 8188eu IOL magic */ ++#define REG_PKT_BUF_ACCESS_CTRL 0x0106 ++#define PKT_BUF_ACCESS_CTRL_TX 0x69 ++#define PKT_BUF_ACCESS_CTRL_RX 0xa5 ++ + #define REG_TRXDMA_CTRL 0x010c + #define TRXDMA_CTRL_RXDMA_AGG_EN BIT(2) + #define TRXDMA_CTRL_VOQ_SHIFT 4 +@@ -451,6 +456,7 @@ + + #define REG_FIFOPAGE 0x0204 + #define REG_TDECTRL 0x0208 ++ + #define REG_TXDMA_OFFSET_CHK 0x020c + #define TXDMA_OFFSET_DROP_DATA_EN BIT(9) + #define REG_TXDMA_STATUS 0x0210 diff --git a/package/kernel/mac80211/patches/652-0059-rtl8xxxu-Clear-SYS_FUNC_UPLL-during-power-up-on-8188.patch b/package/kernel/mac80211/patches/652-0059-rtl8xxxu-Clear-SYS_FUNC_UPLL-during-power-up-on-8188.patch new file mode 100644 index 0000000000..acaf7f8ef3 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0059-rtl8xxxu-Clear-SYS_FUNC_UPLL-during-power-up-on-8188.patch @@ -0,0 +1,23 @@ +From 8206e03abfe80c4801d3573bd43252fb37bb69be Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 30 Aug 2016 14:33:18 -0400 +Subject: [PATCH] rtl8xxxu: Clear SYS_FUNC_UPLL during power up on 8188eu + +The vendor driver doesn't set this bit during BB config, so avoid +setting it here too. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -561,6 +561,7 @@ static void rtl8188eu_init_phy_bb(struct + val16 = rtl8xxxu_read16(priv, REG_SYS_FUNC); + val16 |= (SYS_FUNC_USBA | SYS_FUNC_USBD | + SYS_FUNC_BB_GLB_RSTN | SYS_FUNC_BBRSTB); ++ val16 &= ~SYS_FUNC_UPLL; + rtl8xxxu_write16(priv, REG_SYS_FUNC, val16); + + rtl8xxxu_init_phy_regs(priv, rtl8188eu_phy_init_table); diff --git a/package/kernel/mac80211/patches/652-0060-rtl8xxxu-Early-enable-of-WEP-TKIP-security-on-8188eu.patch b/package/kernel/mac80211/patches/652-0060-rtl8xxxu-Early-enable-of-WEP-TKIP-security-on-8188eu.patch new file mode 100644 index 0000000000..46fbece7c4 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0060-rtl8xxxu-Early-enable-of-WEP-TKIP-security-on-8188eu.patch @@ -0,0 +1,25 @@ +From 1cfcfed81b36a64a45a2418c628b2430191ec38a Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 30 Aug 2016 15:47:05 -0400 +Subject: [PATCH] rtl8xxxu: Early enable of WEP/TKIP security on 8188eu + +This matches action taken in the vendor driver, however it is unclear +why this is done. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1394,6 +1394,9 @@ static void rtl8188e_usb_quirks(struct r + val32 = rtl8xxxu_read32(priv, REG_TXDMA_OFFSET_CHK); + val32 |= TXDMA_OFFSET_DROP_DATA_EN; + rtl8xxxu_write32(priv, REG_TXDMA_OFFSET_CHK, val32); ++ ++ /* Pre-TX enable WEP/TKIP security */ ++ rtl8xxxu_write8(priv, REG_EARLY_MODE_CONTROL_8188E + 3, 0x01); + } + + struct rtl8xxxu_fileops rtl8188eu_fops = { diff --git a/package/kernel/mac80211/patches/652-0061-rtl8xxxu-Correct-power-down-sequence-for-8188eu.patch b/package/kernel/mac80211/patches/652-0061-rtl8xxxu-Correct-power-down-sequence-for-8188eu.patch new file mode 100644 index 0000000000..cf8c170db8 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0061-rtl8xxxu-Correct-power-down-sequence-for-8188eu.patch @@ -0,0 +1,65 @@ +From 503e2c16e21b49e912bcbe6af5cda34b65e30502 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 30 Aug 2016 17:23:35 -0400 +Subject: [PATCH] rtl8xxxu: Correct power down sequence for 8188eu + +This matches the vendor driver more correctly + +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 26 ++++++++++++++++------ + 1 file changed, 19 insertions(+), 7 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1083,7 +1083,8 @@ static void rtl8188e_disabled_to_emu(str + u16 val16; + + val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); +- val16 &= ~(APS_FSMCO_PFM_WOWL | APS_FSMCO_ENABLE_POWERDOWN); ++ val16 &= ~(APS_FSMCO_PFM_WOWL | APS_FSMCO_ENABLE_POWERDOWN | ++ APS_FSMCO_HW_POWERDOWN); + rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); + } + +@@ -1196,15 +1197,26 @@ static int rtl8188eu_emu_to_disabled(str + { + u8 val8; + +- /* 0x04[12:11] = 01 enable WL suspend */ +- val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 2); +- val8 &= ~BIT(0); +- rtl8xxxu_write8(priv, REG_APS_FSMCO + 2, val8); ++ val8 = rtl8xxxu_read8(priv, REG_AFE_XTAL_CTRL + 2); ++ val8 |= BIT(7); ++ rtl8xxxu_write8(priv, REG_AFE_XTAL_CTRL + 2, val8); + + val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); +- val8 |= BIT(7); ++ val8 &= ~(BIT(3) | BIT(4)); ++ val8 |= BIT(3); + rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); + ++ rtl8xxxu_write8(priv, REG_APS_FSMCO + 3, 0x00); ++ ++ val8 = rtl8xxxu_read8(priv, REG_GPIO_MUXCFG + 1); ++ val8 &= ~BIT(4); ++ rtl8xxxu_write8(priv, REG_GPIO_MUXCFG + 1, val8); ++ ++ /* Set USB suspend enable local register 0xfe10[4]=1 */ ++ val8 = rtl8xxxu_read8(priv, 0xfe10); ++ val8 |= BIT(4); ++ rtl8xxxu_write8(priv, 0xfe10, val8); ++ + return 0; + } + +@@ -1339,7 +1351,7 @@ void rtl8188eu_power_off(struct rtl8xxxu + rtl8xxxu_write8(priv, REG_GPIO_PIN_CTRL + 2, 0xff); + + val8 = rtl8xxxu_read8(priv, REG_GPIO_IO_SEL); +- rtl8xxxu_write8(priv, REG_GPIO_IO_SEL + 1, val8 << 4); ++ rtl8xxxu_write8(priv, REG_GPIO_IO_SEL, val8 << 4); + val8 = rtl8xxxu_read8(priv, REG_GPIO_IO_SEL + 1); + rtl8xxxu_write8(priv, REG_GPIO_IO_SEL + 1, val8 | 0x0f); + diff --git a/package/kernel/mac80211/patches/652-0062-rtl8xxxu-Reset-8188eu-REG_GPIO_MUXCFG-on-power-off.patch b/package/kernel/mac80211/patches/652-0062-rtl8xxxu-Reset-8188eu-REG_GPIO_MUXCFG-on-power-off.patch new file mode 100644 index 0000000000..f09b30cf97 --- /dev/null +++ b/package/kernel/mac80211/patches/652-0062-rtl8xxxu-Reset-8188eu-REG_GPIO_MUXCFG-on-power-off.patch @@ -0,0 +1,21 @@ +From 8953c3173a1b365db19346f31857c10c1439e281 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 30 Aug 2016 17:30:14 -0400 +Subject: [PATCH] rtl8xxxu: Reset 8188eu REG_GPIO_MUXCFG on power off + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1363,6 +1363,8 @@ void rtl8188eu_power_off(struct rtl8xxxu + + rtl8xxxu_write8(priv, REG_RSV_CTRL, 0x00); + ++ rtl8xxxu_write32(priv, REG_GPIO_MUXCFG, 0x00000000); ++ + val16 = rtl8xxxu_read16(priv, REG_APS_FSMCO); + val16 |= APS_FSMCO_ENABLE_POWERDOWN | APS_FSMCO_HW_POWERDOWN; + rtl8xxxu_write16(priv, REG_APS_FSMCO, val16); diff --git a/package/kernel/mac80211/patches/652-0063-rtl8xxxu-Handle-devices-with-a-smaller-LLT-buffer.patch b/package/kernel/mac80211/patches/652-0063-rtl8xxxu-Handle-devices-with-a-smaller-LLT-buffer.patch new file mode 100644 index 0000000000..c81044967f --- /dev/null +++ b/package/kernel/mac80211/patches/652-0063-rtl8xxxu-Handle-devices-with-a-smaller-LLT-buffer.patch @@ -0,0 +1,70 @@ +From 19caed8a5ff27226e22f95a6c082a093c0b7b23f Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 31 Aug 2016 16:31:38 -0400 +Subject: [PATCH] rtl8xxxu: Handle devices with a smaller LLT buffer + +The 8188e (except for I cut parts) seem to have a smaller LLT buffer +than all other known devices. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 + + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 11 ++++++++--- + 3 files changed, 10 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h +@@ -1409,6 +1409,7 @@ struct rtl8xxxu_fileops { + u8 page_num_hi; + u8 page_num_lo; + u8 page_num_norm; ++ u8 last_llt_entry; + }; + + extern int rtl8xxxu_debug; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1454,4 +1454,5 @@ struct rtl8xxxu_fileops rtl8188eu_fops = + .page_num_hi = TX_PAGE_NUM_HI_PQ_8188E, + .page_num_lo = TX_PAGE_NUM_LO_PQ_8188E, + .page_num_norm = TX_PAGE_NUM_NORM_PQ_8188E, ++ .last_llt_entry = 176, + }; +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -2485,11 +2485,16 @@ static int rtl8xxxu_llt_write(struct rtl + int rtl8xxxu_init_llt_table(struct rtl8xxxu_priv *priv) + { + int ret; +- int i; ++ int i, last_entry; + u8 last_tx_page; + + last_tx_page = priv->fops->total_page_num; + ++ if (priv->fops->last_llt_entry) ++ last_entry = priv->fops->last_llt_entry; ++ else ++ last_entry = 255; ++ + for (i = 0; i < last_tx_page; i++) { + ret = rtl8xxxu_llt_write(priv, i, i + 1); + if (ret) +@@ -2501,14 +2506,14 @@ int rtl8xxxu_init_llt_table(struct rtl8x + goto exit; + + /* Mark remaining pages as a ring buffer */ +- for (i = last_tx_page + 1; i < 0xff; i++) { ++ for (i = last_tx_page + 1; i < last_entry; i++) { + ret = rtl8xxxu_llt_write(priv, i, (i + 1)); + if (ret) + goto exit; + } + + /* Let last entry point to the start entry of ring buffer */ +- ret = rtl8xxxu_llt_write(priv, 0xff, last_tx_page + 1); ++ ret = rtl8xxxu_llt_write(priv, last_entry, last_tx_page + 1); + if (ret) + goto exit; + diff --git a/package/kernel/mac80211/patches/652-0064-rtl8xxxu-Write-correct-value-to-REG_CR-in-rtl8188eu_.patch b/package/kernel/mac80211/patches/652-0064-rtl8xxxu-Write-correct-value-to-REG_CR-in-rtl8188eu_.patch new file mode 100644 index 0000000000..883f9ade0d --- /dev/null +++ b/package/kernel/mac80211/patches/652-0064-rtl8xxxu-Write-correct-value-to-REG_CR-in-rtl8188eu_.patch @@ -0,0 +1,24 @@ +From a1967ad244697b2929e462b0579932431387f489 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Tue, 13 Sep 2016 15:13:08 -0400 +Subject: [PATCH] rtl8xxxu: Write correct value to REG_CR in + rtl8188eu_active_to_lps() + +Stupid bug writing the wrong value to register REG_CR. + +Signed-off-by: Jes Sorensen +--- + drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1259,7 +1259,7 @@ static int rtl8188eu_active_to_lps(struc + /* Reset MAC TRX */ + val16 = rtl8xxxu_read16(priv, REG_CR); + val16 &= ~(CR_MAC_TX_ENABLE | CR_MAC_RX_ENABLE | CR_SECURITY_ENABLE); +- rtl8xxxu_write16(priv, REG_CR, val8); ++ rtl8xxxu_write16(priv, REG_CR, val16); + + val8 = rtl8xxxu_read8(priv, REG_DUAL_TSF_RST); + val8 |= DUAL_TSF_TX_OK; diff --git a/package/kernel/mac80211/patches/652-0065-rtl8xxxu-Fix-reloading-of-driver-for-8188eu-devices.patch b/package/kernel/mac80211/patches/652-0065-rtl8xxxu-Fix-reloading-of-driver-for-8188eu-devices.patch new file mode 100644 index 0000000000..4b50b2c83b --- /dev/null +++ b/package/kernel/mac80211/patches/652-0065-rtl8xxxu-Fix-reloading-of-driver-for-8188eu-devices.patch @@ -0,0 +1,72 @@ +From 81e308a3678706670e237501e02b0ea2c7029c94 Mon Sep 17 00:00:00 2001 +From: Jes Sorensen +Date: Wed, 14 Sep 2016 14:10:42 -0400 +Subject: [PATCH] rtl8xxxu: Fix reloading of driver for 8188eu devices + +For 8188eu, once the MAC is asked to power down by setting +APS_FSMCO_MAC_OFF, there seems to be no way to bring it back to life. + +In addition, only disable RF_ENABLE in RF_CTRL rather than all bits. + +This was spotted by Andrea Merello who noticed that if we dropped the +call to rtl8188eu_active_to_emu() reloading started working. + +Reported-by: Andrea Merello +Signed-off-by: Jes Sorensen +--- + .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 29 +++++----------------- + 1 file changed, 6 insertions(+), 23 deletions(-) + +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c +@@ -1160,37 +1160,18 @@ exit: + static int rtl8188eu_active_to_emu(struct rtl8xxxu_priv *priv) + { + u8 val8; +- int count, ret = 0; + + /* Turn off RF */ +- rtl8xxxu_write8(priv, REG_RF_CTRL, 0); ++ val8 = rtl8xxxu_read8(priv, REG_RF_CTRL); ++ val8 &= ~RF_ENABLE; ++ rtl8xxxu_write8(priv, REG_RF_CTRL, val8); + + /* LDO Sleep mode */ + val8 = rtl8xxxu_read8(priv, REG_LPLDO_CTRL); + val8 |= BIT(4); + rtl8xxxu_write8(priv, REG_LPLDO_CTRL, val8); + +- /* 0x0005[1] = 1 turn off MAC by HW state machine*/ +- val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); +- val8 |= BIT(1); +- rtl8xxxu_write8(priv, REG_APS_FSMCO + 1, val8); +- +- for (count = RTL8XXXU_MAX_REG_POLL; count; count--) { +- val8 = rtl8xxxu_read8(priv, REG_APS_FSMCO + 1); +- if ((val8 & BIT(1)) == 0) +- break; +- udelay(10); +- } +- +- if (!count) { +- dev_warn(&priv->udev->dev, "%s: Disabling MAC timed out\n", +- __func__); +- ret = -EBUSY; +- goto exit; +- } +- +-exit: +- return ret; ++ return 0; + } + + static int rtl8188eu_emu_to_disabled(struct rtl8xxxu_priv *priv) +@@ -1372,6 +1353,8 @@ void rtl8188eu_power_off(struct rtl8xxxu + + static void rtl8188e_enable_rf(struct rtl8xxxu_priv *priv) + { ++ rtl8xxxu_write8(priv, REG_RF_CTRL, RF_ENABLE | RF_RSTB | RF_SDMRSTB); ++ + rtl8xxxu_write8(priv, REG_TXPAUSE, 0x00); + } + -- 2.25.1