Lines Matching full:wo
21 mtk_wed_mmio_r32(struct mtk_wed_wo *wo, u32 reg) in mtk_wed_mmio_r32() argument
25 if (regmap_read(wo->mmio.regs, reg, &val)) in mtk_wed_mmio_r32()
32 mtk_wed_mmio_w32(struct mtk_wed_wo *wo, u32 reg, u32 val) in mtk_wed_mmio_w32() argument
34 regmap_write(wo->mmio.regs, reg, val); in mtk_wed_mmio_w32()
38 mtk_wed_wo_get_isr(struct mtk_wed_wo *wo) in mtk_wed_wo_get_isr() argument
40 u32 val = mtk_wed_mmio_r32(wo, MTK_WED_WO_CCIF_RCHNUM); in mtk_wed_wo_get_isr()
46 mtk_wed_wo_set_isr(struct mtk_wed_wo *wo, u32 mask) in mtk_wed_wo_set_isr() argument
48 mtk_wed_mmio_w32(wo, MTK_WED_WO_CCIF_IRQ0_MASK, mask); in mtk_wed_wo_set_isr()
52 mtk_wed_wo_set_ack(struct mtk_wed_wo *wo, u32 mask) in mtk_wed_wo_set_ack() argument
54 mtk_wed_mmio_w32(wo, MTK_WED_WO_CCIF_ACK, mask); in mtk_wed_wo_set_ack()
58 mtk_wed_wo_set_isr_mask(struct mtk_wed_wo *wo, u32 mask, u32 val, bool set) in mtk_wed_wo_set_isr_mask() argument
62 spin_lock_irqsave(&wo->mmio.lock, flags); in mtk_wed_wo_set_isr_mask()
63 wo->mmio.irq_mask &= ~mask; in mtk_wed_wo_set_isr_mask()
64 wo->mmio.irq_mask |= val; in mtk_wed_wo_set_isr_mask()
66 mtk_wed_wo_set_isr(wo, wo->mmio.irq_mask); in mtk_wed_wo_set_isr_mask()
67 spin_unlock_irqrestore(&wo->mmio.lock, flags); in mtk_wed_wo_set_isr_mask()
71 mtk_wed_wo_irq_enable(struct mtk_wed_wo *wo, u32 mask) in mtk_wed_wo_irq_enable() argument
73 mtk_wed_wo_set_isr_mask(wo, 0, mask, false); in mtk_wed_wo_irq_enable()
74 tasklet_schedule(&wo->mmio.irq_tasklet); in mtk_wed_wo_irq_enable()
78 mtk_wed_wo_irq_disable(struct mtk_wed_wo *wo, u32 mask) in mtk_wed_wo_irq_disable() argument
80 mtk_wed_wo_set_isr_mask(wo, mask, 0, true); in mtk_wed_wo_irq_disable()
84 mtk_wed_wo_kickout(struct mtk_wed_wo *wo) in mtk_wed_wo_kickout() argument
86 mtk_wed_mmio_w32(wo, MTK_WED_WO_CCIF_BUSY, 1 << MTK_WED_WO_TXCH_NUM); in mtk_wed_wo_kickout()
87 mtk_wed_mmio_w32(wo, MTK_WED_WO_CCIF_TCHNUM, MTK_WED_WO_TXCH_NUM); in mtk_wed_wo_kickout()
91 mtk_wed_wo_queue_kick(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, in mtk_wed_wo_queue_kick() argument
95 mtk_wed_mmio_w32(wo, q->regs.cpu_idx, val); in mtk_wed_wo_queue_kick()
99 mtk_wed_wo_dequeue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, u32 *len, in mtk_wed_wo_dequeue() argument
126 dma_unmap_single(wo->hw->dev, entry->addr, buf_len, in mtk_wed_wo_dequeue()
134 mtk_wed_wo_queue_refill(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, in mtk_wed_wo_queue_refill() argument
150 addr = dma_map_single(wo->hw->dev, buf, q->buf_size, dir); in mtk_wed_wo_queue_refill()
151 if (unlikely(dma_mapping_error(wo->hw->dev, addr))) { in mtk_wed_wo_queue_refill()
179 mtk_wed_wo_rx_complete(struct mtk_wed_wo *wo) in mtk_wed_wo_rx_complete() argument
181 mtk_wed_wo_set_ack(wo, MTK_WED_WO_RXCH_INT_MASK); in mtk_wed_wo_rx_complete()
182 mtk_wed_wo_irq_enable(wo, MTK_WED_WO_RXCH_INT_MASK); in mtk_wed_wo_rx_complete()
186 mtk_wed_wo_rx_run_queue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q) in mtk_wed_wo_rx_run_queue() argument
194 data = mtk_wed_wo_dequeue(wo, q, &len, false); in mtk_wed_wo_rx_run_queue()
205 if (mtk_wed_mcu_check_msg(wo, skb)) { in mtk_wed_wo_rx_run_queue()
212 mtk_wed_mcu_rx_event(wo, skb); in mtk_wed_wo_rx_run_queue()
214 mtk_wed_mcu_rx_unsolicited_event(wo, skb); in mtk_wed_wo_rx_run_queue()
217 if (mtk_wed_wo_queue_refill(wo, q, true)) { in mtk_wed_wo_rx_run_queue()
220 mtk_wed_wo_queue_kick(wo, q, index); in mtk_wed_wo_rx_run_queue()
227 struct mtk_wed_wo *wo = data; in mtk_wed_wo_irq_handler() local
229 mtk_wed_wo_set_isr(wo, 0); in mtk_wed_wo_irq_handler()
230 tasklet_schedule(&wo->mmio.irq_tasklet); in mtk_wed_wo_irq_handler()
237 struct mtk_wed_wo *wo = from_tasklet(wo, t, mmio.irq_tasklet); in mtk_wed_wo_irq_tasklet() local
241 mtk_wed_wo_set_isr(wo, 0); in mtk_wed_wo_irq_tasklet()
243 intr = mtk_wed_wo_get_isr(wo); in mtk_wed_wo_irq_tasklet()
244 intr &= wo->mmio.irq_mask; in mtk_wed_wo_irq_tasklet()
246 mtk_wed_wo_irq_disable(wo, mask); in mtk_wed_wo_irq_tasklet()
249 mtk_wed_wo_rx_run_queue(wo, &wo->q_rx); in mtk_wed_wo_irq_tasklet()
250 mtk_wed_wo_rx_complete(wo); in mtk_wed_wo_irq_tasklet()
254 /* mtk wed wo hw queues */
257 mtk_wed_wo_queue_alloc(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, in mtk_wed_wo_queue_alloc() argument
265 q->desc = dmam_alloc_coherent(wo->hw->dev, n_desc * sizeof(*q->desc), in mtk_wed_wo_queue_alloc()
270 q->entry = devm_kzalloc(wo->hw->dev, n_desc * sizeof(*q->entry), in mtk_wed_wo_queue_alloc()
279 mtk_wed_wo_queue_free(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q) in mtk_wed_wo_queue_free() argument
281 mtk_wed_mmio_w32(wo, q->regs.cpu_idx, 0); in mtk_wed_wo_queue_free()
282 dma_free_coherent(wo->hw->dev, q->n_desc * sizeof(*q->desc), q->desc, in mtk_wed_wo_queue_free()
287 mtk_wed_wo_queue_tx_clean(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q) in mtk_wed_wo_queue_tx_clean() argument
297 dma_unmap_single(wo->hw->dev, entry->addr, entry->len, in mtk_wed_wo_queue_tx_clean()
307 mtk_wed_wo_queue_rx_clean(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q) in mtk_wed_wo_queue_rx_clean() argument
310 void *buf = mtk_wed_wo_dequeue(wo, q, NULL, true); in mtk_wed_wo_queue_rx_clean()
322 mtk_wed_wo_queue_reset(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q) in mtk_wed_wo_queue_reset() argument
324 mtk_wed_mmio_w32(wo, q->regs.cpu_idx, 0); in mtk_wed_wo_queue_reset()
325 mtk_wed_mmio_w32(wo, q->regs.desc_base, q->desc_dma); in mtk_wed_wo_queue_reset()
326 mtk_wed_mmio_w32(wo, q->regs.ring_size, q->n_desc); in mtk_wed_wo_queue_reset()
329 int mtk_wed_wo_queue_tx_skb(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, in mtk_wed_wo_queue_tx_skb() argument
337 q->tail = mtk_wed_mmio_r32(wo, q->regs.dma_idx); in mtk_wed_wo_queue_tx_skb()
353 dma_sync_single_for_cpu(wo->hw->dev, entry->addr, skb->len, in mtk_wed_wo_queue_tx_skb()
356 dma_sync_single_for_device(wo->hw->dev, entry->addr, skb->len, in mtk_wed_wo_queue_tx_skb()
364 mtk_wed_wo_queue_kick(wo, q, q->head); in mtk_wed_wo_queue_tx_skb()
365 mtk_wed_wo_kickout(wo); in mtk_wed_wo_queue_tx_skb()
373 mtk_wed_wo_exception_init(struct mtk_wed_wo *wo) in mtk_wed_wo_exception_init() argument
379 mtk_wed_wo_hardware_init(struct mtk_wed_wo *wo) in mtk_wed_wo_hardware_init() argument
385 np = of_parse_phandle(wo->hw->node, "mediatek,wo-ccif", 0); in mtk_wed_wo_hardware_init()
389 wo->mmio.regs = syscon_regmap_lookup_by_phandle(np, NULL); in mtk_wed_wo_hardware_init()
390 if (IS_ERR(wo->mmio.regs)) { in mtk_wed_wo_hardware_init()
391 ret = PTR_ERR(wo->mmio.regs); in mtk_wed_wo_hardware_init()
395 wo->mmio.irq = irq_of_parse_and_map(np, 0); in mtk_wed_wo_hardware_init()
396 wo->mmio.irq_mask = MTK_WED_WO_ALL_INT_MASK; in mtk_wed_wo_hardware_init()
397 spin_lock_init(&wo->mmio.lock); in mtk_wed_wo_hardware_init()
398 tasklet_setup(&wo->mmio.irq_tasklet, mtk_wed_wo_irq_tasklet); in mtk_wed_wo_hardware_init()
400 ret = devm_request_irq(wo->hw->dev, wo->mmio.irq, in mtk_wed_wo_hardware_init()
402 KBUILD_MODNAME, wo); in mtk_wed_wo_hardware_init()
411 ret = mtk_wed_wo_queue_alloc(wo, &wo->q_tx, MTK_WED_WO_RING_SIZE, in mtk_wed_wo_hardware_init()
417 mtk_wed_wo_queue_refill(wo, &wo->q_tx, false); in mtk_wed_wo_hardware_init()
418 mtk_wed_wo_queue_reset(wo, &wo->q_tx); in mtk_wed_wo_hardware_init()
425 ret = mtk_wed_wo_queue_alloc(wo, &wo->q_rx, MTK_WED_WO_RING_SIZE, in mtk_wed_wo_hardware_init()
431 mtk_wed_wo_queue_refill(wo, &wo->q_rx, true); in mtk_wed_wo_hardware_init()
432 mtk_wed_wo_queue_reset(wo, &wo->q_rx); in mtk_wed_wo_hardware_init()
435 mtk_wed_wo_set_isr(wo, wo->mmio.irq_mask); in mtk_wed_wo_hardware_init()
440 devm_free_irq(wo->hw->dev, wo->mmio.irq, wo); in mtk_wed_wo_hardware_init()
447 mtk_wed_wo_hw_deinit(struct mtk_wed_wo *wo) in mtk_wed_wo_hw_deinit() argument
450 mtk_wed_wo_set_isr(wo, 0); in mtk_wed_wo_hw_deinit()
452 tasklet_disable(&wo->mmio.irq_tasklet); in mtk_wed_wo_hw_deinit()
454 disable_irq(wo->mmio.irq); in mtk_wed_wo_hw_deinit()
455 devm_free_irq(wo->hw->dev, wo->mmio.irq, wo); in mtk_wed_wo_hw_deinit()
457 mtk_wed_wo_queue_tx_clean(wo, &wo->q_tx); in mtk_wed_wo_hw_deinit()
458 mtk_wed_wo_queue_rx_clean(wo, &wo->q_rx); in mtk_wed_wo_hw_deinit()
459 mtk_wed_wo_queue_free(wo, &wo->q_tx); in mtk_wed_wo_hw_deinit()
460 mtk_wed_wo_queue_free(wo, &wo->q_rx); in mtk_wed_wo_hw_deinit()
465 struct mtk_wed_wo *wo; in mtk_wed_wo_init() local
468 wo = devm_kzalloc(hw->dev, sizeof(*wo), GFP_KERNEL); in mtk_wed_wo_init()
469 if (!wo) in mtk_wed_wo_init()
472 hw->wed_wo = wo; in mtk_wed_wo_init()
473 wo->hw = hw; in mtk_wed_wo_init()
475 ret = mtk_wed_wo_hardware_init(wo); in mtk_wed_wo_init()
479 ret = mtk_wed_mcu_init(wo); in mtk_wed_wo_init()
483 return mtk_wed_wo_exception_init(wo); in mtk_wed_wo_init()
488 struct mtk_wed_wo *wo = hw->wed_wo; in mtk_wed_wo_deinit() local
490 mtk_wed_wo_hw_deinit(wo); in mtk_wed_wo_deinit()