1 /***************************************************************************
2 * Copyright (C) 2013 Andes technology. *
3 * Hsiangkai Wang <hkwang@andestech.com> *
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. *
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. *
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 ***************************************************************************/
24 #include <helper/log.h>
25 #include "nds32_aice.h"
27 int aice_read_reg_64(struct aice_port_s
*aice
, uint32_t num
, uint64_t *val
)
29 if (aice
->port
->api
->read_reg_64
== NULL
) {
30 LOG_WARNING("Not implemented: %s", __func__
);
34 return aice
->port
->api
->read_reg_64(aice
->coreid
, num
, val
);
37 int aice_write_reg_64(struct aice_port_s
*aice
, uint32_t num
, uint64_t val
)
39 if (aice
->port
->api
->write_reg_64
== NULL
) {
40 LOG_WARNING("Not implemented: %s", __func__
);
44 return aice
->port
->api
->write_reg_64(aice
->coreid
, num
, val
);
47 int aice_read_tlb(struct aice_port_s
*aice
, uint32_t virtual_address
,
48 uint32_t *physical_address
)
50 if (aice
->port
->api
->read_tlb
== NULL
) {
51 LOG_WARNING("Not implemented: %s", __func__
);
55 return aice
->port
->api
->read_tlb(aice
->coreid
, virtual_address
, physical_address
);
58 int aice_cache_ctl(struct aice_port_s
*aice
, uint32_t subtype
, uint32_t address
)
60 if (aice
->port
->api
->cache_ctl
== NULL
) {
61 LOG_WARNING("Not implemented: %s", __func__
);
65 return aice
->port
->api
->cache_ctl(aice
->coreid
, subtype
, address
);
68 int aice_set_retry_times(struct aice_port_s
*aice
, uint32_t a_retry_times
)
70 if (aice
->port
->api
->set_retry_times
== NULL
) {
71 LOG_WARNING("Not implemented: %s", __func__
);
75 return aice
->port
->api
->set_retry_times(a_retry_times
);
78 int aice_program_edm(struct aice_port_s
*aice
, char *command_sequence
)
80 if (aice
->port
->api
->program_edm
== NULL
) {
81 LOG_WARNING("Not implemented: %s", __func__
);
85 return aice
->port
->api
->program_edm(aice
->coreid
, command_sequence
);
88 int aice_set_command_mode(struct aice_port_s
*aice
,
89 enum aice_command_mode command_mode
)
91 if (aice
->port
->api
->set_command_mode
== NULL
) {
92 LOG_WARNING("Not implemented: %s", __func__
);
96 return aice
->port
->api
->set_command_mode(command_mode
);
99 int aice_execute(struct aice_port_s
*aice
, uint32_t *instructions
,
100 uint32_t instruction_num
)
102 if (aice
->port
->api
->execute
== NULL
) {
103 LOG_WARNING("Not implemented: %s", __func__
);
107 return aice
->port
->api
->execute(aice
->coreid
, instructions
, instruction_num
);
110 int aice_set_custom_srst_script(struct aice_port_s
*aice
, const char *script
)
112 if (aice
->port
->api
->set_custom_srst_script
== NULL
) {
113 LOG_WARNING("Not implemented: %s", __func__
);
117 return aice
->port
->api
->set_custom_srst_script(script
);
120 int aice_set_custom_trst_script(struct aice_port_s
*aice
, const char *script
)
122 if (aice
->port
->api
->set_custom_trst_script
== NULL
) {
123 LOG_WARNING("Not implemented: %s", __func__
);
127 return aice
->port
->api
->set_custom_trst_script(script
);
130 int aice_set_custom_restart_script(struct aice_port_s
*aice
, const char *script
)
132 if (aice
->port
->api
->set_custom_restart_script
== NULL
) {
133 LOG_WARNING("Not implemented: %s", __func__
);
137 return aice
->port
->api
->set_custom_restart_script(script
);
140 int aice_set_count_to_check_dbger(struct aice_port_s
*aice
, uint32_t count_to_check
)
142 if (aice
->port
->api
->set_count_to_check_dbger
== NULL
) {
143 LOG_WARNING("Not implemented: %s", __func__
);
147 return aice
->port
->api
->set_count_to_check_dbger(count_to_check
);
150 int aice_profiling(struct aice_port_s
*aice
, uint32_t interval
, uint32_t iteration
,
151 uint32_t reg_no
, uint32_t *samples
, uint32_t *num_samples
)
153 if (aice
->port
->api
->profiling
== NULL
) {
154 LOG_WARNING("Not implemented: %s", __func__
);
158 return aice
->port
->api
->profiling(aice
->coreid
, interval
, iteration
,
159 reg_no
, samples
, num_samples
);