altera-jtag.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * altera-jtag.h
  3. *
  4. * altera FPGA driver
  5. *
  6. * Copyright (C) Altera Corporation 1998-2001
  7. * Copyright (C) 2010 NetUP Inc.
  8. * Copyright (C) 2010 Igor M. Liplianin <liplianin@netup.ru>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. *
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #ifndef ALTERA_JTAG_H
  26. #define ALTERA_JTAG_H
  27. /* Function Prototypes */
  28. enum altera_jtag_state {
  29. ILLEGAL_JTAG_STATE = -1,
  30. RESET = 0,
  31. IDLE = 1,
  32. DRSELECT = 2,
  33. DRCAPTURE = 3,
  34. DRSHIFT = 4,
  35. DREXIT1 = 5,
  36. DRPAUSE = 6,
  37. DREXIT2 = 7,
  38. DRUPDATE = 8,
  39. IRSELECT = 9,
  40. IRCAPTURE = 10,
  41. IRSHIFT = 11,
  42. IREXIT1 = 12,
  43. IRPAUSE = 13,
  44. IREXIT2 = 14,
  45. IRUPDATE = 15
  46. };
  47. struct altera_jtag {
  48. /* Global variable to store the current JTAG state */
  49. enum altera_jtag_state jtag_state;
  50. /* Store current stop-state for DR and IR scan commands */
  51. enum altera_jtag_state drstop_state;
  52. enum altera_jtag_state irstop_state;
  53. /* Store current padding values */
  54. u32 dr_pre;
  55. u32 dr_post;
  56. u32 ir_pre;
  57. u32 ir_post;
  58. u32 dr_length;
  59. u32 ir_length;
  60. u8 *dr_pre_data;
  61. u8 *dr_post_data;
  62. u8 *ir_pre_data;
  63. u8 *ir_post_data;
  64. u8 *dr_buffer;
  65. u8 *ir_buffer;
  66. };
  67. #define ALTERA_STACK_SIZE 128
  68. #define ALTERA_MESSAGE_LENGTH 1024
  69. struct altera_state {
  70. struct altera_config *config;
  71. struct altera_jtag js;
  72. char msg_buff[ALTERA_MESSAGE_LENGTH + 1];
  73. long stack[ALTERA_STACK_SIZE];
  74. };
  75. int altera_jinit(struct altera_state *astate);
  76. int altera_set_drstop(struct altera_jtag *js, enum altera_jtag_state state);
  77. int altera_set_irstop(struct altera_jtag *js, enum altera_jtag_state state);
  78. int altera_set_dr_pre(struct altera_jtag *js, u32 count, u32 start_index,
  79. u8 *preamble_data);
  80. int altera_set_ir_pre(struct altera_jtag *js, u32 count, u32 start_index,
  81. u8 *preamble_data);
  82. int altera_set_dr_post(struct altera_jtag *js, u32 count, u32 start_index,
  83. u8 *postamble_data);
  84. int altera_set_ir_post(struct altera_jtag *js, u32 count, u32 start_index,
  85. u8 *postamble_data);
  86. int altera_goto_jstate(struct altera_state *astate,
  87. enum altera_jtag_state state);
  88. int altera_wait_cycles(struct altera_state *astate, s32 cycles,
  89. enum altera_jtag_state wait_state);
  90. int altera_wait_msecs(struct altera_state *astate, s32 microseconds,
  91. enum altera_jtag_state wait_state);
  92. int altera_irscan(struct altera_state *astate, u32 count,
  93. u8 *tdi_data, u32 start_index);
  94. int altera_swap_ir(struct altera_state *astate,
  95. u32 count, u8 *in_data,
  96. u32 in_index, u8 *out_data,
  97. u32 out_index);
  98. int altera_drscan(struct altera_state *astate, u32 count,
  99. u8 *tdi_data, u32 start_index);
  100. int altera_swap_dr(struct altera_state *astate, u32 count,
  101. u8 *in_data, u32 in_index,
  102. u8 *out_data, u32 out_index);
  103. void altera_free_buffers(struct altera_state *astate);
  104. #endif /* ALTERA_JTAG_H */