diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eae6529 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.cmd +*.o +Module.symvers +modules.order +.tmp_versions +*.ko +*.mod.c diff --git a/Makefile b/Makefile index 77cb3cd..47977ea 100755 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ endif OBJS = esp_debug.o sdio_sif_esp.o spi_sif_esp.o esp_io.o \ esp_file.o esp_main.o esp_sip.o esp_ext.o esp_ctrl.o \ - esp_mac80211.o esp_debug.o esp_utils.o esp_pm.o testmode.o + esp_mac80211.o esp_debug.o esp_utils.o testmode.o all: config_check modules diff --git a/dts-4.6/sun8i-a33-aoson-m751s.dtb b/dts-4.6/sun8i-a33-aoson-m751s.dtb new file mode 100644 index 0000000..f9c9c23 Binary files /dev/null and b/dts-4.6/sun8i-a33-aoson-m751s.dtb differ diff --git a/dts-4.6/sun8i-a33-aoson-m751s.dts b/dts-4.6/sun8i-a33-aoson-m751s.dts new file mode 100644 index 0000000..fc6475e --- /dev/null +++ b/dts-4.6/sun8i-a33-aoson-m751s.dts @@ -0,0 +1,157 @@ +/* + * Copyright 2015 Hans de Goede + * + * This file is dual-licensed: you can use it either under the terms + * of the GPL or the X11 license, at your option. Note that this dual + * licensing only applies to this file, and not this project as a + * whole. + * + * a) This file is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This file 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. + * + * Or, alternatively, + * + * b) Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/dts-v1/; +#include "sun8i-a33.dtsi" +#include "sun8i-q8-common.dtsi" + +/ { + model = "Aoson M751s Q8 A33 Tablet"; + compatible = "allwinner,q8-a33", "allwinner,sun8i-a33"; + + /* + * This is actually an active-low reset line for the WLAN + * part of the WiFi CHIP. + * + * Just like for DLDO1 and DLDO2, we cannot tie it to the DT + * node of the SDIO device for now, as there is no bindings + * for it, so we need to have this hack. + */ + wifi_reg_on: wifi_reg_on { + compatible = "regulator-fixed"; + pinctrl-names = "default"; + pinctrl-0 = <&m751s_wifi_reg_on_pin>; + + regulator-name = "wifi-reg-on"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + gpio = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */ + enable-active-high; + }; + + mmc1_pwrseq: mmc1_pwrseq { + compatible = "mmc-pwrseq-simple"; + pinctrl-names = "default"; + pinctrl-0 = <&m751s_wifi_reset_pin>; + reset-gpios = <&r_pio 0 11 GPIO_ACTIVE_LOW>; /* PH9 WIFI_EN */ + }; + + /* + * Both DLDO1 and DLDO2 are used in parallel to power up the + * WiFi Chip. + * + * If those are not enabled, the SDIO part will not enumerate, + * and since there's no way currently to pass DT infos to an + * SDIO device, we cannot really do better than this ugly hack + * for now. + */ + + vcc_wifi: wifi_reg { + compatible = "coupled-voltage-regulator"; + regulator-name = "vcc-wifi"; + vin0-supply = <&vcc_wifi_1>; + vin1-supply = <&vcc_wifi_2>; + }; +}; + +&axp22x { + regulators { + vcc_wifi_1: dldo1 { + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc-wifi-1"; + }; + + vcc_wifi_2: dldo2 { + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-name = "vcc-wifi-2"; + regulator-always-on; + }; + }; +}; + +&mmc1 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc1_pins_a>; + vmmc-supply = <&vcc_wifi_1>; + mmc-pwrseq = <&mmc1_pwrseq>; + bus-width = <4>; + //non-removable; + broken-cd; + status = "okay"; +}; + +&mmc1_pins_a { + allwinner,pull = ; +}; + +&r_pio { + m751s_wifi_reg_on_pin: m751s_wifi_reg_on_pin@0 { + allwinner,pins = "PL6"; + allwinner,function = "gpio_out"; + allwinner,drive = ; + allwinner,pull = ; + }; + m751s_wifi_reset_pin: m751s_wifi_reset_pin@0 { + allwinner,pins = "PL11"; + allwinner,function = "gpio_out"; + allwinner,drive = ; + allwinner,pull = ; + }; +}; + +/* + * FIXME for now we only support host mode and rely on u-boot to have + * turned on Vbus which is controlled by the axp223 pmic on the board. + * + * Once we have axp223 support we should switch to fully supporting otg. + */ +&usb_otg { + dr_mode = "host"; + status = "okay"; +}; + +&usbphy { + status = "okay"; +}; diff --git a/esp_conf.h b/esp_conf.h index 76c4bb3..7a992bc 100755 --- a/esp_conf.h +++ b/esp_conf.h @@ -1,6 +1,8 @@ #ifndef _ESP_CONF_H_ #define _ESP_CONF_H_ -#define INIT_DATA_CONF_BUF "crystal_26M_en=1;test_xtal=0;sdio_configure=2;bt_configure=0;bt_protocol=0;dual_ant_configure=0;test_uart_configure=2;share_xtal=0;gpio_wake=0;no_auto_sleep=0;ext_rst=0;wakeup_gpio=12;ate_test=0;speed_suspend=0;$" +//#define INIT_DATA_CONF_BUF "crystal_26M_en=1;test_xtal=0;sdio_configure=2;bt_configure=0;bt_protocol=0;dual_ant_configure=0;test_uart_configure=2;share_xtal=0;gpio_wake=0;no_auto_sleep=0;ext_rst=0;wakeup_gpio=12;ate_test=0;speed_suspend=0;$" + +#define INIT_DATA_CONF_BUF "crystal_26M_en=0;test_xtal=0;sdio_configure=2;bt_configure=0;bt_protocol=0;dual_ant_configure=0;test_uart_configure=2;share_xtal=0;gpio_wake=0;no_auto_sleep=0;ext_rst=0;wakeup_gpio=12;ate_test=0;speed_suspend=0;$" #endif /*_ESP_CONF_H_ */ diff --git a/esp_config.mk b/esp_config.mk index 2026cdf..2e75320 100755 --- a/esp_config.mk +++ b/esp_config.mk @@ -1 +1 @@ -EXTRA_CFLAGS += -DP2P_CONCURRENT -DESP_ACK_INTERRUPT -DESP_USE_SDIO +EXTRA_CFLAGS += -DP2P_CONCURRENT -DESP_USE_SDIO -DESP_ACK_INTERRUPT diff --git a/esp_ctrl.c b/esp_ctrl.c index 25f04a8..0c2774c 100755 --- a/esp_ctrl.c +++ b/esp_ctrl.c @@ -265,14 +265,14 @@ int sip_parse_events(struct esp_sip *sip, u8 *buf) char test_res_str[560]; sprintf(test_res_str, "esp_host:%llx\nesp_target: %.*s", DRIVER_VER, *len, p); - esp_dbg(ESP_SHOW, "%s\n", test_res_str); + esp_dbg(ESP_DBG_TRACE, "%s\n", test_res_str); if(*len && sip->epub->sdio_state == ESP_SDIO_STATE_FIRST_INIT){ char filename[256]; if (mod_eagle_path_get() == NULL) sprintf(filename, "%s/%s", FWPATH, "test_results"); else sprintf(filename, "%s/%s", mod_eagle_path_get(), "test_results"); - esp_readwrite_file(filename, NULL, test_res_str, strlen(test_res_str)); + esp_dbg (ESP_DBG_TRACE, "SNPRINTF TO HOST: %s\n", test_res_str); } break; } diff --git a/esp_debug.c b/esp_debug.c index 57ea8f2..86f65fa 100755 --- a/esp_debug.c +++ b/esp_debug.c @@ -8,6 +8,7 @@ #include #include +#include #include #include "sip2_common.h" @@ -88,7 +89,11 @@ struct dentry *esp_dump_var(const char *name, struct dentry *parent, void *value rc = debugfs_create_u64(name, mode, parent, (u64*)value); break; case ESP_BOOL: +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)) rc = debugfs_create_bool(name, mode, parent, (u32*)value); +#else + rc = debugfs_create_bool(name, mode, parent, (bool*)value); +#endif break; default: //32 rc = debugfs_create_u32(name, mode, parent, (u32*)value); diff --git a/esp_mac80211.c b/esp_mac80211.c index 8fa5858..73661d7 100755 --- a/esp_mac80211.c +++ b/esp_mac80211.c @@ -15,8 +15,6 @@ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)) #include #endif -/* for support scan in p2p concurrent */ -#include <../net/mac80211/ieee80211_i.h> #include "esp_pub.h" #include "esp_sip.h" #include "esp_ctrl.h" @@ -29,9 +27,7 @@ #define GET_NEXT_SEQ(seq) (((seq) +1) & 0x0fff) -#ifdef P2P_CONCURRENT static u8 esp_mac_addr[ETH_ALEN * 2]; -#endif static u8 getaddr_index(u8 * addr, struct esp_pub *epub); static @@ -225,23 +221,23 @@ static int esp_op_add_interface(struct ieee80211_hw *hw, case NL80211_IFTYPE_STATION: //if (svif.index == 1) // vif->type = NL80211_IFTYPE_UNSPECIFIED; - ESP_IEEE80211_DBG(ESP_SHOW, "%s STA \n", __func__); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s STA \n", __func__); svif.op_mode = 0; svif.is_p2p = 0; break; case NL80211_IFTYPE_AP: - ESP_IEEE80211_DBG(ESP_SHOW, "%s AP \n", __func__); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s AP \n", __func__); svif.op_mode = 1; svif.is_p2p = 0; break; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) case NL80211_IFTYPE_P2P_CLIENT: - ESP_IEEE80211_DBG(ESP_SHOW, "%s P2P_CLIENT \n", __func__); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s P2P_CLIENT \n", __func__); svif.op_mode = 0; svif.is_p2p = 1; break; case NL80211_IFTYPE_P2P_GO: - ESP_IEEE80211_DBG(ESP_SHOW, "%s P2P_GO \n", __func__); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s P2P_GO \n", __func__); svif.op_mode = 1; svif.is_p2p = 1; break; @@ -271,11 +267,11 @@ static int esp_op_change_interface(struct ieee80211_hw *hw, ESP_IEEE80211_DBG(ESP_DBG_OP, "%s enter,change to if:%d \n", __func__, new_type); if (new_type == NL80211_IFTYPE_AP) { - ESP_IEEE80211_DBG(ESP_SHOW, "%s enter,change to AP \n", __func__); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s enter,change to AP \n", __func__); } if (vif->type != new_type) { - ESP_IEEE80211_DBG(ESP_SHOW, "%s type from %d to %d\n", __func__, vif->type, new_type); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s type from %d to %d\n", __func__, vif->type, new_type); } memset(&svif, 0, sizeof(struct sip_cmd_setvif)); @@ -436,7 +432,7 @@ static void drv_handle_beacon(unsigned long data) tim_reach = beacon_tim_alter(beacon); if (beacon && !(dbgcnt++ % 600)) { - ESP_IEEE80211_DBG(ESP_SHOW, " beacon length:%d,fc:0x%x\n", beacon->len, + ESP_IEEE80211_DBG(ESP_DBG_TRACE, " beacon length:%d,fc:0x%x\n", beacon->len, ((struct ieee80211_mgmt *)(beacon->data))->frame_control); } @@ -562,7 +558,6 @@ static int esp_op_config_interface (struct ieee80211_hw *hw, // assoc = 2 means AP struct esp_pub *epub = (struct esp_pub *)hw->priv; struct esp_vif *evif = (struct esp_vif *)vif->drv_priv; - //struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); ESP_IEEE80211_DBG(ESP_DBG_OP, " %s enter: changed %x, bssid %pM,vif->type = %d\n", __func__, conf->changed, conf->bssid,vif->type); if(conf->bssid) @@ -626,9 +621,6 @@ static void esp_op_bss_info_changed(struct ieee80211_hw *hw, sip_send_set_sta(epub, evif->index, 1, node, vif, (u8)node->index); } #else -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) - struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); -#endif // ieee80211_bss_conf(include/net/mac80211.h) is included in ieee80211_sub_if_data(net/mac80211/ieee80211_i.h) , does bssid=ieee80211_if_ap's ssid ? // in 2.6.27, ieee80211_sub_if_data has ieee80211_bss_conf while in 2.6.32 ieee80211_sub_if_data don't have ieee80211_bss_conf @@ -665,7 +657,7 @@ static void esp_op_bss_info_changed(struct ieee80211_hw *hw, evif->ap_up = true; } else if (!info->enable_beacon && evif->ap_up && #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) - !test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state) + !(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) #else true #endif @@ -1556,16 +1548,37 @@ static int esp_op_ampdu_action(struct ieee80211_hw *hw, enum ieee80211_ampdu_mlme_action action, struct ieee80211_sta *sta, u16 tid, u16 *ssn) #else +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)) static int esp_op_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size) +#else +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) +static int esp_op_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 *ssn, + u8 buf_size, bool amsdu) +#else +static int esp_op_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_ampdu_params *params) +#endif +#endif #endif #endif /* NEW_KERNEL && KERNEL_35 */ { int ret = -EOPNOTSUPP; struct esp_pub *epub = (struct esp_pub *)hw->priv; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) + enum ieee80211_ampdu_mlme_action action = params->action; + struct ieee80211_sta *sta = params->sta; + u16 tid = params->tid; + u16 *ssn = ¶ms->ssn; + u8 buf_size = params->buf_size; +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) struct esp_node * node = (struct esp_node *)sta->drv_priv; #else @@ -1600,9 +1613,9 @@ static int esp_op_ampdu_action(struct ieee80211_hw *hw, // return ret; #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)) - ESP_IEEE80211_DBG(ESP_DBG_ERROR, "%s TX START, addr:%pM,tid:%u\n", __func__, addr, tid); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s TX START, addr:%pM,tid:%u\n", __func__, addr, tid); #else - ESP_IEEE80211_DBG(ESP_DBG_ERROR, "%s TX START, addr:%pM,tid:%u,state:%d\n", __func__, sta->addr, tid, tid_info->state); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s TX START, addr:%pM,tid:%u,state:%d\n", __func__, sta->addr, tid, tid_info->state); #endif spin_lock_bh(&epub->tx_ampdu_lock); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) @@ -1649,9 +1662,9 @@ static int esp_op_ampdu_action(struct ieee80211_hw *hw, case IEEE80211_AMPDU_TX_STOP: #endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)) - ESP_IEEE80211_DBG(ESP_DBG_ERROR, "%s TX STOP, addr:%pM,tid:%u\n", __func__, addr, tid); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s TX STOP, addr:%pM,tid:%u\n", __func__, addr, tid); #else - ESP_IEEE80211_DBG(ESP_DBG_ERROR, "%s TX STOP, addr:%pM,tid:%u,state:%d\n", __func__, sta->addr, tid, tid_info->state); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s TX STOP, addr:%pM,tid:%u,state:%d\n", __func__, sta->addr, tid, tid_info->state); #endif spin_lock_bh(&epub->tx_ampdu_lock); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) @@ -1692,7 +1705,7 @@ static int esp_op_ampdu_action(struct ieee80211_hw *hw, #else case IEEE80211_AMPDU_TX_RESUME: #endif - ESP_IEEE80211_DBG(ESP_DBG_ERROR, "%s TX OPERATION, addr:%pM,tid:%u,state:%d\n", __func__, sta->addr, tid, tid_info->state); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s TX OPERATION, addr:%pM,tid:%u,state:%d\n", __func__, sta->addr, tid, tid_info->state); spin_lock_bh(&epub->tx_ampdu_lock); if (tid_info->state != ESP_TID_STATE_PROGRESS) { @@ -1742,19 +1755,19 @@ static int esp_op_ampdu_action(struct ieee80211_hw *hw, ) return ret; #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)) - ESP_IEEE80211_DBG(ESP_DBG_ERROR, "%s RX START %pM tid %u %u\n", __func__, addr, tid, *ssn); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s RX START %pM tid %u %u\n", __func__, addr, tid, *ssn); ret = sip_send_ampdu_action(epub, SIP_AMPDU_RX_START, addr, tid, *ssn, 64); #else - ESP_IEEE80211_DBG(ESP_DBG_ERROR, "%s RX START %pM tid %u %u\n", __func__, sta->addr, tid, *ssn); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s RX START %pM tid %u %u\n", __func__, sta->addr, tid, *ssn); ret = sip_send_ampdu_action(epub, SIP_AMPDU_RX_START, sta->addr, tid, *ssn, 64); #endif break; case IEEE80211_AMPDU_RX_STOP: #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)) - ESP_IEEE80211_DBG(ESP_DBG_ERROR, "%s RX STOP %pM tid %u\n", __func__, addr, tid); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s RX STOP %pM tid %u\n", __func__, addr, tid); ret = sip_send_ampdu_action(epub, SIP_AMPDU_RX_STOP, addr, tid, 0, 0); #else - ESP_IEEE80211_DBG(ESP_DBG_ERROR, "%s RX STOP %pM tid %u\n", __func__, sta->addr, tid); + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s RX STOP %pM tid %u\n", __func__, sta->addr, tid); ret = sip_send_ampdu_action(epub, SIP_AMPDU_RX_STOP, sta->addr, tid, 0, 0); #endif break; @@ -2201,15 +2214,12 @@ int esp_register_mac80211(struct esp_pub *epub) { int ret = 0; -#ifdef P2P_CONCURRENT u8 *wlan_addr; u8 *p2p_addr; int idx; -#endif esp_pub_init_mac80211(epub); -#ifdef P2P_CONCURRENT epub->hw->wiphy->addresses = (struct mac_address *)esp_mac_addr; memcpy(&epub->hw->wiphy->addresses[0], epub->mac_addr, ETH_ALEN); memcpy(&epub->hw->wiphy->addresses[1], epub->mac_addr, ETH_ALEN); @@ -2224,10 +2234,6 @@ esp_register_mac80211(struct esp_pub *epub) } epub->hw->wiphy->n_addresses = 2; -#else - - SET_IEEE80211_PERM_ADDR(epub->hw, epub->mac_addr); -#endif ret = ieee80211_register_hw(epub->hw); @@ -2259,14 +2265,10 @@ esp_register_mac80211(struct esp_pub *epub) static u8 getaddr_index(u8 * addr, struct esp_pub *epub) { -#ifdef P2P_CONCURRENT int i; for(i = 0; i < ESP_PUB_MAX_VIF; i++) if(memcmp(addr, (u8 *)&epub->hw->wiphy->addresses[i], ETH_ALEN) == 0) return i; return ESP_PUB_MAX_VIF; -#else - return 0; -#endif } diff --git a/esp_main.c b/esp_main.c index 13de2fe..a7a49d8 100755 --- a/esp_main.c +++ b/esp_main.c @@ -34,7 +34,7 @@ MODULE_PARM_DESC(no_txampdu, "Disable tx ampdu."); module_param_named(no_rxampdu, modparam_no_rxampdu, int, 0444); MODULE_PARM_DESC(no_rxampdu, "Disable rx ampdu."); -static char *modparam_eagle_path = ""; +static char *modparam_eagle_path = "/lib/firmware"; module_param_named(eagle_path, modparam_eagle_path, charp, 0444); MODULE_PARM_DESC(eagle_path, "eagle path"); @@ -165,9 +165,9 @@ struct esp_fw_blk_hdr { u32 data_len; } __packed; -#define ESP_FW_NAME1 "eagle_fw1.bin" -#define ESP_FW_NAME2 "eagle_fw2.bin" -#define ESP_FW_NAME3 "eagle_fw3.bin" +#define ESP_FW_NAME1 "eagle_fw_ate_config_v19.bin" +#define ESP_FW_NAME2 "eagle_fw_first_init_v19.bin" +#define ESP_FW_NAME3 "eagle_fw_second_init_v19.bin" #ifndef FPGA_DEBUG static int esp_download_fw(struct esp_pub * epub) diff --git a/esp_path.h b/esp_path.h index 514f79c..8e403f9 100755 --- a/esp_path.h +++ b/esp_path.h @@ -1,6 +1,6 @@ #ifndef _ESP_PATH_H_ #define _ESP_PATH_H_ -#define FWPATH "/system/lib/modules" +#define FWPATH "/lib/firmware" //module_param_string(fwpath, fwpath, sizeof(fwpath), 0644); #endif /* _ESP_PATH_H_ */ diff --git a/esp_pm.c b/esp_pm.c deleted file mode 100755 index ca8bfe7..0000000 --- a/esp_pm.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2010 -2014 Espressif System. - * - * power save control of system - */ -#ifdef CONFIG_HAS_WAKELOCK -#include -#endif -#ifdef CONFIG_HAS_EARLYSUSPEND -#include -#endif -#include "esp_pub.h" - -#ifdef CONFIG_HAS_EARLYSUSPEND - -static void esp_early_suspend(struct early_suspend *h) -{ - printk("%s\n", __func__); -} - -static void esp_late_resume(struct early_suspend*h) -{ - printk("%s\n", __func__); -} - -static struct early_suspend esp_early_suspend_ctrl = { - .suspend = esp_early_suspend, - .resume = esp_late_resume, - .level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN - 20, -}; -#endif /* EARLYSUSPEND */ - -void esp_register_early_suspend(void) -{ -#ifdef CONFIG_HAS_EARLYSUSPEND - register_early_suspend(&esp_early_suspend_ctrl); -#endif -} - -void esp_unregister_early_suspend(void) -{ -#ifdef CONFIG_HAS_EARLYSUSPEND - unregister_early_suspend(&esp_early_suspend_ctrl); -#endif -} - -#ifdef CONFIG_HAS_WAKELOCK -static struct wake_lock esp_wake_lock_; -#endif /* WAKELOCK */ - -void esp_wakelock_init(void) -{ -#ifdef CONFIG_HAS_WAKELOCK - wake_lock_init(&esp_wake_lock_, WAKE_LOCK_SUSPEND, "eagle"); -#endif -} - -void esp_wakelock_destroy(void) -{ -#ifdef CONFIG_HAS_WAKELOCK - wake_lock_destroy(&esp_wake_lock_); -#endif -} - -void esp_wake_lock(void) -{ -#ifdef CONFIG_HAS_WAKELOCK - wake_lock(&esp_wake_lock_); -#endif -} - -void esp_wake_unlock(void) -{ -#ifdef CONFIG_HAS_WAKELOCK - wake_unlock(&esp_wake_lock_); -#endif -} diff --git a/esp_pub.h b/esp_pub.h index fe8b56f..f2a903a 100755 --- a/esp_pub.h +++ b/esp_pub.h @@ -21,6 +21,13 @@ #include #endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) +#define ieee80211_band nl80211_band +#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ +#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ +#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS +#endif + enum esp_sdio_state{ ESP_SDIO_STATE_FIRST_INIT, ESP_SDIO_STATE_FIRST_NORMAL_EXIT, @@ -211,13 +218,6 @@ void esp_rocdone_process(struct ieee80211_hw *hw, struct sip_evt_roc *report); void esp_ps_config(struct esp_pub *epub, struct esp_ps *ps, bool on); - -void esp_register_early_suspend(void); -void esp_unregister_early_suspend(void); -void esp_wakelock_init(void); -void esp_wakelock_destroy(void); -void esp_wake_lock(void); -void esp_wake_unlock(void); struct esp_node * esp_get_node_by_addr(struct esp_pub * epub, const u8 *addr); struct esp_node * esp_get_node_by_index(struct esp_pub * epub, u8 index); int esp_get_empty_rxampdu(struct esp_pub * epub, const u8 *addr, u8 tid); diff --git a/esp_sif.h b/esp_sif.h index 2a47ae6..7b5c80a 100755 --- a/esp_sif.h +++ b/esp_sif.h @@ -196,7 +196,6 @@ int sif_lldesc_read_sync(struct esp_pub *epub, u8 *buf, u32 len); int sif_lldesc_write_sync(struct esp_pub *epub, u8 *buf, u32 len); int sif_lldesc_read_raw(struct esp_pub *epub, u8 *buf, u32 len, bool noround); int sif_lldesc_write_raw(struct esp_pub *epub, u8 *buf, u32 len); -void sif_platform_check_r1_ready(struct esp_pub *epub); #endif #ifdef ESP_USE_SPI @@ -252,13 +251,6 @@ struct slc_host_regs * sif_get_regs(struct esp_pub *epub); void sif_lock_bus(struct esp_pub *epub); void sif_unlock_bus(struct esp_pub *epub); -void sif_platform_target_poweroff(void); -void sif_platform_target_poweron(void); -void sif_platform_target_speed(int high_speed); - -void sif_platform_reset_target(void); -void sif_platform_rescan_card(unsigned insert); - int sif_interrupt_target(struct esp_pub *epub, u8 index); #ifdef USE_EXT_GPIO int sif_config_gpio_mode(struct esp_pub *epub, u8 gpio_num, u8 gpio_mode); @@ -280,11 +272,6 @@ int sif_get_retry_config(void); void sif_record_wakeup_gpio_config(int value); int sif_get_wakeup_gpio_config(void); -#ifdef ESP_ACK_INTERRUPT -//extern void sif_platform_ack_interrupt(struct mmc_host *mmc); -extern void sif_platform_ack_interrupt(struct esp_pub *epub); -#endif //ESP_ACK_INTERRUPT - #define sif_reg_read_sync(epub, addr, buf, len) sif_io_sync((epub), (addr), (buf), (len), SIF_FROM_DEVICE | SIF_BYTE_BASIS | SIF_INC_ADDR) #define sif_reg_write_sync(epub, addr, buf, len) sif_io_sync((epub), (addr), (buf), (len), SIF_TO_DEVICE | SIF_BYTE_BASIS | SIF_INC_ADDR) diff --git a/firmware/eagle_fw_ate_config_v19.bin b/firmware/eagle_fw_ate_config_v19.bin new file mode 100644 index 0000000..a5dc48b Binary files /dev/null and b/firmware/eagle_fw_ate_config_v19.bin differ diff --git a/firmware/eagle_fw_first_init_v19.bin b/firmware/eagle_fw_first_init_v19.bin new file mode 100644 index 0000000..c9488a2 Binary files /dev/null and b/firmware/eagle_fw_first_init_v19.bin differ diff --git a/firmware/eagle_fw_second_init_v19.bin b/firmware/eagle_fw_second_init_v19.bin new file mode 100644 index 0000000..644fd77 Binary files /dev/null and b/firmware/eagle_fw_second_init_v19.bin differ diff --git a/sdio_sif_esp.c b/sdio_sif_esp.c index dbdbfa9..03d293b 100755 --- a/sdio_sif_esp.c +++ b/sdio_sif_esp.c @@ -32,6 +32,25 @@ #include "esp_ext.h" #endif /* USE_EXT_GPIO */ +/* + * HdG: Note: + * 1) MMC_HAS_FORCE_DETECT_CHANGE is a hack which is set by my sunxi-wip + * tree. FIXME replace with a version check once mmc_force_detect_change() + * is added to the mainline kernel. + * 2) This version does NOT implement keep_power, the dts must mark the + * regulators as regulator-always-on and not use mmc-pwrseq for this stub + * to work. + */ +#ifndef MMC_HAS_FORCE_DETECT_CHANGE +void mmc_force_detect_change(struct mmc_host *host, unsigned long delay, + bool keep_power) +{ + host->caps &= ~MMC_CAP_NONREMOVABLE; + host->caps |= MMC_CAP_NEEDS_POLL; + mmc_detect_change(host, delay); +} +#endif + static int /*__init*/ esp_sdio_init(void); static void /*__exit*/ esp_sdio_exit(void); @@ -41,9 +60,6 @@ static void /*__exit*/ esp_sdio_exit(void); //unsigned int esp_msg_level = 0; unsigned int esp_msg_level = ESP_DBG_ERROR | ESP_SHOW; -static struct semaphore esp_powerup_sem; - -static enum esp_sdio_state sif_sdio_state; struct esp_sdio_ctrl *sif_sctrl = NULL; #ifdef ESP_ANDROID_LOGGER @@ -55,8 +71,6 @@ static int esdio_power_on(struct esp_sdio_ctrl *sctrl); void sif_set_clock(struct sdio_func *func, int clk); -#include "sdio_stub.c" - void sif_lock_bus(struct esp_pub *epub) { EPUB_FUNC_CHECK(epub, _exit); @@ -104,7 +118,6 @@ void sdio_io_writeb(struct esp_pub *epub, u8 value, int addr, int *res) sdio_f0_writeb(func, value, addr, res); else sdio_writeb(func, value, addr, res); - sif_platform_check_r1_ready(epub); } int sif_io_raw(struct esp_pub *epub, u32 addr, u8 *buf, u32 len, u32 flag) @@ -151,7 +164,6 @@ int sif_io_raw(struct esp_pub *epub, u32 addr, u8 *buf, u32 len, u32 flag) else if (flag & SIF_INC_ADDR) { err = sdio_memcpy_toio(func, addr, ibuf, len); } - sif_platform_check_r1_ready(epub); } else if (flag & SIF_FROM_DEVICE) { if (flag & SIF_FIXED_ADDR) @@ -216,7 +228,6 @@ int sif_io_sync(struct esp_pub *epub, u32 addr, u8 *buf, u32 len, u32 flag) else if (flag & SIF_INC_ADDR) { err = sdio_memcpy_toio(func, addr, ibuf, len); } - sif_platform_check_r1_ready(epub); sdio_release_host(func); } else if (flag & SIF_FROM_DEVICE) { @@ -428,7 +439,6 @@ void sif_enable_irq(struct esp_pub *epub) void sif_disable_irq(struct esp_pub *epub) { - int err; struct esp_sdio_ctrl *sctrl = (struct esp_sdio_ctrl *)epub->sif; int i = 0; @@ -447,11 +457,8 @@ void sif_disable_irq(struct esp_pub *epub) } } - err = sdio_release_irq(sctrl->func); - - if (err) { - esp_dbg(ESP_DBG_ERROR, "%s release irq failed\n", __func__); - } + /* Ignore errors, we don't always use an irq. */ + sdio_release_irq(sctrl->func); atomic_set(&sctrl->irq_installed, 0); @@ -489,14 +496,15 @@ static void esp_sdio_remove(struct sdio_func *func); static int esp_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { int err = 0; - struct esp_pub *epub; + struct esp_pub *epub = NULL; struct esp_sdio_ctrl *sctrl; + struct mmc_host *host = func->card->host; esp_dbg(ESP_DBG_TRACE, "sdio_func_num: 0x%X, vendor id: 0x%X, dev id: 0x%X, block size: 0x%X/0x%X\n", func->num, func->vendor, func->device, func->max_blksize, func->cur_blksize); - if(sif_sdio_state == ESP_SDIO_STATE_FIRST_INIT){ + if (sif_sctrl == NULL) { sctrl = kzalloc(sizeof(struct esp_sdio_ctrl), GFP_KERNEL); if (sctrl == NULL) { @@ -521,6 +529,7 @@ static int esp_sdio_probe(struct sdio_func *func, const struct sdio_device_id *i goto _err_dma; } epub->sif = (void *)sctrl; + epub->sdio_state = ESP_SDIO_STATE_FIRST_INIT; sctrl->epub = epub; #ifdef USE_EXT_GPIO @@ -537,12 +546,11 @@ static int esp_sdio_probe(struct sdio_func *func, const struct sdio_device_id *i sctrl = sif_sctrl; sif_sctrl = NULL; epub = sctrl->epub; + epub->sdio_state = ESP_SDIO_STATE_SECOND_INIT; SET_IEEE80211_DEV(epub->hw, &func->dev); epub->dev = &func->dev; } - epub->sdio_state = sif_sdio_state; - sctrl->func = func; sdio_set_drvdata(func, sctrl); @@ -556,7 +564,7 @@ static int esp_sdio_probe(struct sdio_func *func, const struct sdio_device_id *i esp_dbg(ESP_DBG_TRACE, " %s >> power_on err %d \n", __func__, err); if (err){ - if(sif_sdio_state == ESP_SDIO_STATE_FIRST_INIT) + if(epub->sdio_state == ESP_SDIO_STATE_FIRST_INIT) goto _err_ext_gpio; else goto _err_second_init; @@ -571,7 +579,7 @@ static int esp_sdio_probe(struct sdio_func *func, const struct sdio_device_id *i esp_dbg(ESP_DBG_ERROR, "Set sdio block size %d failed: %d)\n", sctrl->slc_blk_sz, err); sdio_release_host(func); - if(sif_sdio_state == ESP_SDIO_STATE_FIRST_INIT) + if(epub->sdio_state == ESP_SDIO_STATE_FIRST_INIT) goto _err_off; else goto _err_second_init; @@ -588,19 +596,20 @@ static int esp_sdio_probe(struct sdio_func *func, const struct sdio_device_id *i if (err) { esp_dbg(ESP_DBG_ERROR, "esp_init_all failed: %d\n", err); - if(sif_sdio_state == ESP_SDIO_STATE_FIRST_INIT){ + if (epub->sdio_state == ESP_SDIO_STATE_FIRST_INIT) { err = 0; goto _err_first_init; } - if(sif_sdio_state == ESP_SDIO_STATE_SECOND_INIT) + if (epub->sdio_state == ESP_SDIO_STATE_SECOND_INIT) goto _err_second_init; } esp_dbg(ESP_DBG_TRACE, " %s return %d\n", __func__, err); - if(sif_sdio_state == ESP_SDIO_STATE_FIRST_INIT){ - esp_dbg(ESP_DBG_ERROR, "first normal exit\n"); - sif_sdio_state = ESP_SDIO_STATE_FIRST_NORMAL_EXIT; - up(&esp_powerup_sem); + if (epub->sdio_state == ESP_SDIO_STATE_FIRST_INIT) { + esp_dbg(ESP_DBG_TRACE, "first normal exit\n"); + epub->sdio_state = ESP_SDIO_STATE_FIRST_NORMAL_EXIT; + /* Rescan the esp8089 after loading the initial firmware */ + mmc_force_detect_change(host, msecs_to_jiffies(100), true); } return err; @@ -619,14 +628,13 @@ static int esp_sdio_probe(struct sdio_func *func, const struct sdio_device_id *i _err_last: kfree(sctrl); _err_first_init: - if(sif_sdio_state == ESP_SDIO_STATE_FIRST_INIT){ + if (epub && epub->sdio_state == ESP_SDIO_STATE_FIRST_INIT) { esp_dbg(ESP_DBG_ERROR, "first error exit\n"); - sif_sdio_state = ESP_SDIO_STATE_FIRST_ERROR_EXIT; - up(&esp_powerup_sem); + epub->sdio_state = ESP_SDIO_STATE_FIRST_ERROR_EXIT; } return err; _err_second_init: - sif_sdio_state = ESP_SDIO_STATE_SECOND_ERROR_EXIT; + epub->sdio_state = ESP_SDIO_STATE_SECOND_ERROR_EXIT; esp_sdio_remove(func); return err; } @@ -635,7 +643,7 @@ static void esp_sdio_remove(struct sdio_func *func) { struct esp_sdio_ctrl *sctrl = NULL; - esp_dbg(ESP_SHOW, "%s enter\n", __func__); + esp_dbg(ESP_DBG_TRACE, "%s enter\n", __func__); sctrl = sdio_get_drvdata(func); @@ -649,8 +657,7 @@ static void esp_sdio_remove(struct sdio_func *func) esp_dbg(ESP_DBG_ERROR, "%s epub null\n", __func__); break; } - sctrl->epub->sdio_state = sif_sdio_state; - if(sif_sdio_state != ESP_SDIO_STATE_FIRST_NORMAL_EXIT){ + if (sctrl->epub->sdio_state != ESP_SDIO_STATE_FIRST_NORMAL_EXIT) { if (sctrl->epub->sip) { sip_detach(sctrl->epub->sip); sctrl->epub->sip = NULL; @@ -674,7 +681,7 @@ static void esp_sdio_remove(struct sdio_func *func) #ifdef TEST_MODE test_exit_netlink(); #endif /* TEST_MODE */ - if(sif_sdio_state != ESP_SDIO_STATE_FIRST_NORMAL_EXIT){ + if (sctrl->epub->sdio_state != ESP_SDIO_STATE_FIRST_NORMAL_EXIT) { esp_pub_dealloc_mac80211(sctrl->epub); esp_dbg(ESP_DBG_TRACE, "%s dealloc mac80211 \n", __func__); @@ -763,149 +770,25 @@ static struct sdio_driver esp_sdio_driver = { .drv = { .pm = &esp_sdio_pm_ops, }, }; -static int esp_sdio_dummy_probe(struct sdio_func *func, const struct sdio_device_id *id) -{ - esp_dbg(ESP_DBG_ERROR, "%s enter\n", __func__); - - up(&esp_powerup_sem); - - return 0; -} - -static void esp_sdio_dummy_remove(struct sdio_func *func) -{ - return; -} - -static struct sdio_driver esp_sdio_dummy_driver = { - .name = "eagle_sdio_dummy", - .id_table = esp_sdio_devices, - .probe = esp_sdio_dummy_probe, - .remove = esp_sdio_dummy_remove, -}; - static int /*__init*/ esp_sdio_init(void) { -#define ESP_WAIT_UP_TIME_MS 11000 - int err; - u64 ver; - int retry = 3; - bool powerup = false; - int edf_ret = 0; - - esp_dbg(ESP_DBG_TRACE, "%s \n", __func__); - -#ifdef DRIVER_VER - ver = DRIVER_VER; - esp_dbg(ESP_SHOW, "\n***** EAGLE DRIVER VER:%llx*****\n\n", ver); -#endif - edf_ret = esp_debugfs_init(); - + esp_debugfs_init(); request_init_conf(); - esp_wakelock_init(); - esp_wake_lock(); - - do { - sema_init(&esp_powerup_sem, 0); - - sif_platform_target_poweron(); - - sif_platform_rescan_card(1); - - err = sdio_register_driver(&esp_sdio_dummy_driver); - if (err) { - esp_dbg(ESP_DBG_ERROR, "eagle sdio driver registration failed, error code: %d\n", err); - goto _fail; - } - - if (down_timeout(&esp_powerup_sem, - msecs_to_jiffies(ESP_WAIT_UP_TIME_MS)) == 0) - { - - powerup = true; - msleep(200); - break; - } - - esp_dbg(ESP_SHOW, "%s ------ RETRY ------ \n", __func__); - - sif_record_retry_config(); - - sdio_unregister_driver(&esp_sdio_dummy_driver); - - sif_platform_rescan_card(0); - - sif_platform_target_poweroff(); - - } while (retry--); - - if (!powerup) { - esp_dbg(ESP_DBG_ERROR, "eagle sdio can not power up!\n"); - - err = -ENODEV; - goto _fail; - } - - esp_dbg(ESP_SHOW, "%s power up OK\n", __func__); - - sdio_unregister_driver(&esp_sdio_dummy_driver); - - sif_sdio_state = ESP_SDIO_STATE_FIRST_INIT; - sema_init(&esp_powerup_sem, 0); - sdio_register_driver(&esp_sdio_driver); - - if ((down_timeout(&esp_powerup_sem, - msecs_to_jiffies(ESP_WAIT_UP_TIME_MS)) == 0 ) && sif_get_ate_config() == 0) { - if(sif_sdio_state == ESP_SDIO_STATE_FIRST_NORMAL_EXIT){ - sdio_unregister_driver(&esp_sdio_driver); - - sif_platform_rescan_card(0); - - msleep(100); - - sif_platform_rescan_card(1); - - sif_sdio_state = ESP_SDIO_STATE_SECOND_INIT; - - sdio_register_driver(&esp_sdio_driver); - } - - } - - - esp_register_early_suspend(); - esp_wake_unlock(); - return err; - -_fail: - esp_wake_unlock(); - esp_wakelock_destroy(); - - return err; + return 0; } static void /*__exit*/ esp_sdio_exit(void) -{ - esp_dbg(ESP_SHOW, "%s \n", __func__); - - esp_debugfs_exit(); - - esp_unregister_early_suspend(); - +{ sdio_unregister_driver(&esp_sdio_driver); - - sif_platform_rescan_card(0); - -#ifndef FPGA_DEBUG - sif_platform_target_poweroff(); -#endif /* !FPGA_DEBUG */ - - esp_wakelock_destroy(); + esp_debugfs_exit(); } MODULE_AUTHOR("Espressif System"); MODULE_DESCRIPTION("Driver for SDIO interconnected eagle low-power WLAN devices"); MODULE_LICENSE("GPL"); + +module_init(esp_sdio_init); +module_exit(esp_sdio_exit); #endif /* ESP_USE_SDIO */ diff --git a/sdio_stub.c b/sdio_stub.c deleted file mode 100755 index c367fd1..0000000 --- a/sdio_stub.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2013 Espressif System. - * - * sdio stub code for RK - */ - -#include -//#include - -#define ESP8089_DRV_VERSION "1.9" - -extern int rk29sdk_wifi_power(int on); -extern int rk29sdk_wifi_set_carddetect(int val); -int rockchip_wifi_init_module(void) -{ - return esp_sdio_init(); -} - -void rockchip_wifi_exit_module(void) -{ - esp_sdio_exit(); - -} -void sif_platform_rescan_card(unsigned insert) -{ -} - -void sif_platform_reset_target(void) -{ -} - -void sif_platform_target_poweroff(void) -{ -} - -void sif_platform_target_poweron(void) -{ -} - -void sif_platform_target_speed(int high_speed) -{ -} - -void sif_platform_check_r1_ready(struct esp_pub *epub) -{ -} - - -#ifdef ESP_ACK_INTERRUPT -extern void sdmmc_ack_interrupt(struct mmc_host *mmc); - -void sif_platform_ack_interrupt(struct esp_pub *epub) -{ - struct esp_sdio_ctrl *sctrl = NULL; - struct sdio_func *func = NULL; - - if (epub == NULL) { - ESSERT(epub != NULL); - return; - } - sctrl = (struct esp_sdio_ctrl *)epub->sif; - func = sctrl->func; - if (func == NULL) { - ESSERT(func != NULL); - return; - } - - sdmmc_ack_interrupt(func->card->host); -} -#endif //ESP_ACK_INTERRUPT - EXPORT_SYMBOL(rockchip_wifi_init_module); - EXPORT_SYMBOL(rockchip_wifi_exit_module); - -late_initcall(esp_sdio_init); -module_exit(esp_sdio_exit);