From fd2b9ff9ccb92d01c809e0452d85818d2c9d882b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Wed, 25 Nov 2020 07:10:35 +0100
Subject: [PATCH 011/463] 8723cs: Make the driver compile and probe, drop
 rockchip platform code

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 drivers/staging/rtl8723cs/Kconfig             |  7 ++-
 drivers/staging/rtl8723cs/Makefile            | 22 +++----
 .../staging/rtl8723cs/core/rtw_ieee80211.c    |  5 +-
 drivers/staging/rtl8723cs/hal/phydm/phydm.mk  |  4 +-
 .../rtl8723cs/hal/phydm/sd4_phydm_2_kernel.mk |  2 +-
 .../rtl8723cs/os_dep/linux/sdio_intf.c        | 57 +------------------
 .../staging/rtl8723cs/platform/platform_ops.c |  4 +-
 7 files changed, 26 insertions(+), 75 deletions(-)

diff --git a/drivers/staging/rtl8723cs/Kconfig b/drivers/staging/rtl8723cs/Kconfig
index 78e5f124ca80c..9b2e6ad9dbbc2 100644
--- a/drivers/staging/rtl8723cs/Kconfig
+++ b/drivers/staging/rtl8723cs/Kconfig
@@ -1,5 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 config RTL8723CS
-	tristate "Realtek 8723C SDIO or SPI WiFi"
-	---help---
+	tristate "Realtek RTL8723CS SDIO or SPI WiFi driver (2020)"
+	depends on WLAN && MMC && CFG80211
+	select WIRELESS_EXT
+	select WEXT_PRIV
+	help
 	  Help message of RTL8723CS
diff --git a/drivers/staging/rtl8723cs/Makefile b/drivers/staging/rtl8723cs/Makefile
index f6a05d0213a66..7105db9b41fe2 100644
--- a/drivers/staging/rtl8723cs/Makefile
+++ b/drivers/staging/rtl8723cs/Makefile
@@ -21,7 +21,7 @@ ifeq ($(GCC_VER_49),1)
 EXTRA_CFLAGS += -Wno-date-time	# Fix compile error && warning on gcc 4.9 and later
 endif
 
-EXTRA_CFLAGS += -I$(src)/include
+EXTRA_CFLAGS += -I$(srctree)/$(src)/include
 
 EXTRA_LDFLAGS += --strip-debug
 
@@ -202,7 +202,7 @@ CONFIG_CUSTOMER_HUAWEI_GENERAL = n
 
 CONFIG_DRVEXT_MODULE = n
 
-export TopDIR ?= $(src)
+export TopDIR ?= $(srctree)/$(src)
 
 ########### COMMON  #################################
 ifeq ($(CONFIG_GSPI_HCI), y)
@@ -268,10 +268,10 @@ _HAL_INTFS_FILES :=	hal/hal_intf.o \
 			hal/led/hal_$(HCI_NAME)_led.o
 
 
-EXTRA_CFLAGS += -I$(src)/platform
+EXTRA_CFLAGS += -I$(srctree)/$(src)/platform
 _PLATFORM_FILES := platform/platform_ops.o
 
-EXTRA_CFLAGS += -I$(src)/hal/btc
+EXTRA_CFLAGS += -I$(srctree)/$(src)/hal/btc
 
 ########### HAL_RTL8188E #################################
 ifeq ($(CONFIG_RTL8188E), y)
@@ -2331,31 +2331,31 @@ endif
 ifneq ($(KERNELRELEASE),)
 
 ########### this part for *.mk ############################
-include $(src)/hal/phydm/phydm.mk
+include $(srctree)/$(src)/hal/phydm/phydm.mk
 
 ########### HAL_RTL8822B #################################
 ifeq ($(CONFIG_RTL8822B), y)
-include $(src)/rtl8822b.mk
+include $(srctree)/$(src)/rtl8822b.mk
 endif
 
 ########### HAL_RTL8821C #################################
 ifeq ($(CONFIG_RTL8821C), y)
