96 LOG_ERROR(
"Unknown id! Specify family and preload-length manually.");
101 uint32_t out_val,
bool do_idle)
155 uint8_t *
buffer = malloc(sz_bytes);
160 memset(
buffer, 0xff, sz_bytes);
197 LOG_ERROR(
"verifying user code register failed got: 0x%08" PRIx32
" expected: 0x%08" PRIx32,
217 uint32_t out,
bool do_idle)
219 if (!lattice_device->
tap)
232 if (!lattice_device->
tap)
250 LOG_ERROR(
"verifying status register failed got: 0x%08" PRIx32
" expected: 0x%08" PRIx32,
266 LOG_ERROR(
"verifying status register failed got: 0x%08" PRIx64
" expected: 0x%08" PRIx64,
279 if (!lattice_device || !lattice_device->
tap)
295 uint32_t
id = tap->
idcode;
297 switch (lattice_device->
family) {
307 LOG_WARNING(
"Id on device (0x%8.8" PRIx32
") and id in bit-stream (0x%8.8" PRIx32
") don't match.",
315 LOG_ERROR(
"loading unknown device family");
329 if (!pld_device_info || !pld_device_info->
tap)
332 hub->
tap = pld_device_info->
tap;
336 }
else if (user_num == 2) {
339 LOG_ERROR(
"lattice devices only have user register 1 & 2");
388 unsigned int *trailing_write_bits)
411 *has_instruction =
true;
420 if (strcmp(
CMD_ARGV[2],
"-chain-position") != 0)
432 if (strcmp(
CMD_ARGV[4],
"-family") != 0)
435 if (strcasecmp(
CMD_ARGV[5],
"ecp2") == 0) {
437 }
else if (strcasecmp(
CMD_ARGV[5],
"ecp3") == 0) {
439 }
else if (strcasecmp(
CMD_ARGV[5],
"ecp5") == 0) {
441 }
else if (strcasecmp(
CMD_ARGV[5],
"certus") == 0) {
450 if (!lattice_device) {
455 lattice_device->
tap =
tap;
459 pld->driver_priv = lattice_device;
609 .
name =
"read_status",
611 .handler = lattice_read_status_command_handler,
612 .help =
"reading status register from FPGA",
617 .handler = lattice_read_usercode_register_command_handler,
618 .help =
"reading usercode register from FPGA",
621 .name =
"write_user",
623 .handler = lattice_write_usercode_register_command_handler,
624 .help =
"writing usercode register to FPGA",
625 .usage =
"pld_name value",
627 .name =
"set_preload",
629 .handler = lattice_set_preload_command_handler,
630 .help =
"set length for preload (device specific)",
631 .usage =
"pld_name value",
635 .handler = lattice_refresh_command_handler,
636 .help =
"refresh from configuration memory",
646 .help =
"lattice specific commands",
656 .pld_create_command = &lattice_pld_create_command,
static const struct device_t * device
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
int lattice_certus_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file)
int lattice_certus_refresh(struct lattice_pld_device *lattice_device)
int lattice_certus_write_usercode(struct lattice_pld_device *lattice_device, uint32_t usercode)
int lattice_certus_get_facing_read_bits(struct lattice_pld_device *pld_device_info, unsigned int *facing_read_bits)
int lattice_certus_read_usercode(struct jtag_tap *tap, uint32_t *usercode, uint32_t out)
int lattice_certus_read_status(struct jtag_tap *tap, uint64_t *status, uint64_t out)
int lattice_certus_connect_spi_to_jtag(struct lattice_pld_device *pld_device_info)
int lattice_certus_disconnect_spi_from_jtag(struct lattice_pld_device *pld_device_info)
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
int lattice_ecp2_3_read_status(struct jtag_tap *tap, uint32_t *status, uint32_t out, bool do_idle)
int lattice_ecp2_3_disconnect_spi_from_jtag(struct lattice_pld_device *pld_device_info)
int lattice_ecp2_3_read_usercode(struct jtag_tap *tap, uint32_t *usercode, uint32_t out)
int lattice_ecp2_3_get_facing_read_bits(struct lattice_pld_device *pld_device_info, unsigned int *facing_read_bits)
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, uint32_t usercode)
int lattice_ecp2_3_refresh(struct lattice_pld_device *lattice_device)
int lattice_ecp2_3_connect_spi_to_jtag(struct lattice_pld_device *pld_device_info)
int lattice_ecp2_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file)
int lattice_ecp5_refresh(struct lattice_pld_device *lattice_device)
int lattice_ecp5_connect_spi_to_jtag(struct lattice_pld_device *pld_device_info)
int lattice_ecp5_load(struct lattice_pld_device *lattice_device, struct lattice_bit_file *bit_file)
int lattice_ecp5_disconnect_spi_from_jtag(struct lattice_pld_device *pld_device_info)
int lattice_ecp5_write_usercode(struct lattice_pld_device *lattice_device, uint32_t usercode)
int lattice_ecp5_read_usercode(struct jtag_tap *tap, uint32_t *usercode, uint32_t out)
int lattice_ecp5_read_status(struct jtag_tap *tap, uint32_t *status, uint32_t out, bool do_idle)
int lattice_ecp5_get_facing_read_bits(struct lattice_pld_device *pld_device_info, unsigned int *facing_read_bits)
struct jtag_tap * jtag_tap_by_string(const char *s)
void jtag_add_runtest(unsigned int num_cycles, tap_state_t state)
Goes to TAP_IDLE (if we're not already there), cycle precisely num_cycles in the TAP_IDLE state,...
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
void jtag_add_sleep(uint32_t us)
void jtag_add_ir_scan(struct jtag_tap *active, struct scan_field *in_fields, tap_state_t state)
Generate an IR SCAN with a list of scan fields with one entry for each enabled TAP.
void jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, tap_state_t state)
Generate a DR SCAN using the fields passed to the function.
The JTAG interface can be implemented with a software or hardware fifo.
enum tap_state tap_state_t
Defines JTAG Test Access Port states.
static const struct lattice_devices_elem lattice_devices[]
int lattice_verify_status_register_u32(struct lattice_pld_device *lattice_device, uint32_t out, uint32_t expected, uint32_t mask, bool do_idle)
static const struct command_registration lattice_command_handler[]
int lattice_set_instr(struct jtag_tap *tap, uint8_t new_instr, tap_state_t endstate)
static int lattice_has_jtagspi_instruction(struct pld_device *device, bool *has_instruction)
int lattice_preload(struct lattice_pld_device *lattice_device)
struct pld_driver lattice_pld
static int lattice_get_stuff_bits(struct pld_device *pld_device, unsigned int *facing_read_bits, unsigned int *trailing_write_bits)
static int lattice_write_usercode(struct lattice_pld_device *lattice_device, uint32_t usercode)
static int lattice_disconnect_spi_from_jtag(struct pld_device *pld_device)
int lattice_read_u64_register(struct jtag_tap *tap, uint8_t cmd, uint64_t *in_val, uint64_t out_val)
static int lattice_read_status_u64(struct lattice_pld_device *lattice_device, uint64_t *status, uint64_t out)
static int lattice_read_usercode(struct lattice_pld_device *lattice_device, uint32_t *usercode, uint32_t out)
COMMAND_HANDLER(lattice_read_usercode_register_command_handler)
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_verify_usercode(struct lattice_pld_device *lattice_device, uint32_t out, uint32_t expected, uint32_t mask)
static int lattice_check_device_family(struct lattice_pld_device *lattice_device)
static const struct command_registration lattice_exec_command_handlers[]
static int lattice_connect_spi_to_jtag(struct pld_device *pld_device)
static int lattice_read_status_u32(struct lattice_pld_device *lattice_device, uint32_t *status, uint32_t out, bool do_idle)
static int lattice_get_ipdbg_hub(int user_num, struct pld_device *pld_device, struct pld_ipdbg_hub *hub)
int lattice_verify_status_register_u64(struct lattice_pld_device *lattice_device, uint64_t out, uint64_t expected, uint64_t mask)
static int lattice_load_command(struct pld_device *pld_device, const char *filename)
PLD_CREATE_COMMAND_HANDLER(lattice_pld_create_command)
int lattice_read_file(struct lattice_bit_file *bit_file, const char *filename, enum lattice_family_e family)
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
struct pld_device * get_pld_device_by_name_or_numstr(const char *str)
unsigned int ir_length
size of instruction register
uint8_t * expected
Capture-IR expected value.
bool has_idcode
not all devices have idcode, we'll discover this during chain examination
uint32_t idcode
device identification code
struct raw_bit_file raw_bit
enum lattice_family_e family
enum lattice_family_e family
unsigned int user_ir_code
This structure defines a single scan field in the scan.
uint8_t * in_value
A pointer to a 32-bit memory location for data scanned out.
const uint8_t * out_value
A pointer to value to be scanned into the device.
unsigned int num_bits
The number of bits this field specifies.
static uint64_t le_to_h_u64(const uint8_t *buf)
static void h_u32_to_le(uint8_t *buf, uint32_t val)
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
#define DIV_ROUND_UP(m, n)
Rounds m up to the nearest multiple of n using division.
static uint32_t le_to_h_u32(const uint8_t *buf)
static void h_u64_to_le(uint8_t *buf, uint64_t val)