brintos

brintos / linux-shallow public Read only

0
0
Text · 12.1 KiB · ee1a42a Raw
449 lines · c
1/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */2/*3 * Xilinx SD-FEC4 *5 * Copyright (C) 2019 Xilinx, Inc.6 *7 * Description:8 * This driver is developed for SDFEC16 IP. It provides a char device9 * in sysfs and supports file operations like open(), close() and ioctl().10 */11#ifndef __XILINX_SDFEC_H__12#define __XILINX_SDFEC_H__13 14#include <linux/types.h>15 16/* Shared LDPC Tables */17#define XSDFEC_LDPC_SC_TABLE_ADDR_BASE (0x10000)18#define XSDFEC_LDPC_SC_TABLE_ADDR_HIGH (0x10400)19#define XSDFEC_LDPC_LA_TABLE_ADDR_BASE (0x18000)20#define XSDFEC_LDPC_LA_TABLE_ADDR_HIGH (0x19000)21#define XSDFEC_LDPC_QC_TABLE_ADDR_BASE (0x20000)22#define XSDFEC_LDPC_QC_TABLE_ADDR_HIGH (0x28000)23 24/* LDPC tables depth */25#define XSDFEC_SC_TABLE_DEPTH                                                  \26	(XSDFEC_LDPC_SC_TABLE_ADDR_HIGH - XSDFEC_LDPC_SC_TABLE_ADDR_BASE)27#define XSDFEC_LA_TABLE_DEPTH                                                  \28	(XSDFEC_LDPC_LA_TABLE_ADDR_HIGH - XSDFEC_LDPC_LA_TABLE_ADDR_BASE)29#define XSDFEC_QC_TABLE_DEPTH                                                  \30	(XSDFEC_LDPC_QC_TABLE_ADDR_HIGH - XSDFEC_LDPC_QC_TABLE_ADDR_BASE)31 32/**33 * enum xsdfec_code - Code Type.34 * @XSDFEC_TURBO_CODE: Driver is configured for Turbo mode.35 * @XSDFEC_LDPC_CODE: Driver is configured for LDPC mode.36 *37 * This enum is used to indicate the mode of the driver. The mode is determined38 * by checking which codes are set in the driver. Note that the mode cannot be39 * changed by the driver.40 */41enum xsdfec_code {42	XSDFEC_TURBO_CODE = 0,43	XSDFEC_LDPC_CODE,44};45 46/**47 * enum xsdfec_order - Order48 * @XSDFEC_MAINTAIN_ORDER: Maintain order execution of blocks.49 * @XSDFEC_OUT_OF_ORDER: Out-of-order execution of blocks.50 *51 * This enum is used to indicate whether the order of blocks can change from52 * input to output.53 */54enum xsdfec_order {55	XSDFEC_MAINTAIN_ORDER = 0,56	XSDFEC_OUT_OF_ORDER,57};58 59/**60 * enum xsdfec_turbo_alg - Turbo Algorithm Type.61 * @XSDFEC_MAX_SCALE: Max Log-Map algorithm with extrinsic scaling. When62 *		      scaling is set to this is equivalent to the Max Log-Map63 *		      algorithm.64 * @XSDFEC_MAX_STAR: Log-Map algorithm.65 * @XSDFEC_TURBO_ALG_MAX: Used to indicate out of bound Turbo algorithms.66 *67 * This enum specifies which Turbo Decode algorithm is in use.68 */69enum xsdfec_turbo_alg {70	XSDFEC_MAX_SCALE = 0,71	XSDFEC_MAX_STAR,72	XSDFEC_TURBO_ALG_MAX,73};74 75/**76 * enum xsdfec_state - State.77 * @XSDFEC_INIT: Driver is initialized.78 * @XSDFEC_STARTED: Driver is started.79 * @XSDFEC_STOPPED: Driver is stopped.80 * @XSDFEC_NEEDS_RESET: Driver needs to be reset.81 * @XSDFEC_PL_RECONFIGURE: Programmable Logic needs to be recofigured.82 *83 * This enum is used to indicate the state of the driver.84 */85enum xsdfec_state {86	XSDFEC_INIT = 0,87	XSDFEC_STARTED,88	XSDFEC_STOPPED,89	XSDFEC_NEEDS_RESET,90	XSDFEC_PL_RECONFIGURE,91};92 93/**94 * enum xsdfec_axis_width - AXIS_WIDTH.DIN Setting for 128-bit width.95 * @XSDFEC_1x128b: DIN data input stream consists of a 128-bit lane96 * @XSDFEC_2x128b: DIN data input stream consists of two 128-bit lanes97 * @XSDFEC_4x128b: DIN data input stream consists of four 128-bit lanes98 *99 * This enum is used to indicate the AXIS_WIDTH.DIN setting for 128-bit width.100 * The number of lanes of the DIN data input stream depends upon the101 * AXIS_WIDTH.DIN parameter.102 */103enum xsdfec_axis_width {104	XSDFEC_1x128b = 1,105	XSDFEC_2x128b = 2,106	XSDFEC_4x128b = 4,107};108 109/**110 * enum xsdfec_axis_word_include - Words Configuration.111 * @XSDFEC_FIXED_VALUE: Fixed, the DIN_WORDS AXI4-Stream interface is removed112 *			from the IP instance and is driven with the specified113 *			number of words.114 * @XSDFEC_IN_BLOCK: In Block, configures the IP instance to expect a single115 *		     DIN_WORDS value per input code block. The DIN_WORDS116 *		     interface is present.117 * @XSDFEC_PER_AXI_TRANSACTION: Per Transaction, configures the IP instance to118 * expect one DIN_WORDS value per input transaction on the DIN interface. The119 * DIN_WORDS interface is present.120 * @XSDFEC_AXIS_WORDS_INCLUDE_MAX: Used to indicate out of bound Words121 *				   Configurations.122 *123 * This enum is used to specify the DIN_WORDS configuration.124 */125enum xsdfec_axis_word_include {126	XSDFEC_FIXED_VALUE = 0,127	XSDFEC_IN_BLOCK,128	XSDFEC_PER_AXI_TRANSACTION,129	XSDFEC_AXIS_WORDS_INCLUDE_MAX,130};131 132/**133 * struct xsdfec_turbo - User data for Turbo codes.134 * @alg: Specifies which Turbo decode algorithm to use135 * @scale: Specifies the extrinsic scaling to apply when the Max Scale algorithm136 *	   has been selected137 *138 * Turbo code structure to communicate parameters to XSDFEC driver.139 */140struct xsdfec_turbo {141	__u32 alg;142	__u8 scale;143};144 145/**146 * struct xsdfec_ldpc_params - User data for LDPC codes.147 * @n: Number of code word bits148 * @k: Number of information bits149 * @psize: Size of sub-matrix150 * @nlayers: Number of layers in code151 * @nqc: Quasi Cyclic Number152 * @nmqc: Number of M-sized QC operations in parity check matrix153 * @nm: Number of M-size vectors in N154 * @norm_type: Normalization required or not155 * @no_packing: Determines if multiple QC ops should be performed156 * @special_qc: Sub-Matrix property for Circulant weight > 0157 * @no_final_parity: Decide if final parity check needs to be performed158 * @max_schedule: Experimental code word scheduling limit159 * @sc_off: SC offset160 * @la_off: LA offset161 * @qc_off: QC offset162 * @sc_table: Pointer to SC Table which must be page aligned163 * @la_table: Pointer to LA Table which must be page aligned164 * @qc_table: Pointer to QC Table which must be page aligned165 * @code_id: LDPC Code166 *167 * This structure describes the LDPC code that is passed to the driver by the168 * application.169 */170struct xsdfec_ldpc_params {171	__u32 n;172	__u32 k;173	__u32 psize;174	__u32 nlayers;175	__u32 nqc;176	__u32 nmqc;177	__u32 nm;178	__u32 norm_type;179	__u32 no_packing;180	__u32 special_qc;181	__u32 no_final_parity;182	__u32 max_schedule;183	__u32 sc_off;184	__u32 la_off;185	__u32 qc_off;186	__u32 *sc_table;187	__u32 *la_table;188	__u32 *qc_table;189	__u16 code_id;190};191 192/**193 * struct xsdfec_status - Status of SD-FEC core.194 * @state: State of the SD-FEC core195 * @activity: Describes if the SD-FEC instance is Active196 */197struct xsdfec_status {198	__u32 state;199	__s8 activity;200};201 202/**203 * struct xsdfec_irq - Enabling or Disabling Interrupts.204 * @enable_isr: If true enables the ISR205 * @enable_ecc_isr: If true enables the ECC ISR206 */207struct xsdfec_irq {208	__s8 enable_isr;209	__s8 enable_ecc_isr;210};211 212/**213 * struct xsdfec_config - Configuration of SD-FEC core.214 * @code: The codes being used by the SD-FEC instance215 * @order: Order of Operation216 * @din_width: Width of the DIN AXI4-Stream217 * @din_word_include: How DIN_WORDS are inputted218 * @dout_width: Width of the DOUT AXI4-Stream219 * @dout_word_include: HOW DOUT_WORDS are outputted220 * @irq: Enabling or disabling interrupts221 * @bypass: Is the core being bypassed222 * @code_wr_protect: Is write protection of LDPC codes enabled223 */224struct xsdfec_config {225	__u32 code;226	__u32 order;227	__u32 din_width;228	__u32 din_word_include;229	__u32 dout_width;230	__u32 dout_word_include;231	struct xsdfec_irq irq;232	__s8 bypass;233	__s8 code_wr_protect;234};235 236/**237 * struct xsdfec_stats - Stats retrived by ioctl XSDFEC_GET_STATS. Used238 *			 to buffer atomic_t variables from struct239 *			 xsdfec_dev. Counts are accumulated until240 *			 the user clears them.241 * @isr_err_count: Count of ISR errors242 * @cecc_count: Count of Correctable ECC errors (SBE)243 * @uecc_count: Count of Uncorrectable ECC errors (MBE)244 */245struct xsdfec_stats {246	__u32 isr_err_count;247	__u32 cecc_count;248	__u32 uecc_count;249};250 251/**252 * struct xsdfec_ldpc_param_table_sizes - Used to store sizes of SD-FEC table253 *					  entries for an individual LPDC code254 *					  parameter.255 * @sc_size: Size of SC table used256 * @la_size: Size of LA table used257 * @qc_size: Size of QC table used258 */259struct xsdfec_ldpc_param_table_sizes {260	__u32 sc_size;261	__u32 la_size;262	__u32 qc_size;263};264 265/*266 * XSDFEC IOCTL List267 */268#define XSDFEC_MAGIC 'f'269/**270 * DOC: XSDFEC_START_DEV271 *272 * @Description273 *274 * ioctl to start SD-FEC core275 *276 * This fails if the XSDFEC_SET_ORDER ioctl has not been previously called277 */278#define XSDFEC_START_DEV _IO(XSDFEC_MAGIC, 0)279/**280 * DOC: XSDFEC_STOP_DEV281 *282 * @Description283 *284 * ioctl to stop the SD-FEC core285 */286#define XSDFEC_STOP_DEV _IO(XSDFEC_MAGIC, 1)287/**288 * DOC: XSDFEC_GET_STATUS289 *290 * @Description291 *292 * ioctl that returns status of SD-FEC core293 */294#define XSDFEC_GET_STATUS _IOR(XSDFEC_MAGIC, 2, struct xsdfec_status)295/**296 * DOC: XSDFEC_SET_IRQ297 * @Parameters298 *299 * @struct xsdfec_irq *300 *	Pointer to the &struct xsdfec_irq that contains the interrupt settings301 *	for the SD-FEC core302 *303 * @Description304 *305 * ioctl to enable or disable irq306 */307#define XSDFEC_SET_IRQ _IOW(XSDFEC_MAGIC, 3, struct xsdfec_irq)308/**309 * DOC: XSDFEC_SET_TURBO310 * @Parameters311 *312 * @struct xsdfec_turbo *313 *	Pointer to the &struct xsdfec_turbo that contains the Turbo decode314 *	settings for the SD-FEC core315 *316 * @Description317 *318 * ioctl that sets the SD-FEC Turbo parameter values319 *320 * This can only be used when the driver is in the XSDFEC_STOPPED state321 */322#define XSDFEC_SET_TURBO _IOW(XSDFEC_MAGIC, 4, struct xsdfec_turbo)323/**324 * DOC: XSDFEC_ADD_LDPC_CODE_PARAMS325 * @Parameters326 *327 * @struct xsdfec_ldpc_params *328 *	Pointer to the &struct xsdfec_ldpc_params that contains the LDPC code329 *	parameters to be added to the SD-FEC Block330 *331 * @Description332 * ioctl to add an LDPC code to the SD-FEC LDPC codes333 *334 * This can only be used when:335 *336 * - Driver is in the XSDFEC_STOPPED state337 *338 * - SD-FEC core is configured as LPDC339 *340 * - SD-FEC Code Write Protection is disabled341 */342#define XSDFEC_ADD_LDPC_CODE_PARAMS                                            \343	_IOW(XSDFEC_MAGIC, 5, struct xsdfec_ldpc_params)344/**345 * DOC: XSDFEC_GET_CONFIG346 * @Parameters347 *348 * @struct xsdfec_config *349 *	Pointer to the &struct xsdfec_config that contains the current350 *	configuration settings of the SD-FEC Block351 *352 * @Description353 *354 * ioctl that returns SD-FEC core configuration355 */356#define XSDFEC_GET_CONFIG _IOR(XSDFEC_MAGIC, 6, struct xsdfec_config)357/**358 * DOC: XSDFEC_GET_TURBO359 * @Parameters360 *361 * @struct xsdfec_turbo *362 *	Pointer to the &struct xsdfec_turbo that contains the current Turbo363 *	decode settings of the SD-FEC Block364 *365 * @Description366 *367 * ioctl that returns SD-FEC turbo param values368 */369#define XSDFEC_GET_TURBO _IOR(XSDFEC_MAGIC, 7, struct xsdfec_turbo)370/**371 * DOC: XSDFEC_SET_ORDER372 * @Parameters373 *374 * @struct unsigned long *375 *	Pointer to the unsigned long that contains a value from the376 *	@enum xsdfec_order377 *378 * @Description379 *380 * ioctl that sets order, if order of blocks can change from input to output381 *382 * This can only be used when the driver is in the XSDFEC_STOPPED state383 */384#define XSDFEC_SET_ORDER _IOW(XSDFEC_MAGIC, 8, unsigned long)385/**386 * DOC: XSDFEC_SET_BYPASS387 * @Parameters388 *389 * @struct bool *390 *	Pointer to bool that sets the bypass value, where false results in391 *	normal operation and false results in the SD-FEC performing the392 *	configured operations (same number of cycles) but output data matches393 *	the input data394 *395 * @Description396 *397 * ioctl that sets bypass.398 *399 * This can only be used when the driver is in the XSDFEC_STOPPED state400 */401#define XSDFEC_SET_BYPASS _IOW(XSDFEC_MAGIC, 9, bool)402/**403 * DOC: XSDFEC_IS_ACTIVE404 * @Parameters405 *406 * @struct bool *407 *	Pointer to bool that returns true if the SD-FEC is processing data408 *409 * @Description410 *411 * ioctl that determines if SD-FEC is processing data412 */413#define XSDFEC_IS_ACTIVE _IOR(XSDFEC_MAGIC, 10, bool)414/**415 * DOC: XSDFEC_CLEAR_STATS416 *417 * @Description418 *419 * ioctl that clears error stats collected during interrupts420 */421#define XSDFEC_CLEAR_STATS _IO(XSDFEC_MAGIC, 11)422/**423 * DOC: XSDFEC_GET_STATS424 * @Parameters425 *426 * @struct xsdfec_stats *427 *	Pointer to the &struct xsdfec_stats that will contain the updated stats428 *	values429 *430 * @Description431 *432 * ioctl that returns SD-FEC core stats433 *434 * This can only be used when the driver is in the XSDFEC_STOPPED state435 */436#define XSDFEC_GET_STATS _IOR(XSDFEC_MAGIC, 12, struct xsdfec_stats)437/**438 * DOC: XSDFEC_SET_DEFAULT_CONFIG439 *440 * @Description441 *442 * ioctl that returns SD-FEC core to default config, use after a reset443 *444 * This can only be used when the driver is in the XSDFEC_STOPPED state445 */446#define XSDFEC_SET_DEFAULT_CONFIG _IO(XSDFEC_MAGIC, 13)447 448#endif /* __XILINX_SDFEC_H__ */449