brintos

brintos / linux-shallow public Read only

0
0
Text · 11.6 KiB · 698e663 Raw
293 lines · plain
1.. SPDX-License-Identifier: GPL-2.0+2 3====================4Xilinx SD-FEC Driver5====================6 7Overview8========9 10This driver supports SD-FEC Integrated Block for Zynq |Ultrascale+ (TM)| RFSoCs.11 12.. |Ultrascale+ (TM)| unicode:: Ultrascale+ U+212213   .. with trademark sign14 15For 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>`_16 17This driver supports the following features:18 19  - Retrieval of the Integrated Block configuration and status information20  - Configuration of LDPC codes21  - Configuration of Turbo decoding22  - Monitoring errors23 24Missing features, known issues, and limitations of the SD-FEC driver are as25follows:26 27  - Only allows a single open file handler to any instance of the driver at any time28  - Reset of the SD-FEC Integrated Block is not controlled by this driver29  - Does not support shared LDPC code table wraparound30 31The device tree entry is described in:32`linux-xlnx/Documentation/devicetree/bindings/misc/xlnx,sd-fec.yaml <https://github.com/Xilinx/linux-xlnx/blob/master/Documentation/devicetree/bindings/misc/xlnx%2Csd-fec.yaml>`_33 34 35Modes of Operation36------------------37 38The driver works with the SD-FEC core in two modes of operation:39 40  - Run-time configuration41  - Programmable Logic (PL) initialization42 43 44Run-time Configuration45~~~~~~~~~~~~~~~~~~~~~~46 47For Run-time configuration the role of driver is to allow the software application to do the following:48 49	- Load the configuration parameters for either Turbo decode or LDPC encode or decode50	- Activate the SD-FEC core51	- Monitor the SD-FEC core for errors52	- Retrieve the status and configuration of the SD-FEC core53 54Programmable Logic (PL) Initialization55~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~56 57For PL initialization, supporting logic loads configuration parameters for either58the Turbo decode or LDPC encode or decode.  The role of the driver is to allow59the software application to do the following:60 61	- Activate the SD-FEC core62	- Monitor the SD-FEC core for errors63	- Retrieve the status and configuration of the SD-FEC core64 65 66Driver Structure67================68 69The driver provides a platform device where the ``probe`` and ``remove``70operations are provided.71 72  - 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.73 74 75The driver defines the following driver file operations to provide user76application interfaces:77 78  - open: Implements restriction that only a single file descriptor can be open per SD-FEC instance at any time79  - release: Allows another file descriptor to be open, that is after current file descriptor is closed80  - poll: Provides a method to monitor for SD-FEC Error events81  - unlocked_ioctl: Provides the following ioctl commands that allows the application configure the SD-FEC core:82 83		- :c:macro:`XSDFEC_START_DEV`84		- :c:macro:`XSDFEC_STOP_DEV`85		- :c:macro:`XSDFEC_GET_STATUS`86		- :c:macro:`XSDFEC_SET_IRQ`87		- :c:macro:`XSDFEC_SET_TURBO`88		- :c:macro:`XSDFEC_ADD_LDPC_CODE_PARAMS`89		- :c:macro:`XSDFEC_GET_CONFIG`90		- :c:macro:`XSDFEC_SET_ORDER`91		- :c:macro:`XSDFEC_SET_BYPASS`92		- :c:macro:`XSDFEC_IS_ACTIVE`93		- :c:macro:`XSDFEC_CLEAR_STATS`94		- :c:macro:`XSDFEC_SET_DEFAULT_CONFIG`95 96 97Driver Usage98============99 100 101Overview102--------103 104After opening the driver, the user should find out what operations need to be105performed to configure and activate the SD-FEC core and determine the106configuration of the driver.107The following outlines the flow the user should perform:108 109  - Determine Configuration110  - Set the order, if not already configured as desired111  - Set Turbo decode, LPDC encode or decode parameters, depending on how the112    SD-FEC core is configured plus if the SD-FEC has not been configured for PL113    initialization114  - Enable interrupts, if not already enabled115  - Bypass the SD-FEC core, if required116  - Start the SD-FEC core if not already started117  - Get the SD-FEC core status118  - Monitor for interrupts119  - Stop the SD-FEC core120 121 122Note: 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.123 124 125Determine Configuration126-----------------------127 128Determine the configuration of the SD-FEC core by using the ioctl129:c:macro:`XSDFEC_GET_CONFIG`.130 131Set the Order132-------------133 134Setting the order determines how the order of Blocks can change from input to output.135 136Setting the order is done by using the ioctl :c:macro:`XSDFEC_SET_ORDER`137 138Setting the order can only be done if the following restrictions are met:139 140	- 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 STARTED141 142 143Add LDPC Codes144--------------145 146The following steps indicate how to add LDPC codes to the SD-FEC core:147 148	- Use the auto-generated parameters to fill the :c:type:`struct xsdfec_ldpc_params <xsdfec_ldpc_params>` for the desired LDPC code.149	- 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>`150	- Set the desired Code Id value in the structure :c:type:`struct xsdfec_ldpc_params <xsdfec_ldpc_params>`151	- Add the LPDC Code Parameters using the ioctl :c:macro:`XSDFEC_ADD_LDPC_CODE_PARAMS`152	- 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.153	- Repeat for each LDPC code parameter.154 155Adding LDPC codes can only be done if the following restrictions are met:156 157	- 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 LDPC158	- 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 enabled159	- 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 started160 161Set Turbo Decode162----------------163 164Configuring 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.165 166Adding Turbo decode can only be done if the following restrictions are met:167 168	- 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 TURBO169	- 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 STARTED170 171Enable Interrupts172-----------------173 174Enabling 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:175 176  - ``enable_isr`` controls the ``tlast`` interrupts177  - ``enable_ecc_isr`` controls the ECC interrupts178 179If 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.180 181Bypass the SD-FEC182-----------------183 184Bypassing the SD-FEC is done by using the ioctl :c:macro:`XSDFEC_SET_BYPASS`185 186Bypassing the SD-FEC can only be done if the following restrictions are met:187 188	- 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 STARTED189 190Start the SD-FEC core191---------------------192 193Start the SD-FEC core by using the ioctl :c:macro:`XSDFEC_START_DEV`194 195Get SD-FEC Status196-----------------197 198Get 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>`199 200Monitor for Interrupts201----------------------202 203	- 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.204	- On return Poll ``revents`` will indicate whether stats and/or state have been updated205		- ``POLLPRI`` indicates a critical error and the user should use :c:macro:`XSDFEC_GET_STATUS` and :c:macro:`XSDFEC_GET_STATS` to confirm206		- ``POLLRDNORM`` indicates a non-critical error has occurred and the user should use  :c:macro:`XSDFEC_GET_STATS` to confirm207	- Get stats by using the ioctl :c:macro:`XSDFEC_GET_STATS`208		- For critical error the ``isr_err_count`` or ``uecc_count`` member  of :c:type:`struct xsdfec_stats <xsdfec_stats>` is non-zero209		- For non-critical errors the ``cecc_count`` member of :c:type:`struct xsdfec_stats <xsdfec_stats>` is non-zero210	- Get state by using the ioctl :c:macro:`XSDFEC_GET_STATUS`211		- For a critical error the ``state`` of :c:type:`xsdfec_status <xsdfec_status>` will indicate a Reset Is Required212	- Clear stats by using the ioctl :c:macro:`XSDFEC_CLEAR_STATS`213 214If 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`215 216Note: Using poll system call prevents busy looping using :c:macro:`XSDFEC_GET_STATS` and :c:macro:`XSDFEC_GET_STATUS`217 218Stop the SD-FEC Core219---------------------220 221Stop the device by using the ioctl :c:macro:`XSDFEC_STOP_DEV`222 223Set the Default Configuration224-----------------------------225 226Load default configuration by using the ioctl :c:macro:`XSDFEC_SET_DEFAULT_CONFIG` to restore the driver.227 228Limitations229-----------230 231Users should not duplicate SD-FEC device file handlers, for example fork() or dup() a process that has a created an SD-FEC file handler.232 233Driver IOCTLs234==============235 236.. c:macro:: XSDFEC_START_DEV237.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h238   :doc: XSDFEC_START_DEV239 240.. c:macro:: XSDFEC_STOP_DEV241.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h242   :doc: XSDFEC_STOP_DEV243 244.. c:macro:: XSDFEC_GET_STATUS245.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h246   :doc: XSDFEC_GET_STATUS247 248.. c:macro:: XSDFEC_SET_IRQ249.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h250   :doc: XSDFEC_SET_IRQ251 252.. c:macro:: XSDFEC_SET_TURBO253.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h254   :doc: XSDFEC_SET_TURBO255 256.. c:macro:: XSDFEC_ADD_LDPC_CODE_PARAMS257.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h258   :doc: XSDFEC_ADD_LDPC_CODE_PARAMS259 260.. c:macro:: XSDFEC_GET_CONFIG261.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h262   :doc: XSDFEC_GET_CONFIG263 264.. c:macro:: XSDFEC_SET_ORDER265.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h266   :doc: XSDFEC_SET_ORDER267 268.. c:macro:: XSDFEC_SET_BYPASS269.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h270   :doc: XSDFEC_SET_BYPASS271 272.. c:macro:: XSDFEC_IS_ACTIVE273.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h274   :doc: XSDFEC_IS_ACTIVE275 276.. c:macro:: XSDFEC_CLEAR_STATS277.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h278   :doc: XSDFEC_CLEAR_STATS279 280.. c:macro:: XSDFEC_GET_STATS281.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h282   :doc: XSDFEC_GET_STATS283 284.. c:macro:: XSDFEC_SET_DEFAULT_CONFIG285.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h286   :doc: XSDFEC_SET_DEFAULT_CONFIG287 288Driver Type Definitions289=======================290 291.. kernel-doc:: include/uapi/misc/xilinx_sdfec.h292   :internal:293