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