knav_qmss.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifndef __SOC_TI_KNAV_QMSS_H__
  19. #define __SOC_TI_KNAV_QMSS_H__
  20. #include <linux/err.h>
  21. #include <linux/time.h>
  22. #include <linux/atomic.h>
  23. #include <linux/device.h>
  24. #include <linux/fcntl.h>
  25. #include <linux/dma-mapping.h>
  26. /* queue types */
  27. #define KNAV_QUEUE_QPEND ((unsigned)-2) /* interruptible qpend queue */
  28. #define KNAV_QUEUE_ACC ((unsigned)-3) /* Accumulated queue */
  29. #define KNAV_QUEUE_GP ((unsigned)-4) /* General purpose queue */
  30. /* queue flags */
  31. #define KNAV_QUEUE_SHARED 0x0001 /* Queue can be shared */
  32. /**
  33. * enum knav_queue_ctrl_cmd - queue operations.
  34. * @KNAV_QUEUE_GET_ID: Get the ID number for an open queue
  35. * @KNAV_QUEUE_FLUSH: forcibly empty a queue if possible
  36. * @KNAV_QUEUE_SET_NOTIFIER: Set a notifier callback to a queue handle.
  37. * @KNAV_QUEUE_ENABLE_NOTIFY: Enable notifier callback for a queue handle.
  38. * @KNAV_QUEUE_DISABLE_NOTIFY: Disable notifier callback for a queue handle.
  39. * @KNAV_QUEUE_GET_COUNT: Get number of queues.
  40. */
  41. enum knav_queue_ctrl_cmd {
  42. KNAV_QUEUE_GET_ID,
  43. KNAV_QUEUE_FLUSH,
  44. KNAV_QUEUE_SET_NOTIFIER,
  45. KNAV_QUEUE_ENABLE_NOTIFY,
  46. KNAV_QUEUE_DISABLE_NOTIFY,
  47. KNAV_QUEUE_GET_COUNT
  48. };
  49. /* Queue notifier callback prototype */
  50. typedef void (*knav_queue_notify_fn)(void *arg);
  51. /**
  52. * struct knav_queue_notify_config: Notifier configuration
  53. * @fn: Notifier function
  54. * @fn_arg: Notifier function arguments
  55. */
  56. struct knav_queue_notify_config {
  57. knav_queue_notify_fn fn;
  58. void *fn_arg;
  59. };
  60. void *knav_queue_open(const char *name, unsigned id,
  61. unsigned flags);
  62. void knav_queue_close(void *qhandle);
  63. int knav_queue_device_control(void *qhandle,
  64. enum knav_queue_ctrl_cmd cmd,
  65. unsigned long arg);
  66. dma_addr_t knav_queue_pop(void *qhandle, unsigned *size);
  67. int knav_queue_push(void *qhandle, dma_addr_t dma,
  68. unsigned size, unsigned flags);
  69. void *knav_pool_create(const char *name,
  70. int num_desc, int region_id);
  71. void knav_pool_destroy(void *ph);
  72. int knav_pool_count(void *ph);
  73. void *knav_pool_desc_get(void *ph);
  74. void knav_pool_desc_put(void *ph, void *desc);
  75. int knav_pool_desc_map(void *ph, void *desc, unsigned size,
  76. dma_addr_t *dma, unsigned *dma_sz);
  77. void *knav_pool_desc_unmap(void *ph, dma_addr_t dma, unsigned dma_sz);
  78. dma_addr_t knav_pool_desc_virt_to_dma(void *ph, void *virt);
  79. void *knav_pool_desc_dma_to_virt(void *ph, dma_addr_t dma);
  80. #endif /* __SOC_TI_KNAV_QMSS_H__ */