}
#endif
-/*
- * Interrupt initialization and handling functions
- */
-
-void linux_wlan_enable_irq(void)
-{
-
-#if (RX_BH_TYPE != RX_BH_THREADED_IRQ)
-#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
- PRINT_D(INT_DBG, "Enabling IRQ ...\n");
- enable_irq(g_linux_wlan->dev_irq_num);
-#endif
-#endif
-}
-
-void linux_wlan_disable_irq(int wait)
-{
-#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
- if (wait) {
- PRINT_D(INT_DBG, "Disabling IRQ ...\n");
- disable_irq(g_linux_wlan->dev_irq_num);
- } else {
- PRINT_D(INT_DBG, "Disabling IRQ ...\n");
- disable_irq_nosync(g_linux_wlan->dev_irq_num);
- }
-#endif
-}
-
#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
static irqreturn_t isr_uh_routine(int irq, void *user_data)
{
-#if (RX_BH_TYPE != RX_BH_THREADED_IRQ)
- linux_wlan_disable_irq(IRQ_NO_WAIT);
-#endif
PRINT_D(INT_DBG, "Interrupt received UH\n");
/*While mac is closing cacncel the handling of any interrupts received*/
if (g_linux_wlan->close) {
PRINT_ER("Driver is CLOSING: Can't handle UH interrupt\n");
- #if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
return IRQ_HANDLED;
- #else
- return IRQ_NONE;
- #endif
-
}
-#if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
- schedule_work(&g_linux_wlan->rx_work_queue);
- return IRQ_HANDLED;
-#elif (RX_BH_TYPE == RX_BH_KTHREAD)
- up(&g_linux_wlan->rx_sem);
- return IRQ_HANDLED;
-#elif (RX_BH_TYPE == RX_BH_THREADED_IRQ)
return IRQ_WAKE_THREAD;
-#endif
-
}
#endif
-#if (RX_BH_TYPE == RX_BH_WORK_QUEUE || RX_BH_TYPE == RX_BH_THREADED_IRQ)
-
-#if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
irqreturn_t isr_bh_routine(int irq, void *userdata)
{
linux_wlan_t *nic;
nic = (linux_wlan_t *)userdata;
-#else
-static void isr_bh_routine(struct work_struct *work)
-{
- perInterface_wlan_t *nic;
-
- nic = (perInterface_wlan_t *)container_of(work, linux_wlan_t, rx_work_queue);
-#endif
/*While mac is closing cacncel the handling of any interrupts received*/
if (g_linux_wlan->close) {
PRINT_ER("Driver is CLOSING: Can't handle BH interrupt\n");
- #if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
return IRQ_HANDLED;
- #else
- return;
- #endif
}
PRINT_D(INT_DBG, "Interrupt received BH\n");
else
PRINT_ER("wlan_handle_rx_isr() hasn't been initialized\n");
-#if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
return IRQ_HANDLED;
-#endif
}
-#elif (RX_BH_TYPE == RX_BH_KTHREAD)
-static int isr_bh_routine(void *vp)
-{
- linux_wlan_t *nic;
-
- nic = (linux_wlan_t *)vp;
-
- while (1) {
- down(&nic->rx_sem);
- if (g_linux_wlan->close) {
-
- while (!kthread_should_stop())
- schedule();
-
- break;
- }
- PRINT_D(INT_DBG, "Interrupt received BH\n");
- if (g_linux_wlan->oup.wlan_handle_rx_isr != NULL)
- g_linux_wlan->oup.wlan_handle_rx_isr();
- else
- PRINT_ER("wlan_handle_rx_isr() hasn't been initialized\n");
- }
-
- return 0;
-}
-#endif
#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
static int init_irq(linux_wlan_t *p_nic)
PRINT_ER("could not obtain gpio for WILC_INTR\n");
}
-#if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
if ((ret != -1) && (request_threaded_irq(nic->dev_irq_num, isr_uh_routine, isr_bh_routine,
IRQF_TRIGGER_LOW | IRQF_ONESHOT, /*Without IRQF_ONESHOT the uh will remain kicked in and dont gave a chance to bh*/
"WILC_IRQ", nic)) < 0) {
-#else
- /*Request IRQ*/
- if ((ret != -1) && (request_irq(nic->dev_irq_num, isr_uh_routine,
- IRQF_TRIGGER_LOW, "WILC_IRQ", nic) < 0)) {
-
-#endif
PRINT_ER("Failed to request IRQ for GPIO: %d\n", GPIO_NUM);
ret = -1;
} else {
PRINT_D(INIT_DBG, "Disabling IRQ\n");
#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
- linux_wlan_disable_irq(IRQ_WAIT);
#else
#if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
if (&g_linux_wlan->txq_event != NULL)
up(&g_linux_wlan->txq_event);
- #if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
- /*Removing the work struct from the linux kernel workqueue*/
- if (&g_linux_wlan->rx_work_queue != NULL)
- flush_work(&g_linux_wlan->rx_work_queue);
-
- #elif (RX_BH_TYPE == RX_BH_KTHREAD)
- /* if(&nic->rx_sem != NULL) */
- /* up(&nic->rx_sem); */
- #endif
-
PRINT_D(INIT_DBG, "Deinitializing Threads\n");
wlan_deinitialize_threads(nic);
sema_init(&g_linux_wlan->txq_thread_started, 0);
- #if (RX_BH_TYPE == RX_BH_KTHREAD)
- sema_init(&g_linux_wlan->rx_sem, 0);
- #endif
-
return 0;
}
PRINT_D(INIT_DBG, "Initializing Threads ...\n");
-#if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
- /*Initialize rx work queue task*/
- INIT_WORK(&g_linux_wlan->rx_work_queue, isr_bh_routine);
-#elif (RX_BH_TYPE == RX_BH_KTHREAD)
- PRINT_D(INIT_DBG, "Creating kthread for Rxq BH\n");
- g_linux_wlan->rx_bh_thread = kthread_run(isr_bh_routine, (void *)g_linux_wlan, "K_RXQ_BH");
- if (g_linux_wlan->rx_bh_thread == NULL) {
- PRINT_ER("couldn't create RX BH thread\n");
- ret = -ENOBUFS;
- goto _fail_;
- }
-#endif
-
/* create tx task */
PRINT_D(INIT_DBG, "Creating kthread for transmission\n");
g_linux_wlan->txq_thread = kthread_run(linux_wlan_txq_task, (void *)g_linux_wlan, "K_TXQ_TASK");
/*De-Initialize 2nd thread*/
g_linux_wlan->close = 1;
- #if (RX_BH_TYPE == RX_BH_KTHREAD)
- /*De-Initialize 1st thread*/
- g_linux_wlan->close = 1;
- up(&g_linux_wlan->rx_sem);
- kthread_stop(g_linux_wlan->rx_bh_thread);
-_fail_:
- #endif
g_linux_wlan->close = 0;
return ret;
}
kthread_stop(g_linux_wlan->txq_thread);
g_linux_wlan->txq_thread = NULL;
}
-
- #if (RX_BH_TYPE == RX_BH_KTHREAD)
- if (&g_linux_wlan->rx_sem != NULL)
- up(&g_linux_wlan->rx_sem);
-
- if (g_linux_wlan->rx_bh_thread != NULL) {
- kthread_stop(g_linux_wlan->rx_bh_thread);
- g_linux_wlan->rx_bh_thread = NULL;
- }
- #endif
}
#ifdef COMPLEMENT_BOOT