Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Keystone Navigator Queue Management Sub-System header
0004  *
0005  * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com
0006  * Author:  Sandeep Nair <sandeep_n@ti.com>
0007  *      Cyril Chemparathy <cyril@ti.com>
0008  *      Santosh Shilimkar <santosh.shilimkar@ti.com>
0009  */
0010 
0011 #ifndef __SOC_TI_KNAV_QMSS_H__
0012 #define __SOC_TI_KNAV_QMSS_H__
0013 
0014 #include <linux/err.h>
0015 #include <linux/time.h>
0016 #include <linux/atomic.h>
0017 #include <linux/device.h>
0018 #include <linux/fcntl.h>
0019 #include <linux/dma-mapping.h>
0020 
0021 /* queue types */
0022 #define KNAV_QUEUE_QPEND    ((unsigned)-2) /* interruptible qpend queue */
0023 #define KNAV_QUEUE_ACC      ((unsigned)-3) /* Accumulated queue */
0024 #define KNAV_QUEUE_GP       ((unsigned)-4) /* General purpose queue */
0025 
0026 /* queue flags */
0027 #define KNAV_QUEUE_SHARED   0x0001      /* Queue can be shared */
0028 
0029 /**
0030  * enum knav_queue_ctrl_cmd -   queue operations.
0031  * @KNAV_QUEUE_GET_ID:      Get the ID number for an open queue
0032  * @KNAV_QUEUE_FLUSH:       forcibly empty a queue if possible
0033  * @KNAV_QUEUE_SET_NOTIFIER:    Set a notifier callback to a queue handle.
0034  * @KNAV_QUEUE_ENABLE_NOTIFY:   Enable notifier callback for a queue handle.
0035  * @KNAV_QUEUE_DISABLE_NOTIFY:  Disable notifier callback for a queue handle.
0036  * @KNAV_QUEUE_GET_COUNT:   Get number of queues.
0037  */
0038 enum knav_queue_ctrl_cmd {
0039     KNAV_QUEUE_GET_ID,
0040     KNAV_QUEUE_FLUSH,
0041     KNAV_QUEUE_SET_NOTIFIER,
0042     KNAV_QUEUE_ENABLE_NOTIFY,
0043     KNAV_QUEUE_DISABLE_NOTIFY,
0044     KNAV_QUEUE_GET_COUNT
0045 };
0046 
0047 /* Queue notifier callback prototype */
0048 typedef void (*knav_queue_notify_fn)(void *arg);
0049 
0050 /**
0051  * struct knav_queue_notify_config: Notifier configuration
0052  * @fn:                 Notifier function
0053  * @fn_arg:             Notifier function arguments
0054  */
0055 struct knav_queue_notify_config {
0056     knav_queue_notify_fn fn;
0057     void *fn_arg;
0058 };
0059 
0060 void *knav_queue_open(const char *name, unsigned id,
0061                     unsigned flags);
0062 void knav_queue_close(void *qhandle);
0063 int knav_queue_device_control(void *qhandle,
0064                 enum knav_queue_ctrl_cmd cmd,
0065                 unsigned long arg);
0066 dma_addr_t knav_queue_pop(void *qhandle, unsigned *size);
0067 int knav_queue_push(void *qhandle, dma_addr_t dma,
0068                 unsigned size, unsigned flags);
0069 
0070 void *knav_pool_create(const char *name,
0071                 int num_desc, int region_id);
0072 void knav_pool_destroy(void *ph);
0073 int knav_pool_count(void *ph);
0074 void *knav_pool_desc_get(void *ph);
0075 void knav_pool_desc_put(void *ph, void *desc);
0076 int knav_pool_desc_map(void *ph, void *desc, unsigned size,
0077                     dma_addr_t *dma, unsigned *dma_sz);
0078 void *knav_pool_desc_unmap(void *ph, dma_addr_t dma, unsigned dma_sz);
0079 dma_addr_t knav_pool_desc_virt_to_dma(void *ph, void *virt);
0080 void *knav_pool_desc_dma_to_virt(void *ph, dma_addr_t dma);
0081 bool knav_qmss_device_ready(void);
0082 
0083 #endif /* __SOC_TI_KNAV_QMSS_H__ */