Lines Matching full:pd
257 static int init_rm(struct dma_iproc_pax_data *pd) in init_rm() argument
261 k_mutex_lock(&pd->dma_lock, K_FOREVER); in init_rm()
265 if ((sys_read32(RM_COMM_REG(pd, RM_COMM_MAIN_HW_INIT_DONE)) & in init_rm()
272 k_mutex_unlock(&pd->dma_lock); in init_rm()
283 static void rm_cfg_start(struct dma_iproc_pax_data *pd) in rm_cfg_start() argument
287 k_mutex_lock(&pd->dma_lock, K_FOREVER); in rm_cfg_start()
290 val = sys_read32(RM_COMM_REG(pd, RM_COMM_CONTROL)); in rm_cfg_start()
292 sys_write32(val, RM_COMM_REG(pd, RM_COMM_CONTROL)); in rm_cfg_start()
303 sys_write32(val, RM_COMM_REG(pd, RM_COMM_CONTROL)); in rm_cfg_start()
305 RM_COMM_REG(pd, RM_COMM_MSI_DISABLE)); in rm_cfg_start()
307 val = sys_read32(RM_COMM_REG(pd, RM_COMM_AXI_READ_BURST_THRESHOLD)); in rm_cfg_start()
312 sys_write32(val, RM_COMM_REG(pd, RM_COMM_AXI_READ_BURST_THRESHOLD)); in rm_cfg_start()
314 val = sys_read32(RM_COMM_REG(pd, RM_COMM_FIFO_FULL_THRESHOLD)); in rm_cfg_start()
324 sys_write32(val, RM_COMM_REG(pd, RM_COMM_FIFO_FULL_THRESHOLD)); in rm_cfg_start()
327 val = sys_read32(RM_COMM_REG(pd, RM_COMM_CONTROL)); in rm_cfg_start()
329 sys_write32(val, RM_COMM_REG(pd, RM_COMM_CONTROL)); in rm_cfg_start()
333 RM_COMM_REG(pd, RM_COMM_AE_TIMEOUT)); in rm_cfg_start()
334 val = sys_read32(RM_COMM_REG(pd, RM_COMM_CONTROL)); in rm_cfg_start()
336 sys_write32(val, RM_COMM_REG(pd, RM_COMM_CONTROL)); in rm_cfg_start()
339 val = sys_read32(RM_COMM_REG(pd, RM_AE0_AE_CONTROL)); in rm_cfg_start()
341 sys_write32(val, RM_COMM_REG(pd, RM_AE0_AE_CONTROL)); in rm_cfg_start()
343 sys_write32(val, RM_COMM_REG(pd, RM_AE0_AE_CONTROL)); in rm_cfg_start()
346 val = sys_read32(RM_COMM_REG(pd, RM_COMM_AXI_CONTROL)); in rm_cfg_start()
348 sys_write32(val, RM_COMM_REG(pd, RM_COMM_AXI_CONTROL)); in rm_cfg_start()
352 RM_COMM_REG(pd, RM_COMM_TIMER_CONTROL_0)); in rm_cfg_start()
354 RM_COMM_REG(pd, RM_COMM_TIMER_CONTROL_1)); in rm_cfg_start()
355 val = sys_read32(RM_COMM_REG(pd, RM_COMM_BURST_LENGTH)); in rm_cfg_start()
360 sys_write32(val, RM_COMM_REG(pd, RM_COMM_BURST_LENGTH)); in rm_cfg_start()
362 val = sys_read32(RM_COMM_REG(pd, RM_COMM_BD_FETCH_MODE_CONTROL)); in rm_cfg_start()
365 sys_write32(val, RM_COMM_REG(pd, RM_COMM_BD_FETCH_MODE_CONTROL)); in rm_cfg_start()
368 val = sys_read32(RM_COMM_REG(pd, RM_COMM_MASK_SEQUENCE_MAX_COUNT)); in rm_cfg_start()
370 sys_write32(val, RM_COMM_REG(pd, RM_COMM_MASK_SEQUENCE_MAX_COUNT)); in rm_cfg_start()
372 k_mutex_unlock(&pd->dma_lock); in rm_cfg_start()
375 static void rm_ring_clear_stats(struct dma_iproc_pax_data *pd, in rm_ring_clear_stats() argument
379 sys_read32(RM_RING_REG(pd, idx, RING_NUM_REQ_RECV_LS)); in rm_ring_clear_stats()
380 sys_read32(RM_RING_REG(pd, idx, RING_NUM_REQ_RECV_MS)); in rm_ring_clear_stats()
381 sys_read32(RM_RING_REG(pd, idx, RING_NUM_REQ_TRANS_LS)); in rm_ring_clear_stats()
382 sys_read32(RM_RING_REG(pd, idx, RING_NUM_REQ_TRANS_MS)); in rm_ring_clear_stats()
383 sys_read32(RM_RING_REG(pd, idx, RING_NUM_REQ_OUTSTAND)); in rm_ring_clear_stats()
386 static void rm_cfg_finish(struct dma_iproc_pax_data *pd) in rm_cfg_finish() argument
390 k_mutex_lock(&pd->dma_lock, K_FOREVER); in rm_cfg_finish()
393 val = sys_read32(RM_COMM_REG(pd, RM_COMM_CONTROL)); in rm_cfg_finish()
395 sys_write32(val, RM_COMM_REG(pd, RM_COMM_CONTROL)); in rm_cfg_finish()
397 k_mutex_unlock(&pd->dma_lock); in rm_cfg_finish()
400 static inline void write_doorbell(struct dma_iproc_pax_data *pd, in write_doorbell() argument
403 struct dma_iproc_pax_ring_data *ring = &(pd->ring[idx]); in write_doorbell()
406 RM_RING_REG(pd, idx, RING_DOORBELL_BD_WRITE_COUNT)); in write_doorbell()
410 static inline void set_ring_active(struct dma_iproc_pax_data *pd, in set_ring_active() argument
416 val = sys_read32(RM_RING_REG(pd, idx, RING_CONTROL)); in set_ring_active()
422 sys_write32(val, RM_RING_REG(pd, idx, RING_CONTROL)); in set_ring_active()
425 static int init_ring(struct dma_iproc_pax_data *pd, enum ring_idx idx) in init_ring() argument
428 uintptr_t desc = (uintptr_t)pd->ring[idx].bd; in init_ring()
429 uintptr_t cmpl = (uintptr_t)pd->ring[idx].cmpl; in init_ring()
432 k_mutex_lock(&pd->dma_lock, K_FOREVER); in init_ring()
435 sys_read32(RM_RING_REG(pd, idx, RING_CMPL_WRITE_PTR)); in init_ring()
438 sys_write32(0x0, RM_RING_REG(pd, idx, RING_CONTROL)); in init_ring()
441 val = sys_read32(RM_COMM_REG(pd, RM_COMM_CONTROL)); in init_ring()
443 sys_write32(val, RM_COMM_REG(pd, RM_COMM_CONTROL)); in init_ring()
445 sys_write32(RING_CONTROL_FLUSH, RM_RING_REG(pd, idx, in init_ring()
448 if (sys_read32(RM_RING_REG(pd, idx, RING_FLUSH_DONE)) & RING_FLUSH_DONE_MASK) { in init_ring()
461 sys_write32(0x0, RM_RING_REG(pd, idx, RING_CONTROL)); in init_ring()
464 val = sys_read32(RM_COMM_REG(pd, RM_COMM_CONTROL)); in init_ring()
466 sys_write32(val, RM_COMM_REG(pd, RM_COMM_CONTROL)); in init_ring()
468 val = sys_read32(RM_COMM_REG(pd, RM_COMM_CTRL_REG(idx))); in init_ring()
470 sys_write32(val, RM_COMM_REG(pd, RM_COMM_CTRL_REG(idx))); in init_ring()
477 sys_write32(val, RM_RING_REG(pd, idx, RING_CMPL_WR_PTR_DDR_CONTROL)); in init_ring()
480 RM_RING_REG(pd, idx, RING_DISABLE_MSI_TIMEOUT)); in init_ring()
483 sys_write32((uint32_t)desc, RM_RING_REG(pd, idx, RING_BD_START_ADDR)); in init_ring()
484 sys_write32((uint32_t)cmpl, RM_RING_REG(pd, idx, RING_CMPL_START_ADDR)); in init_ring()
485 val = sys_read32(RM_RING_REG(pd, idx, RING_BD_READ_PTR)); in init_ring()
489 set_ring_active(pd, idx, false); in init_ring()
491 set_ring_active(pd, idx, true); in init_ring()
496 sys_write32(0x0, RM_RING_REG(pd, idx, in init_ring()
499 rm_ring_clear_stats(pd, idx); in init_ring()
501 k_mutex_unlock(&pd->dma_lock); in init_ring()
553 struct dma_iproc_pax_data *pd = dev->data; in process_cmpl_event() local
555 struct dma_iproc_pax_ring_data *ring = &(pd->ring[idx]); in process_cmpl_event()
562 wr_offs = sys_read32(RM_RING_REG(pd, idx, in process_cmpl_event()
585 is_outstanding = sys_read32(RM_RING_REG(pd, idx, in process_cmpl_event()
615 struct dma_iproc_pax_data *pd = dev->data; in peek_ring_cmpl() local
617 struct dma_iproc_pax_ring_data *ring = &(pd->ring[idx]); in peek_ring_cmpl()
624 wr_offs = sys_read32(RM_RING_REG(pd, idx, in peek_ring_cmpl()
646 struct dma_iproc_pax_data *pd = dev->data; in rm_isr() local
649 sys_read32(RM_COMM_REG(pd, in rm_isr()
652 RM_COMM_REG(pd, in rm_isr()
658 sys_read32(RM_RING_REG(pd, idx, in rm_isr()
661 RM_RING_REG(pd, idx, in rm_isr()
664 k_sem_give(&pd->ring[idx].alert); in rm_isr()
673 struct dma_iproc_pax_data *pd = dev->data; in dma_iproc_pax_init() local
682 pd->dma_base = cfg->dma_base; in dma_iproc_pax_init()
683 pd->rm_comm_base = cfg->rm_comm_base; in dma_iproc_pax_init()
684 pd->used_rings = (cfg->use_rings < PAX_DMA_RINGS_MAX) ? in dma_iproc_pax_init()
688 k_mutex_init(&pd->dma_lock); in dma_iproc_pax_init()
691 if (init_rm(pd)) { in dma_iproc_pax_init()
696 rm_cfg_start(pd); in dma_iproc_pax_init()
699 for (r = 0; r < pd->used_rings; r++) { in dma_iproc_pax_init()
701 k_mutex_init(&pd->ring[r].lock); in dma_iproc_pax_init()
703 k_sem_init(&pd->ring[r].alert, 0, 1); in dma_iproc_pax_init()
705 pd->ring[r].idx = r; in dma_iproc_pax_init()
706 pd->ring[r].ring_base = cfg->rm_base + in dma_iproc_pax_init()
708 LOG_DBG("RING%d,VERSION:0x%x\n", pd->ring[r].idx, in dma_iproc_pax_init()
709 sys_read32(RM_RING_REG(pd, r, RING_VER))); in dma_iproc_pax_init()
712 pd->ring[r].ring_mem = (void *)((uintptr_t)cfg->bd_memory_base + in dma_iproc_pax_init()
714 if (!pd->ring[r].ring_mem) { in dma_iproc_pax_init()
719 mem_aligned = ((uintptr_t)pd->ring[r].ring_mem + in dma_iproc_pax_init()
723 pd->ring[r].cmpl = (void *)mem_aligned; in dma_iproc_pax_init()
724 pd->ring[r].bd = (void *)(mem_aligned + in dma_iproc_pax_init()
726 pd->ring[r].sync_loc = (void *)((uintptr_t)pd->ring[r].bd + in dma_iproc_pax_init()
731 pd->ring[r].idx, in dma_iproc_pax_init()
732 pd->ring[r].ring_mem, in dma_iproc_pax_init()
735 pd->ring[r].idx, in dma_iproc_pax_init()
736 pd->ring[r].bd, in dma_iproc_pax_init()
737 pd->ring[r].cmpl, in dma_iproc_pax_init()
738 pd->ring[r].sync_loc); in dma_iproc_pax_init()
741 prepare_ring(&(pd->ring[r])); in dma_iproc_pax_init()
744 init_ring(pd, r); in dma_iproc_pax_init()
748 rm_cfg_finish(pd); in dma_iproc_pax_init()
761 LOG_INF("%s RM setup %d rings\n", dev->name, pd->used_rings); in dma_iproc_pax_init()
885 struct dma_iproc_pax_data *pd = dev->data; in set_pkt_count() local
889 val = sys_read32(RM_RING_REG(pd, idx, in set_pkt_count()
893 sys_write32(val, RM_RING_REG(pd, idx, in set_pkt_count()
901 struct dma_iproc_pax_data *pd = dev->data; in wait_for_pkt_completion() local
904 ring = &(pd->ring[idx]); in wait_for_pkt_completion()
919 struct dma_iproc_pax_data *pd = dev->data; in dma_iproc_pax_process_dma_blocks() local
933 ring = &(pd->ring[idx]); in dma_iproc_pax_process_dma_blocks()
998 struct dma_iproc_pax_data *pd = dev->data; in dma_iproc_pax_configure() local
1007 ring = &(pd->ring[channel]); in dma_iproc_pax_configure()
1041 struct dma_iproc_pax_data *pd = dev->data; in dma_iproc_pax_transfer_start() local
1049 ring = &(pd->ring[channel]); in dma_iproc_pax_transfer_start()
1053 write_doorbell(pd, channel); in dma_iproc_pax_transfer_start()
1056 set_ring_active(pd, channel, true); in dma_iproc_pax_transfer_start()
1073 set_ring_active(pd, channel, false); in dma_iproc_pax_transfer_start()