1 /* 2 * Keystone Navigator Queue Management Sub-System header 3 * 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com 5 * Author: Sandeep Nair <sandeep_n@ti.com> 6 * Cyril Chemparathy <cyril@ti.com> 7 * Santosh Shilimkar <santosh.shilimkar@ti.com> 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License as 11 * published by the Free Software Foundation version 2. 12 * 13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any 14 * kind, whether express or implied; without even the implied warranty 15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 */ 18 19 #ifndef __SOC_TI_KNAV_QMSS_H__ 20 #define __SOC_TI_KNAV_QMSS_H__ 21 22 #include <linux/err.h> 23 #include <linux/time.h> 24 #include <linux/atomic.h> 25 #include <linux/device.h> 26 #include <linux/fcntl.h> 27 #include <linux/dma-mapping.h> 28 29 /* queue types */ 30 #define KNAV_QUEUE_QPEND ((unsigned)-2) /* interruptible qpend queue */ 31 #define KNAV_QUEUE_ACC ((unsigned)-3) /* Accumulated queue */ 32 #define KNAV_QUEUE_GP ((unsigned)-4) /* General purpose queue */ 33 34 /* queue flags */ 35 #define KNAV_QUEUE_SHARED 0x0001 /* Queue can be shared */ 36 37 /** 38 * enum knav_queue_ctrl_cmd - queue operations. 39 * @KNAV_QUEUE_GET_ID: Get the ID number for an open queue 40 * @KNAV_QUEUE_FLUSH: forcibly empty a queue if possible 41 * @KNAV_QUEUE_SET_NOTIFIER: Set a notifier callback to a queue handle. 42 * @KNAV_QUEUE_ENABLE_NOTIFY: Enable notifier callback for a queue handle. 43 * @KNAV_QUEUE_DISABLE_NOTIFY: Disable notifier callback for a queue handle. 44 * @KNAV_QUEUE_GET_COUNT: Get number of queues. 45 */ 46 enum knav_queue_ctrl_cmd { 47 KNAV_QUEUE_GET_ID, 48 KNAV_QUEUE_FLUSH, 49 KNAV_QUEUE_SET_NOTIFIER, 50 KNAV_QUEUE_ENABLE_NOTIFY, 51 KNAV_QUEUE_DISABLE_NOTIFY, 52 KNAV_QUEUE_GET_COUNT 53 }; 54 55 /* Queue notifier callback prototype */ 56 typedef void (*knav_queue_notify_fn)(void *arg); 57 58 /** 59 * struct knav_queue_notify_config: Notifier configuration 60 * @fn: Notifier function 61 * @fn_arg: Notifier function arguments 62 */ 63 struct knav_queue_notify_config { 64 knav_queue_notify_fn fn; 65 void *fn_arg; 66 }; 67 68 void *knav_queue_open(const char *name, unsigned id, 69 unsigned flags); 70 void knav_queue_close(void *qhandle); 71 int knav_queue_device_control(void *qhandle, 72 enum knav_queue_ctrl_cmd cmd, 73 unsigned long arg); 74 dma_addr_t knav_queue_pop(void *qhandle, unsigned *size); 75 int knav_queue_push(void *qhandle, dma_addr_t dma, 76 unsigned size, unsigned flags); 77 78 void *knav_pool_create(const char *name, 79 int num_desc, int region_id); 80 void knav_pool_destroy(void *ph); 81 int knav_pool_count(void *ph); 82 void *knav_pool_desc_get(void *ph); 83 void knav_pool_desc_put(void *ph, void *desc); 84 int knav_pool_desc_map(void *ph, void *desc, unsigned size, 85 dma_addr_t *dma, unsigned *dma_sz); 86 void *knav_pool_desc_unmap(void *ph, dma_addr_t dma, unsigned dma_sz); 87 dma_addr_t knav_pool_desc_virt_to_dma(void *ph, void *virt); 88 void *knav_pool_desc_dma_to_virt(void *ph, dma_addr_t dma); 89 bool knav_qmss_device_ready(void); 90 91 #endif /* __SOC_TI_KNAV_QMSS_H__ */ 92