c8sectpfe-core.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /*
  2. * c8sectpfe-core.h - C8SECTPFE STi DVB driver
  3. *
  4. * Copyright (c) STMicroelectronics 2015
  5. *
  6. * Author:Peter Bennett <peter.bennett@st.com>
  7. * Peter Griffin <peter.griffin@linaro.org>
  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; either version 2 of
  12. * the License, or (at your option) any later version.
  13. */
  14. #ifndef _C8SECTPFE_CORE_H_
  15. #define _C8SECTPFE_CORE_H_
  16. #define C8SECTPFEI_MAXCHANNEL 16
  17. #define C8SECTPFEI_MAXADAPTER 3
  18. #define C8SECTPFE_MAX_TSIN_CHAN 8
  19. struct channel_info {
  20. int tsin_id;
  21. bool invert_ts_clk;
  22. bool serial_not_parallel;
  23. bool async_not_sync;
  24. int i2c;
  25. int dvb_card;
  26. int rst_gpio;
  27. struct i2c_adapter *i2c_adapter;
  28. struct i2c_adapter *tuner_i2c;
  29. struct i2c_adapter *lnb_i2c;
  30. struct i2c_client *i2c_client;
  31. struct dvb_frontend *frontend;
  32. struct pinctrl_state *pstate;
  33. int demux_mapping;
  34. int active;
  35. void *back_buffer_start;
  36. void *back_buffer_aligned;
  37. dma_addr_t back_buffer_busaddr;
  38. void *pid_buffer_start;
  39. void *pid_buffer_aligned;
  40. dma_addr_t pid_buffer_busaddr;
  41. unsigned long fifo;
  42. struct completion idle_completion;
  43. struct tasklet_struct tsklet;
  44. struct c8sectpfei *fei;
  45. void __iomem *irec;
  46. };
  47. struct c8sectpfe_hw {
  48. int num_ib;
  49. int num_mib;
  50. int num_swts;
  51. int num_tsout;
  52. int num_ccsc;
  53. int num_ram;
  54. int num_tp;
  55. };
  56. struct c8sectpfei {
  57. struct device *dev;
  58. struct pinctrl *pinctrl;
  59. struct dentry *root;
  60. struct debugfs_regset32 *regset;
  61. struct completion fw_ack;
  62. atomic_t fw_loaded;
  63. int tsin_count;
  64. struct c8sectpfe_hw hw_stats;
  65. struct c8sectpfe *c8sectpfe[C8SECTPFEI_MAXADAPTER];
  66. int mapping[C8SECTPFEI_MAXCHANNEL];
  67. struct mutex lock;
  68. struct timer_list timer; /* timer interrupts for outputs */
  69. void __iomem *io;
  70. void __iomem *sram;
  71. unsigned long sram_size;
  72. struct channel_info *channel_data[C8SECTPFE_MAX_TSIN_CHAN];
  73. struct clk *c8sectpfeclk;
  74. int nima_rst_gpio;
  75. int nimb_rst_gpio;
  76. int idle_irq;
  77. int error_irq;
  78. int global_feed_count;
  79. };
  80. /* C8SECTPFE SYS Regs list */
  81. #define SYS_INPUT_ERR_STATUS 0x0
  82. #define SYS_OTHER_ERR_STATUS 0x8
  83. #define SYS_INPUT_ERR_MASK 0x10
  84. #define SYS_OTHER_ERR_MASK 0x18
  85. #define SYS_DMA_ROUTE 0x20
  86. #define SYS_INPUT_CLKEN 0x30
  87. #define IBENABLE_MASK 0x7F
  88. #define SYS_OTHER_CLKEN 0x38
  89. #define TSDMAENABLE BIT(1)
  90. #define MEMDMAENABLE BIT(0)
  91. #define SYS_CFG_NUM_IB 0x200
  92. #define SYS_CFG_NUM_MIB 0x204
  93. #define SYS_CFG_NUM_SWTS 0x208
  94. #define SYS_CFG_NUM_TSOUT 0x20C
  95. #define SYS_CFG_NUM_CCSC 0x210
  96. #define SYS_CFG_NUM_RAM 0x214
  97. #define SYS_CFG_NUM_TP 0x218
  98. /* Input Block Regs */
  99. #define C8SECTPFE_INPUTBLK_OFFSET 0x1000
  100. #define C8SECTPFE_CHANNEL_OFFSET(x) ((x*0x40) + C8SECTPFE_INPUTBLK_OFFSET)
  101. #define C8SECTPFE_IB_IP_FMT_CFG(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x00)
  102. #define C8SECTPFE_IGNORE_ERR_AT_SOP BIT(7)
  103. #define C8SECTPFE_IGNORE_ERR_IN_PKT BIT(6)
  104. #define C8SECTPFE_IGNORE_ERR_IN_BYTE BIT(5)
  105. #define C8SECTPFE_INVERT_TSCLK BIT(4)
  106. #define C8SECTPFE_ALIGN_BYTE_SOP BIT(3)
  107. #define C8SECTPFE_ASYNC_NOT_SYNC BIT(2)
  108. #define C8SECTPFE_BYTE_ENDIANNESS_MSB BIT(1)
  109. #define C8SECTPFE_SERIAL_NOT_PARALLEL BIT(0)
  110. #define C8SECTPFE_IB_SYNCLCKDRP_CFG(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x04)
  111. #define C8SECTPFE_SYNC(x) (x & 0xf)
  112. #define C8SECTPFE_DROP(x) ((x<<4) & 0xf)
  113. #define C8SECTPFE_TOKEN(x) ((x<<8) & 0xff00)
  114. #define C8SECTPFE_SLDENDIANNESS BIT(16)
  115. #define C8SECTPFE_IB_TAGBYTES_CFG(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x08)
  116. #define C8SECTPFE_TAG_HEADER(x) (x << 16)
  117. #define C8SECTPFE_TAG_COUNTER(x) ((x<<1) & 0x7fff)
  118. #define C8SECTPFE_TAG_ENABLE BIT(0)
  119. #define C8SECTPFE_IB_PID_SET(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x0C)
  120. #define C8SECTPFE_PID_OFFSET(x) (x & 0x3f)
  121. #define C8SECTPFE_PID_NUMBITS(x) ((x << 6) & 0xfff)
  122. #define C8SECTPFE_PID_ENABLE BIT(31)
  123. #define C8SECTPFE_IB_PKT_LEN(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x10)
  124. #define C8SECTPFE_IB_BUFF_STRT(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x14)
  125. #define C8SECTPFE_IB_BUFF_END(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x18)
  126. #define C8SECTPFE_IB_READ_PNT(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x1C)
  127. #define C8SECTPFE_IB_WRT_PNT(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x20)
  128. #define C8SECTPFE_IB_PRI_THRLD(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x24)
  129. #define C8SECTPFE_PRI_VALUE(x) (x & 0x7fffff)
  130. #define C8SECTPFE_PRI_LOWPRI(x) ((x & 0xf) << 24)
  131. #define C8SECTPFE_PRI_HIGHPRI(x) ((x & 0xf) << 28)
  132. #define C8SECTPFE_IB_STAT(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x28)
  133. #define C8SECTPFE_STAT_FIFO_OVERFLOW(x) (x & 0x1)
  134. #define C8SECTPFE_STAT_BUFFER_OVERFLOW(x) (x & 0x2)
  135. #define C8SECTPFE_STAT_OUTOFORDERRP(x) (x & 0x4)
  136. #define C8SECTPFE_STAT_PID_OVERFLOW(x) (x & 0x8)
  137. #define C8SECTPFE_STAT_PKT_OVERFLOW(x) (x & 0x10)
  138. #define C8SECTPFE_STAT_ERROR_PACKETS(x) ((x >> 8) & 0xf)
  139. #define C8SECTPFE_STAT_SHORT_PACKETS(x) ((x >> 12) & 0xf)
  140. #define C8SECTPFE_IB_MASK(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x2C)
  141. #define C8SECTPFE_MASK_FIFO_OVERFLOW BIT(0)
  142. #define C8SECTPFE_MASK_BUFFER_OVERFLOW BIT(1)
  143. #define C8SECTPFE_MASK_OUTOFORDERRP(x) BIT(2)
  144. #define C8SECTPFE_MASK_PID_OVERFLOW(x) BIT(3)
  145. #define C8SECTPFE_MASK_PKT_OVERFLOW(x) BIT(4)
  146. #define C8SECTPFE_MASK_ERROR_PACKETS(x) ((x & 0xf) << 8)
  147. #define C8SECTPFE_MASK_SHORT_PACKETS(x) ((x & 0xf) >> 12)
  148. #define C8SECTPFE_IB_SYS(x) (C8SECTPFE_CHANNEL_OFFSET(x) + 0x30)
  149. #define C8SECTPFE_SYS_RESET BIT(1)
  150. #define C8SECTPFE_SYS_ENABLE BIT(0)
  151. /*
  152. * Ponter record data structure required for each input block
  153. * see Table 82 on page 167 of functional specification.
  154. */
  155. #define DMA_PRDS_MEMBASE 0x0 /* Internal sram base address */
  156. #define DMA_PRDS_MEMTOP 0x4 /* Internal sram top address */
  157. /*
  158. * TS packet size, including tag bytes added by input block,
  159. * rounded up to the next multiple of 8 bytes. The packet size,
  160. * including any tagging bytes and rounded up to the nearest
  161. * multiple of 8 bytes must be less than 255 bytes.
  162. */
  163. #define DMA_PRDS_PKTSIZE 0x8
  164. #define DMA_PRDS_TPENABLE 0xc
  165. #define TP0_OFFSET 0x10
  166. #define DMA_PRDS_BUSBASE_TP(x) ((0x10*x) + TP0_OFFSET)
  167. #define DMA_PRDS_BUSTOP_TP(x) ((0x10*x) + TP0_OFFSET + 0x4)
  168. #define DMA_PRDS_BUSWP_TP(x) ((0x10*x) + TP0_OFFSET + 0x8)
  169. #define DMA_PRDS_BUSRP_TP(x) ((0x10*x) + TP0_OFFSET + 0xc)
  170. #define DMA_PRDS_SIZE (0x20)
  171. #define DMA_MEMDMA_OFFSET 0x4000
  172. #define DMA_IMEM_OFFSET 0x0
  173. #define DMA_DMEM_OFFSET 0x4000
  174. #define DMA_CPU 0x8000
  175. #define DMA_PER_OFFSET 0xb000
  176. #define DMA_MEMDMA_DMEM (DMA_MEMDMA_OFFSET + DMA_DMEM_OFFSET)
  177. #define DMA_MEMDMA_IMEM (DMA_MEMDMA_OFFSET + DMA_IMEM_OFFSET)
  178. /* XP70 Slim core regs */
  179. #define DMA_CPU_ID (DMA_MEMDMA_OFFSET + DMA_CPU + 0x0)
  180. #define DMA_CPU_VCR (DMA_MEMDMA_OFFSET + DMA_CPU + 0x4)
  181. #define DMA_CPU_RUN (DMA_MEMDMA_OFFSET + DMA_CPU + 0x8)
  182. #define DMA_CPU_CLOCKGATE (DMA_MEMDMA_OFFSET + DMA_CPU + 0xc)
  183. #define DMA_CPU_PC (DMA_MEMDMA_OFFSET + DMA_CPU + 0x20)
  184. /* Enable Interrupt for a IB */
  185. #define DMA_PER_TPn_DREQ_MASK (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xd00)
  186. /* Ack interrupt by setting corresponding bit */
  187. #define DMA_PER_TPn_DACK_SET (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xd80)
  188. #define DMA_PER_TPn_DREQ (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xe00)
  189. #define DMA_PER_TPn_DACK (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xe80)
  190. #define DMA_PER_DREQ_MODE (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xf80)
  191. #define DMA_PER_STBUS_SYNC (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xf88)
  192. #define DMA_PER_STBUS_ACCESS (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xf8c)
  193. #define DMA_PER_STBUS_ADDRESS (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xf90)
  194. #define DMA_PER_IDLE_INT (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfa8)
  195. #define DMA_PER_PRIORITY (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfac)
  196. #define DMA_PER_MAX_OPCODE (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfb0)
  197. #define DMA_PER_MAX_CHUNK (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfb4)
  198. #define DMA_PER_PAGE_SIZE (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfbc)
  199. #define DMA_PER_MBOX_STATUS (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfc0)
  200. #define DMA_PER_MBOX_SET (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfc8)
  201. #define DMA_PER_MBOX_CLEAR (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfd0)
  202. #define DMA_PER_MBOX_MASK (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfd8)
  203. #define DMA_PER_INJECT_PKT_SRC (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfe0)
  204. #define DMA_PER_INJECT_PKT_DEST (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfe4)
  205. #define DMA_PER_INJECT_PKT_ADDR (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfe8)
  206. #define DMA_PER_INJECT_PKT (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xfec)
  207. #define DMA_PER_PAT_PTR_INIT (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xff0)
  208. #define DMA_PER_PAT_PTR (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xff4)
  209. #define DMA_PER_SLEEP_MASK (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xff8)
  210. #define DMA_PER_SLEEP_COUNTER (DMA_MEMDMA_OFFSET + DMA_PER_OFFSET + 0xffc)
  211. /* #define DMA_RF_CPUREGn DMA_RFBASEADDR n=0 to 15) slim regsa */
  212. /* The following are from DMA_DMEM_BaseAddress */
  213. #define DMA_FIRMWARE_VERSION (DMA_MEMDMA_OFFSET + DMA_DMEM_OFFSET + 0x0)
  214. #define DMA_PTRREC_BASE (DMA_MEMDMA_OFFSET + DMA_DMEM_OFFSET + 0x4)
  215. #define DMA_PTRREC_INPUT_OFFSET (DMA_MEMDMA_OFFSET + DMA_DMEM_OFFSET + 0x8)
  216. #define DMA_ERRREC_BASE (DMA_MEMDMA_OFFSET + DMA_DMEM_OFFSET + 0xc)
  217. #define DMA_ERROR_RECORD(n) ((n*4) + DMA_ERRREC_BASE + 0x4)
  218. #define DMA_IDLE_REQ (DMA_MEMDMA_OFFSET + DMA_DMEM_OFFSET + 0x10)
  219. #define IDLEREQ BIT(31)
  220. #define DMA_FIRMWARE_CONFIG (DMA_MEMDMA_OFFSET + DMA_DMEM_OFFSET + 0x14)
  221. /* Regs for PID Filter */
  222. #define PIDF_OFFSET 0x2800
  223. #define PIDF_BASE(n) ((n*4) + PIDF_OFFSET)
  224. #define PIDF_LEAK_ENABLE (PIDF_OFFSET + 0x100)
  225. #define PIDF_LEAK_STATUS (PIDF_OFFSET + 0x108)
  226. #define PIDF_LEAK_COUNT_RESET (PIDF_OFFSET + 0x110)
  227. #define PIDF_LEAK_COUNTER (PIDF_OFFSET + 0x114)
  228. #endif /* _C8SECTPFE_CORE_H_ */