Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / misc / altera-stapl / altera-jtag.h
blob90235b31e7e82df7e8e2e7962c50489be153ab90
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * altera-jtag.h
5 * altera FPGA driver
7 * Copyright (C) Altera Corporation 1998-2001
8 * Copyright (C) 2010 NetUP Inc.
9 * Copyright (C) 2010 Igor M. Liplianin <liplianin@netup.ru>
12 #ifndef ALTERA_JTAG_H
13 #define ALTERA_JTAG_H
15 /* Function Prototypes */
16 enum altera_jtag_state {
17 ILLEGAL_JTAG_STATE = -1,
18 RESET = 0,
19 IDLE = 1,
20 DRSELECT = 2,
21 DRCAPTURE = 3,
22 DRSHIFT = 4,
23 DREXIT1 = 5,
24 DRPAUSE = 6,
25 DREXIT2 = 7,
26 DRUPDATE = 8,
27 IRSELECT = 9,
28 IRCAPTURE = 10,
29 IRSHIFT = 11,
30 IREXIT1 = 12,
31 IRPAUSE = 13,
32 IREXIT2 = 14,
33 IRUPDATE = 15
37 struct altera_jtag {
38 /* Global variable to store the current JTAG state */
39 enum altera_jtag_state jtag_state;
41 /* Store current stop-state for DR and IR scan commands */
42 enum altera_jtag_state drstop_state;
43 enum altera_jtag_state irstop_state;
45 /* Store current padding values */
46 u32 dr_pre;
47 u32 dr_post;
48 u32 ir_pre;
49 u32 ir_post;
50 u32 dr_length;
51 u32 ir_length;
52 u8 *dr_pre_data;
53 u8 *dr_post_data;
54 u8 *ir_pre_data;
55 u8 *ir_post_data;
56 u8 *dr_buffer;
57 u8 *ir_buffer;
60 #define ALTERA_STACK_SIZE 128
61 #define ALTERA_MESSAGE_LENGTH 1024
63 struct altera_state {
64 struct altera_config *config;
65 struct altera_jtag js;
66 char msg_buff[ALTERA_MESSAGE_LENGTH + 1];
67 long stack[ALTERA_STACK_SIZE];
70 int altera_jinit(struct altera_state *astate);
71 int altera_set_drstop(struct altera_jtag *js, enum altera_jtag_state state);
72 int altera_set_irstop(struct altera_jtag *js, enum altera_jtag_state state);
73 int altera_set_dr_pre(struct altera_jtag *js, u32 count, u32 start_index,
74 u8 *preamble_data);
75 int altera_set_ir_pre(struct altera_jtag *js, u32 count, u32 start_index,
76 u8 *preamble_data);
77 int altera_set_dr_post(struct altera_jtag *js, u32 count, u32 start_index,
78 u8 *postamble_data);
79 int altera_set_ir_post(struct altera_jtag *js, u32 count, u32 start_index,
80 u8 *postamble_data);
81 int altera_goto_jstate(struct altera_state *astate,
82 enum altera_jtag_state state);
83 int altera_wait_cycles(struct altera_state *astate, s32 cycles,
84 enum altera_jtag_state wait_state);
85 int altera_wait_msecs(struct altera_state *astate, s32 microseconds,
86 enum altera_jtag_state wait_state);
87 int altera_irscan(struct altera_state *astate, u32 count,
88 u8 *tdi_data, u32 start_index);
89 int altera_swap_ir(struct altera_state *astate,
90 u32 count, u8 *in_data,
91 u32 in_index, u8 *out_data,
92 u32 out_index);
93 int altera_drscan(struct altera_state *astate, u32 count,
94 u8 *tdi_data, u32 start_index);
95 int altera_swap_dr(struct altera_state *astate, u32 count,
96 u8 *in_data, u32 in_index,
97 u8 *out_data, u32 out_index);
98 void altera_free_buffers(struct altera_state *astate);
99 #endif /* ALTERA_JTAG_H */