openocd: fix SPDX tag format for files .c
[fw/openocd] / src / target / nds32_aice.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2
3 /***************************************************************************
4  *   Copyright (C) 2013 Andes technology.                                  *
5  *   Hsiangkai Wang <hkwang@andestech.com>                                 *
6  ***************************************************************************/
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10
11 #include <helper/log.h>
12 #include "nds32_aice.h"
13
14 int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
15 {
16         if (!aice->port->api->read_reg_64) {
17                 LOG_WARNING("Not implemented: %s", __func__);
18                 return ERROR_FAIL;
19         }
20
21         return aice->port->api->read_reg_64(aice->coreid, num, val);
22 }
23
24 int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
25 {
26         if (!aice->port->api->write_reg_64) {
27                 LOG_WARNING("Not implemented: %s", __func__);
28                 return ERROR_FAIL;
29         }
30
31         return aice->port->api->write_reg_64(aice->coreid, num, val);
32 }
33
34 int aice_read_tlb(struct aice_port_s *aice, target_addr_t virtual_address,
35                 target_addr_t *physical_address)
36 {
37         if (!aice->port->api->read_tlb) {
38                 LOG_WARNING("Not implemented: %s", __func__);
39                 return ERROR_FAIL;
40         }
41
42         return aice->port->api->read_tlb(aice->coreid, virtual_address, physical_address);
43 }
44
45 int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
46 {
47         if (!aice->port->api->cache_ctl) {
48                 LOG_WARNING("Not implemented: %s", __func__);
49                 return ERROR_FAIL;
50         }
51
52         return aice->port->api->cache_ctl(aice->coreid, subtype, address);
53 }
54
55 int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
56 {
57         if (!aice->port->api->set_retry_times) {
58                 LOG_WARNING("Not implemented: %s", __func__);
59                 return ERROR_FAIL;
60         }
61
62         return aice->port->api->set_retry_times(a_retry_times);
63 }
64
65 int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
66 {
67         if (!aice->port->api->program_edm) {
68                 LOG_WARNING("Not implemented: %s", __func__);
69                 return ERROR_FAIL;
70         }
71
72         return aice->port->api->program_edm(aice->coreid, command_sequence);
73 }
74
75 int aice_set_command_mode(struct aice_port_s *aice,
76                 enum aice_command_mode command_mode)
77 {
78         if (!aice->port->api->set_command_mode) {
79                 LOG_WARNING("Not implemented: %s", __func__);
80                 return ERROR_FAIL;
81         }
82
83         return aice->port->api->set_command_mode(command_mode);
84 }
85
86 int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
87                 uint32_t instruction_num)
88 {
89         if (!aice->port->api->execute) {
90                 LOG_WARNING("Not implemented: %s", __func__);
91                 return ERROR_FAIL;
92         }
93
94         return aice->port->api->execute(aice->coreid, instructions, instruction_num);
95 }
96
97 int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
98 {
99         if (!aice->port->api->set_custom_srst_script) {
100                 LOG_WARNING("Not implemented: %s", __func__);
101                 return ERROR_FAIL;
102         }
103
104         return aice->port->api->set_custom_srst_script(script);
105 }
106
107 int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
108 {
109         if (!aice->port->api->set_custom_trst_script) {
110                 LOG_WARNING("Not implemented: %s", __func__);
111                 return ERROR_FAIL;
112         }
113
114         return aice->port->api->set_custom_trst_script(script);
115 }
116
117 int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
118 {
119         if (!aice->port->api->set_custom_restart_script) {
120                 LOG_WARNING("Not implemented: %s", __func__);
121                 return ERROR_FAIL;
122         }
123
124         return aice->port->api->set_custom_restart_script(script);
125 }
126
127 int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check)
128 {
129         if (!aice->port->api->set_count_to_check_dbger) {
130                 LOG_WARNING("Not implemented: %s", __func__);
131                 return ERROR_FAIL;
132         }
133
134         return aice->port->api->set_count_to_check_dbger(count_to_check);
135 }
136
137 int aice_profiling(struct aice_port_s *aice, uint32_t interval, uint32_t iteration,
138                 uint32_t reg_no, uint32_t *samples, uint32_t *num_samples)
139 {
140         if (!aice->port->api->profiling) {
141                 LOG_WARNING("Not implemented: %s", __func__);
142                 return ERROR_FAIL;
143         }
144
145         return aice->port->api->profiling(aice->coreid, interval, iteration,
146                         reg_no, samples, num_samples);
147 }