0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ALTERA_JTAG_H
0013 #define ALTERA_JTAG_H
0014
0015
0016 enum altera_jtag_state {
0017 ILLEGAL_JTAG_STATE = -1,
0018 RESET = 0,
0019 IDLE = 1,
0020 DRSELECT = 2,
0021 DRCAPTURE = 3,
0022 DRSHIFT = 4,
0023 DREXIT1 = 5,
0024 DRPAUSE = 6,
0025 DREXIT2 = 7,
0026 DRUPDATE = 8,
0027 IRSELECT = 9,
0028 IRCAPTURE = 10,
0029 IRSHIFT = 11,
0030 IREXIT1 = 12,
0031 IRPAUSE = 13,
0032 IREXIT2 = 14,
0033 IRUPDATE = 15
0034
0035 };
0036
0037 struct altera_jtag {
0038
0039 enum altera_jtag_state jtag_state;
0040
0041
0042 enum altera_jtag_state drstop_state;
0043 enum altera_jtag_state irstop_state;
0044
0045
0046 u32 dr_pre;
0047 u32 dr_post;
0048 u32 ir_pre;
0049 u32 ir_post;
0050 u32 dr_length;
0051 u32 ir_length;
0052 u8 *dr_pre_data;
0053 u8 *dr_post_data;
0054 u8 *ir_pre_data;
0055 u8 *ir_post_data;
0056 u8 *dr_buffer;
0057 u8 *ir_buffer;
0058 };
0059
0060 #define ALTERA_STACK_SIZE 128
0061 #define ALTERA_MESSAGE_LENGTH 1024
0062
0063 struct altera_state {
0064 struct altera_config *config;
0065 struct altera_jtag js;
0066 char msg_buff[ALTERA_MESSAGE_LENGTH + 1];
0067 long stack[ALTERA_STACK_SIZE];
0068 };
0069
0070 int altera_jinit(struct altera_state *astate);
0071 int altera_set_drstop(struct altera_jtag *js, enum altera_jtag_state state);
0072 int altera_set_irstop(struct altera_jtag *js, enum altera_jtag_state state);
0073 int altera_set_dr_pre(struct altera_jtag *js, u32 count, u32 start_index,
0074 u8 *preamble_data);
0075 int altera_set_ir_pre(struct altera_jtag *js, u32 count, u32 start_index,
0076 u8 *preamble_data);
0077 int altera_set_dr_post(struct altera_jtag *js, u32 count, u32 start_index,
0078 u8 *postamble_data);
0079 int altera_set_ir_post(struct altera_jtag *js, u32 count, u32 start_index,
0080 u8 *postamble_data);
0081 int altera_goto_jstate(struct altera_state *astate,
0082 enum altera_jtag_state state);
0083 int altera_wait_cycles(struct altera_state *astate, s32 cycles,
0084 enum altera_jtag_state wait_state);
0085 int altera_wait_msecs(struct altera_state *astate, s32 microseconds,
0086 enum altera_jtag_state wait_state);
0087 int altera_irscan(struct altera_state *astate, u32 count,
0088 u8 *tdi_data, u32 start_index);
0089 int altera_swap_ir(struct altera_state *astate,
0090 u32 count, u8 *in_data,
0091 u32 in_index, u8 *out_data,
0092 u32 out_index);
0093 int altera_drscan(struct altera_state *astate, u32 count,
0094 u8 *tdi_data, u32 start_index);
0095 int altera_swap_dr(struct altera_state *astate, u32 count,
0096 u8 *in_data, u32 in_index,
0097 u8 *out_data, u32 out_index);
0098 void altera_free_buffers(struct altera_state *astate);
0099 #endif