]> rtime.felk.cvut.cz Git - zynq/linux.git/blob - include/uapi/misc/xilinx_sdfec.h
misc: xilinx-sdfec: Add IOCTL to get LDPC Params
[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 };
45
46 enum xsdfec_state {
47         XSDFEC_INIT = 0,
48         XSDFEC_STARTED,
49         XSDFEC_STOPPED,
50         XSDFEC_NEEDS_RESET,
51 };
52
53 enum xsdfec_op_mode {
54         XSDFEC_UNKNOWN_MODE = 0,
55         XSDFEC_ENCODE,
56         XSDFEC_DECODE,
57 };
58
59 /**
60  * struct xsdfec_turbo - User data for Turbo Codes
61  * @alg: Algorithm used by Turbo Codes
62  * @scale: Scale Factor
63  * Turbo Code structure to communicate parameters to XSDFEC driver
64  */
65 struct xsdfec_turbo {
66         bool alg;
67         u8 scale;
68 };
69
70 /**
71  * struct xsdfec_ldpc_params - User data for LDPC Codes
72  * @n: Number of code word bits
73  * @k: Number of information bits
74  * @psize: Size of sub-matrix
75  * @nlayers: Number of layers in code
76  * @nqc: Quasi Cyclic Number
77  * @nmqc: Number of M-sized QC operations in parity check matrix
78  * @nm: Number of M-size vectors in N
79  * @norm_type: Normalization required or not
80  * @no_packing: Determines if multiple QC ops should be performed
81  * @special_qc: Sub-Matrix property for Circulant weight > 0
82  * @no_final_parity: Decide if final parity check needs to be performed
83  * @max_schedule: Experimental code word scheduling limit
84  * @sc_off: SC offset
85  * @la_off: LA offset
86  * @qc_off: QC offset
87  * @sc_table: SC Table
88  * @la_table: LA Table
89  * @qc_table: QC Table
90  * @code_id: LDPC Code
91  *
92  * This structure describes the LDPC code that is passed to the driver
93  * by the application.
94  */
95 struct xsdfec_ldpc_params {
96         u32 n;
97         u32 k;
98         u32 psize;
99         u32 nlayers;
100         u32 nqc;
101         u32 nmqc;
102         u32 nm;
103         u32 norm_type;
104         u32 no_packing;
105         u32 special_qc;
106         u32 no_final_parity;
107         u32 max_schedule;
108         u32 sc_off;
109         u32 la_off;
110         u32 qc_off;
111         u32 sc_table[XSDFEC_LDPC_SC_TABLE_ADDR_HIGH -
112                         XSDFEC_LDPC_SC_TABLE_ADDR_BASE];
113         u32 la_table[XSDFEC_LDPC_LA_TABLE_ADDR_HIGH -
114                         XSDFEC_LDPC_LA_TABLE_ADDR_BASE];
115         u32 qc_table[XSDFEC_LDPC_QC_TABLE_ADDR_HIGH -
116                         XSDFEC_LDPC_QC_TABLE_ADDR_BASE];
117         u16 code_id;
118 };
119
120 /**
121  * struct xsdfec_status - Status of SDFEC device
122  * @fec_id: ID of SDFEC instance
123  * @code: The codes being used by the SDFEC instance
124  * @order: Order of Operation
125  * @state: State of the SDFEC device
126  * @mode: Mode of Operation
127  * @activity: Describes if the SDFEC instance is Active
128  * @cecc_count: Count of the Correctable ECC Errors occurred
129  */
130 struct xsdfec_status {
131         s32 fec_id;
132         enum xsdfec_code code;
133         enum xsdfec_order order;
134         enum xsdfec_state state;
135         enum xsdfec_op_mode mode;
136         bool activity;
137         int cecc_count;
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  * @mode: Mode that the SDFEC is operating
145  * @order: Order of Operation
146  * @state: State of the SDFEC device
147  */
148 struct xsdfec_config {
149         s32 fec_id;
150         enum xsdfec_code code;
151         enum xsdfec_op_mode mode;
152         enum xsdfec_order order;
153         enum xsdfec_state state;
154 };
155
156 /**
157  * struct xsdfec_irq - Enabling or Disabling Interrupts
158  * @enable_isr: If true enables the ISR
159  * @enable_ecc_isr: If true enables the ECC ISR
160  */
161 struct xsdfec_irq {
162         bool enable_isr;
163         bool enable_ecc_isr;
164 };
165
166 /*
167  * XSDFEC IOCTL List
168  */
169 #define XSDFEC_MAGIC            'f'
170 /* ioctl to start sdfec device */
171 #define XSDFEC_START_DEV        _IO(XSDFEC_MAGIC, 0)
172 /* ioctl to stop the device */
173 #define XSDFEC_STOP_DEV         _IO(XSDFEC_MAGIC, 1)
174 /* ioctl to communicate to the driver that device has been reset */
175 #define XSDFEC_RESET_REQ        _IO(XSDFEC_MAGIC, 2)
176 /* ioctl that returns status of sdfec device */
177 #define XSDFEC_GET_STATUS       _IOR(XSDFEC_MAGIC, 3, struct xsdfec_status *)
178 /* ioctl to enable or disable irq */
179 #define XSDFEC_SET_IRQ          _IOW(XSDFEC_MAGIC, 4, struct xsdfec_irq *)
180 /* ioctl to enable turbo params for sdfec device */
181 #define XSDFEC_SET_TURBO        _IOW(XSDFEC_MAGIC, 5, struct xsdfec_turbo *)
182 /* ioctl to add an LDPC code to the sdfec ldpc codes */
183 #define XSDFEC_ADD_LDPC_CODE_PARAMS     \
184         _IOW(XSDFEC_MAGIC, 6, struct xsdfec_ldpc_params *)
185 /* ioctl that returns sdfec device configuration */
186 #define XSDFEC_GET_CONFIG       _IOR(XSDFEC_MAGIC, 7, struct xsdfec_config *)
187 /* ioctl that returns sdfec turbo param values */
188 #define XSDFEC_GET_TURBO        _IOR(XSDFEC_MAGIC, 8, struct xsdfec_turbo *)
189 /* ioctl that returns sdfec LDPC code param values, code_id must be specified */
190 #define XSDFEC_GET_LDPC_CODE_PARAMS \
191         _IOWR(XSDFEC_MAGIC, 9, struct xsdfec_ldpc_params *)
192
193 #endif /* __XILINX_SDFEC_H__ */