Skip to content

Instantly share code, notes, and snippets.

@amery
Created July 11, 2012 16:58
Show Gist options
  • Save amery/3091730 to your computer and use it in GitHub Desktop.
Save amery/3091730 to your computer and use it in GitHub Desktop.
[PATCH] arm: sun4i: rtl8192cu wifi enabler
From 3b18c169fab56165763b7ccdb265650a6379b546 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emilio=20L=C3=B3pez?= <turl@tuxfamily.org>
Date: Wed, 6 Jun 2012 22:48:07 +0000
Subject: [PATCH] arm: sun4i: rtl8192cu wifi enabler
The sun4i-rtl8192cu will power and enable the rtl8192cu wifi chip
on the sun4i platform, so you can use the rtl8192cu mainline driver.
Choosing y will enable it on boot, choosing m will give you a
loadable module to turn it on/off.
---
arch/arm/mach-sun4i/Kconfig | 2 ++
arch/arm/mach-sun4i/Makefile | 1 +
arch/arm/mach-sun4i/wifi/Kconfig | 4 +++
arch/arm/mach-sun4i/wifi/Makefile | 1 +
arch/arm/mach-sun4i/wifi/sun4i-rtl8192cu.c | 40 ++++++++++++++++++++++++++++
5 files changed, 48 insertions(+)
create mode 100644 arch/arm/mach-sun4i/wifi/Kconfig
create mode 100644 arch/arm/mach-sun4i/wifi/Makefile
create mode 100644 arch/arm/mach-sun4i/wifi/sun4i-rtl8192cu.c
diff --git a/arch/arm/mach-sun4i/Kconfig b/arch/arm/mach-sun4i/Kconfig
index e35bf58..1a936c6 100644
--- a/arch/arm/mach-sun4i/Kconfig
+++ b/arch/arm/mach-sun4i/Kconfig
@@ -13,4 +13,6 @@ config SW_DEBUG_UART
Choose the UART on which kernel low-level debug messages should be
output.
+source "arch/arm/mach-sun4i/wifi/Kconfig"
+
endif
diff --git a/arch/arm/mach-sun4i/Makefile b/arch/arm/mach-sun4i/Makefile
index cd49c0e..7a98787 100755
--- a/arch/arm/mach-sun4i/Makefile
+++ b/arch/arm/mach-sun4i/Makefile
@@ -1,5 +1,6 @@
obj-y += clock/
obj-y += dma/
+obj-y += wifi/
obj-y += core.o devices.o sys_config.o
obj-$(CONFIG_PM) += pm/
obj-$(CONFIG_CPU_FREQ) += cpu-freq/
diff --git a/arch/arm/mach-sun4i/wifi/Kconfig b/arch/arm/mach-sun4i/wifi/Kconfig
new file mode 100644
index 0000000..81652b5
--- /dev/null
+++ b/arch/arm/mach-sun4i/wifi/Kconfig
@@ -0,0 +1,4 @@
+config SUN4I_RTL8192CU
+ tristate "Enable RTL8192CU chip"
+ depends on RTL8192CU
+ default n
diff --git a/arch/arm/mach-sun4i/wifi/Makefile b/arch/arm/mach-sun4i/wifi/Makefile
new file mode 100644
index 0000000..61583ed
--- /dev/null
+++ b/arch/arm/mach-sun4i/wifi/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_SUN4I_RTL8192CU) += sun4i-rtl8192cu.o
diff --git a/arch/arm/mach-sun4i/wifi/sun4i-rtl8192cu.c b/arch/arm/mach-sun4i/wifi/sun4i-rtl8192cu.c
new file mode 100644
index 0000000..579bab3
--- /dev/null
+++ b/arch/arm/mach-sun4i/wifi/sun4i-rtl8192cu.c
@@ -0,0 +1,40 @@
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <mach/sys_config.h>
+
+extern int sw_usb_disable_hcd(__u32 usbc_no);
+extern int sw_usb_enable_hcd(__u32 usbc_no);
+static int usb_wifi_host = 2;
+
+static int __init sun4i_enable_rtl8192cu_wifi(void)
+{
+ int ret = 0;
+
+ ret = script_parser_fetch("usb_wifi_para", "usb_wifi_usbc_num", (int *)&usb_wifi_host, 64);
+ if(ret != 0) {
+ printk(KERN_ERR "script_parser_fetch usb_wifi_usbc_num failed\n");
+ ret = -ENOMEM;
+ return ret;
+ }
+
+ printk(KERN_INFO "sw_usb_enable_hcd: usbc_num = %d\n", usb_wifi_host);
+
+ sw_usb_enable_hcd(usb_wifi_host);
+
+ return ret;
+}
+
+static void __exit sun4i_disable_rtl8192cu_wifi(void)
+{
+ printk(KERN_INFO "sw_usb_disable_hcd: usbc_num = %d\n", usb_wifi_host);
+ sw_usb_disable_hcd(usb_wifi_host);
+}
+
+
+module_init(sun4i_enable_rtl8192cu_wifi);
+module_exit(sun4i_disable_rtl8192cu_wifi);
+
+MODULE_DESCRIPTION("Enable RTL8192CU on SUN4I");
+MODULE_LICENSE("GPL");
+
--
1.7.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment