This is an automated email from Gerrit. "Daniel Anselmi <danse...@gmx.ch>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7680
-- gerrit commit 3256bbde94fa0fc13ae1446415d92adb933b39c7 Author: Daniel Anselmi <danse...@gmx.ch> Date: Thu Apr 20 23:26:57 2023 +0200 move tap-pointer to pld_device Change-Id: Iba2bd7854186012aea204715e732350871ed07e3 Signed-off-by: Daniel Anselmi <danse...@gmx.ch> diff --git a/src/pld/certus.c b/src/pld/certus.c index 692ea1907d..cd19df9211 100644 --- a/src/pld/certus.c +++ b/src/pld/certus.c @@ -50,12 +50,8 @@ static int lattice_certus_enable_transparent_mode(struct jtag_tap *tap) return jtag_execute_queue(); } -static int lattice_certus_erase_device(struct lattice_pld_device *lattice_device) +static int lattice_certus_erase_device(struct lattice_pld_device *lattice_device, struct jtag_tap *tap) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - int retval = lattice_set_instr(tap, LSC_DEVICE_CTRL, TAP_IRPAUSE); if (retval != ERROR_OK) return retval; @@ -99,7 +95,7 @@ static int lattice_certus_erase_device(struct lattice_pld_device *lattice_device /* check done is cleared and fail is cleared */ const uint64_t status_done_flag = 0x100; const uint64_t status_fail_flag = 0x2000; - return lattice_verify_status_register_u64(lattice_device, 0x0, 0x0, status_done_flag | status_fail_flag); + return lattice_verify_status_register_u64(lattice_device, tap, 0x0, 0x0, status_done_flag | status_fail_flag); } static int lattice_certus_enable_programming(struct jtag_tap *tap) @@ -163,19 +159,16 @@ static int lattice_certus_program_config_map(struct jtag_tap *tap, struct lattic return jtag_execute_queue(); } -int lattice_certus_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file) +int lattice_certus_load(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, + struct lattice_bit_file *bit_file) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - - int retval = lattice_preload(lattice_device); + int retval = lattice_preload(lattice_device, tap); if (retval != ERROR_OK) return retval; /* check password protection is disabled */ const uint64_t status_pwd_protection = 0x20000; - retval = lattice_verify_status_register_u64(lattice_device, 0x0, 0x0, status_pwd_protection); + retval = lattice_verify_status_register_u64(lattice_device, tap, 0x0, 0x0, status_pwd_protection); if (retval != ERROR_OK) { LOG_ERROR("Password protection is set"); return retval; @@ -187,7 +180,7 @@ int lattice_certus_load(struct lattice_pld_device *lattice_device, struct lattic /* Check the SRAM Erase Lock */ const uint64_t status_otp = 0x40; - retval = lattice_verify_status_register_u64(lattice_device, 0x0, status_otp, status_otp); + retval = lattice_verify_status_register_u64(lattice_device, tap, 0x0, status_otp, status_otp); if (retval != ERROR_OK) { LOG_ERROR("NV User Feature Sector OTP is Set"); return retval; @@ -195,7 +188,7 @@ int lattice_certus_load(struct lattice_pld_device *lattice_device, struct lattic /* Check the SRAM Lock */ const uint64_t status_write_protected = 0x400; - retval = lattice_verify_status_register_u64(lattice_device, 0x0, 0x0, status_write_protected); + retval = lattice_verify_status_register_u64(lattice_device, tap, 0x0, 0x0, status_write_protected); if (retval != ERROR_OK) { LOG_ERROR("NV User Feature Sector OTP is Set"); return retval; @@ -207,7 +200,7 @@ int lattice_certus_load(struct lattice_pld_device *lattice_device, struct lattic return retval; } - retval = lattice_certus_erase_device(lattice_device); + retval = lattice_certus_erase_device(lattice_device, tap); if (retval != ERROR_OK) { LOG_ERROR("erasing device failed"); return retval; @@ -224,7 +217,7 @@ int lattice_certus_load(struct lattice_pld_device *lattice_device, struct lattic const uint32_t mask = expected | 0x3000 | // Busy Flag and Fail Flag 0xf000000; // BSE Error - retval = lattice_verify_status_register_u64(lattice_device, 0x0, 0x100, mask); + retval = lattice_verify_status_register_u64(lattice_device, tap, 0x0, 0x100, mask); if (retval != ERROR_OK) return retval; diff --git a/src/pld/certus.h b/src/pld/certus.h index 51defc5ca2..38b7243988 100644 --- a/src/pld/certus.h +++ b/src/pld/certus.h @@ -12,7 +12,8 @@ int lattice_certus_read_status(struct jtag_tap *tap, uint64_t *status, uint64_t out); int lattice_certus_read_usercode(struct jtag_tap *tap, uint32_t *usercode, uint32_t out); -int lattice_certus_write_usercode(struct lattice_pld_device *lattice_device, uint32_t usercode); -int lattice_certus_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file); +int lattice_certus_write_usercode(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t usercode); +int lattice_certus_load(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, + struct lattice_bit_file *bit_file); #endif /* OPENOCD_PLD_CERTUS_H */ diff --git a/src/pld/ecp2_3.c b/src/pld/ecp2_3.c index 6826d0b4a1..d00a38f444 100644 --- a/src/pld/ecp2_3.c +++ b/src/pld/ecp2_3.c @@ -37,12 +37,8 @@ int lattice_ecp2_3_read_usercode(struct jtag_tap *tap, uint32_t *usercode, uint3 return lattice_read_u32_register(tap, READ_USERCODE, usercode, out, false); } -int lattice_ecp2_3_write_usercode(struct lattice_pld_device *lattice_device, uint32_t usercode) +int lattice_ecp2_3_write_usercode(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t usercode) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - int retval = lattice_set_instr(tap, ISC_ENABLE, TAP_IDLE); if (retval != ERROR_OK) return retval; @@ -72,15 +68,11 @@ int lattice_ecp2_3_write_usercode(struct lattice_pld_device *lattice_device, uin retval = jtag_execute_queue(); if (retval != ERROR_OK) return retval; - return lattice_verify_usercode(lattice_device, 0x0, usercode, REGISTER_ALL_BITS_1); + return lattice_verify_usercode(lattice_device, tap, 0x0, usercode, REGISTER_ALL_BITS_1); } -static int lattice_ecp2_3_erase_device(struct lattice_pld_device *lattice_device) +static int lattice_ecp2_3_erase_device(struct lattice_pld_device *lattice_device, struct jtag_tap *tap) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - /* program user code with all bits set */ int retval = lattice_set_instr(tap, ISC_PROGRAM_USERCODE, TAP_IRPAUSE); if (retval != ERROR_OK) @@ -98,7 +90,7 @@ static int lattice_ecp2_3_erase_device(struct lattice_pld_device *lattice_device const uint32_t out = REGISTER_ALL_BITS_1; const uint32_t mask = REGISTER_ALL_BITS_1; const uint32_t expected_pre = REGISTER_ALL_BITS_1; - retval = lattice_verify_usercode(lattice_device, out, expected_pre, mask); + retval = lattice_verify_usercode(lattice_device, tap, out, expected_pre, mask); if (retval != ERROR_OK) return retval; @@ -119,16 +111,11 @@ static int lattice_ecp2_3_erase_device(struct lattice_pld_device *lattice_device /* after erasing check all bits in user register are cleared */ const uint32_t expected_post = REGISTER_ALL_BITS_0; - return lattice_verify_usercode(lattice_device, out, expected_post, mask); + return lattice_verify_usercode(lattice_device, tap, out, expected_post, mask); } -static int lattice_ecp2_3_program_config_map(struct lattice_pld_device *lattice_device, - struct lattice_bit_file *bit_file) +static int lattice_ecp2_3_program_config_map(struct jtag_tap *tap, struct lattice_bit_file *bit_file) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - int retval = lattice_set_instr(tap, LSCC_RESET_ADDRESS, TAP_IDLE); if (retval != ERROR_OK) return retval; @@ -148,12 +135,8 @@ static int lattice_ecp2_3_program_config_map(struct lattice_pld_device *lattice_ return jtag_execute_queue(); } -static int lattice_ecp2_3_exit_programming_mode(struct lattice_pld_device *lattice_device) +static int lattice_ecp2_3_exit_programming_mode(struct jtag_tap *tap) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - int retval = lattice_set_instr(tap, ISC_DISABLE, TAP_IDLE); if (retval != ERROR_OK) return retval; @@ -167,13 +150,10 @@ static int lattice_ecp2_3_exit_programming_mode(struct lattice_pld_device *latti return jtag_execute_queue(); } -int lattice_ecp2_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file) +int lattice_ecp2_load(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, + struct lattice_bit_file *bit_file) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - - int retval = lattice_preload(lattice_device); + int retval = lattice_preload(lattice_device, tap); if (retval != ERROR_OK) return retval; @@ -188,33 +168,30 @@ int lattice_ecp2_load(struct lattice_pld_device *lattice_device, struct lattice_ jtag_add_sleep(20000); /* Erase the device */ - retval = lattice_ecp2_3_erase_device(lattice_device); + retval = lattice_ecp2_3_erase_device(lattice_device, tap); if (retval != ERROR_OK) return retval; /* Program Fuse Map */ - retval = lattice_ecp2_3_program_config_map(lattice_device, bit_file); + retval = lattice_ecp2_3_program_config_map(tap, bit_file); if (retval != ERROR_OK) return retval; - retval = lattice_ecp2_3_exit_programming_mode(lattice_device); + retval = lattice_ecp2_3_exit_programming_mode(tap); if (retval != ERROR_OK) return retval; const uint32_t out = REGISTER_ALL_BITS_1; const uint32_t mask = STATUS_DONE_BIT | STATUS_ERROR_BITS_ECP2; const uint32_t expected = STATUS_DONE_BIT; - return lattice_verify_status_register_u32(lattice_device, out, expected, mask, false); + return lattice_verify_status_register_u32(lattice_device, tap, out, expected, mask, false); } -int lattice_ecp3_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file) +int lattice_ecp3_load(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, + struct lattice_bit_file *bit_file) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - /* Program Bscan register */ - int retval = lattice_preload(lattice_device); + int retval = lattice_preload(lattice_device, tap); if (retval != ERROR_OK) return retval; @@ -230,21 +207,21 @@ int lattice_ecp3_load(struct lattice_pld_device *lattice_device, struct lattice_ jtag_add_runtest(5, TAP_IDLE); jtag_add_sleep(20000); - retval = lattice_ecp2_3_erase_device(lattice_device); + retval = lattice_ecp2_3_erase_device(lattice_device, tap); if (retval != ERROR_OK) return retval; /* Program Fuse Map */ - retval = lattice_ecp2_3_program_config_map(lattice_device, bit_file); + retval = lattice_ecp2_3_program_config_map(tap, bit_file); if (retval != ERROR_OK) return retval; - retval = lattice_ecp2_3_exit_programming_mode(lattice_device); + retval = lattice_ecp2_3_exit_programming_mode(tap); if (retval != ERROR_OK) return retval; const uint32_t out = REGISTER_ALL_BITS_1; const uint32_t mask = STATUS_DONE_BIT | STATUS_ERROR_BITS_ECP3; const uint32_t expected = STATUS_DONE_BIT; - return lattice_verify_status_register_u32(lattice_device, out, expected, mask, false); + return lattice_verify_status_register_u32(lattice_device, tap, out, expected, mask, false); } diff --git a/src/pld/ecp2_3.h b/src/pld/ecp2_3.h index 5f3e9e97b3..79f19cf9d7 100644 --- a/src/pld/ecp2_3.h +++ b/src/pld/ecp2_3.h @@ -12,8 +12,10 @@ int lattice_ecp2_3_read_status(struct jtag_tap *tap, uint32_t *status, uint32_t out, bool do_idle); int lattice_ecp2_3_read_usercode(struct jtag_tap *tap, uint32_t *usercode, uint32_t out); -int lattice_ecp2_3_write_usercode(struct lattice_pld_device *lattice_device, uint32_t usercode); -int lattice_ecp2_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file); -int lattice_ecp3_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file); +int lattice_ecp2_3_write_usercode(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t usercode); +int lattice_ecp2_load(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, + struct lattice_bit_file *bit_file); +int lattice_ecp3_load(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, + struct lattice_bit_file *bit_file); #endif /* OPENOCD_PLD_ECP2_3_H */ diff --git a/src/pld/ecp5.c b/src/pld/ecp5.c index 298b55f4e2..a4e293ef40 100644 --- a/src/pld/ecp5.c +++ b/src/pld/ecp5.c @@ -31,12 +31,8 @@ int lattice_ecp5_read_usercode(struct jtag_tap *tap, uint32_t *usercode, uint32_ return lattice_read_u32_register(tap, READ_USERCODE, usercode, out, true); } -int lattice_ecp5_write_usercode(struct lattice_pld_device *lattice_device, uint32_t usercode) +int lattice_ecp5_write_usercode(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t usercode) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - int retval = lattice_set_instr(tap, ISC_ENABLE, TAP_IDLE); if (retval != ERROR_OK) return retval; @@ -66,7 +62,7 @@ int lattice_ecp5_write_usercode(struct lattice_pld_device *lattice_device, uint3 retval = jtag_execute_queue(); if (retval != ERROR_OK) return retval; - return lattice_verify_usercode(lattice_device, 0x0, usercode, REGISTER_ALL_BITS_1); + return lattice_verify_usercode(lattice_device, tap, 0x0, usercode, REGISTER_ALL_BITS_1); } static int lattice_ecp5_enable_sram_programming(struct jtag_tap *tap) @@ -158,13 +154,10 @@ static int lattice_ecp5_exit_programming_mode(struct jtag_tap *tap) return jtag_execute_queue(); } -int lattice_ecp5_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file) +int lattice_ecp5_load(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, + struct lattice_bit_file *bit_file) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - - int retval = lattice_preload(lattice_device); + int retval = lattice_preload(lattice_device, tap); if (retval != ERROR_OK) return retval; @@ -175,7 +168,7 @@ int lattice_ecp5_load(struct lattice_pld_device *lattice_device, struct lattice_ const uint32_t out = 0x0; const uint32_t expected1 = 0x0; const uint32_t mask1 = STATUS_ERROR_BITS | STATUS_FEA_OTP; - retval = lattice_verify_status_register_u32(lattice_device, out, expected1, mask1, true); + retval = lattice_verify_status_register_u32(lattice_device, tap, out, expected1, mask1, true); if (retval != ERROR_OK) return retval; @@ -184,7 +177,7 @@ int lattice_ecp5_load(struct lattice_pld_device *lattice_device, struct lattice_ return retval; const uint32_t mask2 = STATUS_FAIL_FLAG | STATUS_BUSY_FLAG; - retval = lattice_verify_status_register_u32(lattice_device, out, expected1, mask2, false); + retval = lattice_verify_status_register_u32(lattice_device, tap, out, expected1, mask2, false); if (retval != ERROR_OK) return retval; @@ -202,5 +195,5 @@ int lattice_ecp5_load(struct lattice_pld_device *lattice_device, struct lattice_ const uint32_t expected2 = STATUS_DONE_BIT; const uint32_t mask3 = STATUS_DONE_BIT | STATUS_FAIL_FLAG; - return lattice_verify_status_register_u32(lattice_device, out, expected2, mask3, false); + return lattice_verify_status_register_u32(lattice_device, tap, out, expected2, mask3, false); } diff --git a/src/pld/ecp5.h b/src/pld/ecp5.h index 7b0c86b4ad..424b9e2f61 100644 --- a/src/pld/ecp5.h +++ b/src/pld/ecp5.h @@ -12,7 +12,8 @@ int lattice_ecp5_read_status(struct jtag_tap *tap, uint32_t *status, uint32_t out, bool do_idle); int lattice_ecp5_read_usercode(struct jtag_tap *tap, uint32_t *usercode, uint32_t out); -int lattice_ecp5_write_usercode(struct lattice_pld_device *lattice_device, uint32_t usercode); -int lattice_ecp5_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file); +int lattice_ecp5_write_usercode(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t usercode); +int lattice_ecp5_load(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, + struct lattice_bit_file *bit_file); #endif /* OPENOCD_PLD_ECP5_H */ diff --git a/src/pld/efinix.c b/src/pld/efinix.c index f08439476c..90d4ef3a2d 100644 --- a/src/pld/efinix.c +++ b/src/pld/efinix.c @@ -21,10 +21,6 @@ #define RUNTEST_START_CYCLES 100 #define RUNTEST_FINISH_CYCLES 100 -struct efinix_pld_device { - struct jtag_tap *tap; -}; - static int efinix_read_bit_file(struct raw_bit_file *bit_file, const char *filename) { FILE *input_file = fopen(filename, "r"); @@ -126,13 +122,9 @@ static int efinix_load(struct pld_device *pld_device, const char *filename) struct raw_bit_file bit_file; struct scan_field field[2]; - if (!pld_device || !pld_device->driver_priv) - return ERROR_FAIL; - - struct efinix_pld_device *efinix_info = pld_device->driver_priv; - if (!efinix_info || !efinix_info->tap) + struct jtag_tap *tap = pld_device->tap; + if (!tap) return ERROR_FAIL; - struct jtag_tap *tap = efinix_info->tap; jtag_add_tlr(); @@ -199,14 +191,7 @@ PLD_DEVICE_COMMAND_HANDLER(efinix_pld_device_command) return ERROR_FAIL; } - struct efinix_pld_device *efinix_info = malloc(sizeof(struct efinix_pld_device)); - if (!efinix_info) { - LOG_ERROR("Out of memory"); - return ERROR_FAIL; - } - efinix_info->tap = tap; - - pld->driver_priv = efinix_info; + pld->tap = tap; return ERROR_OK; } diff --git a/src/pld/gatemate.c b/src/pld/gatemate.c index 43b3f02d1d..e463d230b5 100644 --- a/src/pld/gatemate.c +++ b/src/pld/gatemate.c @@ -16,10 +16,6 @@ #define JTAG_CONFIGURE 0x06 -struct gatemate_pld_device { - struct jtag_tap *tap; -}; - struct gatemate_bit_file { struct raw_bit_file raw_file; size_t capacity; @@ -182,9 +178,9 @@ static int gatemate_load(struct pld_device *pld_device, const char *filename) struct gatemate_pld_device *gatemate_info = pld_device->driver_priv; - if (!gatemate_info || !gatemate_info->tap) + if (!gatemate_info || !pld_device->tap) return ERROR_FAIL; - struct jtag_tap *tap = gatemate_info->tap; + struct jtag_tap *tap = pld_device->tap; struct gatemate_bit_file bit_file; int retval = gatemate_read_file(&bit_file, filename); @@ -211,27 +207,16 @@ static int gatemate_load(struct pld_device *pld_device, const char *filename) PLD_DEVICE_COMMAND_HANDLER(gatemate_pld_device_command) { - struct jtag_tap *tap; - - struct gatemate_pld_device *gatemate_info; - if (CMD_ARGC != 2) return ERROR_COMMAND_SYNTAX_ERROR; - tap = jtag_tap_by_string(CMD_ARGV[1]); + struct jtag_tap *tap = jtag_tap_by_string(CMD_ARGV[1]); if (!tap) { command_print(CMD, "Tap: %s does not exist", CMD_ARGV[1]); return ERROR_FAIL; } - gatemate_info = malloc(sizeof(struct gatemate_pld_device)); - if (!gatemate_info) { - LOG_ERROR("Out of memory"); - return ERROR_FAIL; - } - gatemate_info->tap = tap; - - pld->driver_priv = gatemate_info; + pld->tap = tap; return ERROR_OK; } diff --git a/src/pld/gowin.c b/src/pld/gowin.c index 467b799374..209fb26f99 100644 --- a/src/pld/gowin.c +++ b/src/pld/gowin.c @@ -32,10 +32,6 @@ #define STAUS_MASK_MEMORY_ERASE BIT(5) #define STAUS_MASK_SYSTEM_EDIT_MODE BIT(7) -struct gowin_pld_device { - struct jtag_tap *tap; -}; - struct gowin_bit_file { struct raw_bit_file raw_file; size_t capacity; @@ -340,14 +336,9 @@ static int gowin_erase_sram(struct jtag_tap *tap, bool tx_erase_done) static int gowin_load_to_sram(struct pld_device *pld_device, const char *filename) { - if (!pld_device) - return ERROR_FAIL; - - struct gowin_pld_device *gowin_info = pld_device->driver_priv; - - if (!gowin_info || !gowin_info->tap) + if (!pld_device || !pld_device->tap) return ERROR_FAIL; - struct jtag_tap *tap = gowin_info->tap; + struct jtag_tap *tap = pld_device->tap; bool is_fs = false; struct gowin_bit_file bit_file; @@ -400,7 +391,7 @@ static int gowin_load_to_sram(struct pld_device *pld_device, const char *filenam field.num_bits = bit_file.raw_file.length * 8; field.out_value = bit_file.raw_file.data; field.in_value = bit_file.raw_file.data; - jtag_add_dr_scan(gowin_info->tap, 1, &field, TAP_IDLE); + jtag_add_dr_scan(tap, 1, &field, TAP_IDLE); jtag_add_runtest(3, TAP_IDLE); retval = jtag_execute_queue(); @@ -414,7 +405,7 @@ static int gowin_load_to_sram(struct pld_device *pld_device, const char *filenam if (retval != ERROR_OK) return retval; - retval = gowin_set_instr(gowin_info->tap, NO_OP); + retval = gowin_set_instr(tap, NO_OP); if (retval != ERROR_OK) return retval; @@ -425,15 +416,10 @@ static int gowin_load_to_sram(struct pld_device *pld_device, const char *filenam static int gowin_read_register_command(struct pld_device *pld_device, uint32_t cmd, uint32_t *value) { - if (!pld_device) + if (!pld_device || pld_device->tap) return ERROR_FAIL; - struct gowin_pld_device *gowin_info = pld_device->driver_priv; - - if (!gowin_info || !gowin_info->tap) - return ERROR_FAIL; - - return gowin_read_register(gowin_info->tap, cmd, value); + return gowin_read_register(pld_device->tap, cmd, value); } static int gowin_reload_command(struct pld_device *pld_device) @@ -441,12 +427,7 @@ static int gowin_reload_command(struct pld_device *pld_device) if (!pld_device) return ERROR_FAIL; - struct gowin_pld_device *gowin_info = pld_device->driver_priv; - - if (!gowin_info || !gowin_info->tap) - return ERROR_FAIL; - - return gowin_reload(gowin_info->tap); + return gowin_reload(pld_device->tap); } COMMAND_HANDLER(gowin_read_status_command_handler) @@ -548,27 +529,16 @@ static const struct command_registration gowin_command_handler[] = { PLD_DEVICE_COMMAND_HANDLER(gowin_pld_device_command) { - struct jtag_tap *tap; - - struct gowin_pld_device *gowin_info; - if (CMD_ARGC != 2) return ERROR_COMMAND_SYNTAX_ERROR; - tap = jtag_tap_by_string(CMD_ARGV[1]); + struct jtag_tap *tap = jtag_tap_by_string(CMD_ARGV[1]); if (!tap) { command_print(CMD, "Tap: %s does not exist", CMD_ARGV[1]); return ERROR_FAIL; } - gowin_info = malloc(sizeof(struct gowin_pld_device)); - if (!gowin_info) { - LOG_ERROR("Out of memory"); - return ERROR_FAIL; - } - gowin_info->tap = tap; - - pld->driver_priv = gowin_info; + pld->tap = tap; return ERROR_OK; } diff --git a/src/pld/intel.c b/src/pld/intel.c index 119a5695dc..d8318f11e6 100644 --- a/src/pld/intel.c +++ b/src/pld/intel.c @@ -29,7 +29,6 @@ enum intel_family_e { }; struct intel_pld_device { - struct jtag_tap *tap; unsigned int boundary_scan_length; int checkpos; enum intel_family_e family; @@ -122,10 +121,10 @@ static const struct intel_device_parameters_elem intel_device_parameters[] = { {0x024820dd, 2682, -1, INTEL_ARRIAII}, /* EP2AGZ350 */ }; -static int intel_fill_device_parameters(struct intel_pld_device *intel_info) +static int intel_fill_device_parameters(struct intel_pld_device *intel_info, uint32_t idcode) { for (size_t i = 0; i < ARRAY_SIZE(intel_device_parameters); ++i) { - if (intel_device_parameters[i].id == intel_info->tap->idcode && + if (intel_device_parameters[i].id == idcode && intel_info->family == intel_device_parameters[i].family) { if (intel_info->boundary_scan_length == 0) intel_info->boundary_scan_length = intel_device_parameters[i].boundary_scan_length; @@ -140,11 +139,11 @@ static int intel_fill_device_parameters(struct intel_pld_device *intel_info) return ERROR_FAIL; } -static int intel_check_for_unique_id(struct intel_pld_device *intel_info) +static int intel_check_for_unique_id(struct intel_pld_device *intel_info, uint32_t idcode) { int found = 0; for (size_t i = 0; i < ARRAY_SIZE(intel_device_parameters); ++i) { - if (intel_device_parameters[i].id == intel_info->tap->idcode) { + if (intel_device_parameters[i].id == idcode) { ++found; intel_info->family = intel_device_parameters[i].family; } @@ -153,22 +152,17 @@ static int intel_check_for_unique_id(struct intel_pld_device *intel_info) return (found == 1) ? ERROR_OK : ERROR_FAIL; } -static int intel_check_config(struct intel_pld_device *intel_info) +static int intel_check_config(struct intel_pld_device *intel_info, uint32_t idcode) { - if (!intel_info->tap->hasidcode) { - LOG_ERROR("no IDCODE"); - return ERROR_FAIL; - } - if (intel_info->family == INTEL_UNKNOWN) { - if (intel_check_for_unique_id(intel_info) != ERROR_OK) { + if (intel_check_for_unique_id(intel_info, idcode) != ERROR_OK) { LOG_ERROR("id is ambiguous, please specify family"); return ERROR_FAIL; } } if (intel_info->boundary_scan_length == 0 || intel_info->checkpos == -1) { - int ret = intel_fill_device_parameters(intel_info); + int ret = intel_fill_device_parameters(intel_info, idcode); if (ret != ERROR_OK) return ret; } @@ -218,7 +212,6 @@ static int intel_set_instr(struct jtag_tap *tap, uint16_t new_instr) return ERROR_OK; } - static int intel_load(struct pld_device *pld_device, const char *filename) { unsigned int speed = adapter_get_speed_khz(); @@ -233,11 +226,16 @@ static int intel_load(struct pld_device *pld_device, const char *filename) return ERROR_FAIL; struct intel_pld_device *intel_info = pld_device->driver_priv; - if (!intel_info || !intel_info->tap) + if (!intel_info || !pld_device->tap) return ERROR_FAIL; - struct jtag_tap *tap = intel_info->tap; - int retval = intel_check_config(intel_info); + struct jtag_tap *tap = pld_device->tap; + if (!tap->hasidcode) { + LOG_ERROR("no IDCODE"); + return ERROR_FAIL; + } + + int retval = intel_check_config(intel_info, tap->idcode); if (retval != ERROR_OK) return retval; @@ -428,11 +426,11 @@ PLD_DEVICE_COMMAND_HANDLER(intel_pld_device_command) return ERROR_FAIL; } } - intel_info->tap = tap; intel_info->boundary_scan_length = 0; intel_info->checkpos = -1; intel_info->family = family; + pld->tap = tap; pld->driver_priv = intel_info; return ERROR_OK; diff --git a/src/pld/lattice.c b/src/pld/lattice.c index 4ab5f63c0b..f468ee1b6b 100644 --- a/src/pld/lattice.c +++ b/src/pld/lattice.c @@ -73,16 +73,16 @@ int lattice_set_instr(struct jtag_tap *tap, uint8_t new_instr, tap_state_t endst return ERROR_OK; } -static int lattice_check_device_family(struct lattice_pld_device *lattice_device) +static int lattice_check_device_family(struct lattice_pld_device *lattice_device, struct jtag_tap *tap) { if (lattice_device->family != LATTICE_UNKNOWN && lattice_device->preload_length != 0) return ERROR_OK; - if (!lattice_device->tap || !lattice_device->tap->hasidcode) + if (!tap || !tap->hasidcode) return ERROR_FAIL; for (size_t i = 0; i < ARRAY_SIZE(lattice_devices); ++i) { - if (lattice_devices[i].id == lattice_device->tap->idcode) { + if (lattice_devices[i].id == tap->idcode) { if (lattice_device->family == LATTICE_UNKNOWN) lattice_device->family = lattice_devices[i].family; if (lattice_device->preload_length == 0) @@ -141,12 +141,12 @@ int lattice_read_u64_register(struct jtag_tap *tap, uint8_t cmd, uint64_t *in_va return retval; } -int lattice_preload(struct lattice_pld_device *lattice_device) +int lattice_preload(struct lattice_pld_device *lattice_device, struct jtag_tap *tap) { struct scan_field field; size_t sz_bytes = DIV_ROUND_UP(lattice_device->preload_length, 8); - int retval = lattice_set_instr(lattice_device->tap, PRELOAD, TAP_IDLE); + int retval = lattice_set_instr(tap, PRELOAD, TAP_IDLE); if (retval != ERROR_OK) return retval; uint8_t *buffer = malloc(sz_bytes); @@ -159,18 +159,15 @@ int lattice_preload(struct lattice_pld_device *lattice_device) field.num_bits = lattice_device->preload_length; field.out_value = buffer; field.in_value = NULL; - jtag_add_dr_scan(lattice_device->tap, 1, &field, TAP_IDLE); + jtag_add_dr_scan(tap, 1, &field, TAP_IDLE); retval = jtag_execute_queue(); free(buffer); return retval; } -static int lattice_read_usercode(struct lattice_pld_device *lattice_device, uint32_t *usercode, uint32_t out) +static int lattice_read_usercode(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t *usercode, + uint32_t out) { - struct jtag_tap *tap = lattice_device->tap; - if (!tap) - return ERROR_FAIL; - if (lattice_device->family == LATTICE_ECP2 || lattice_device->family == LATTICE_ECP3) return lattice_ecp2_3_read_usercode(tap, usercode, out); else if (lattice_device->family == LATTICE_ECP5) @@ -181,12 +178,12 @@ static int lattice_read_usercode(struct lattice_pld_device *lattice_device, uint return ERROR_FAIL; } -int lattice_verify_usercode(struct lattice_pld_device *lattice_device, uint32_t out, +int lattice_verify_usercode(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t out, uint32_t expected, uint32_t mask) { uint32_t usercode; - int retval = lattice_read_usercode(lattice_device, &usercode, out); + int retval = lattice_read_usercode(lattice_device, tap, &usercode, out); if (retval != ERROR_OK) return retval; @@ -198,48 +195,43 @@ int lattice_verify_usercode(struct lattice_pld_device *lattice_device, uint32_t return ERROR_OK; } -static int lattice_write_usercode(struct lattice_pld_device *lattice_device, uint32_t usercode) +static int lattice_write_usercode(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t usercode) { if (lattice_device->family == LATTICE_ECP2 || lattice_device->family == LATTICE_ECP3) - return lattice_ecp2_3_write_usercode(lattice_device, usercode); + return lattice_ecp2_3_write_usercode(lattice_device, tap, usercode); else if (lattice_device->family == LATTICE_ECP5) - return lattice_ecp5_write_usercode(lattice_device, usercode); + return lattice_ecp5_write_usercode(lattice_device, tap, usercode); else if (lattice_device->family == LATTICE_CERTUS) - return lattice_certus_write_usercode(lattice_device, usercode); + return lattice_certus_write_usercode(lattice_device, tap, usercode); return ERROR_FAIL; } -static int lattice_read_status_u32(struct lattice_pld_device *lattice_device, uint32_t *status, +static int lattice_read_status_u32(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t *status, uint32_t out, bool do_idle) { - if (!lattice_device->tap) - return ERROR_FAIL; - if (lattice_device->family == LATTICE_ECP2 || lattice_device->family == LATTICE_ECP3) - return lattice_ecp2_3_read_status(lattice_device->tap, status, out, do_idle); + return lattice_ecp2_3_read_status(tap, status, out, do_idle); else if (lattice_device->family == LATTICE_ECP5) - return lattice_ecp5_read_status(lattice_device->tap, status, out, do_idle); + return lattice_ecp5_read_status(tap, status, out, do_idle); return ERROR_FAIL; } -static int lattice_read_status_u64(struct lattice_pld_device *lattice_device, uint64_t *status, - uint64_t out) -{ - if (!lattice_device->tap) - return ERROR_FAIL; +static int lattice_read_status_u64(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, + uint64_t *status, uint64_t out) +{ if (lattice_device->family == LATTICE_CERTUS) - return lattice_certus_read_status(lattice_device->tap, status, out); + return lattice_certus_read_status(tap, status, out); return ERROR_FAIL; } -int lattice_verify_status_register_u32(struct lattice_pld_device *lattice_device, uint32_t out, +int lattice_verify_status_register_u32(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t out, uint32_t expected, uint32_t mask, bool do_idle) { uint32_t status; - int retval = lattice_read_status_u32(lattice_device, &status, out, do_idle); + int retval = lattice_read_status_u32(lattice_device, tap, &status, out, do_idle); if (retval != ERROR_OK) return retval; @@ -251,11 +243,11 @@ int lattice_verify_status_register_u32(struct lattice_pld_device *lattice_device return ERROR_OK; } -int lattice_verify_status_register_u64(struct lattice_pld_device *lattice_device, uint64_t out, +int lattice_verify_status_register_u64(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint64_t out, uint64_t expected, uint64_t mask) { uint64_t status; - int retval = lattice_read_status_u64(lattice_device, &status, out); + int retval = lattice_read_status_u64(lattice_device, tap, &status, out); if (retval != ERROR_OK) return retval; @@ -272,15 +264,15 @@ static int lattice_load_command(struct pld_device *pld_device, const char *filen if (!pld_device) return ERROR_FAIL; + struct jtag_tap *tap = pld_device->tap; struct lattice_pld_device *lattice_device = pld_device->driver_priv; - if (!lattice_device || !lattice_device->tap) + if (!lattice_device || !tap) return ERROR_FAIL; - struct jtag_tap *tap = lattice_device->tap; if (!tap || !tap->hasidcode) return ERROR_FAIL; - int retval = lattice_check_device_family(lattice_device); + int retval = lattice_check_device_family(lattice_device, tap); if (retval != ERROR_OK) return retval; @@ -293,10 +285,10 @@ static int lattice_load_command(struct pld_device *pld_device, const char *filen retval = ERROR_FAIL; switch (lattice_device->family) { case LATTICE_ECP2: - retval = lattice_ecp2_load(lattice_device, &bit_file); + retval = lattice_ecp2_load(lattice_device, tap, &bit_file); break; case LATTICE_ECP3: - retval = lattice_ecp3_load(lattice_device, &bit_file); + retval = lattice_ecp3_load(lattice_device, tap, &bit_file); break; case LATTICE_ECP5: case LATTICE_CERTUS: @@ -304,9 +296,9 @@ static int lattice_load_command(struct pld_device *pld_device, const char *filen LOG_WARNING("Id on device (0x%8.8" PRIx32 ") and id in bit-stream (0x%8.8" PRIx32 ") don't match.", id, bit_file.idcode); if (lattice_device->family == LATTICE_ECP5) - retval = lattice_ecp5_load(lattice_device, &bit_file); + retval = lattice_ecp5_load(lattice_device, tap, &bit_file); else - retval = lattice_certus_load(lattice_device, &bit_file); + retval = lattice_certus_load(lattice_device, tap, &bit_file); break; default: LOG_ERROR("loading unknown device family"); @@ -349,7 +341,7 @@ PLD_DEVICE_COMMAND_HANDLER(lattice_pld_device_command) return ERROR_FAIL; } } - lattice_device->tap = tap; + pld->tap = tap; lattice_device->family = family; lattice_device->preload_length = 0; @@ -373,15 +365,16 @@ COMMAND_HANDLER(lattice_read_usercode_register_command_handler) return ERROR_FAIL; } + struct jtag_tap *tap = device->tap; struct lattice_pld_device *lattice_device = device->driver_priv; - if (!lattice_device) + if (!lattice_device || !tap) return ERROR_FAIL; - int retval = lattice_check_device_family(lattice_device); + int retval = lattice_check_device_family(lattice_device, tap); if (retval != ERROR_OK) return retval; - retval = lattice_read_usercode(lattice_device, &usercode, 0x0); + retval = lattice_read_usercode(lattice_device, tap, &usercode, 0x0); if (retval == ERROR_OK) command_print(CMD, "0x%8.8" PRIx32, usercode); @@ -432,15 +425,16 @@ COMMAND_HANDLER(lattice_write_usercode_register_command_handler) COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], usercode); + struct jtag_tap *tap = device->tap; struct lattice_pld_device *lattice_device = device->driver_priv; - if (!lattice_device) + if (!lattice_device || !tap) return ERROR_FAIL; - int retval = lattice_check_device_family(lattice_device); + int retval = lattice_check_device_family(lattice_device, tap); if (retval != ERROR_OK) return retval; - return lattice_write_usercode(lattice_device, usercode); + return lattice_write_usercode(lattice_device, tap, usercode); } COMMAND_HANDLER(lattice_read_status_command_handler) @@ -457,23 +451,24 @@ COMMAND_HANDLER(lattice_read_status_command_handler) return ERROR_FAIL; } + struct jtag_tap *tap = device->tap; struct lattice_pld_device *lattice_device = device->driver_priv; - if (!lattice_device) + if (!lattice_device || !tap) return ERROR_FAIL; - int retval = lattice_check_device_family(lattice_device); + int retval = lattice_check_device_family(lattice_device, tap); if (retval != ERROR_OK) return retval; if (lattice_device->family == LATTICE_CERTUS) { uint64_t status; - retval = lattice_read_status_u64(lattice_device, &status, 0x0); + retval = lattice_read_status_u64(lattice_device, tap, &status, 0x0); if (retval == ERROR_OK) command_print(CMD, "0x%016" PRIx64, status); } else { uint32_t status; const bool do_idle = lattice_device->family == LATTICE_ECP5; - retval = lattice_read_status_u32(lattice_device, &status, 0x0, do_idle); + retval = lattice_read_status_u32(lattice_device, tap, &status, 0x0, do_idle); if (retval == ERROR_OK) command_print(CMD, "0x%8.8" PRIx32, status); } diff --git a/src/pld/lattice.h b/src/pld/lattice.h index 9a76a4ec37..14f4f2d7d1 100644 --- a/src/pld/lattice.h +++ b/src/pld/lattice.h @@ -15,22 +15,19 @@ #define BYPASS 0xFF struct lattice_pld_device { - struct jtag_tap *tap; size_t preload_length; enum lattice_family_e family; }; int lattice_set_instr(struct jtag_tap *tap, uint8_t new_instr, tap_state_t endstate); -int lattice_read_u32_register(struct jtag_tap *tap, uint8_t cmd, uint32_t *in_val, - uint32_t out_val, bool do_idle); -int lattice_read_u64_register(struct jtag_tap *tap, uint8_t cmd, uint64_t *in_val, - uint64_t out_val); -int lattice_verify_usercode(struct lattice_pld_device *lattice_device, uint32_t out, - uint32_t expected, uint32_t mask); -int lattice_verify_status_register_u32(struct lattice_pld_device *lattice_device, uint32_t out, - uint32_t expected, uint32_t mask, bool do_idle); -int lattice_verify_status_register_u64(struct lattice_pld_device *lattice_device, uint64_t out, - uint64_t expected, uint64_t mask); -int lattice_preload(struct lattice_pld_device *lattice_device); +int lattice_read_u32_register(struct jtag_tap *tap, uint8_t cmd, uint32_t *in_val, uint32_t out_val, bool do_idle); +int lattice_read_u64_register(struct jtag_tap *tap, uint8_t cmd, uint64_t *in_val, uint64_t out_val); +int lattice_verify_usercode(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t out, + uint32_t expected, uint32_t mask); +int lattice_verify_status_register_u32(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint32_t out, + uint32_t expected, uint32_t mask, bool do_idle); +int lattice_verify_status_register_u64(struct lattice_pld_device *lattice_device, struct jtag_tap *tap, uint64_t out, + uint64_t expected, uint64_t mask); +int lattice_preload(struct lattice_pld_device *lattice_device, struct jtag_tap *tap); #endif /* OPENOCD_PLD_LATTICE_H */ diff --git a/src/pld/pld.h b/src/pld/pld.h index a7cd20f641..4fb35dae4d 100644 --- a/src/pld/pld.h +++ b/src/pld/pld.h @@ -27,6 +27,7 @@ struct pld_driver { struct pld_device { struct pld_driver *driver; + struct jtag_tap *tap; void *driver_priv; struct pld_device *next; }; diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index 3c174ae594..e6f7cbaecc 100644 --- a/src/pld/virtex2.c +++ b/src/pld/virtex2.c @@ -39,10 +39,11 @@ static int virtex2_set_instr(struct jtag_tap *tap, uint32_t new_instr) return ERROR_OK; } -static int virtex2_send_32(struct pld_device *pld_device, - int num_words, uint32_t *words) +static int virtex2_send_32(struct pld_device *pld_device, int num_words, uint32_t *words) { - struct virtex2_pld_device *virtex2_info = pld_device->driver_priv; + if (!pld_device || !pld_device->tap) + return ERROR_FAIL; + struct scan_field scan_field; uint8_t *values; int i; @@ -60,13 +61,13 @@ static int virtex2_send_32(struct pld_device *pld_device, for (i = 0; i < num_words; i++) buf_set_u32(values + 4 * i, 0, 32, flip_u32(*words++, 32)); - int retval = virtex2_set_instr(virtex2_info->tap, 0x5); /* CFG_IN */ + int retval = virtex2_set_instr(pld_device->tap, 0x5); /* CFG_IN */ if (retval != ERROR_OK) { free(values); return retval; } - jtag_add_dr_scan(virtex2_info->tap, 1, &scan_field, TAP_DRPAUSE); + jtag_add_dr_scan(pld_device->tap, 1, &scan_field, TAP_DRPAUSE); free(values); @@ -79,24 +80,25 @@ static inline void virtexflip32(jtag_callback_data_t arg) *((uint32_t *)arg) = flip_u32(le_to_h_u32(in), 32); } -static int virtex2_receive_32(struct pld_device *pld_device, - int num_words, uint32_t *words) +static int virtex2_receive_32(struct pld_device *pld_device, int num_words, uint32_t *words) { - struct virtex2_pld_device *virtex2_info = pld_device->driver_priv; + if (!pld_device || !pld_device->tap) + return ERROR_FAIL; + struct scan_field scan_field; scan_field.num_bits = 32; scan_field.out_value = NULL; scan_field.in_value = NULL; - int retval = virtex2_set_instr(virtex2_info->tap, 0x4); /* CFG_OUT */ + int retval = virtex2_set_instr(pld_device->tap, 0x4); /* CFG_OUT */ if (retval != ERROR_OK) return retval; while (num_words--) { scan_field.in_value = (uint8_t *)words; - jtag_add_dr_scan(virtex2_info->tap, 1, &scan_field, TAP_DRPAUSE); + jtag_add_dr_scan(pld_device->tap, 1, &scan_field, TAP_DRPAUSE); jtag_add_callback(virtexflip32, (jtag_callback_data_t)words); @@ -134,10 +136,7 @@ static int virtex2_read_stat(struct pld_device *pld_device, uint32_t *status) static int virtex2_load_prepare(struct pld_device *pld_device) { - struct virtex2_pld_device *virtex2_info = pld_device->driver_priv; - int retval; - - retval = virtex2_set_instr(virtex2_info->tap, 0xb); /* JPROG_B */ + int retval = virtex2_set_instr(pld_device->tap, 0xb); /* JPROG_B */ if (retval != ERROR_OK) return retval; @@ -146,7 +145,7 @@ static int virtex2_load_prepare(struct pld_device *pld_device) return retval; jtag_add_sleep(1000); - retval = virtex2_set_instr(virtex2_info->tap, 0x5); /* CFG_IN */ + retval = virtex2_set_instr(pld_device->tap, 0x5); /* CFG_IN */ if (retval != ERROR_OK) return retval; @@ -161,24 +160,24 @@ static int virtex2_load_cleanup(struct pld_device *pld_device) jtag_add_tlr(); if (!(virtex2_info->no_jstart)) { - retval = virtex2_set_instr(virtex2_info->tap, 0xc); /* JSTART */ + retval = virtex2_set_instr(pld_device->tap, 0xc); /* JSTART */ if (retval != ERROR_OK) return retval; } jtag_add_runtest(13, TAP_IDLE); - retval = virtex2_set_instr(virtex2_info->tap, 0x3f); /* BYPASS */ + retval = virtex2_set_instr(pld_device->tap, 0x3f); /* BYPASS */ if (retval != ERROR_OK) return retval; - retval = virtex2_set_instr(virtex2_info->tap, 0x3f); /* BYPASS */ + retval = virtex2_set_instr(pld_device->tap, 0x3f); /* BYPASS */ if (retval != ERROR_OK) return retval; if (!(virtex2_info->no_jstart)) { - retval = virtex2_set_instr(virtex2_info->tap, 0xc); /* JSTART */ + retval = virtex2_set_instr(pld_device->tap, 0xc); /* JSTART */ if (retval != ERROR_OK) return retval; } jtag_add_runtest(13, TAP_IDLE); - retval = virtex2_set_instr(virtex2_info->tap, 0x3f); /* BYPASS */ + retval = virtex2_set_instr(pld_device->tap, 0x3f); /* BYPASS */ if (retval != ERROR_OK) return retval; @@ -187,7 +186,9 @@ static int virtex2_load_cleanup(struct pld_device *pld_device) static int virtex2_load(struct pld_device *pld_device, const char *filename) { - struct virtex2_pld_device *virtex2_info = pld_device->driver_priv; + if (!pld_device || !pld_device->tap) + return ERROR_FAIL; + struct xilinx_bit_file bit_file; int retval; unsigned int i; @@ -211,7 +212,7 @@ static int virtex2_load(struct pld_device *pld_device, const char *filename) field.num_bits = bit_file.length * 8; field.out_value = bit_file.data; - jtag_add_dr_scan(virtex2_info->tap, 1, &field, TAP_DRPAUSE); + jtag_add_dr_scan(pld_device->tap, 1, &field, TAP_DRPAUSE); retval = jtag_execute_queue(); if (retval != ERROR_OK) { xilinx_free_bit_file(&bit_file); @@ -268,12 +269,12 @@ PLD_DEVICE_COMMAND_HANDLER(virtex2_pld_device_command) LOG_ERROR("Out of memory"); return ERROR_FAIL; } - virtex2_info->tap = tap; virtex2_info->no_jstart = 0; if (CMD_ARGC >= 3) COMMAND_PARSE_NUMBER(int, CMD_ARGV[2], virtex2_info->no_jstart); + pld->tap = tap; pld->driver_priv = virtex2_info; return ERROR_OK; @@ -289,6 +290,7 @@ static const struct command_registration virtex2_exec_command_handlers[] = { }, COMMAND_REGISTRATION_DONE }; + static const struct command_registration virtex2_command_handler[] = { { .name = "virtex2", diff --git a/src/pld/virtex2.h b/src/pld/virtex2.h index 05558f709d..108f28fa3b 100644 --- a/src/pld/virtex2.h +++ b/src/pld/virtex2.h @@ -11,7 +11,6 @@ #include <jtag/jtag.h> struct virtex2_pld_device { - struct jtag_tap *tap; int no_jstart; }; --