xilinx_sdfec.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. ====================
  3. Xilinx SD-FEC Driver
  4. ====================
  5. Overview
  6. ========
  7. This driver supports SD-FEC Integrated Block for Zynq |Ultrascale+ (TM)| RFSoCs.
  8. .. |Ultrascale+ (TM)| unicode:: Ultrascale+ U+2122
  9. .. with trademark sign
  10. For a full description of SD-FEC core features, see the `SD-FEC Product Guide (PG256) <https://www.xilinx.com/cgi-bin/docs/ipdoc?c=sd_fec;v=latest;d=pg256-sdfec-integrated-block.pdf>`_
  11. This driver supports the following features:
  12. - Retrieval of the Integrated Block configuration and status information
  13. - Configuration of LDPC codes
  14. - Configuration of Turbo decoding
  15. - Monitoring errors
  16. Missing features, known issues, and limitations of the SD-FEC driver are as
  17. follows:
  18. - Only allows a single open file handler to any instance of the driver at any time
  19. - Reset of the SD-FEC Integrated Block is not controlled by this driver
  20. - Does not support shared LDPC code table wraparound
  21. The device tree entry is described in:
  22. `linux-xlnx/Documentation/devicetree/bindings/misc/xlnx,sd-fec.txt <https://github.com/Xilinx/linux-xlnx/blob/master/Documentation/devicetree/bindings/misc/xlnx%2Csd-fec.txt>`_
  23. Modes of Operation
  24. ------------------
  25. The driver works with the SD-FEC core in two modes of operation:
  26. - Run-time configuration
  27. - Programmable Logic (PL) initialization
  28. Run-time Configuration
  29. ~~~~~~~~~~~~~~~~~~~~~~
  30. For Run-time configuration the role of driver is to allow the software application to do the following:
  31. - Load the configuration parameters for either Turbo decode or LDPC encode or decode
  32. - Activate the SD-FEC core
  33. - Monitor the SD-FEC core for errors
  34. - Retrieve the status and configuration of the SD-FEC core
  35. Programmable Logic (PL) Initialization
  36. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37. For PL initialization, supporting logic loads configuration parameters for either
  38. the Turbo decode or LDPC encode or decode. The role of the driver is to allow
  39. the software application to do the following:
  40. - Activate the SD-FEC core
  41. - Monitor the SD-FEC core for errors
  42. - Retrieve the status and configuration of the SD-FEC core
  43. Driver Structure
  44. ================
  45. The driver provides a platform device where the ``probe`` and ``remove``
  46. operations are provided.
  47. - probe: Updates configuration register with device-tree entries plus determines the current activate state of the core, for example, is the core bypassed or has the core been started.
  48. The driver defines the following driver file operations to provide user
  49. application interfaces:
  50. - open: Implements restriction that only a single file descriptor can be open per SD-FEC instance at any time
  51. - release: Allows another file descriptor to be open, that is after current file descriptor is closed
  52. - poll: Provides a method to monitor for SD-FEC Error events
  53. - unlocked_ioctl: Provides the following ioctl commands that allows the application configure the SD-FEC core:
  54. - :c:macro:`XSDFEC_START_DEV`
  55. - :c:macro:`XSDFEC_STOP_DEV`
  56. - :c:macro:`XSDFEC_GET_STATUS`
  57. - :c:macro:`XSDFEC_SET_IRQ`
  58. - :c:macro:`XSDFEC_SET_TURBO`
  59. - :c:macro:`XSDFEC_ADD_LDPC_CODE_PARAMS`
  60. - :c:macro:`XSDFEC_GET_CONFIG`
  61. - :c:macro:`XSDFEC_SET_ORDER`
  62. - :c:macro:`XSDFEC_SET_BYPASS`
  63. - :c:macro:`XSDFEC_IS_ACTIVE`
  64. - :c:macro:`XSDFEC_CLEAR_STATS`
  65. - :c:macro:`XSDFEC_SET_DEFAULT_CONFIG`
  66. Driver Usage
  67. ============
  68. Overview
  69. --------
  70. After opening the driver, the user should find out what operations need to be
  71. performed to configure and activate the SD-FEC core and determine the
  72. configuration of the driver.
  73. The following outlines the flow the user should perform:
  74. - Determine Configuration
  75. - Set the order, if not already configured as desired
  76. - Set Turbo decode, LPDC encode or decode parameters, depending on how the
  77. SD-FEC core is configured plus if the SD-FEC has not been configured for PL
  78. initialization
  79. - Enable interrupts, if not already enabled
  80. - Bypass the SD-FEC core, if required
  81. - Start the SD-FEC core if not already started
  82. - Get the SD-FEC core status
  83. - Monitor for interrupts
  84. - Stop the SD-FEC core
  85. Note: When monitoring for interrupts if a critical error is detected where a reset is required, the driver will be required to load the default configuration.
  86. Determine Configuration
  87. -----------------------
  88. Determine the configuration of the SD-FEC core by using the ioctl
  89. :c:macro:`XSDFEC_GET_CONFIG`.
  90. Set the Order
  91. -------------
  92. Setting the order determines how the order of Blocks can change from input to output.
  93. Setting the order is done by using the ioctl :c:macro:`XSDFEC_SET_ORDER`
  94. Setting the order can only be done if the following restrictions are met:
  95. - The ``state`` member of struct :c:type:`xsdfec_status <xsdfec_status>` filled by the ioctl :c:macro:`XSDFEC_GET_STATUS` indicates the SD-FEC core has not STARTED
  96. Add LDPC Codes
  97. --------------
  98. The following steps indicate how to add LDPC codes to the SD-FEC core:
  99. - Use the auto-generated parameters to fill the :c:type:`struct xsdfec_ldpc_params <xsdfec_ldpc_params>` for the desired LDPC code.
  100. - Set the SC, QA, and LA table offsets for the LPDC parameters and the parameters in the structure :c:type:`struct xsdfec_ldpc_params <xsdfec_ldpc_params>`
  101. - Set the desired Code Id value in the structure :c:type:`struct xsdfec_ldpc_params <xsdfec_ldpc_params>`
  102. - Add the LPDC Code Parameters using the ioctl :c:macro:`XSDFEC_ADD_LDPC_CODE_PARAMS`
  103. - For the applied LPDC Code Parameter use the function :c:func:`xsdfec_calculate_shared_ldpc_table_entry_size` to calculate the size of shared LPDC code tables. This allows the user to determine the shared table usage so when selecting the table offsets for the next LDPC code parameters unused table areas can be selected.
  104. - Repeat for each LDPC code parameter.
  105. Adding LDPC codes can only be done if the following restrictions are met:
  106. - The ``code`` member of :c:type:`struct xsdfec_config <xsdfec_config>` filled by the ioctl :c:macro:`XSDFEC_GET_CONFIG` indicates the SD-FEC core is configured as LDPC
  107. - The ``code_wr_protect`` of :c:type:`struct xsdfec_config <xsdfec_config>` filled by the ioctl :c:macro:`XSDFEC_GET_CONFIG` indicates that write protection is not enabled
  108. - The ``state`` member of struct :c:type:`xsdfec_status <xsdfec_status>` filled by the ioctl :c:macro:`XSDFEC_GET_STATUS` indicates the SD-FEC core has not started
  109. Set Turbo Decode
  110. ----------------
  111. Configuring the Turbo decode parameters is done by using the ioctl :c:macro:`XSDFEC_SET_TURBO` using auto-generated parameters to fill the :c:type:`struct xsdfec_turbo <xsdfec_turbo>` for the desired Turbo code.
  112. Adding Turbo decode can only be done if the following restrictions are met:
  113. - The ``code`` member of :c:type:`struct xsdfec_config <xsdfec_config>` filled by the ioctl :c:macro:`XSDFEC_GET_CONFIG` indicates the SD-FEC core is configured as TURBO
  114. - The ``state`` member of struct :c:type:`xsdfec_status <xsdfec_status>` filled by the ioctl :c:macro:`XSDFEC_GET_STATUS` indicates the SD-FEC core has not STARTED
  115. Enable Interrupts
  116. -----------------
  117. Enabling or disabling interrupts is done by using the ioctl :c:macro:`XSDFEC_SET_IRQ`. The members of the parameter passed, :c:type:`struct xsdfec_irq <xsdfec_irq>`, to the ioctl are used to set and clear different categories of interrupts. The category of interrupt is controlled as following:
  118. - ``enable_isr`` controls the ``tlast`` interrupts
  119. - ``enable_ecc_isr`` controls the ECC interrupts
  120. If the ``code`` member of :c:type:`struct xsdfec_config <xsdfec_config>` filled by the ioctl :c:macro:`XSDFEC_GET_CONFIG` indicates the SD-FEC core is configured as TURBO then the enabling ECC errors is not required.
  121. Bypass the SD-FEC
  122. -----------------
  123. Bypassing the SD-FEC is done by using the ioctl :c:macro:`XSDFEC_SET_BYPASS`
  124. Bypassing the SD-FEC can only be done if the following restrictions are met:
  125. - The ``state`` member of :c:type:`struct xsdfec_status <xsdfec_status>` filled by the ioctl :c:macro:`XSDFEC_GET_STATUS` indicates the SD-FEC core has not STARTED
  126. Start the SD-FEC core
  127. ---------------------
  128. Start the SD-FEC core by using the ioctl :c:macro:`XSDFEC_START_DEV`
  129. Get SD-FEC Status
  130. -----------------
  131. Get the SD-FEC status of the device by using the ioctl :c:macro:`XSDFEC_GET_STATUS`, which will fill the :c:type:`struct xsdfec_status <xsdfec_status>`
  132. Monitor for Interrupts
  133. ----------------------
  134. - Use the poll system call to monitor for an interrupt. The poll system call waits for an interrupt to wake it up or times out if no interrupt occurs.
  135. - On return Poll ``revents`` will indicate whether stats and/or state have been updated
  136. - ``POLLPRI`` indicates a critical error and the user should use :c:macro:`XSDFEC_GET_STATUS` and :c:macro:`XSDFEC_GET_STATS` to confirm
  137. - ``POLLRDNORM`` indicates a non-critical error has occurred and the user should use :c:macro:`XSDFEC_GET_STATS` to confirm
  138. - Get stats by using the ioctl :c:macro:`XSDFEC_GET_STATS`
  139. - For critical error the ``isr_err_count`` or ``uecc_count`` member of :c:type:`struct xsdfec_stats <xsdfec_stats>` is non-zero
  140. - For non-critical errors the ``cecc_count`` member of :c:type:`struct xsdfec_stats <xsdfec_stats>` is non-zero
  141. - Get state by using the ioctl :c:macro:`XSDFEC_GET_STATUS`
  142. - For a critical error the ``state`` of :c:type:`xsdfec_status <xsdfec_status>` will indicate a Reset Is Required
  143. - Clear stats by using the ioctl :c:macro:`XSDFEC_CLEAR_STATS`
  144. If a critical error is detected where a reset is required. The application is required to call the ioctl :c:macro:`XSDFEC_SET_DEFAULT_CONFIG`, after the reset and it is not required to call the ioctl :c:macro:`XSDFEC_STOP_DEV`
  145. Note: Using poll system call prevents busy looping using :c:macro:`XSDFEC_GET_STATS` and :c:macro:`XSDFEC_GET_STATUS`
  146. Stop the SD-FEC Core
  147. ---------------------
  148. Stop the device by using the ioctl :c:macro:`XSDFEC_STOP_DEV`
  149. Set the Default Configuration
  150. -----------------------------
  151. Load default configuration by using the ioctl :c:macro:`XSDFEC_SET_DEFAULT_CONFIG` to restore the driver.
  152. Limitations
  153. -----------
  154. Users should not duplicate SD-FEC device file handlers, for example fork() or dup() a process that has a created an SD-FEC file handler.
  155. Driver IOCTLs
  156. ==============
  157. .. c:macro:: XSDFEC_START_DEV
  158. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  159. :doc: XSDFEC_START_DEV
  160. .. c:macro:: XSDFEC_STOP_DEV
  161. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  162. :doc: XSDFEC_STOP_DEV
  163. .. c:macro:: XSDFEC_GET_STATUS
  164. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  165. :doc: XSDFEC_GET_STATUS
  166. .. c:macro:: XSDFEC_SET_IRQ
  167. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  168. :doc: XSDFEC_SET_IRQ
  169. .. c:macro:: XSDFEC_SET_TURBO
  170. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  171. :doc: XSDFEC_SET_TURBO
  172. .. c:macro:: XSDFEC_ADD_LDPC_CODE_PARAMS
  173. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  174. :doc: XSDFEC_ADD_LDPC_CODE_PARAMS
  175. .. c:macro:: XSDFEC_GET_CONFIG
  176. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  177. :doc: XSDFEC_GET_CONFIG
  178. .. c:macro:: XSDFEC_SET_ORDER
  179. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  180. :doc: XSDFEC_SET_ORDER
  181. .. c:macro:: XSDFEC_SET_BYPASS
  182. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  183. :doc: XSDFEC_SET_BYPASS
  184. .. c:macro:: XSDFEC_IS_ACTIVE
  185. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  186. :doc: XSDFEC_IS_ACTIVE
  187. .. c:macro:: XSDFEC_CLEAR_STATS
  188. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  189. :doc: XSDFEC_CLEAR_STATS
  190. .. c:macro:: XSDFEC_GET_STATS
  191. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  192. :doc: XSDFEC_GET_STATS
  193. .. c:macro:: XSDFEC_SET_DEFAULT_CONFIG
  194. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  195. :doc: XSDFEC_SET_DEFAULT_CONFIG
  196. Driver Type Definitions
  197. =======================
  198. .. kernel-doc:: include/uapi/misc/xilinx_sdfec.h
  199. :internal: