obj-$(CONFIG_WILC1000) += wilc1000.o
ccflags-$(CONFIG_WILC1000_SDIO) += -DWILC_SDIO -DCOMPLEMENT_BOOT
-ccflags-$(CONFIG_WILC1000_HW_OOB_INTR) += -DWILC_SDIO_IRQ_GPIO
ccflags-$(CONFIG_WILC1000_SPI) += -DWILC_SPI
ccflags-y += -DSTA_FIRMWARE=\"atmel/wilc1000_fw.bin\" \
return NOTIFY_DONE;
}
-#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
static irqreturn_t isr_uh_routine(int irq, void *user_data)
{
perInterface_wlan_t *nic;
nic = netdev_priv(dev);
wl = nic->wilc;
- if ((gpio_request(GPIO_NUM, "WILC_INTR") == 0) &&
- (gpio_direction_input(GPIO_NUM) == 0)) {
- wl->dev_irq_num = gpio_to_irq(GPIO_NUM);
+ if ((gpio_request(wl->gpio, "WILC_INTR") == 0) &&
+ (gpio_direction_input(wl->gpio) == 0)) {
+ wl->dev_irq_num = gpio_to_irq(wl->gpio);
} else {
ret = -1;
PRINT_ER("could not obtain gpio for WILC_INTR\n");
isr_bh_routine,
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"WILC_IRQ", dev) < 0) {
- PRINT_ER("Failed to request IRQ for GPIO: %d\n", GPIO_NUM);
+ PRINT_ER("Failed to request IRQ for GPIO: %d\n", wl->gpio);
+ gpio_free(wl->gpio);
ret = -1;
} else {
PRINT_D(INIT_DBG, "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n",
- wl->dev_irq_num, GPIO_NUM);
+ wl->dev_irq_num, wl->gpio);
}
return ret;
}
-#endif
static void deinit_irq(struct net_device *dev)
{
nic = netdev_priv(dev);
wilc = nic->wilc;
-#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
- if (&wilc->dev_irq_num != 0) {
+ /* Deintialize IRQ */
+ if (wilc->dev_irq_num) {
free_irq(wilc->dev_irq_num, wilc);
-
- gpio_free(GPIO_NUM);
+ gpio_free(wilc->gpio);
}
-#endif
}
void linux_wlan_dbg(u8 *buff)
#endif
PRINT_D(INIT_DBG, "Disabling IRQ\n");
-#ifdef WILC_SDIO
- mutex_lock(&wl->hif_cs);
- wilc_sdio_disable_interrupt();
- mutex_unlock(&wl->hif_cs);
-#endif
+ if (!wl->dev_irq_num) {
+ mutex_lock(&wl->hif_cs);
+ wilc_sdio_disable_interrupt();
+ mutex_unlock(&wl->hif_cs);
+ }
if (&wl->txq_event)
up(&wl->txq_event);
PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n");
wilc_wlan_cleanup(dev);
-#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
- #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
- PRINT_D(INIT_DBG, "Disabling IRQ 2\n");
-
- mutex_lock(&wl->hif_cs);
- wilc_sdio_disable_interrupt();
- mutex_unlock(&wl->hif_cs);
- #endif
+#if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
+ if (!wl->dev_irq_num) {
+ PRINT_D(INIT_DBG, "Disabling IRQ 2\n");
+
+ mutex_lock(&wl->hif_cs);
+ wilc_sdio_disable_interrupt();
+ mutex_unlock(&wl->hif_cs);
+ }
#endif
PRINT_D(INIT_DBG, "Deinitializing Locks\n");
goto _fail_locks_;
}
-#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
- if (init_irq(dev)) {
+ if (wl->gpio >= 0 && init_irq(dev)) {
PRINT_ER("couldn't initialize IRQ\n");
ret = -EIO;
goto _fail_locks_;
}
-#endif
ret = wlan_initialize_threads(dev);
if (ret < 0) {
goto _fail_wilc_wlan_;
}
-#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
- if (wilc_sdio_enable_interrupt()) {
+ if (!wl->dev_irq_num && wilc_sdio_enable_interrupt()) {
PRINT_ER("couldn't initialize IRQ\n");
ret = -EIO;
goto _fail_irq_init_;
}
-#endif
if (wilc_wlan_get_firmware(dev)) {
PRINT_ER("Can't get firmware\n");
wilc_wlan_stop();
_fail_irq_enable_:
-#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
- wilc_sdio_disable_interrupt();
+ if (!wl->dev_irq_num)
+ wilc_sdio_disable_interrupt();
_fail_irq_init_:
-#endif
-#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
- deinit_irq(dev);
+ if (wl->dev_irq_num)
+ deinit_irq(dev);
-#endif
wlan_deinitialize_threads(dev);
_fail_wilc_wlan_:
wilc_wlan_cleanup(dev);
#endif
}
-int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type)
+int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, int gpio)
{
int i;
perInterface_wlan_t *nic;
*wilc = wilc_dev;
wilc_dev->io_type = io_type;
+ wilc_dev->gpio = gpio;
+
register_inetaddr_notifier(&g_dev_notifier);
for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
#include <linux/mmc/sdio_ids.h>
#include <linux/mmc/sdio.h>
#include <linux/mmc/host.h>
+#include <linux/of_gpio.h>
};
-#ifndef WILC_SDIO_IRQ_GPIO
static void wilc_sdio_interrupt(struct sdio_func *func)
{
sdio_release_host(func);
wilc_handle_isr(sdio_get_drvdata(func));
sdio_claim_host(func);
}
-#endif
-
int wilc_sdio_cmd52(sdio_cmd52_t *cmd)
{
static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
{
struct wilc *wilc;
+ int gpio;
+ gpio = -1;
+ if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
+ gpio = of_get_gpio(func->dev.of_node, 0);
+ if (gpio < 0)
+ gpio = GPIO_NUM;
+ }
PRINT_D(INIT_DBG, "Initializing netdev\n");
wilc_sdio_func = func;
- if (wilc_netdev_init(&wilc, &func->dev, HIF_SDIO)) {
+ if (wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, gpio)) {
PRINT_ER("Couldn't initialize netdev\n");
return -1;
}
int wilc_sdio_enable_interrupt(void)
{
int ret = 0;
-#ifndef WILC_SDIO_IRQ_GPIO
sdio_claim_host(wilc_sdio_func);
ret = sdio_claim_irq(wilc_sdio_func, wilc_sdio_interrupt);
PRINT_ER("can't claim sdio_irq, err(%d)\n", ret);
ret = -EIO;
}
-#endif
return ret;
}
void wilc_sdio_disable_interrupt(void)
{
-
-#ifndef WILC_SDIO_IRQ_GPIO
int ret;
PRINT_D(INIT_DBG, "wilc_sdio_disable_interrupt IN\n");
sdio_release_host(wilc_sdio_func);
PRINT_D(INIT_DBG, "wilc_sdio_disable_interrupt OUT\n");
-#endif
}
static int linux_sdio_set_speed(int speed)
wilc_debugfs_init();
- ret = wilc_netdev_init(&wilc, NULL, HIF_SPI);
+ ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, GPIO_NUM);
if (ret) {
wilc_debugfs_remove();
return ret;
#define WILC_SDIO_BLOCK_SIZE 512
typedef struct {
+ bool irq_gpio;
u32 block_size;
wilc_debug_func dPrint;
int nint;
static wilc_sdio_t g_sdio;
-#ifdef WILC_SDIO_IRQ_GPIO
static int sdio_write_reg(u32 addr, u32 data);
static int sdio_read_reg(u32 addr, u32 *data);
-#endif
/********************************************
*
static int sdio_clear_int(void)
{
-#ifndef WILC_SDIO_IRQ_GPIO
- /* u32 sts; */
- sdio_cmd52_t cmd;
+ if (!g_sdio.irq_gpio) {
+ /* u32 sts; */
+ sdio_cmd52_t cmd;
- cmd.read_write = 0;
- cmd.function = 1;
- cmd.raw = 0;
- cmd.address = 0x4;
- cmd.data = 0;
- wilc_sdio_cmd52(&cmd);
+ cmd.read_write = 0;
+ cmd.function = 1;
+ cmd.raw = 0;
+ cmd.address = 0x4;
+ cmd.data = 0;
+ wilc_sdio_cmd52(&cmd);
- return cmd.data;
-#else
- u32 reg;
+ return cmd.data;
+ } else {
+ u32 reg;
- if (!sdio_read_reg(WILC_HOST_RX_CTRL_0, ®)) {
- g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_HOST_RX_CTRL_0);
- return 0;
+ if (!sdio_read_reg(WILC_HOST_RX_CTRL_0, ®)) {
+ g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_HOST_RX_CTRL_0);
+ return 0;
+ }
+ reg &= ~0x1;
+ sdio_write_reg(WILC_HOST_RX_CTRL_0, reg);
+ return 1;
}
- reg &= ~0x1;
- sdio_write_reg(WILC_HOST_RX_CTRL_0, reg);
- return 1;
-#endif
}
return 0;
}
-#ifdef WILC_SDIO_IRQ_GPIO
- {
+ if (g_sdio.irq_gpio) {
u32 reg;
int ret;
return 0;
}
}
-#endif
return 1;
}
memset(&g_sdio, 0, sizeof(wilc_sdio_t));
g_sdio.dPrint = func;
+ g_sdio.irq_gpio = (wilc->dev_irq_num);
if (!wilc_sdio_init()) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed io init bus...\n");
/**
* Read IRQ flags
**/
-#ifndef WILC_SDIO_IRQ_GPIO
- cmd.function = 1;
- cmd.address = 0x04;
- cmd.data = 0;
- wilc_sdio_cmd52(&cmd);
-
- if (cmd.data & BIT(0))
- tmp |= INT_0;
- if (cmd.data & BIT(2))
- tmp |= INT_1;
- if (cmd.data & BIT(3))
- tmp |= INT_2;
- if (cmd.data & BIT(4))
- tmp |= INT_3;
- if (cmd.data & BIT(5))
- tmp |= INT_4;
- if (cmd.data & BIT(6))
- tmp |= INT_5;
- {
+ if (!g_sdio.irq_gpio) {
int i;
+ cmd.function = 1;
+ cmd.address = 0x04;
+ cmd.data = 0;
+ wilc_sdio_cmd52(&cmd);
+
+ if (cmd.data & BIT(0))
+ tmp |= INT_0;
+ if (cmd.data & BIT(2))
+ tmp |= INT_1;
+ if (cmd.data & BIT(3))
+ tmp |= INT_2;
+ if (cmd.data & BIT(4))
+ tmp |= INT_3;
+ if (cmd.data & BIT(5))
+ tmp |= INT_4;
+ if (cmd.data & BIT(6))
+ tmp |= INT_5;
for (i = g_sdio.nint; i < MAX_NUM_INT; i++) {
if ((tmp >> (IRG_FLAGS_OFFSET + i)) & 0x1) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Unexpected interrupt (1) : tmp=%x, data=%x\n", tmp, cmd.data);
break;
}
}
- }
-#else
- {
+ } else {
u32 irq_flags;
cmd.read_write = 0;
tmp |= ((irq_flags >> 0) << IRG_FLAGS_OFFSET);
}
-#endif
-
*int_status = tmp;
return 1;
if (g_sdio.has_thrpt_enh3) {
u32 reg;
-#ifdef WILC_SDIO_IRQ_GPIO
- {
+ if (g_sdio.irq_gpio) {
u32 flags;
flags = val & (BIT(MAX_NUN_INT_THRPT_ENH2) - 1);
reg = flags;
+ } else {
+ reg = 0;
}
-#else
- reg = 0;
-#endif
/* select VMM table 0 */
if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
reg |= BIT(5);
}
} else {
-#ifdef WILC_SDIO_IRQ_GPIO
- {
+ if (g_sdio.irq_gpio) {
/* see below. has_thrpt_enh2 uses register 0xf8 to clear interrupts. */
/* Cannot clear multiple interrupts. Must clear each interrupt individually */
u32 flags;
}
}
}
-#endif /* WILC_SDIO_IRQ_GPIO */
{
u32 vmm_ctl;
return 0;
}
-#ifdef WILC_SDIO_IRQ_GPIO
- {
+ if (g_sdio.irq_gpio) {
u32 reg;
int ret, i;
}
}
}
-#endif /* WILC_SDIO_IRQ_GPIO */
return 1;
}
struct wilc {
int io_type;
int mac_status;
+ int gpio;
bool initialized;
- #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
- unsigned short dev_irq_num;
- #endif
+ int dev_irq_num;
int close;
u8 vif_num;
struct wilc_vif vif[NUM_CONCURRENT_IFC];
void linux_wlan_dbg(u8 *buff);
int linux_wlan_lock_timeout(void *vp, u32 timeout);
void wilc_netdev_cleanup(struct wilc *wilc);
-int wilc_netdev_init(struct wilc **wilc, struct device *, int io_type);
+int wilc_netdev_init(struct wilc **wilc, struct device *, int io_type, int gpio);
void wilc1000_wlan_deinit(struct net_device *dev);
void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
u16 wilc_set_machw_change_vir_if(struct net_device *dev, bool value);
wilc_sleeptimer_isr_ext(int_status);
if (!(int_status & (ALL_INT_EXT))) {
-#ifdef WILC_SDIO
- PRINT_D(TX_DBG, ">> UNKNOWN_INTERRUPT - 0x%08x\n", int_status);
-#endif
wilc_unknown_isr_ext();
}
release_bus(RELEASE_ALLOW_SLEEP);
return ret;
}
reg = 0;
-#ifdef WILC_SDIO_IRQ_GPIO
- reg |= WILC_HAVE_SDIO_IRQ_GPIO;
-#endif
+ if (p->io_type == HIF_SDIO && wilc_dev->dev_irq_num)
+ reg |= WILC_HAVE_SDIO_IRQ_GPIO;
#ifdef WILC_DISABLE_PMU
#else