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.
 
 
 
 
 
 

161 lines
5.1 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2013 Andes technology. *
  3. * Hsiangkai Wang <hkwang@andestech.com> *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
  19. ***************************************************************************/
  20. #ifdef HAVE_CONFIG_H
  21. #include "config.h"
  22. #endif
  23. #include <helper/log.h>
  24. #include "nds32_aice.h"
  25. int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
  26. {
  27. if (aice->port->api->read_reg_64 == NULL) {
  28. LOG_WARNING("Not implemented: %s", __func__);
  29. return ERROR_FAIL;
  30. }
  31. return aice->port->api->read_reg_64(aice->coreid, num, val);
  32. }
  33. int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
  34. {
  35. if (aice->port->api->write_reg_64 == NULL) {
  36. LOG_WARNING("Not implemented: %s", __func__);
  37. return ERROR_FAIL;
  38. }
  39. return aice->port->api->write_reg_64(aice->coreid, num, val);
  40. }
  41. int aice_read_tlb(struct aice_port_s *aice, uint32_t virtual_address,
  42. uint32_t *physical_address)
  43. {
  44. if (aice->port->api->read_tlb == NULL) {
  45. LOG_WARNING("Not implemented: %s", __func__);
  46. return ERROR_FAIL;
  47. }
  48. return aice->port->api->read_tlb(aice->coreid, virtual_address, physical_address);
  49. }
  50. int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
  51. {
  52. if (aice->port->api->cache_ctl == NULL) {
  53. LOG_WARNING("Not implemented: %s", __func__);
  54. return ERROR_FAIL;
  55. }
  56. return aice->port->api->cache_ctl(aice->coreid, subtype, address);
  57. }
  58. int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
  59. {
  60. if (aice->port->api->set_retry_times == NULL) {
  61. LOG_WARNING("Not implemented: %s", __func__);
  62. return ERROR_FAIL;
  63. }
  64. return aice->port->api->set_retry_times(a_retry_times);
  65. }
  66. int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
  67. {
  68. if (aice->port->api->program_edm == NULL) {
  69. LOG_WARNING("Not implemented: %s", __func__);
  70. return ERROR_FAIL;
  71. }
  72. return aice->port->api->program_edm(aice->coreid, command_sequence);
  73. }
  74. int aice_set_command_mode(struct aice_port_s *aice,
  75. enum aice_command_mode command_mode)
  76. {
  77. if (aice->port->api->set_command_mode == NULL) {
  78. LOG_WARNING("Not implemented: %s", __func__);
  79. return ERROR_FAIL;
  80. }
  81. return aice->port->api->set_command_mode(command_mode);
  82. }
  83. int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
  84. uint32_t instruction_num)
  85. {
  86. if (aice->port->api->execute == NULL) {
  87. LOG_WARNING("Not implemented: %s", __func__);
  88. return ERROR_FAIL;
  89. }
  90. return aice->port->api->execute(aice->coreid, instructions, instruction_num);
  91. }
  92. int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
  93. {
  94. if (aice->port->api->set_custom_srst_script == NULL) {
  95. LOG_WARNING("Not implemented: %s", __func__);
  96. return ERROR_FAIL;
  97. }
  98. return aice->port->api->set_custom_srst_script(script);
  99. }
  100. int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
  101. {
  102. if (aice->port->api->set_custom_trst_script == NULL) {
  103. LOG_WARNING("Not implemented: %s", __func__);
  104. return ERROR_FAIL;
  105. }
  106. return aice->port->api->set_custom_trst_script(script);
  107. }
  108. int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
  109. {
  110. if (aice->port->api->set_custom_restart_script == NULL) {
  111. LOG_WARNING("Not implemented: %s", __func__);
  112. return ERROR_FAIL;
  113. }
  114. return aice->port->api->set_custom_restart_script(script);
  115. }
  116. int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check)
  117. {
  118. if (aice->port->api->set_count_to_check_dbger == NULL) {
  119. LOG_WARNING("Not implemented: %s", __func__);
  120. return ERROR_FAIL;
  121. }
  122. return aice->port->api->set_count_to_check_dbger(count_to_check);
  123. }
  124. int aice_profiling(struct aice_port_s *aice, uint32_t interval, uint32_t iteration,
  125. uint32_t reg_no, uint32_t *samples, uint32_t *num_samples)
  126. {
  127. if (aice->port->api->profiling == NULL) {
  128. LOG_WARNING("Not implemented: %s", __func__);
  129. return ERROR_FAIL;
  130. }
  131. return aice->port->api->profiling(aice->coreid, interval, iteration,
  132. reg_no, samples, num_samples);
  133. }