1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) Marvell International Ltd. and its affiliates
4  */
5 
6 #ifndef _SEQ_EXEC_H
7 #define _SEQ_EXEC_H
8 
9 #define NA			0xff
10 #define DEFAULT_PARAM		0
11 #define MV_BOARD_TCLK_ERROR	0xffffffff
12 
13 #define NO_DATA			0xffffffff
14 #define MAX_DATA_ARRAY		5
15 #define FIRST_CELL		0
16 
17 /* Operation types */
18 enum mv_op {
19 	WRITE_OP,
20 	DELAY_OP,
21 	POLL_OP,
22 };
23 
24 /* Operation parameters */
25 struct op_params {
26 	u32 unit_base_reg;
27 	u32 unit_offset;
28 	u32 mask;
29 	u32 data[MAX_DATA_ARRAY];	/* data array */
30 	u8 wait_time;			/* msec */
31 	u16 num_of_loops;		/* for polling only */
32 };
33 
34 /*
35  * Sequence parameters. Each sequence contains:
36  * 1. Sequence id.
37  * 2. Sequence size (total amount of operations during the sequence)
38  * 3. a series of operations. operations can be write, poll or delay
39  * 4. index in the data array (the entry where the relevant data sits)
40  */
41 struct cfg_seq {
42 	struct op_params *op_params_ptr;
43 	u8 cfg_seq_size;
44 	u8 data_arr_idx;
45 };
46 
47 extern struct cfg_seq serdes_seq_db[];
48 
49 /*
50  * A generic function type for executing an operation (write, poll or delay)
51  */
52 typedef int (*op_execute_func_ptr)(u32 serdes_num, struct op_params *params,
53 				   u32 data_arr_idx);
54 
55 /* Specific functions for executing each operation */
56 int write_op_execute(u32 serdes_num, struct op_params *params,
57 		     u32 data_arr_idx);
58 int delay_op_execute(u32 serdes_num, struct op_params *params,
59 		     u32 data_arr_idx);
60 int poll_op_execute(u32 serdes_num, struct op_params *params, u32 data_arr_idx);
61 enum mv_op get_cfg_seq_op(struct op_params *params);
62 int mv_seq_exec(u32 serdes_num, u32 seq_id);
63 
64 #endif /*_SEQ_EXEC_H*/
65