]> rtime.felk.cvut.cz Git - zynq/linux.git/blob - include/uapi/misc/xilinx_sdfec.h
misc: xilinx-sdfec: Remove RESET_REQ IOCTL
[zynq/linux.git] / include / uapi / misc / xilinx_sdfec.h
1 /*
2  * Xilinx SDFEC
3  *
4  * Copyright (C) 2016 - 2017 Xilinx, Inc.
5  *
6  * Description:
7  * This driver is developed for SDFEC16 IP. It provides a char device
8  * in sysfs and supports file operations like  open(), close() and ioctl().
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  */
23 #ifndef __XILINX_SDFEC_H__
24 #define __XILINX_SDFEC_H__
25
26 /* Shared LDPC Tables */
27 #define XSDFEC_LDPC_SC_TABLE_ADDR_BASE          (0x10000)
28 #define XSDFEC_LDPC_SC_TABLE_ADDR_HIGH          (0x103FC)
29 #define XSDFEC_LDPC_LA_TABLE_ADDR_BASE          (0x18000)
30 #define XSDFEC_LDPC_LA_TABLE_ADDR_HIGH          (0x18FFC)
31 #define XSDFEC_LDPC_QC_TABLE_ADDR_BASE          (0x20000)
32 #define XSDFEC_LDPC_QC_TABLE_ADDR_HIGH          (0x27FFC)
33
34 enum xsdfec_code {
35         XSDFEC_CODE_INVALID = 0,
36         XSDFEC_TURBO_CODE,
37         XSDFEC_LDPC_CODE,
38 };
39
40 enum xsdfec_order {
41         XSDFEC_INVALID_ORDER = 0,
42         XSDFEC_MAINTAIN_ORDER,
43         XSDFEC_OUT_OF_ORDER,
44         XSDFEC_ORDER_MAX,
45 };
46
47 enum xsdfec_state {
48         XSDFEC_INIT = 0,
49         XSDFEC_STARTED,
50         XSDFEC_STOPPED,
51         XSDFEC_NEEDS_RESET,
52 };
53
54 enum xsdfec_axis_width {
55         XSDFEC_1x128b = 1,
56         XSDFEC_2x128b = 2,
57         XSDFEC_4x128b = 4,
58 };
59
60 enum xsdfec_axis_word_include {
61         XSDFEC_FIXED_VALUE = 0,
62         XSDFEC_IN_BLOCK,
63         XSDFEC_PER_AXI_TRANSACTION,
64         XSDFEC_AXIS_WORDS_INCLUDE_MAX,
65 };
66
67 /**
68  * struct xsdfec_turbo - User data for Turbo Codes
69  * @alg: Algorithm used by Turbo Codes
70  * @scale: Scale Factor
71  * Turbo Code structure to communicate parameters to XSDFEC driver
72  */
73 struct xsdfec_turbo {
74         bool alg;
75         u8 scale;
76 };
77
78 /**
79  * struct xsdfec_ldpc_params - User data for LDPC Codes
80  * @n: Number of code word bits
81  * @k: Number of information bits
82  * @psize: Size of sub-matrix
83  * @nlayers: Number of layers in code
84  * @nqc: Quasi Cyclic Number
85  * @nmqc: Number of M-sized QC operations in parity check matrix
86  * @nm: Number of M-size vectors in N
87  * @norm_type: Normalization required or not
88  * @no_packing: Determines if multiple QC ops should be performed
89  * @special_qc: Sub-Matrix property for Circulant weight > 0
90  * @no_final_parity: Decide if final parity check needs to be performed
91  * @max_schedule: Experimental code word scheduling limit
92  * @sc_off: SC offset
93  * @la_off: LA offset
94  * @qc_off: QC offset
95  * @sc_table: SC Table
96  * @la_table: LA Table
97  * @qc_table: QC Table
98  * @code_id: LDPC Code
99  *
100  * This structure describes the LDPC code that is passed to the driver
101  * by the application.
102  */
103 struct xsdfec_ldpc_params {
104         u32 n;
105         u32 k;
106         u32 psize;
107         u32 nlayers;
108         u32 nqc;
109         u32 nmqc;
110         u32 nm;
111         u32 norm_type;
112         u32 no_packing;
113         u32 special_qc;
114         u32 no_final_parity;
115         u32 max_schedule;
116         u32 sc_off;
117         u32 la_off;
118         u32 qc_off;
119         u32 sc_table[XSDFEC_LDPC_SC_TABLE_ADDR_HIGH -
120                         XSDFEC_LDPC_SC_TABLE_ADDR_BASE];
121         u32 la_table[XSDFEC_LDPC_LA_TABLE_ADDR_HIGH -
122                         XSDFEC_LDPC_LA_TABLE_ADDR_BASE];
123         u32 qc_table[XSDFEC_LDPC_QC_TABLE_ADDR_HIGH -
124                         XSDFEC_LDPC_QC_TABLE_ADDR_BASE];
125         u16 code_id;
126 };
127
128 /**
129  * struct xsdfec_status - Status of SDFEC device
130  * @fec_id: ID of SDFEC instance
131  * @state: State of the SDFEC device
132  * @activity: Describes if the SDFEC instance is Active
133  */
134 struct xsdfec_status {
135         s32 fec_id;
136         enum xsdfec_state state;
137         bool activity;
138 };
139
140 /**
141  * struct xsdfec_config - Configuration of SDFEC device
142  * @fec_id: ID of SDFEC instance
143  * @code: The codes being used by the SDFEC instance
144  * @order: Order of Operation
145  * @din_width: Width of the DIN AXI Stream
146  * @din_word_include: How DIN_WORDS are inputted
147  * @dout_width: Width of the DOUT AXI Stream
148  * @dout_word_include: HOW DOUT_WORDS are outputted
149  */
150 struct xsdfec_config {
151         s32 fec_id;
152         enum xsdfec_code code;
153         enum xsdfec_order order;
154         enum xsdfec_axis_width din_width;
155         enum xsdfec_axis_word_include din_word_include;
156         enum xsdfec_axis_width dout_width;
157         enum xsdfec_axis_word_include dout_word_include;
158 };
159
160 /**
161  * struct xsdfec_irq - Enabling or Disabling Interrupts
162  * @enable_isr: If true enables the ISR
163  * @enable_ecc_isr: If true enables the ECC ISR
164  */
165 struct xsdfec_irq {
166         bool enable_isr;
167         bool enable_ecc_isr;
168 };
169
170 /**
171  * struct xsdfec_ioctl_stats - Stats retrived by ioctl XSDFEC_GET_STATS. Used
172  *                             to buffer atomic_t variables from struct
173  *                             xsdfec_dev.
174  * @isr_err_count: Count of ISR errors
175  * @cecc_count: Count of Correctable ECC errors (SBE)
176  * @uecc_count: Count of Uncorrectable ECC errors (MBE)
177  */
178 struct xsdfec_stats {
179         u32 isr_err_count;
180         u32 cecc_count;
181         u32 uecc_count;
182 };
183
184 /*
185  * XSDFEC IOCTL List
186  */
187 #define XSDFEC_MAGIC            'f'
188 /* ioctl to start sdfec device */
189 #define XSDFEC_START_DEV        _IO(XSDFEC_MAGIC, 0)
190 /* ioctl to stop the device */
191 #define XSDFEC_STOP_DEV         _IO(XSDFEC_MAGIC, 1)
192 /* ioctl that returns status of sdfec device */
193 #define XSDFEC_GET_STATUS       _IOR(XSDFEC_MAGIC, 3, struct xsdfec_status *)
194 /* ioctl to enable or disable irq */
195 #define XSDFEC_SET_IRQ          _IOW(XSDFEC_MAGIC, 4, struct xsdfec_irq *)
196 /* ioctl to enable turbo params for sdfec device */
197 #define XSDFEC_SET_TURBO        _IOW(XSDFEC_MAGIC, 5, struct xsdfec_turbo *)
198 /* ioctl to add an LDPC code to the sdfec ldpc codes */
199 #define XSDFEC_ADD_LDPC_CODE_PARAMS     \
200         _IOW(XSDFEC_MAGIC, 6, struct xsdfec_ldpc_params *)
201 /* ioctl that returns sdfec device configuration */
202 #define XSDFEC_GET_CONFIG       _IOR(XSDFEC_MAGIC, 7, struct xsdfec_config *)
203 /* ioctl that returns sdfec turbo param values */
204 #define XSDFEC_GET_TURBO        _IOR(XSDFEC_MAGIC, 8, struct xsdfec_turbo *)
205 /* ioctl that returns sdfec LDPC code param values, code_id must be specified */
206 #define XSDFEC_GET_LDPC_CODE_PARAMS \
207         _IOWR(XSDFEC_MAGIC, 9, struct xsdfec_ldpc_params *)
208 /* ioctl that sets order, if order of blocks can change from input to output */
209 #define XSDFEC_SET_ORDER        _IOW(XSDFEC_MAGIC, 10, unsigned long *)
210 /*
211  * ioctl that sets bypass.
212  * setting a value of 0 results in normal operation.
213  * setting a value of 1 results in the sdfec performing the configured
214  * operations (same number of cycles) but output data matches the input data
215  */
216 #define XSDFEC_SET_BYPASS       _IOW(XSDFEC_MAGIC, 11, unsigned long *)
217 /* ioctl that determines if sdfec is processing data */
218 #define XSDFEC_IS_ACTIVE        _IOR(XSDFEC_MAGIC, 12, bool *)
219 /* ioctl that clears error stats collected during interrupts */
220 #define XSDFEC_CLEAR_STATS      _IO(XSDFEC_MAGIC, 13)
221 /* ioctl that returns sdfec device stats */
222 #define XSDFEC_GET_STATS        _IOR(XSDFEC_MAGIC, 14, struct xsdfec_stats *)
223 /* ioctl that returns sdfec device to default config, use after a reset */
224 #define XSDFEC_SET_DEFAULT_CONFIG _IO(XSDFEC_MAGIC, 15)
225
226 #endif /* __XILINX_SDFEC_H__ */