您的位置:首页 > 其它

wifi(rtl8188eu)移植及调试笔记

2017-08-01 20:56 309 查看
/*

* Dave/nova_wangwenbo@126.com

*/

wifi移植及调试笔记

一.rtl8188eu

1.修改设备树:

添加wifi ap电源控制引脚

WIFI,power_ap_gpio = <&gpio3 GPIO_B5 GPIO_ACTIVE_LOW>;


2.修改文件:include/linux/rfkill-wlan.h

增加gpio资源:

struct rksdmmc_iomux {
char    *name;  //set the MACRO of gpio
int     fgpio;
int     fmux;
};


struct rksdmmc_gpio {
int     io;                             //set the address of gpio
char    name[64];   //
int     enable;  // disable = !enable   //set the default value,i.e,GPIO_HIGH or GPIO_LOW
struct rksdmmc_iomux  iomux;
};


struct rksdmmc_pmu {
bool power_ctrl_by_pmu;
char pmu_regulator[20];
int  enable;
};


struct rksdmmc_gpio_wifi_moudle {
int sdio_vol;    //sdio reference voltage
bool vref_ctrl_enble;
bool wifi_power_remain;
struct rksdmmc_pmu    mregulator;
struct rksdmmc_pmu    ioregulator;
struct rksdmmc_gpio   power_n;  //PMU_EN
struct rksdmmc_gpio   reset_n;  //SYSRET_B, DAIRST
struct rksdmmc_gpio   vddio;
struct rksdmmc_gpio   bgf_int_b;
struct rksdmmc_gpio   wifi_int_b;
struct rksdmmc_gpio   gps_sync;
struct rksdmmc_gpio   ANTSEL2;  //pin5--ANTSEL2
struct rksdmmc_gpio   ANTSEL3;  //pin6--ANTSEL3
struct rksdmmc_gpio   GPS_LAN;  //pin33--GPS_LAN
struct regmap *grf;
struct rksdmmc_gpio   power_ap;   //add
};


3.修改文件:linux-3.10.0-rk32xx/net/rfkill/rfkill-wlan.c

<1>.申请gpio资源,修改函数如下:

static int wlan_platdata_parse_dt(struct device *dev, struct rksdmmc_gpio_wifi_moudle *data)
gpio = of_get_named_gpio_flags(node, "WIFI,power_ap_gpio", 0, &flags);
if (gpio_is_valid(gpio)){
data->power_ap.io = gpio;
data->power_ap.enable = (flags == GPIO_ACTIVE_HIGH)? 1:0;
LOG("%s: get property: WIFI,power_ap_gpio = %d, flags = %d.\n", __func__, gpio, flags);
}
else data->power_ap.io = -1;


<2>.power控制函数:


int rockchip_wifi_power_ap(int on)
{
struct rfkill_wlan_data *mrfkill = g_rfkill;

LOG("%s: %d\n", __func__, on);

if (mrfkill == NULL) {
LOG("%s: rfkill-wlan driver has not Successful initialized\n", __func__);
return -1;
}
poweron = &mrfkill->pdata->power_ap;
if (on){
if (gpio_is_valid(poweron->io)) {
gpio_set_value(poweron->io, poweron->enable);
msleep(100);
}
if (gpio_is_valid(reset->io)) {
gpio_set_value(reset->io, reset->enable);
msleep(100);
}
wifi_power_state = 1;
LOG("wifi turn on power. %d\n", poweron->io);
}else{
if (gpio_is_valid(poweron->io)) {
gpio_set_value(poweron->io, !(poweron->enable));
msleep(100);
}
if (gpio_is_valid(reset->io)) {
gpio_set_value(reset->io, !(reset->enable));
}
wifi_power_state = 0;
LOG("wifi shut off power.\n");
}
return 0;
}
EXPORT_SYMBOL(rockchip_wifi_power_ap);


<3>.匹配函数修改添加:


int rfkill_wlan_probe(struct platform_device *pdev)
if (gpio_is_valid(pdata->power_p.io))
{
gpio_direction_output(pdata->power_ap.io, !pdata->power_ap.enable);
}
{
-rockchip_wifi_power(1); //原有
+rockchip_wifi_power_ap(1);//add
}


<4>.移除函数修改与添加


static int rfkill_wlan_remove(struct platform_device *pdev)
+if (gpio_is_valid(rfkill->pdata->power_ap.io))
+gpio_free(rfkill->pdata->power_ap.io);


4.在/sys/class/rkwifi/下添加控制节点

添加节点1. /sys/class/rkwifi/power_ap

+static ssize_t wifi_power_write_ap(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count)
{
int poweren = 0;
poweren = simple_strtol(_buf, NULL, 10);
printk("%s: poweren = %d\n", __func__, poweren);
if(poweren > 0) {
rockchip_wifi_power_ap(1);
} else {
rockchip_wifi_power_ap(0);
}
return _count;
}
+static CLASS_ATTR(power_ap, 0660, NULL, wifi_power_write_ap);


在入口函数rkwifi_sysif_init(void)添加:


+ret =  class_create_file(rkwifi_class, &class_attr_power_ap);


在出口函数rkwifi_sysif_exit(void)添加:


+class_remove_file(rkwifi_class, &class_attr_power_ap);


添加节点2. /sys/class/rkwifi/ap


+static ssize_t wifi_driver_ap(struct class *cls, struct class_attribute *attr, const char *_buf, size_t _count)
{
int enable = 0, ret = 0;
down(&driver_sem);
enable = simple_strtol(_buf, NULL, 10);
//printk("%s: enable = %d\n", __func__, enable);
if (ap_driver_insmod == enable) {
printk("%s: wifi driver already %s\n", __func__, enable? "insmod":"rmmod");
up(&driver_sem);
return _count;
}
if(enable > 0) {
ret = ap_init_exit_module(enable);
if (ret >= 0)
ap_driver_insmod = enable;
} else {
ap_init_exit_module(enable);
ap_driver_insmod = enable;
}
up(&driver_sem);
return _count;
}
static CLASS_ATTR(ap, 0660, NULL, wifi_driver_ap);


在入口函数rkwifi_sysif_init(void)添加:


ret =  class_create_file(rkwifi_class, &class_attr_ap)


在出口函数rkwifi_sysif_exit(void)添加:


class_remove_file(rkwifi_class, &class_attr_ap);


5.将power gpio与rtl8188eu驱动进行关联

rockchip_wifi_init_module_rtkwifi()函数中注-if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;

-rockchip_wifi_power(1);

+rockchip_wifi_power_ap(1);rockchip_wifi_exit_module_rtkwifi(void)函数中注释

-if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
-rockchip_wifi_power(0);
+rockchip_wifi_power_ap(0);
6.启动rtl8188eu ap模式


echo 1 > /sys/class/rfwifi/power_ap
echo 1 > /sys/class/rfwifi/ap
ifconfig wlan0 up
ifconfig


7.启动dnsmasq服务

修改配置文件dnsmasq.conf:

interface=wlan0
listen-address=192.168.1.1
dhcp-range=192.168.1.50,192.168.1.150,12h
server=/google/8.8.8.8


启动dnsmasq服务:
dnsmasq &


8.配置wlan0的IP地址

ifconfig wlan0 192.16.1.111

9.配置hostapd.conf

interface=wlan0
driver=nl80211
ssid=ProUHD_Wifi
channel=6
hw_mode=g
ignore_broadcast_ssid=0
auth_algs=1
wpa=3
wpa_passphrase=novastar
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP


启动hostapd:
hostapd -dd hostapd.conf
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: