From 578a8c991824de499bb8810b05361b69256322d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Wed, 4 Jan 2023 12:03:27 +0000 Subject: [PATCH] wifi/pc: add rtlwifi driver Due to lacking hardware access the driver was test with one RTL8188EE based device, namely [10ec:8179] (rev 01), only. As the access to the PCI config space is restricted the driver loads the non power-saving FW and the driver port is therefor only tested with that. The accesses are documented should we choose to support them one way or another later on. The 'wifi.run' run script as well as Sculpt served as testing ground where the driver worked fine so far. Fixes #4714. --- repos/dde_linux/ports/linux-firmware.hash | 2 +- repos/dde_linux/ports/linux-firmware.port | 4 +- .../recipes/raw/wifi_firmware/content.mk | 1 + repos/pc/lib/mk/wifi.inc | 2 + repos/pc/lib/mk/wifi_firmware.mk | 4 + repos/pc/run/wifi.run | 2 + repos/pc/src/include/lx_emul/initcall_order.h | 2 + repos/pc/src/lib/wifi/dep.list | 31 +++++++ repos/pc/src/lib/wifi/dummies.c | 14 +++ repos/pc/src/lib/wifi/firmware.cc | 5 ++ repos/pc/src/lib/wifi/lx_emul.c | 87 ++++++++++++++++++- repos/pc/src/lib/wifi/spec/x86_32/source.list | 20 +++++ repos/pc/src/lib/wifi/spec/x86_64/source.list | 20 +++++ repos/pc/src/pc_linux/target.inc | 3 + 14 files changed, 192 insertions(+), 5 deletions(-) diff --git a/repos/dde_linux/ports/linux-firmware.hash b/repos/dde_linux/ports/linux-firmware.hash index 946b3f2507..5f5646e621 100644 --- a/repos/dde_linux/ports/linux-firmware.hash +++ b/repos/dde_linux/ports/linux-firmware.hash @@ -1 +1 @@ -e9fdf82a31f0106cd2604a644685e7c080a12d09 +1e536cdd935a3c4fe906d49533a4762ffffdc6ee diff --git a/repos/dde_linux/ports/linux-firmware.port b/repos/dde_linux/ports/linux-firmware.port index 981d16a09f..5a56c426dd 100644 --- a/repos/dde_linux/ports/linux-firmware.port +++ b/repos/dde_linux/ports/linux-firmware.port @@ -2,7 +2,7 @@ LICENSE := mixed VERSION := 1 DOWNLOADS := fw.archive -FW_REV := cbd51e5ee647ec834c30a3987225cae2341753b0 +FW_REV := 416c8baf3066e4fbf5c6bf610c37a1f50ffb77b9 URL(fw) := https://github.com/cnuke/dde_linux_firmware/archive/$(FW_REV).tar.gz -SHA(fw) := 486e3e4cc3022acca2b134c11feb8d3bbc4bd07a588a7c56e6fc07174bf3d573 +SHA(fw) := 60ed44d326b0f8a007b41ec46a24f8a9a3d807c40b75e3ba9757995f78ae9bcc DIR(fw) := firmware diff --git a/repos/dde_linux/recipes/raw/wifi_firmware/content.mk b/repos/dde_linux/recipes/raw/wifi_firmware/content.mk index e401f3c944..c7a47dc800 100644 --- a/repos/dde_linux/recipes/raw/wifi_firmware/content.mk +++ b/repos/dde_linux/recipes/raw/wifi_firmware/content.mk @@ -5,6 +5,7 @@ content: ucode_files LICENSE.wifi_drv .PHONY: ucode_files ucode_files: + cp $(PORT_DIR)/firmware/*.bin . cp $(PORT_DIR)/firmware/*.ucode . cp $(PORT_DIR)/firmware/*.pnvm . cp $(PORT_DIR)/firmware/regulatory.db . diff --git a/repos/pc/lib/mk/wifi.inc b/repos/pc/lib/mk/wifi.inc index 54583be571..88052e0cfb 100644 --- a/repos/pc/lib/mk/wifi.inc +++ b/repos/pc/lib/mk/wifi.inc @@ -27,6 +27,8 @@ SRC_C += $(notdir $(wildcard $(TARGET_LIB_DIR)/generated_dummies.c)) SRC_C += lx_emul/common_dummies.c CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/intel/iwlwifi +CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/realtek/rtlwifi +CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl8188ee CC_C_OPT += -I$(LX_SRC_DIR)/include/linux CC_C_OPT += -Wno-address-of-packed-member diff --git a/repos/pc/lib/mk/wifi_firmware.mk b/repos/pc/lib/mk/wifi_firmware.mk index bad533c218..9ce61d4c44 100644 --- a/repos/pc/lib/mk/wifi_firmware.mk +++ b/repos/pc/lib/mk/wifi_firmware.mk @@ -6,6 +6,7 @@ FW_CONTRIB_DIR := $(call select_from_ports,linux-firmware) IMAGES := $(notdir $(wildcard $(FW_CONTRIB_DIR)/firmware/*.ucode)) IMAGES += $(notdir $(wildcard $(FW_CONTRIB_DIR)/firmware/*.pnvm)) +IMAGES += $(notdir $(wildcard $(FW_CONTRIB_DIR)/firmware/*.bin)) IMAGES += $(notdir $(wildcard $(FW_CONTRIB_DIR)/firmware/*.db)) IMAGES += $(notdir $(wildcard $(FW_CONTRIB_DIR)/firmware/*.p7s)) BIN_DIR := $(BUILD_BASE_DIR)/bin @@ -13,6 +14,9 @@ FW_DIR := $(FW_CONTRIB_DIR)/firmware CUSTOM_TARGET_DEPS += $(addprefix $(BIN_DIR)/,$(IMAGES)) +$(BIN_DIR)/%.bin: $(FW_DIR)/%.bin + $(VERBOSE)cp $^ $@ + $(BIN_DIR)/%.ucode: $(FW_DIR)/%.ucode $(VERBOSE)cp $^ $@ diff --git a/repos/pc/run/wifi.run b/repos/pc/run/wifi.run index 5b4bd460a1..9088198ee9 100644 --- a/repos/pc/run/wifi.run +++ b/repos/pc/run/wifi.run @@ -314,6 +314,8 @@ set firmware_modules { iwlwifi-9000-pu-b0-jf-b0-34.ucode iwlwifi-9000-pu-b0-jf-b0-46.ucode iwlwifi-QuZ-a0-hr-b0-63.ucode + rtl8192eu_nic.bin + rtl8188efw.bin regulatory.db regulatory.db.p7s } diff --git a/repos/pc/src/include/lx_emul/initcall_order.h b/repos/pc/src/include/lx_emul/initcall_order.h index eff6274450..8d13a2509b 100644 --- a/repos/pc/src/include/lx_emul/initcall_order.h +++ b/repos/pc/src/include/lx_emul/initcall_order.h @@ -205,6 +205,8 @@ static const char * lx_emul_initcall_order[] = { "__initcall_iwl_drv_init6", "__initcall_iwl_init6", "__initcall_iwl_mvm_init6", + "__initcall_rtl_core_module_init6", + "__initcall_rtl88ee_driver_init6", "__initcall_asix_driver_init6", "__initcall_ax88179_178a_driver_init6", "__initcall_cdc_driver_init6", diff --git a/repos/pc/src/lib/wifi/dep.list b/repos/pc/src/lib/wifi/dep.list index 75ff76de22..7a934a2eac 100644 --- a/repos/pc/src/lib/wifi/dep.list +++ b/repos/pc/src/lib/wifi/dep.list @@ -88,6 +88,37 @@ drivers/net/wireless/intel/iwlwifi/mvm/testmode.h drivers/net/wireless/intel/iwlwifi/mvm/time-event.h drivers/net/wireless/intel/iwlwifi/pcie/internal.h drivers/net/wireless/intel/iwlwifi/queue/tx.h +drivers/net/wireless/realtek/rtlwifi/base.h +drivers/net/wireless/realtek/rtlwifi/btcoexist/halbt_precomp.h +drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.h +drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.h +drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.h +drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h +drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h +drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.h +drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h +drivers/net/wireless/realtek/rtlwifi/cam.h +drivers/net/wireless/realtek/rtlwifi/core.h +drivers/net/wireless/realtek/rtlwifi/debug.h +drivers/net/wireless/realtek/rtlwifi/efuse.h +drivers/net/wireless/realtek/rtlwifi/pci.h +drivers/net/wireless/realtek/rtlwifi/ps.h +drivers/net/wireless/realtek/rtlwifi/pwrseqcmd.h +drivers/net/wireless/realtek/rtlwifi/rc.h +drivers/net/wireless/realtek/rtlwifi/regd.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/def.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/led.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/pwrseq.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/reg.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/rf.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/table.h +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.h +drivers/net/wireless/realtek/rtlwifi/stats.h +drivers/net/wireless/realtek/rtlwifi/wifi.h include/crypto/acompress.h include/crypto/aead.h include/crypto/aes.h diff --git a/repos/pc/src/lib/wifi/dummies.c b/repos/pc/src/lib/wifi/dummies.c index 5edfb9da31..005fd51c38 100644 --- a/repos/pc/src/lib/wifi/dummies.c +++ b/repos/pc/src/lib/wifi/dummies.c @@ -341,6 +341,8 @@ void synchronize_rcu_expedited(void) } +#include + int pci_enable_msi(struct pci_dev *dev) { lx_emul_trace(__func__); @@ -348,9 +350,21 @@ int pci_enable_msi(struct pci_dev *dev) } +void pci_disable_msi(struct pci_dev *dev) +{ + lx_emul_trace(__func__); +} + + int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, int maxvec) { lx_emul_trace(__func__); return -ENOSYS; } + + +void pci_disable_device(struct pci_dev * dev) +{ + lx_emul_trace(__func__); +} diff --git a/repos/pc/src/lib/wifi/firmware.cc b/repos/pc/src/lib/wifi/firmware.cc index 195cdc56e7..a386257dd0 100644 --- a/repos/pc/src/lib/wifi/firmware.cc +++ b/repos/pc/src/lib/wifi/firmware.cc @@ -48,6 +48,11 @@ Firmware_list fw_list[] = { { "iwlwifi-so-a0-hr-b0-64.ucode", 1427384, nullptr }, { "iwlwifi-so-a0-gf-a0-64.ucode", 1515812, nullptr }, { "iwlwifi-so-a0-gf-a0.pnvm", 41808, nullptr }, + + { "rtl8192eu_nic.bin", 31818, nullptr }, + { "rtlwifi/rtl8192eefw.bin", 31818, "rtl8192eu_nic.bin" }, + { "rtl8188efw.bin", 11216, nullptr }, + { "rtlwifi/rtl8188efw.bin", 11216, "rtl8188efw.bin" }, /* FW Power Save off */ }; diff --git a/repos/pc/src/lib/wifi/lx_emul.c b/repos/pc/src/lib/wifi/lx_emul.c index ae803ea61e..297dec8862 100644 --- a/repos/pc/src/lib/wifi/lx_emul.c +++ b/repos/pc/src/lib/wifi/lx_emul.c @@ -594,8 +594,28 @@ int pci_write_config_byte(const struct pci_dev * dev,int where,u8 val) */ case PCI_CFG_RETRY_TIMEOUT: return 0; + + /* + * rtlwifi: "leave D3 mode" + */ + case 0x44: + case PCI_COMMAND: + return 0; + /* + * rtlwifi: needed for enabling DMA 64bit support + */ + case 0x719: + return 0; + /* + * rtlwifi: below are registers related to ASPM and PCI link + * control that we do not handle (yet). + */ + case 0x81: + case 0x98: + return 0; }; - lx_emul_trace_and_stop(__func__); + + return -1; } @@ -605,6 +625,69 @@ int pci_read_config_word(const struct pci_dev * dev,int where,u16 * val) case PCI_COMMAND: *val = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO; return 0; + /* + * rtlwifi: read but ignored + */ + case PCI_INTERRUPT_LINE: + *val = 0; + return 0; }; - lx_emul_trace_and_stop(__func__); + + return -1; +} + + +int pci_read_config_byte(const struct pci_dev * dev,int where,u8 * val) +{ + switch (where) { + /* + * rtlwifi: apparently needed for device distinction + */ + case PCI_REVISION_ID: + *val = dev->revision; + return 0; + /* + * rtlwifi: needed for enabling DMA 64bit support + */ + case 0x719: + *val = 0; + return 0; + /* + * rtlwifi: below are registers related to ASPM and PCI link + * control that we do not handle (yet). + */ + case 0x80: + case 0x81: + case 0x98: + *val = 0; + return 0; + } + + return -1; +} + + +void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) +{ + struct resource *r; + unsigned long phys_addr; + unsigned long size; + + if (!dev || bar > 5) { + printk("%s:%d: invalid request for dev: %p bar: %d\n", + __func__, __LINE__, dev, bar); + return NULL; + } + + printk("pci_iomap: request for dev: %s bar: %d\n", dev_name(&dev->dev), bar); + + r = &dev->resource[bar]; + + phys_addr = r->start; + size = r->end - r->start; + + if (!phys_addr || !size) + return NULL; + + return lx_emul_io_mem_map(phys_addr, size); } diff --git a/repos/pc/src/lib/wifi/spec/x86_32/source.list b/repos/pc/src/lib/wifi/spec/x86_32/source.list index 35f22c35b1..08e2f59251 100644 --- a/repos/pc/src/lib/wifi/spec/x86_32/source.list +++ b/repos/pc/src/lib/wifi/spec/x86_32/source.list @@ -116,6 +116,26 @@ drivers/net/wireless/intel/iwlwifi/pcie/trans.c drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c drivers/net/wireless/intel/iwlwifi/pcie/tx.c drivers/net/wireless/intel/iwlwifi/queue/tx.c +drivers/net/wireless/realtek/rtlwifi/base.c +drivers/net/wireless/realtek/rtlwifi/cam.c +drivers/net/wireless/realtek/rtlwifi/core.c +drivers/net/wireless/realtek/rtlwifi/debug.c +drivers/net/wireless/realtek/rtlwifi/efuse.c +drivers/net/wireless/realtek/rtlwifi/pci.c +drivers/net/wireless/realtek/rtlwifi/ps.c +drivers/net/wireless/realtek/rtlwifi/rc.c +drivers/net/wireless/realtek/rtlwifi/regd.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/led.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/pwrseq.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/rf.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/table.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c +drivers/net/wireless/realtek/rtlwifi/stats.c drivers/pci/pci-driver.c fs/nls/nls_base.c kernel/irq/chip.c diff --git a/repos/pc/src/lib/wifi/spec/x86_64/source.list b/repos/pc/src/lib/wifi/spec/x86_64/source.list index 40f2646615..e2b8a215f3 100644 --- a/repos/pc/src/lib/wifi/spec/x86_64/source.list +++ b/repos/pc/src/lib/wifi/spec/x86_64/source.list @@ -116,6 +116,26 @@ drivers/net/wireless/intel/iwlwifi/pcie/trans.c drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c drivers/net/wireless/intel/iwlwifi/pcie/tx.c drivers/net/wireless/intel/iwlwifi/queue/tx.c +drivers/net/wireless/realtek/rtlwifi/base.c +drivers/net/wireless/realtek/rtlwifi/cam.c +drivers/net/wireless/realtek/rtlwifi/core.c +drivers/net/wireless/realtek/rtlwifi/debug.c +drivers/net/wireless/realtek/rtlwifi/efuse.c +drivers/net/wireless/realtek/rtlwifi/pci.c +drivers/net/wireless/realtek/rtlwifi/ps.c +drivers/net/wireless/realtek/rtlwifi/rc.c +drivers/net/wireless/realtek/rtlwifi/regd.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/led.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/pwrseq.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/rf.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/table.c +drivers/net/wireless/realtek/rtlwifi/rtl8188ee/trx.c +drivers/net/wireless/realtek/rtlwifi/stats.c drivers/pci/pci-driver.c fs/nls/nls_base.c kernel/irq/chip.c diff --git a/repos/pc/src/pc_linux/target.inc b/repos/pc/src/pc_linux/target.inc index f282ab6646..ebcaae8d24 100644 --- a/repos/pc/src/pc_linux/target.inc +++ b/repos/pc/src/pc_linux/target.inc @@ -31,6 +31,9 @@ LX_ENABLE += RFKILL # iwlwifi LX_ENABLE += WLAN_VENDOR_INTEL IWLWIFI IWLDVM IWLMVM +# rtlwifi +LX_ENABLE += WLAN_VENDOR_REALTEK RTL_CARDS RTL8188EE + # USB host-controller support LX_ENABLE += USB_SUPPORT USB USB_ARCH_HAS_HCD USB_XHCI_HCD USB_EHCI_HCD USB_OHCI_HCD LX_ENABLE += USB_PCI USB_UHCI_HCD USB_USBNET