You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

113 lines
3.8 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2009 by Simon Qian <SimonQian@SimonQian.com> *
  3. * *
  4. * This program is free software; you can redistribute it and/or modify *
  5. * it under the terms of the GNU General Public License as published by *
  6. * the Free Software Foundation; either version 2 of the License, or *
  7. * (at your option) any later version. *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>. *
  16. ***************************************************************************/
  17. #ifndef OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_H
  18. #define OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_H
  19. #include <libusb.h>
  20. struct usart_status_t {
  21. uint32_t tx_buff_avail;
  22. uint32_t tx_buff_size;
  23. uint32_t rx_buff_avail;
  24. uint32_t rx_buff_size;
  25. };
  26. #include "usbtoxxx/usbtoxxx.h"
  27. /* GPIO pins */
  28. #define GPIO_SRST (1 << 0)
  29. #define GPIO_TRST (1 << 1)
  30. #define GPIO_USR1 (1 << 2)
  31. #define GPIO_USR2 (1 << 3)
  32. #define GPIO_TCK (1 << 4)
  33. #define GPIO_TDO (1 << 5)
  34. #define GPIO_TDI (1 << 6)
  35. #define GPIO_RTCK (1 << 7)
  36. #define GPIO_TMS (1 << 8)
  37. struct interface_gpio_t {
  38. RESULT(*init)(uint8_t interface_index);
  39. RESULT(*fini)(uint8_t interface_index);
  40. RESULT(*config)(uint8_t interface_index, uint32_t pin_mask, uint32_t io,
  41. uint32_t pull_en_mask, uint32_t input_pull_mask);
  42. RESULT(*out)(uint8_t interface_index, uint32_t pin_mask, uint32_t value);
  43. RESULT(*in)(uint8_t interface_index, uint32_t pin_mask, uint32_t *value);
  44. };
  45. struct interface_delay_t {
  46. RESULT(*delayms)(uint16_t ms);
  47. RESULT(*delayus)(uint16_t us);
  48. };
  49. struct interface_swd_t {
  50. RESULT(*init)(uint8_t interface_index);
  51. RESULT(*fini)(uint8_t interface_index);
  52. RESULT(*config)(uint8_t interface_index, uint8_t trn, uint16_t retry,
  53. uint16_t dly);
  54. RESULT(*seqout)(uint8_t interface_index, const uint8_t *data,
  55. uint16_t bitlen);
  56. RESULT(*seqin)(uint8_t interface_index, uint8_t *data, uint16_t bitlen);
  57. RESULT(*transact)(uint8_t interface_index, uint8_t request,
  58. uint32_t *data, uint8_t *ack);
  59. };
  60. struct interface_jtag_raw_t {
  61. RESULT(*init)(uint8_t interface_index);
  62. RESULT(*fini)(uint8_t interface_index);
  63. RESULT(*config)(uint8_t interface_index, uint32_t kHz);
  64. RESULT(*execute)(uint8_t interface_index, uint8_t *tdi, uint8_t *tms,
  65. uint8_t *tdo, uint32_t bitlen);
  66. };
  67. struct interface_target_voltage_t {
  68. RESULT(*get)(uint16_t *voltage);
  69. RESULT(*set)(uint16_t voltage);
  70. };
  71. struct versaloon_adaptors_t {
  72. struct interface_target_voltage_t target_voltage;
  73. struct interface_gpio_t gpio;
  74. struct interface_delay_t delay;
  75. struct interface_swd_t swd;
  76. struct interface_jtag_raw_t jtag_raw;
  77. RESULT(*peripheral_commit)(void);
  78. };
  79. struct versaloon_usb_setting_t {
  80. uint16_t vid;
  81. uint16_t pid;
  82. uint8_t ep_out;
  83. uint8_t ep_in;
  84. uint8_t interface;
  85. char *serialstring;
  86. uint16_t buf_size;
  87. };
  88. struct versaloon_interface_t {
  89. RESULT(*init)(void);
  90. RESULT(*fini)(void);
  91. struct versaloon_adaptors_t adaptors;
  92. struct versaloon_usb_setting_t usb_setting;
  93. };
  94. extern struct versaloon_interface_t versaloon_interface;
  95. extern libusb_device_handle *versaloon_usb_device_handle;
  96. #endif /* OPENOCD_JTAG_DRIVERS_VERSALOON_VERSALOON_H */