Lines Matching +full:udma +full:- +full:c
1 /*-
3 Copyright (C) 2015 Annapurna Labs Ltd.
10 found at http://www.gnu.org/licenses/gpl-2.0.html
40 * UDMA API
44 * @defgroup group_udma_main UDMA Main
46 * UDMA main API
50 * @brief C Header file for the Universal DMA HAL driver
60 /* *INDENT-OFF* */
62 extern "C" {
64 /* *INDENT-ON* */
78 /* Statistics - TBD */
80 /** UDMA submission descriptor */
132 /* TX/RX descriptor Target-ID field (in the buffer address 64 bit field) */
135 /** UDMA completion descriptor */
170 * Target-ID to be assigned to the block descriptors
171 * Requires Target-ID in descriptor to be enabled for the specific UDMA
177 /** UDMA type */
183 /** UDMA state */
194 /** UDMA Q specific parameters from upper layer */
225 /** UDMA parameters from upper layer */
229 uint8_t num_of_queues; /**< number of queues supported by the UDMA */
244 /** UDMA Queue private data structure */
247 * equals to size - 1
249 union udma_q_regs __iomem *q_regs; /**< pointer to the per queue UDMA
263 uint32_t cdesc_size; /**< size (in bytes) of the udma completion ring
290 struct al_udma *udma; /**< pointer to parent UDMA */ member
294 * The following fields are duplicated from the UDMA parent adapter
300 /* UDMA */
305 uint8_t num_of_queues; /* number of queues supported by the UDMA */
306 union udma_regs __iomem *udma_regs; /* pointer to the UDMA registers */
308 struct al_udma_q udma_q[DMA_MAX_Q]; /* Array of UDMA Qs pointers */
309 unsigned int rev_id; /* UDMA revision ID */
319 * Initialize the udma engine
321 * @param udma udma data structure
322 * @param udma_params udma parameters from upper layer
324 * @return 0 on success. -EINVAL otherwise.
326 int al_udma_init(struct al_udma *udma, struct al_udma_params *udma_params);
329 * Initialize the udma queue data structure
331 * @param udma
336 * -EINVAL if the qid is out of range
337 * -EIO if queue was already initialized
340 int al_udma_q_init(struct al_udma *udma, uint32_t qid,
344 * Reset a udma queue
365 * @param udma udma data structure
370 * @return 0 on success. -EINVAL otherwise.
372 int al_udma_q_handle_get(struct al_udma *udma, uint32_t qid,
376 * Change the UDMA's state
378 * @param udma udma data structure
383 int al_udma_state_set(struct al_udma *udma, enum al_udma_state state);
386 * return the current UDMA hardware state
388 * @param udma udma handle
390 * @return the UDMA state as reported by the hardware.
392 enum al_udma_state al_udma_state_get(struct al_udma *udma);
399 * get number of descriptors that can be submitted to the udma.
407 uint16_t tmp = udma_q->next_cdesc_idx - (udma_q->next_desc_idx + 1); in al_udma_available_get()
408 tmp &= udma_q->size_mask; in al_udma_available_get()
423 if (((udma_q->next_cdesc_idx - udma_q->next_desc_idx) & in al_udma_is_empty()
424 udma_q->size_mask) == 0) in al_udma_is_empty()
443 next_desc_idx = udma_q->next_desc_idx; in al_udma_desc_get()
444 desc = udma_q->desc_base_ptr + next_desc_idx; in al_udma_desc_get()
449 udma_q->next_desc_idx = next_desc_idx & udma_q->size_mask; in al_udma_desc_get()
468 ring_id = udma_q->desc_ring_id; in al_udma_ring_id_get()
472 if (unlikely(udma_q->next_desc_idx) == 0) in al_udma_ring_id_get()
473 udma_q->desc_ring_id = (udma_q->desc_ring_id + 1) & in al_udma_ring_id_get()
478 /* add DMA action - trigger the engine */
493 al_assert((num > 0) && (num <= udma_q->size)); in al_udma_desc_action_add()
495 addr = &udma_q->q_regs->rings.drtp_inc; in al_udma_desc_action_add()
525 volatile uint8_t *tmp = (volatile uint8_t *) cdesc + offset * udma_q->cdesc_size; in al_cdesc_next()
530 if (unlikely((tmp > udma_q->end_cdesc_ptr))) in al_cdesc_next()
532 (udma_q->cdesc_base_ptr + in al_cdesc_next()
533 (tmp - udma_q->end_cdesc_ptr - udma_q->cdesc_size)); in al_cdesc_next()
553 == udma_q->comp_ring_id) in al_udma_new_cdesc()
574 if (unlikely(((volatile uint8_t *) cdesc == udma_q->end_cdesc_ptr))) { in al_cdesc_next_update()
575 udma_q->comp_ring_id = in al_cdesc_next_update()
576 (udma_q->comp_ring_id + 1) & DMA_RING_ID_MASK; in al_cdesc_next_update()
577 return (union al_udma_cdesc *) udma_q->cdesc_base_ptr; in al_cdesc_next_update()
579 return (volatile union al_udma_cdesc *) ((volatile uint8_t *) cdesc + udma_q->cdesc_size); in al_cdesc_next_update()
585 * @param udma_q udma queue handle
599 * called to inform the udma driver that those descriptors are freed.
607 ((volatile union al_udma_cdesc *) ((udma_q)->cdesc_base_ptr + \
608 (idx) * (udma_q)->cdesc_size))
614 * @param udma_q udma queue handle
622 * called to inform the udma driver that those descriptors are freed.
632 udma_q->comp_head_idx = (uint16_t) in al_udma_cdesc_get_all()
633 (al_reg_read32(&udma_q->q_regs->rings.crhp) & in al_udma_cdesc_get_all()
636 count = (udma_q->comp_head_idx - udma_q->next_cdesc_idx) & in al_udma_cdesc_get_all()
637 udma_q->size_mask; in al_udma_cdesc_get_all()
640 *cdesc = al_udma_cdesc_idx_to_ptr(udma_q, udma_q->next_cdesc_idx); in al_udma_cdesc_get_all()
649 * @param udma_q udma queue handle
658 udma_q->next_cdesc_idx += num; in al_udma_cdesc_ack()
659 udma_q->next_cdesc_idx &= udma_q->size_mask; in al_udma_cdesc_ack()
664 /* *INDENT-OFF* */
668 /* *INDENT-ON* */
671 /** @} end of UDMA group */