+// SPDX-License-Identifier: GPL-2.0-or-later
+
/***************************************************************************
* Copyright (C) 2011 by Rodrigo L. Rosa *
* rodrigorosa.LG@gmail.com *
* *
* Based on dsp563xx_once.h written by Mathias Kuester *
* mkdorg@users.sourceforge.net *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "target_type.h"
#include "dsp5680xx.h"
-struct dsp5680xx_common dsp5680xx_context;
+static struct dsp5680xx_common dsp5680xx_context;
#define _E "DSP5680XX_ERROR:%d\nAt:%s:%d:%s"
#define err_check(r, c, m) if (r != ERROR_OK) {LOG_ERROR(_E, c, __func__, __LINE__, m); return r; }
*/
int retval = ERROR_OK;
- if (NULL == target->tap) {
+ if (!target->tap) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_INVALID_TAP,
"Invalid tap");
err_check(retval, DSP5680XX_ERROR_JTAG_DRSCAN,
"drscan failed!");
}
- if (d_out != NULL)
+ if (d_out)
LOG_DEBUG("Data read (%d bits): 0x%04X", len, *d_out);
else
LOG_DEBUG("Data read was discarded.");
uint16_t tap_ir_len = DSP5680XX_JTAG_MASTER_TAP_IRLEN;
- if (NULL == target->tap) {
+ if (!target->tap) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_INVALID_TAP,
"Invalid tap");
} else {
struct jtag_tap *t =
jtag_tap_by_string("dsp568013.chp");
- if ((t == NULL)
+ if ((!t)
|| ((t->enabled) && (ir_len != tap_ir_len))) {
retval = ERROR_FAIL;
err_check(retval,
dsp5680xx_irscan(target, &instr, &read_from_ir,
DSP5680XX_JTAG_CORE_TAP_IRLEN);
err_check_propagate(retval);
- if (status != NULL)
+ if (status)
*status = (uint8_t) read_from_ir;
return ERROR_OK;
}
dsp5680xx_drscan(target, (uint8_t *) &instr,
(uint8_t *) &data_read_dummy, num_bits);
err_check_propagate(retval);
- if (data_read != NULL)
+ if (data_read)
*data_read = data_read_dummy;
return retval;
}
retval = jtag_data_write(target, instr_with_flags, 8, &dr_out_tmp);
err_check_propagate(retval);
- if (eonce_status != NULL)
+ if (eonce_status)
*eonce_status = (uint8_t) dr_out_tmp;
return retval;
}
return retval;
}
-static int eonce_load_TX_RX_to_r0(struct target *target)
+static int eonce_load_tx_rx_to_r0(struct target *target)
{
int retval;
return retval;
}
-static int core_load_TX_RX_high_addr_to_r0(struct target *target)
+static int core_load_tx_rx_high_addr_to_r0(struct target *target)
{
int retval = 0;
uint32_t ir_out; /* not used, just to make jtag happy. */
- if (master_tap == NULL) {
+ if (!master_tap) {
master_tap = jtag_tap_by_string("dsp568013.chp");
- if (master_tap == NULL) {
+ if (!master_tap) {
retval = ERROR_FAIL;
const char *msg = "Failed to get master tap.";
msg);
}
}
- if (core_tap == NULL) {
+ if (!core_tap) {
core_tap = jtag_tap_by_string("dsp568013.cpu");
- if (core_tap == NULL) {
+ if (!core_tap) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_CORE,
"Failed to get core tap.");
*/
err_check_propagate(retval);
}
- if (eonce_status != NULL)
+ if (eonce_status)
*eonce_status = data_read_from_dr;
return retval;
}
struct jtag_tap *tap_cpu;
tap_chp = jtag_tap_by_string("dsp568013.chp");
- if (tap_chp == NULL) {
+ if (!tap_chp) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_MASTER,
"Failed to get master tap.");
}
tap_cpu = jtag_tap_by_string("dsp568013.cpu");
- if (tap_cpu == NULL) {
+ if (!tap_cpu) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_CORE,
"Failed to get master tap.");
retval = ERROR_TARGET_FAILURE;
err_check(retval, DSP5680XX_ERROR_ENTER_DEBUG_MODE, msg);
}
- if (eonce_status != NULL)
+ if (eonce_status)
*eonce_status = data_read_from_dr;
return retval;
}
err_check_propagate(retval);
retval = core_move_r4_to_y(target);
err_check_propagate(retval);
- retval = eonce_load_TX_RX_to_r0(target);
+ retval = eonce_load_tx_rx_to_r0(target);
err_check_propagate(retval);
retval = core_move_y0_at_r0(target);
err_check_propagate(retval);
else
retval = core_move_at_r0_to_y0(target);
err_check_propagate(retval);
- retval = eonce_load_TX_RX_to_r0(target);
+ retval = eonce_load_tx_rx_to_r0(target);
err_check_propagate(retval);
retval = core_move_y0_at_r0(target);
err_check_propagate(retval);
err_check_propagate(retval);
}
/* Get lower part of data to TX/RX */
- retval = eonce_load_TX_RX_to_r0(target);
+ retval = eonce_load_tx_rx_to_r0(target);
err_check_propagate(retval);
retval = core_move_y0_at_r0_inc(target); /* This also load TX/RX high to r0 */
err_check_propagate(retval);
* P: (program) memory or X: (dat) memory.
*
* @param target
- * @param address
+ * @param a address
* @param size Bytes (1), Half words (2), Words (4).
* @param count In bytes.
- * @param buffer
+ * @param b buffer
*
* @return
*/
-static int dsp5680xx_write(struct target *t, target_addr_t a, uint32_t s, uint32_t c,
+static int dsp5680xx_write(struct target *target, target_addr_t a, uint32_t size, uint32_t count,
const uint8_t *b)
{
/* TODO Cannot write 32bit to odd address, will write 0x12345678 as 0x5678 0x0012 */
- struct target *target = t;
-
uint32_t address = a;
- uint32_t count = c;
-
uint8_t const *buffer = b;
- uint32_t size = s;
-
check_halt_and_debug(target);
int retval = 0;
*
* @return
*/
-static int dsp5680xx_read_buffer(struct target *t, target_addr_t a, uint32_t size,
- uint8_t *buf)
+static int dsp5680xx_read_buffer(struct target *target, target_addr_t address, uint32_t size,
+ uint8_t *buffer)
{
- check_halt_and_debug(t);
+ check_halt_and_debug(target);
/* The "/2" solves the byte/word addressing issue.*/
- return dsp5680xx_read(t, a, 2, size / 2, buf);
+ return dsp5680xx_read(target, address, 2, size / 2, buffer);
}
/**
*
* @return
*/
-static int dsp5680xx_checksum_memory(struct target *t, target_addr_t a, uint32_t s,
+static int dsp5680xx_checksum_memory(struct target *target, target_addr_t address, uint32_t size,
uint32_t *checksum)
{
return ERROR_FAIL;
}
/**
- * Calculates a signature over @a word_count words in the data from @a buff16.
+ * Calculates a signature over @a word_count words in the data from @a buff8.
* The algorithm used is the same the FM uses, so the @a return may be used to compare
* with the one generated by the FM module, and check if flashing was successful.
* This algorithm is based on the perl script available from the Freescale website at FAQ 25630.
*
- * @param buff16
+ * @param buff8
* @param word_count
*
* @return
*
* @return
*/
-static int dsp5680xx_f_SIM_reset(struct target *target)
+static int dsp5680xx_f_sim_reset(struct target *target)
{
int retval = ERROR_OK;
retval = dsp5680xx_halt(target);
err_check_propagate(retval);
- retval = dsp5680xx_f_SIM_reset(target);
+ retval = dsp5680xx_f_sim_reset(target);
err_check_propagate(retval);
return retval;
}
int retval;
check_halt_and_debug(target);
- if (protected == NULL) {
+ if (!protected) {
const char *msg = "NULL pointer not valid.";
err_check(ERROR_FAIL,
* Some commands use the parameters @a address and @a data, others ignore them.
*
* @param target
- * @param command Command to execute.
+ * @param c Command to execute.
* @param address Command parameter.
* @param data Command parameter.
* @param hfm_ustat FM status register.
*
* @return
*/
-static int dsp5680xx_f_ex(struct target *t, uint16_t c, uint32_t a, uint32_t d,
- uint16_t *h, int p)
+static int dsp5680xx_f_ex(struct target *target, uint16_t c, uint32_t address, uint32_t data,
+ uint16_t *hfm_ustat, int pmem)
{
- struct target *target = t;
-
uint32_t command = c;
-
- uint32_t address = a;
-
- uint32_t data = d;
-
- uint16_t *hfm_ustat = h;
-
- int pmem = p;
-
int retval;
- retval = core_load_TX_RX_high_addr_to_r0(target);
+ retval = core_load_tx_rx_high_addr_to_r0(target);
err_check_propagate(retval);
retval = core_move_long_to_r2(target, HFM_BASE_ADDR);
err_check_propagate(retval);
retval = core_move_long_to_r2(target, HFM_BASE_ADDR);
err_check_propagate(retval);
- retval = core_load_TX_RX_high_addr_to_r0(target);
+ retval = core_load_tx_rx_high_addr_to_r0(target);
err_check_propagate(retval);
/* read HFM_CLKD */
retval = core_move_at_r2_to_y0(target);
*
* @return
*/
-static int dsp5680xx_f_signature(struct target *t, uint32_t a, uint32_t words,
+static int dsp5680xx_f_signature(struct target *target, uint32_t address, uint32_t words,
uint16_t *signature)
{
- struct target *target = t;
-
- uint32_t address = a;
-
int retval;
uint16_t hfm_ustat;
retval =
dsp5680xx_f_ex(target, HFM_ERASE_VERIFY, tmp, 0, &hfm_ustat, 1);
err_check_propagate(retval);
- if (erased != NULL)
+ if (erased)
*erased = (uint8_t) (hfm_ustat & HFM_USTAT_MASK_BLANK);
return retval;
}
* Reset SIM
*
*/
- retval = dsp5680xx_f_SIM_reset(target);
+ retval = dsp5680xx_f_sim_reset(target);
err_check_propagate(retval);
/*
* Set hfmdiv
retval = core_move_long_to_r3(target, address); /* Destination address to r3 */
err_check_propagate(retval);
- core_load_TX_RX_high_addr_to_r0(target); /* TX/RX reg address to r0 */
+ core_load_tx_rx_high_addr_to_r0(target); /* TX/RX reg address to r0 */
err_check_propagate(retval);
retval = core_move_long_to_r2(target, HFM_BASE_ADDR); /* FM base address to r2 */
err_check_propagate(retval);
struct jtag_tap *tap_cpu;
tap_chp = jtag_tap_by_string("dsp568013.chp");
- if (tap_chp == NULL) {
+ if (!tap_chp) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_MASTER,
"Failed to get master tap.");
}
tap_cpu = jtag_tap_by_string("dsp568013.cpu");
- if (tap_cpu == NULL) {
+ if (!tap_cpu) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_CORE,
"Failed to get master tap.");
jtag_add_sleep(TIME_DIV_FREESCALE * 300 * 1000);
tap_chp = jtag_tap_by_string("dsp568013.chp");
- if (tap_chp == NULL) {
+ if (!tap_chp) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_MASTER,
"Failed to get master tap.");
}
tap_cpu = jtag_tap_by_string("dsp568013.cpu");
- if (tap_cpu == NULL) {
+ if (!tap_cpu) {
retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_ENABLE_CORE,
"Failed to get master tap.");