Lines Matching refs:wilc
17 static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire)
19 mutex_lock(&wilc->hif_cs);
21 chip_wakeup(wilc);
24 static inline void release_bus(struct wilc *wilc, enum bus_release release)
27 chip_allow_sleep(wilc);
28 mutex_unlock(&wilc->hif_cs);
31 static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe)
34 wilc->txq_entries -= 1;
43 struct wilc *wilc = vif->wilc;
45 spin_lock_irqsave(&wilc->txq_spinlock, flags);
47 if (!list_empty(&wilc->txq_head.list)) {
48 tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t,
51 wilc->txq_entries -= 1;
53 spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
62 struct wilc *wilc = vif->wilc;
64 spin_lock_irqsave(&wilc->txq_spinlock, flags);
66 list_add_tail(&tqe->list, &wilc->txq_head.list);
67 wilc->txq_entries += 1;
69 spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
71 complete(&wilc->txq_event);
78 struct wilc *wilc = vif->wilc;
80 mutex_lock(&wilc->txq_add_to_head_cs);
82 spin_lock_irqsave(&wilc->txq_spinlock, flags);
84 list_add(&tqe->list, &wilc->txq_head.list);
85 wilc->txq_entries += 1;
87 spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
88 mutex_unlock(&wilc->txq_add_to_head_cs);
89 complete(&wilc->txq_event);
140 struct wilc *wilc = vif->wilc;
146 spin_lock_irqsave(&wilc->txq_spinlock, flags);
182 spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
188 struct wilc *wilc = vif->wilc;
194 spin_lock_irqsave(&wilc->txq_spinlock, flags);
215 wilc_wlan_txq_remove(wilc, tqe);
233 spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
236 wait_for_completion_timeout(&wilc->txq_event,
251 struct wilc *wilc = vif->wilc;
254 if (wilc->quit) {
256 complete(&wilc->cfg_event);
283 struct wilc *wilc;
285 wilc = vif->wilc;
287 if (wilc->quit)
305 return wilc->txq_entries;
314 struct wilc *wilc;
316 wilc = vif->wilc;
318 if (wilc->quit)
336 static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc)
341 spin_lock_irqsave(&wilc->txq_spinlock, flags);
343 if (!list_empty(&wilc->txq_head.list))
344 tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t,
347 spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
352 static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc,
357 spin_lock_irqsave(&wilc->txq_spinlock, flags);
359 if (!list_is_last(&tqe->list, &wilc->txq_head.list))
363 spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
368 static void wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
370 if (wilc->quit)
373 mutex_lock(&wilc->rxq_cs);
374 list_add_tail(&rqe->list, &wilc->rxq_head.list);
375 mutex_unlock(&wilc->rxq_cs);
378 static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
382 mutex_lock(&wilc->rxq_cs);
383 if (!list_empty(&wilc->rxq_head.list)) {
384 rqe = list_first_entry(&wilc->rxq_head.list, struct rxq_entry_t,
388 mutex_unlock(&wilc->rxq_cs);
392 void chip_allow_sleep(struct wilc *wilc)
396 wilc->hif_func->hif_read_reg(wilc, WILC_SDIO_WAKEUP_REG, ®);
398 wilc->hif_func->hif_write_reg(wilc, WILC_SDIO_WAKEUP_REG,
400 wilc->hif_func->hif_write_reg(wilc, WILC_SDIO_HOST_TO_FW_REG, 0);
404 void chip_wakeup(struct wilc *wilc)
407 const struct wilc_hif_func *h = wilc->hif_func;
409 if (wilc->io_type == WILC_HIF_SPI) {
411 h->hif_read_reg(wilc, WILC_SPI_WAKEUP_REG, ®);
412 h->hif_write_reg(wilc, WILC_SPI_WAKEUP_REG,
414 h->hif_write_reg(wilc, WILC_SPI_WAKEUP_REG,
419 wilc_get_chipid(wilc, true);
420 } while (wilc_get_chipid(wilc, true) == 0);
421 } while (wilc_get_chipid(wilc, true) == 0);
422 } else if (wilc->io_type == WILC_HIF_SDIO) {
423 h->hif_write_reg(wilc, WILC_SDIO_HOST_TO_FW_REG,
426 h->hif_read_reg(wilc, WILC_SDIO_WAKEUP_REG, ®);
428 h->hif_write_reg(wilc, WILC_SDIO_WAKEUP_REG,
430 h->hif_read_reg(wilc, WILC_SDIO_CLK_STATUS_REG,
436 h->hif_read_reg(wilc, WILC_SDIO_CLK_STATUS_REG,
440 h->hif_write_reg(wilc, WILC_SDIO_WAKEUP_REG,
446 if (wilc->chip_ps_state == WILC_CHIP_SLEEPING_MANUAL) {
447 if (wilc_get_chipid(wilc, false) < WILC_1000_BASE_ID_2B) {
450 h->hif_read_reg(wilc, WILC_REG_4_TO_1_RX, &val32);
452 h->hif_write_reg(wilc, WILC_REG_4_TO_1_RX, val32);
454 h->hif_read_reg(wilc, WILC_REG_4_TO_1_TX_BANK0, &val32);
456 h->hif_write_reg(wilc, WILC_REG_4_TO_1_TX_BANK0, val32);
459 wilc->chip_ps_state = WILC_CHIP_WAKEDUP;
463 void host_wakeup_notify(struct wilc *wilc)
465 acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
466 wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_2, 1);
467 release_bus(wilc, WILC_BUS_RELEASE_ONLY);
471 void host_sleep_notify(struct wilc *wilc)
473 acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
474 wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_1, 1);
475 release_bus(wilc, WILC_BUS_RELEASE_ONLY);
479 int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
492 u8 *txb = wilc->tx_buffer;
496 if (wilc->quit)
499 mutex_lock(&wilc->txq_add_to_head_cs);
500 tqe = wilc_wlan_txq_get_first(wilc);
528 tqe = wilc_wlan_txq_get_next(wilc, tqe);
535 acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
537 func = wilc->hif_func;
539 ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®);
549 ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, 0);
552 } while (!wilc->quit);
559 ret = func->hif_block_tx(wilc,
566 ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x2);
571 ret = func->hif_read_reg(wilc, WILC_HOST_VMM_CTL, ®);
580 ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x0);
588 ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®);
592 ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg);
608 release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
662 acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
664 ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM);
668 ret = func->hif_block_tx_ext(wilc, 0, txb, offset);
671 release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
674 mutex_unlock(&wilc->txq_add_to_head_cs);
677 *txq_count = wilc->txq_entries;
681 static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size)
703 wilc_wfi_mgmt_rx(wilc, buff_ptr, pkt_len);
706 wilc_frmw_to_host(wilc, buff_ptr, pkt_len,
713 wilc_wlan_cfg_indicate_rx(wilc, buff_ptr,
717 if (wilc->cfg_seq_no == rsp.seq_no)
718 complete(&wilc->cfg_event);
720 wilc_mac_indicate(wilc);
728 static void wilc_wlan_handle_rxq(struct wilc *wilc)
734 while (!wilc->quit) {
735 rqe = wilc_wlan_rxq_remove(wilc);
741 wilc_wlan_handle_rx_buff(wilc, buffer, size);
745 if (wilc->quit)
746 complete(&wilc->cfg_event);
749 static void wilc_unknown_isr_ext(struct wilc *wilc)
751 wilc->hif_func->hif_clear_int_ext(wilc, 0);
754 static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status)
756 u32 offset = wilc->rx_buffer_offset;
766 wilc->hif_func->hif_read_size(wilc, &size);
777 buffer = &wilc->rx_buffer[offset];
779 wilc->hif_func->hif_clear_int_ext(wilc, DATA_INT_CLR | ENABLE_RX_VMM);
780 ret = wilc->hif_func->hif_block_rx_ext(wilc, 0, buffer, size);
785 wilc->rx_buffer_offset = offset;
792 wilc_wlan_rxq_add(wilc, rqe);
793 wilc_wlan_handle_rxq(wilc);
796 void wilc_handle_isr(struct wilc *wilc)
800 acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
801 wilc->hif_func->hif_read_int(wilc, &int_status);
804 wilc_wlan_handle_isr_ext(wilc, int_status);
807 wilc_unknown_isr_ext(wilc);
809 release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
813 int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
831 acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
840 ret = wilc->hif_func->hif_block_tx(wilc, addr,
849 release_bus(wilc, WILC_BUS_RELEASE_ONLY);
862 int wilc_wlan_start(struct wilc *wilc)
868 if (wilc->io_type == WILC_HIF_SDIO) {
871 } else if (wilc->io_type == WILC_HIF_SPI) {
874 acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
875 ret = wilc->hif_func->hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg);
877 release_bus(wilc, WILC_BUS_RELEASE_ONLY);
881 if (wilc->io_type == WILC_HIF_SDIO && wilc->dev_irq_num)
884 ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_1, reg);
886 release_bus(wilc, WILC_BUS_RELEASE_ONLY);
890 wilc->hif_func->hif_sync_ext(wilc, NUM_INT_EXT);
892 ret = wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &chipid);
894 release_bus(wilc, WILC_BUS_RELEASE_ONLY);
898 wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
901 wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
902 wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
906 ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
907 wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®);
908 release_bus(wilc, WILC_BUS_RELEASE_ONLY);
913 int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif)
918 acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP);
920 ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, ®);
923 release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
927 ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0,
931 release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
935 ret = wilc->hif_func->hif_read_reg(wilc, WILC_FW_HOST_COMM, ®);
938 release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
943 ret = wilc->hif_func->hif_write_reg(wilc, WILC_FW_HOST_COMM, reg);
946 release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
950 release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
960 struct wilc *wilc = vif->wilc;
962 wilc->quit = 1;
969 while ((rqe = wilc_wlan_rxq_remove(wilc)))
972 kfree(wilc->rx_buffer);
973 wilc->rx_buffer = NULL;
974 kfree(wilc->tx_buffer);
975 wilc->tx_buffer = NULL;
976 wilc->hif_func->hif_deinit(NULL);
982 struct wilc *wilc = vif->wilc;
983 struct wilc_cfg_frame *cfg = &wilc->cfg_frame;
984 int t_len = wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr);
991 cfg->hdr.seq_no = wilc->cfg_seq_no % 256;
994 wilc->cfg_seq_no = cfg->hdr.seq_no;
1007 struct wilc *wilc = vif->wilc;
1009 mutex_lock(&wilc->cfg_cmd_lock);
1012 wilc->cfg_frame_offset = 0;
1014 offset = wilc->cfg_frame_offset;
1015 ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset,
1018 wilc->cfg_frame_offset = offset;
1021 mutex_unlock(&wilc->cfg_cmd_lock);
1025 netdev_dbg(vif->ndev, "%s: seqno[%d]\n", __func__, wilc->cfg_seq_no);
1030 if (!wait_for_completion_timeout(&wilc->cfg_event,
1036 wilc->cfg_frame_offset = 0;
1037 wilc->cfg_seq_no += 1;
1038 mutex_unlock(&wilc->cfg_cmd_lock);
1048 struct wilc *wilc = vif->wilc;
1050 mutex_lock(&wilc->cfg_cmd_lock);
1053 wilc->cfg_frame_offset = 0;
1055 offset = wilc->cfg_frame_offset;
1056 ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, wid);
1058 wilc->cfg_frame_offset = offset;
1061 mutex_unlock(&wilc->cfg_cmd_lock);
1068 if (!wait_for_completion_timeout(&wilc->cfg_event,
1073 wilc->cfg_frame_offset = 0;
1074 wilc->cfg_seq_no += 1;
1075 mutex_unlock(&wilc->cfg_cmd_lock);
1098 wids[i].size = wilc_wlan_cfg_get_val(vif->wilc,
1126 struct wilc *wilc = vif->wilc;
1128 acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
1130 chipid = wilc_get_chipid(wilc, true);
1133 ret = wilc->hif_func->hif_read_reg(wilc,
1141 ret = wilc->hif_func->hif_write_reg(wilc,
1148 ret = wilc->hif_func->hif_write_reg(wilc,
1158 release_bus(wilc, WILC_BUS_RELEASE_ONLY);
1163 u32 wilc_get_chipid(struct wilc *wilc, bool update)
1170 wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &tempchipid);
1171 wilc->hif_func->hif_read_reg(wilc, WILC_RF_REVISION_ID,
1196 struct wilc *wilc;
1198 wilc = vif->wilc;
1200 wilc->quit = 0;
1202 if (wilc->hif_func->hif_init(wilc, false)) {
1207 if (!wilc->tx_buffer)
1208 wilc->tx_buffer = kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL);
1210 if (!wilc->tx_buffer) {
1215 if (!wilc->rx_buffer)
1216 wilc->rx_buffer = kmalloc(WILC_RX_BUFF_SIZE, GFP_KERNEL);
1218 if (!wilc->rx_buffer) {
1232 kfree(wilc->rx_buffer);
1233 wilc->rx_buffer = NULL;
1234 kfree(wilc->tx_buffer);
1235 wilc->tx_buffer = NULL;