Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions wilc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ config WILC_SPI
VDDIO. Select this if your platform is using the SPI bus.
WILC3000 additionally supports BT 4.0 and BLE modes.

config WILC1000_HW_OOB_INTR
bool "WILC1000 out of band interrupt"
depends on WILC1000_SDIO
config WILC_HW_OOB_INTR
bool "WILC out of band interrupt"
depends on WILC_SDIO
default n
---help---
This option enables out-of-band interrupt support for the WILC1000
chipset. This OOB interrupt is intended to provide a faster interrupt
mechanism for SDIO host controllers that don't support SDIO interrupt.
Select this option If the SDIO host controller in your platform
doesn't support SDIO time devision interrupt.
This option enables out-of-band interrupt support for the WILC1000 &
WILC3000 chipset. This OOB interrupt is intended to provide a faster
interrupt mechanism for SDIO host controllers that don't support SDIO
interrupt. Select this option If the SDIO host controller in your
platform doesn't support SDIO time devision interrupt.
130 changes: 82 additions & 48 deletions wilc/linux_wlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <linux/mmc/sdio_func.h>
#include <linux/pm_runtime.h>

#include <linux/of_gpio.h>

#include "linux_wlan.h"

#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Expand All @@ -40,9 +42,9 @@ void handle_pwrsave_during_obtainingIP(struct wilc_vif *vif, uint8_t state)
{

switch(state)
{
{
case IP_STATE_OBTAINING:

PRINT_INFO(vif->ndev, GENERIC_DBG, "Obtaining an IP, Disable (Scan-Set PowerSave)\n");
PRINT_INFO(vif->ndev, GENERIC_DBG, "Save the Current state of the PS = %d\n", vif->pwrsave_current_state);

Expand All @@ -58,7 +60,7 @@ void handle_pwrsave_during_obtainingIP(struct wilc_vif *vif, uint8_t state)
mod_timer(&wilc_during_ip_timer, (jiffies + msecs_to_jiffies(20000)));

break;

case IP_STATE_OBTAINED:

PRINT_INFO(vif->ndev, GENERIC_DBG, "IP obtained , Enable (Scan-Set PowerSave)\n");
Expand All @@ -72,10 +74,10 @@ void handle_pwrsave_during_obtainingIP(struct wilc_vif *vif, uint8_t state)
wilc_set_power_mgmt(vif, vif->pwrsave_current_state, 0);
}

del_timer(&wilc_during_ip_timer);
del_timer(&wilc_during_ip_timer);

break;

case IP_STATE_GO_ASSIGNING:

/* Set the wilc_optaining_ip flag */
Expand All @@ -86,7 +88,7 @@ void handle_pwrsave_during_obtainingIP(struct wilc_vif *vif, uint8_t state)
mod_timer(&wilc_during_ip_timer, (jiffies + msecs_to_jiffies(duringIP_TIME)));

break;

default: //IP_STATE_DEFAULT

/* Clear the wilc_optaining_ip flag */
Expand Down Expand Up @@ -123,7 +125,7 @@ void store_power_save_current_state(struct wilc_vif *vif, bool val)
void clear_duringIP(unsigned long arg)
{
struct wilc_vif *vif = (struct wilc_vif *)arg;

PRINT_ER(vif->ndev, "Unable to Obtain IP\n");

/* Clear the wilc_optaining_ip flag */
Expand Down Expand Up @@ -183,7 +185,7 @@ static int debug_thread(void *arg)
signed long timeout;
struct host_if_drv *hif_drv;
int i = 0;

vif = netdev_priv(dev);

priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy);
Expand Down Expand Up @@ -354,7 +356,7 @@ static int dev_state_ev_handler(struct notifier_block *this,
handle_pwrsave_during_obtainingIP(vif, IP_STATE_DEFAULT);
}


wilc_resolve_disconnect_aberration(vif);

PRINT_INFO(vif->ndev, GENERIC_DBG, "[%s] Down IP\n", dev_iface->ifa_label);
Expand Down Expand Up @@ -438,42 +440,42 @@ static int init_irq(struct net_device *dev)
vif = netdev_priv(dev);
wl = vif->wilc;

if ((gpio_request(wl->gpio, "WILC_INTR") == 0) &&
(gpio_direction_input(wl->gpio) == 0)) {
wl->dev_irq_num = gpio_to_irq(wl->gpio);
if ((gpio_request(wl->gpio_irq, "WILC_INTR") == 0) &&
(gpio_direction_input(wl->gpio_irq) == 0)) {
wl->dev_irq_num = gpio_to_irq(wl->gpio_irq);
} else {
ret = -1;
PRINT_ER(dev, "could not obtain gpio for WILC_INTR\n");
}

if ((wl->io_type & 0x1) == HIF_SPI ||
if ((wl->io_type & 0x1) == HIF_SPI ||
(wl->io_type & 0x2) == HIF_SDIO_GPIO_IRQ) {
if (ret != -1 && request_threaded_irq(wl->dev_irq_num,
isr_uh_routine,
isr_bh_routine,
IRQF_TRIGGER_LOW | IRQF_ONESHOT|IRQF_NO_SUSPEND,
"WILC_IRQ", dev) < 0) {
PRINT_ER(dev, "Failed to request IRQ GPIO: %d\n", wl->gpio);
gpio_free(wl->gpio);
PRINT_ER(dev, "Failed to request IRQ GPIO: %d\n", wl->gpio_irq);
gpio_free(wl->gpio_irq);
ret = -1;
} else {
PRINT_INFO(dev, GENERIC_DBG,
"IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n",
wl->dev_irq_num, wl->gpio);
wl->dev_irq_num, wl->gpio_irq);
enable_irq_wake(wl->dev_irq_num);
}
} else {
if (ret != -1 && request_irq(wl->dev_irq_num,
if (ret != -1 && request_irq(wl->dev_irq_num,
host_wakeup_isr,
IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND,
"WILC_IRQ", dev) < 0) {
PRINT_ER(dev, "Failed to request IRQ GPIO: %d\n", wl->gpio);
gpio_free(wl->gpio);
PRINT_ER(dev, "Failed to request IRQ GPIO: %d\n", wl->gpio_irq);
gpio_free(wl->gpio_irq);
ret = -1;
} else {
PRINT_INFO(dev, GENERIC_DBG,
"IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n",
wl->dev_irq_num, wl->gpio);
wl->dev_irq_num, wl->gpio_irq);
}
}
return ret;
Expand All @@ -490,7 +492,7 @@ static void deinit_irq(struct net_device *dev)
/* Deinitialize IRQ */
if (wilc->dev_irq_num) {
free_irq(wilc->dev_irq_num, wilc);
gpio_free(wilc->gpio);
gpio_free(wilc->gpio_irq);
}
}

Expand Down Expand Up @@ -532,10 +534,10 @@ void eap_buff_timeout(unsigned long user)
{
u8 null_bssid[ETH_ALEN] = {0};
static u8 timeout = 5;
int status = -1;
int status = -1;
struct wilc_priv *priv;
struct wilc_vif *vif ;

priv = (struct wilc_priv *)user;
vif = netdev_priv(priv->dev);
if (!(memcmp(priv->au8AssociatedBss, null_bssid, ETH_ALEN)) && (timeout-- > 0)) {
Expand Down Expand Up @@ -782,7 +784,7 @@ static int wilc_firmware_download(struct net_device *dev)
goto _fail_;

PRINT_INFO(vif->ndev, INIT_DBG, "Download Succeeded\n");

_fail_:
release_firmware(wilc->firmware);
wilc->firmware = NULL;
Expand Down Expand Up @@ -827,7 +829,7 @@ static int linux_wlan_init_test_config(struct net_device *dev,
c_val[0] = G_AUTO_PREAMBLE;
if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = AUTO_PROT;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
goto _fail_;
Expand Down Expand Up @@ -970,7 +972,7 @@ static int linux_wlan_init_test_config(struct net_device *dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0,
0))
goto _fail_;

c_val[0] = 7;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0,
0))
Expand Down Expand Up @@ -1072,15 +1074,15 @@ static int wlan_deinit_locks(struct net_device *dev)

vif = netdev_priv(dev);
wilc = vif->wilc;

PRINT_INFO(vif->ndev, INIT_DBG, "De-Initializing Locks\n");

if (&wilc->hif_cs)
mutex_destroy(&wilc->hif_cs);

if (&wilc->cs)
mutex_destroy(&wilc->cs);

if (&wilc->rxq_cs)
mutex_destroy(&wilc->rxq_cs);

Expand Down Expand Up @@ -1130,7 +1132,7 @@ static void wlan_deinitialize_threads(struct net_device *dev)

vif = netdev_priv(dev);
wl = vif->wilc;

PRINT_INFO(vif->ndev, INIT_DBG, "Deinitializing Threads\n");
if (!recovery_on) {
PRINT_INFO(vif->ndev, INIT_DBG, "Deinitializing debug Thread\n");
Expand Down Expand Up @@ -1173,7 +1175,7 @@ int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
goto _fail_locks_;
}
PRINT_INFO(vif->ndev, GENERIC_DBG, "WILC Initialization done\n");
if (wl->gpio >= 0 && init_irq(dev)) {
if (wl->gpio_irq >= 0 && init_irq(dev)) {
ret = -EIO;
goto _fail_locks_;
}
Expand Down Expand Up @@ -1267,7 +1269,7 @@ static int mac_init_fn(struct net_device *ndev)

int wilc_bt_power_up(struct wilc *wilc, int source);
int wilc_bt_power_down(struct wilc *wilc, int source);

static int wilc_mac_open(struct net_device *ndev)
{
struct wilc_vif *vif;
Expand Down Expand Up @@ -1745,6 +1747,9 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
int gpio, const struct wilc_hif_func *ops)
{
int i, ret;
int gpio_reset = -1;
int gpio_chip_en = -1;
int gpio_irq = -1;
struct wilc_vif *vif;
struct net_device *ndev;
struct wilc *wl;
Expand All @@ -1754,10 +1759,39 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
if (!wl)
return -ENOMEM;

gpio_reset = of_get_named_gpio_flags(dev->of_node, "gpio_reset", 0, NULL);
if (gpio_reset < 0) {
ret = gpio_reset;
gpio_reset = GPIO_NUM_RESET;
dev_warn(dev, "WILC setting default Reset GPIO to %d. Got %d\r\n", gpio_reset, ret);
} else {
dev_info(dev, "WILC got %d for gpio_reset\r\n", gpio_reset);
}

gpio_chip_en = of_get_named_gpio_flags(dev->of_node, "gpio_chip_en", 0, NULL);
if (gpio_chip_en < 0) {
ret = gpio_chip_en;
gpio_chip_en = GPIO_NUM_CHIP_EN;
dev_warn(dev, "WILC setting default Chip Enable GPIO to %d. Got %d\r\n", gpio_chip_en, ret);
} else {
dev_info(dev, "WILC got %d for gpio_chip_en\r\n", gpio_chip_en);
}

gpio_irq = of_get_named_gpio_flags(dev->of_node, "gpio_irq", 0, NULL);
if (gpio_irq < 0) {
ret = gpio_irq;
gpio_irq = GPIO_NUM;
dev_warn(dev, "WILC setting default IRQ GPIO to %d. Got %d\r\n", gpio_irq, ret);
} else {
dev_info(dev, "WILC got %d for gpio_irq\r\n", gpio_irq);
}

*wilc = wl;

wl->io_type = io_type;
wl->gpio = gpio;
wl->gpio_irq = gpio_irq;
wl->gpio_chip_en = gpio_chip_en;
wl->gpio_reset = gpio_reset;
wl->hif_func = ops;

#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Expand Down Expand Up @@ -1820,36 +1854,36 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
}
EXPORT_SYMBOL_GPL(wilc_netdev_init);

static void wilc_wlan_power(int power)
static void wilc_wlan_power(struct wilc *wilc, int power)
{
pr_info("wifi_pm : %d \n", power);
if (gpio_request(GPIO_NUM_CHIP_EN, "CHIP_EN") == 0 &&
gpio_request(GPIO_NUM_RESET, "RESET") == 0) {
gpio_direction_output(GPIO_NUM_CHIP_EN, 0);
gpio_direction_output(GPIO_NUM_RESET, 0);
if (gpio_request(wilc->gpio_chip_en, "CHIP_EN") == 0 &&
gpio_request(wilc->gpio_reset, "RESET") == 0) {
gpio_direction_output(wilc->gpio_chip_en, 0);
gpio_direction_output(wilc->gpio_reset, 0);
if (power) {
gpio_set_value(GPIO_NUM_CHIP_EN, 1);
gpio_set_value(wilc->gpio_chip_en, 1);
mdelay(5);
gpio_set_value(GPIO_NUM_RESET, 1);
gpio_set_value(wilc->gpio_reset, 1);
} else {
gpio_set_value(GPIO_NUM_RESET, 0);
gpio_set_value(GPIO_NUM_CHIP_EN, 0);
gpio_set_value(wilc->gpio_reset, 0);
gpio_set_value(wilc->gpio_chip_en, 0);
}
gpio_free(GPIO_NUM_CHIP_EN);
gpio_free(GPIO_NUM_RESET);
gpio_free(wilc->gpio_chip_en);
gpio_free(wilc->gpio_reset);
}
}

void wilc_wlan_power_on_sequence(void)
void wilc_wlan_power_on_sequence(struct wilc *wilc)
{
wilc_wlan_power(0);
wilc_wlan_power(1);
wilc_wlan_power(wilc, 0);
wilc_wlan_power(wilc, 1);
}
EXPORT_SYMBOL_GPL(wilc_wlan_power_on_sequence);

void wilc_wlan_power_off_sequence(void)
void wilc_wlan_power_off_sequence(struct wilc *wilc)
{
wilc_wlan_power(0);
wilc_wlan_power(wilc, 0);
}
EXPORT_SYMBOL_GPL(wilc_wlan_power_off_sequence);

Expand Down
Loading