-include $(src)/rtl8821c.mk
+include $(srctree)/$(src)/rtl8821c.mk
 endif
 
 ########### HAL_RTL8822C #################################
 ifeq ($(CONFIG_RTL8822C), y)
-include $(src)/rtl8822c.mk
+include $(srctree)/$(src)/rtl8822c.mk
 endif
 
 ########### HAL_RTL8814B #################################
 ifeq ($(CONFIG_RTL8814B), y)
-include $(src)/rtl8814b.mk
+include $(srctree)/$(src)/rtl8814b.mk
 endif
 
 ########### HAL_RTL8723F #################################
 ifeq ($(CONFIG_RTL8723F), y)
-include $(src)/rtl8723f.mk
+include $(srctree)/$(src)/rtl8723f.mk
 endif
 
 rtk_core :=	core/rtw_cmd.o \
@@ -2405,7 +2405,7 @@ ifeq ($(CONFIG_SDIO_HCI), y)
 rtk_core += core/rtw_sdio.o
 endif
 
-EXTRA_CFLAGS += -I$(src)/core/crypto
+EXTRA_CFLAGS += -I$(srctree)/$(src)/core/crypto
 rtk_core += \
 		core/crypto/aes-internal.o \
 		core/crypto/aes-internal-enc.o \
diff --git a/drivers/staging/rtl8723cs/core/rtw_ieee80211.c b/drivers/staging/rtl8723cs/core/rtw_ieee80211.c
index 26d4d4bcff713..d37273216a315 100644
--- a/drivers/staging/rtl8723cs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723cs/core/rtw_ieee80211.c
@@ -18,7 +18,7 @@
 	#include <linux/fs.h>
 #endif
 #include <drv_types.h>
-#include <linux/rfkill-wlan.h>
+#include <linux/rfkill.h>
 
 u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 };
 u16 RTW_WPA_VERSION = 1;
@@ -1774,11 +1774,12 @@ void rtw_macaddr_cfg(u8 *out, const u8 *hw_mac_addr)
 		_rtw_memcpy(mac, hw_mac_addr, ETH_ALEN);
 	}
 
+	/*
 	if (!rockchip_wifi_mac_addr(mac)) {
 		printk("get mac address from flash=[%02x:%02x:%02x:%02x:%02x:%02x]\n", mac[0], mac[1],
 		mac[2], mac[3], mac[4], mac[5]);
 	}
-
+          */
 err_chk:
 	if (rtw_check_invalid_mac_address(mac, _TRUE) == _TRUE) {
 #if DEFAULT_RANDOM_MACADDR
diff --git a/drivers/staging/rtl8723cs/hal/phydm/phydm.mk b/drivers/staging/rtl8723cs/hal/phydm/phydm.mk
index 042db19d26bae..dcf9199097819 100644
--- a/drivers/staging/rtl8723cs/hal/phydm/phydm.mk
+++ b/drivers/staging/rtl8723cs/hal/phydm/phydm.mk
@@ -1,4 +1,4 @@
-EXTRA_CFLAGS += -I$(src)/hal/phydm
+EXTRA_CFLAGS += -I$(srctree)/$(src)/hal/phydm
 
 _PHYDM_FILES := hal/phydm/phydm_debug.o	\
 								hal/phydm/phydm_antdiv.o\
@@ -245,4 +245,4 @@ _PHYDM_FILES += hal/phydm/$(RTL871X)/halhwimg8723f_bb.o\
 								hal/phydm/halrf/$(RTL871X)/halrf_dpk_8723f.o\
 								hal/phydm/halrf/$(RTL871X)/halrf_rfk_init_8723f.o\
 								hal/phydm/halrf/$(RTL871X)/halhwimg8723f_rf.o
-endif
\ No newline at end of file
+endif
diff --git a/drivers/staging/rtl8723cs/hal/phydm/sd4_phydm_2_kernel.mk b/drivers/staging/rtl8723cs/hal/phydm/sd4_phydm_2_kernel.mk
index f11c6ac90bf52..09898476ededd 100644
--- a/drivers/staging/rtl8723cs/hal/phydm/sd4_phydm_2_kernel.mk
+++ b/drivers/staging/rtl8723cs/hal/phydm/sd4_phydm_2_kernel.mk
@@ -1,4 +1,4 @@
-EXTRA_CFLAGS += -I$(src)/hal/phydm
+EXTRA_CFLAGS += -I$(srctree)/$(src)/hal/phydm
 
 _PHYDM_FILES := hal/phydm/phydm_debug.o	\
 								hal/phydm/phydm_interface.o\
diff --git a/drivers/staging/rtl8723cs/os_dep/linux/sdio_intf.c b/drivers/staging/rtl8723cs/os_dep/linux/sdio_intf.c
index ac8ef8bce5180..23964c5c64ffd 100644
--- a/drivers/staging/rtl8723cs/os_dep/linux/sdio_intf.c
+++ b/drivers/staging/rtl8723cs/os_dep/linux/sdio_intf.c
@@ -1403,58 +1403,5 @@ int rtw_sdio_set_power(int on)
 }
 #endif /* CONFIG_PLATFORM_INTEL_BYT */
 
