subsys.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /****************************************************************************
  2. *
  3. * The MIT License (MIT)
  4. *
  5. * Copyright (c) 2014 - 2021 VERISILICON
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. *
  25. *****************************************************************************
  26. *
  27. * The GPL License (GPL)
  28. *
  29. * Copyright (C) 2014 - 2021 VERISILICON
  30. *
  31. * This program is free software; you can redistribute it and/or
  32. * modify it under the terms of the GNU General Public License
  33. * as published by the Free Software Foundation; either version 2
  34. * of the License, or (at your option) any later version.
  35. *
  36. * This program is distributed in the hope that it will be useful,
  37. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. * GNU General Public License for more details.
  40. *
  41. * You should have received a copy of the GNU General Public License
  42. * along with this program; if not, write to the Free Software Foundation,
  43. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  44. *
  45. *****************************************************************************
  46. *
  47. * Note: This software is released under dual MIT and GPL licenses. A
  48. * recipient may use this file under the terms of either the MIT license or
  49. * GPL License. If you wish to use only one license not the other, you can
  50. * indicate your decision by deleting one of the above license notices in your
  51. * version of this file.
  52. *
  53. *****************************************************************************/
  54. #ifndef _SUBSYS_H_
  55. #define _SUBSYS_H_
  56. #ifdef __FREERTOS__
  57. /* nothing */
  58. #elif defined(__linux__)
  59. #include <linux/fs.h>
  60. #include <linux/platform_device.h>
  61. #endif
  62. #include "hantrodec.h"
  63. #ifndef NULL
  64. #ifdef __cplusplus
  65. #define NULL 0
  66. #else
  67. #define NULL ((void *)0)
  68. #endif
  69. #endif
  70. /* Functions provided by all other subsystem IP - hantrodec_xxx.c */
  71. /******************************************************************************/
  72. /* subsys level */
  73. /******************************************************************************/
  74. #define MAX_SUBSYS_NUM 4 /* up to 4 subsystem (temporary) */
  75. #define HXDEC_MAX_CORES MAX_SUBSYS_NUM /* used in hantro_dec_xxx.c */
  76. /* SubsysDesc & CoreDesc are used for configuration */
  77. struct SubsysDesc {
  78. int slice_index; /* slice this subsys belongs to */
  79. int index; /* subsystem index */
  80. long base;
  81. };
  82. struct CoreDesc {
  83. int slice;
  84. int subsys; /* subsys this core belongs to */
  85. enum CoreType core_type;
  86. int offset; /* offset to subsystem base */
  87. int iosize;
  88. int irq;
  89. int has_apb;
  90. };
  91. /* internal config struct (translated from SubsysDesc & CoreDesc) */
  92. struct subsys_config {
  93. unsigned long base_addr;
  94. int irq;
  95. u32 subsys_type; /* identifier for each subsys vc8000e=0,IM=1,vc8000d=2,jpege=3,jpegd=4 */
  96. u32 submodule_offset[HW_CORE_MAX]; /* in bytes */
  97. u16 submodule_iosize[HW_CORE_MAX]; /* in bytes */
  98. volatile u8 *submodule_hwregs[HW_CORE_MAX]; /* virtual address */
  99. int has_apbfilter[HW_CORE_MAX];
  100. };
  101. void CheckSubsysCoreArray(struct subsys_config *subsys, int *vcmd);
  102. /******************************************************************************/
  103. /* VCMD */
  104. /******************************************************************************/
  105. #define OPCODE_WREG (0x01<<27)
  106. #define OPCODE_END (0x02<<27)
  107. #define OPCODE_NOP (0x03<<27)
  108. #define OPCODE_RREG (0x16<<27)
  109. #define OPCODE_INT (0x18<<27)
  110. #define OPCODE_JMP (0x19<<27)
  111. #define OPCODE_STALL (0x09<<27)
  112. #define OPCODE_CLRINT (0x1a<<27)
  113. #define OPCODE_JMP_RDY0 (0x19<<27)
  114. #define OPCODE_JMP_RDY1 ((0x19<<27)|(1<<26))
  115. #define JMP_IE_1 (1<<25)
  116. #define JMP_RDY_1 (1<<26)
  117. /* Used in vcmd initialization in hantro_vcmd_xxx.c. */
  118. /* May be unified in next step. */
  119. struct vcmd_config {
  120. unsigned long vcmd_base_addr;
  121. u32 vcmd_iosize;
  122. int vcmd_irq;
  123. u32 sub_module_type; /*input vc8000e=0,IM=1,vc8000d=2,jpege=3, jpegd=4*/
  124. u16 submodule_main_addr; // in byte
  125. u16 submodule_dec400_addr; //if submodule addr == 0xffff, this submodule does not exist.// in byte
  126. u16 submodule_L2Cache_addr; // in byte
  127. u16 submodule_MMU_addr; // in byte
  128. u16 submodule_MMUWrite_addr;// in byte
  129. u16 submodule_axife_addr; // in byte
  130. };
  131. #ifdef __FREERTOS__
  132. /* nothing */
  133. #elif defined(__linux__)
  134. int hantrovcmd_open(struct inode *inode, struct file *filp);
  135. int hantrovcmd_release(struct inode *inode, struct file *filp);
  136. long hantrovcmd_ioctl(struct file *filp,
  137. unsigned int cmd, unsigned long arg);
  138. int hantrovcmd_init(struct platform_device *pdev);
  139. void hantrovcmd_cleanup(struct platform_device *pdev);
  140. void hantrovcmd_reset(void);
  141. /******************************************************************************/
  142. /* MMU */
  143. /******************************************************************************/
  144. /* Init MMU, should be called in driver init function. */
  145. enum MMUStatus MMUInit(volatile unsigned char *hwregs);
  146. /* Clean up all data in MMU, should be called in driver cleanup function
  147. when rmmod driver*/
  148. enum MMUStatus MMUCleanup(volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
  149. /* The function should be called in driver realease function
  150. when driver exit unnormally */
  151. enum MMUStatus MMURelease(void *filp, volatile unsigned char *hwregs);
  152. enum MMUStatus MMUEnable(volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
  153. /* Used in kernel to map buffer */
  154. enum MMUStatus MMUKernelMemNodeMap(struct kernel_addr_desc *addr);
  155. /* Used in kernel to unmap buffer */
  156. enum MMUStatus MMUKernelMemNodeUnmap(struct kernel_addr_desc *addr);
  157. long MMUIoctl(unsigned int cmd, void *filp, unsigned long arg,
  158. volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
  159. void MMURestore(volatile unsigned char *hwregs[MAX_SUBSYS_NUM][2]);
  160. int allocator_init(struct device *dev);
  161. void allocator_remove(void);
  162. int allocator_open(struct inode *inode, struct file *filp);
  163. void allocator_release(struct inode *inode, struct file *filp);
  164. int allocator_ioctl(void *filp, unsigned int cmd, unsigned long arg);
  165. int allocator_mmap(struct file *filp, struct vm_area_struct *vma);
  166. /******************************************************************************/
  167. /* L2Cache */
  168. /******************************************************************************/
  169. /******************************************************************************/
  170. /* DEC400 */
  171. /******************************************************************************/
  172. /******************************************************************************/
  173. /* AXI FE */
  174. /******************************************************************************/
  175. #endif
  176. #endif