-#include <linux/rfkill-wlan.h>
-extern int get_wifi_chip_type(void);
-extern int rockchip_wifi_power(int on);
-extern int rockchip_wifi_set_carddetect(int val);
-
-int rockchip_wifi_init_module_rtkwifi(void)
-{
-#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
-    int type = get_wifi_chip_type();
-    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
-#endif
-    printk("\n");
-    printk("=======================================================\n");
-    printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====\n");
-    printk("=======================================================\n");
-    printk("Realtek 8723CS SDIO WiFi driver (Powered by Rockchip,Ver %s) init.\n", DRIVERVERSION);
-
-    rockchip_wifi_power(1);
-    rockchip_wifi_set_carddetect(1);
-
-    return rtw_drv_entry();
-}
-
-void rockchip_wifi_exit_module_rtkwifi(void)
-{
-#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
-    int type = get_wifi_chip_type();
-    if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
-#endif
-    printk("\n");
-    printk("=======================================================\n");
-    printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====\n");
-    printk("=======================================================\n");
-    printk("Realtek 8723CS SDIO WiFi driver (Powered by Rockchip,Ver %s) init.\n", DRIVERVERSION);
-
-    rtw_drv_halt();
-
-    rockchip_wifi_set_carddetect(0);
-    rockchip_wifi_power(0);
-}
-#ifdef CONFIG_WIFI_BUILD_MODULE
-module_init(rockchip_wifi_init_module_rtkwifi);
-module_exit(rockchip_wifi_exit_module_rtkwifi);
-#else
-#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
-late_initcall(rockchip_wifi_init_module_rtkwifi);
-module_exit(rockchip_wifi_exit_module_rtkwifi);
-#else
-EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
-EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
-#endif
-#endif
-//module_init(rtw_drv_entry);
-//module_exit(rtw_drv_halt);
-
+module_init(rtw_drv_entry);
+module_exit(rtw_drv_halt);
diff --git a/drivers/staging/rtl8723cs/platform/platform_ops.c b/drivers/staging/rtl8723cs/platform/platform_ops.c
index c281dcb8f121c..de08abc00759e 100644
--- a/drivers/staging/rtl8723cs/platform/platform_ops.c
+++ b/drivers/staging/rtl8723cs/platform/platform_ops.c
@@ -18,13 +18,13 @@
  *	0:	power on successfully
  *	others: power on failed
  */
-#include <linux/rfkill-wlan.h>
+#include <linux/rfkill.h>
 extern unsigned int oob_irq;
 int platform_wifi_power_on(void)
 {
 	int ret = 0;
 
-	oob_irq = rockchip_wifi_get_oob_irq();
+	//oob_irq = rockchip_wifi_get_oob_irq();
 	return ret;
 }
 
-- 
2.46.0

