OpenOCD
gowin.c File Reference
Include dependency graph for gowin.c:

Go to the source code of this file.

Data Structures

struct  gowin_bit_file
 
struct  gowin_pld_device
 

Macros

#define ADDRESS_INITIALIZATION   0x12
 
#define CONFIG_DISABLE   0x3A
 
#define CONFIG_ENABLE   0x15
 
#define ENABLE_2ND_FLASH   0x78
 
#define ERASE_FLASH   0x75
 
#define ERASE_SRAM   0x05
 
#define IDCODE   0x11
 
#define NO_OP   0x02
 
#define READ_USERCODE   0x13
 
#define RELOAD   0x3C
 
#define SRAM_ERASE_DONE   0x09
 
#define STATUS_REGISTER   0x41
 
#define STAUS_MASK_MEMORY_ERASE   BIT(5)
 
#define STAUS_MASK_SYSTEM_EDIT_MODE   BIT(7)
 
#define TRANSFER_CONFIGURATION_DATA   0x17
 
#define USER1   0x42
 
#define USER2   0x43
 

Functions

 COMMAND_HANDLER (gowin_read_status_command_handler)
 
 COMMAND_HANDLER (gowin_read_user_register_command_handler)
 
 COMMAND_HANDLER (gowin_reload_command_handler)
 
static int gowin_add_byte_to_bit_file (struct gowin_bit_file *bit_file, uint8_t byte)
 
static int gowin_check_status_flag (struct jtag_tap *tap, uint32_t mask, uint32_t flag)
 
static int gowin_disable_config (struct jtag_tap *tap)
 
static int gowin_enable_config (struct jtag_tap *tap)
 
static int gowin_erase_sram (struct jtag_tap *tap, bool tx_erase_done)
 
static int gowin_get_ipdbg_hub (int user_num, struct pld_device *pld_device, struct pld_ipdbg_hub *hub)
 
static int gowin_load_to_sram (struct pld_device *pld_device, const char *filename)
 
static int gowin_read_file (struct gowin_bit_file *bit_file, const char *filename, bool *is_fs)
 
static int gowin_read_fs_file (struct gowin_bit_file *bit_file, const char *filename)
 
static uint64_t gowin_read_fs_file_bitsequence (const char *bits, int length)
 
static int gowin_read_fs_file_header (struct gowin_bit_file *bit_file, FILE *stream)
 
static int gowin_read_register (struct jtag_tap *tap, uint32_t reg, uint32_t *result)
 
static int gowin_read_register_command (struct pld_device *pld_device, uint32_t cmd, uint32_t *value)
 
static int gowin_reload (struct jtag_tap *tap)
 
static int gowin_reload_command (struct pld_device *pld_device)
 
static int gowin_runtest_idle (struct jtag_tap *tap, unsigned int frac_sec)
 
static int gowin_set_instr (struct jtag_tap *tap, uint8_t new_instr)
 
 PLD_CREATE_COMMAND_HANDLER (gowin_pld_create_command)
 

Variables

static const struct command_registration gowin_command_handler []
 
static const struct command_registration gowin_exec_command_handlers []
 
struct pld_driver gowin_pld
 

Macro Definition Documentation

◆ ADDRESS_INITIALIZATION

#define ADDRESS_INITIALIZATION   0x12

Definition at line 22 of file gowin.c.

◆ CONFIG_DISABLE

#define CONFIG_DISABLE   0x3A

Definition at line 26 of file gowin.c.

◆ CONFIG_ENABLE

#define CONFIG_ENABLE   0x15

Definition at line 24 of file gowin.c.

◆ ENABLE_2ND_FLASH

#define ENABLE_2ND_FLASH   0x78

Definition at line 30 of file gowin.c.

◆ ERASE_FLASH

#define ERASE_FLASH   0x75

Definition at line 29 of file gowin.c.

◆ ERASE_SRAM

#define ERASE_SRAM   0x05

Definition at line 19 of file gowin.c.

◆ IDCODE

#define IDCODE   0x11

Definition at line 21 of file gowin.c.

◆ NO_OP

#define NO_OP   0x02

Definition at line 18 of file gowin.c.

◆ READ_USERCODE

#define READ_USERCODE   0x13

Definition at line 23 of file gowin.c.

◆ RELOAD

#define RELOAD   0x3C

Definition at line 27 of file gowin.c.

◆ SRAM_ERASE_DONE

#define SRAM_ERASE_DONE   0x09

Definition at line 20 of file gowin.c.

◆ STATUS_REGISTER

#define STATUS_REGISTER   0x41

Definition at line 28 of file gowin.c.

◆ STAUS_MASK_MEMORY_ERASE

#define STAUS_MASK_MEMORY_ERASE   BIT(5)

Definition at line 35 of file gowin.c.

◆ STAUS_MASK_SYSTEM_EDIT_MODE

#define STAUS_MASK_SYSTEM_EDIT_MODE   BIT(7)

Definition at line 36 of file gowin.c.

◆ TRANSFER_CONFIGURATION_DATA

#define TRANSFER_CONFIGURATION_DATA   0x17

Definition at line 25 of file gowin.c.

◆ USER1

#define USER1   0x42

Definition at line 32 of file gowin.c.

◆ USER2

#define USER2   0x43

Definition at line 33 of file gowin.c.

Function Documentation

◆ COMMAND_HANDLER() [1/3]

COMMAND_HANDLER ( gowin_read_status_command_handler  )

◆ COMMAND_HANDLER() [2/3]

COMMAND_HANDLER ( gowin_read_user_register_command_handler  )

◆ COMMAND_HANDLER() [3/3]

COMMAND_HANDLER ( gowin_reload_command_handler  )

◆ gowin_add_byte_to_bit_file()

static int gowin_add_byte_to_bit_file ( struct gowin_bit_file bit_file,
uint8_t  byte 
)
static

◆ gowin_check_status_flag()

static int gowin_check_status_flag ( struct jtag_tap tap,
uint32_t  mask,
uint32_t  flag 
)
static

◆ gowin_disable_config()

static int gowin_disable_config ( struct jtag_tap tap)
static

◆ gowin_enable_config()

static int gowin_enable_config ( struct jtag_tap tap)
static

◆ gowin_erase_sram()

static int gowin_erase_sram ( struct jtag_tap tap,
bool  tx_erase_done 
)
static

◆ gowin_get_ipdbg_hub()

static int gowin_get_ipdbg_hub ( int  user_num,
struct pld_device pld_device,
struct pld_ipdbg_hub hub 
)
static

◆ gowin_load_to_sram()

◆ gowin_read_file()

static int gowin_read_file ( struct gowin_bit_file bit_file,
const char *  filename,
bool *  is_fs 
)
static

◆ gowin_read_fs_file()

static int gowin_read_fs_file ( struct gowin_bit_file bit_file,
const char *  filename 
)
static

◆ gowin_read_fs_file_bitsequence()

static uint64_t gowin_read_fs_file_bitsequence ( const char *  bits,
int  length 
)
static

Definition at line 55 of file gowin.c.

References bits, and length.

Referenced by gowin_read_fs_file(), and gowin_read_fs_file_header().

◆ gowin_read_fs_file_header()

static int gowin_read_fs_file_header ( struct gowin_bit_file bit_file,
FILE *  stream 
)
static

◆ gowin_read_register()

static int gowin_read_register ( struct jtag_tap tap,
uint32_t  reg,
uint32_t *  result 
)
static

◆ gowin_read_register_command()

static int gowin_read_register_command ( struct pld_device pld_device,
uint32_t  cmd,
uint32_t *  value 
)
static

Definition at line 429 of file gowin.c.

References cmd, pld_device::driver_priv, ERROR_FAIL, gowin_read_register(), and gowin_pld_device::tap.

Referenced by COMMAND_HANDLER().

◆ gowin_reload()

static int gowin_reload ( struct jtag_tap tap)
static

Definition at line 281 of file gowin.c.

References ERROR_OK, gowin_set_instr(), jtag_execute_queue(), NO_OP, and RELOAD.

Referenced by gowin_reload_command().

◆ gowin_reload_command()

static int gowin_reload_command ( struct pld_device pld_device)
static

Definition at line 442 of file gowin.c.

References pld_device::driver_priv, ERROR_FAIL, gowin_reload(), and gowin_pld_device::tap.

Referenced by COMMAND_HANDLER().

◆ gowin_runtest_idle()

static int gowin_runtest_idle ( struct jtag_tap tap,
unsigned int  frac_sec 
)
static

◆ gowin_set_instr()

◆ PLD_CREATE_COMMAND_HANDLER()

PLD_CREATE_COMMAND_HANDLER ( gowin_pld_create_command  )

Definition at line 566 of file gowin.c.

Variable Documentation

◆ gowin_command_handler

const struct command_registration gowin_command_handler[]
static
Initial value:
= {
{
.name = "gowin",
.mode = COMMAND_ANY,
.help = "gowin specific commands",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration gowin_exec_command_handlers[]
Definition: gowin.c:532

Definition at line 518 of file gowin.c.

◆ gowin_exec_command_handlers

const struct command_registration gowin_exec_command_handlers[]
static
Initial value:
= {
{
.name = "read_status",
.mode = COMMAND_EXEC,
.handler = gowin_read_status_command_handler,
.help = "reading status register from FPGA",
.usage = "pld_name",
}, {
.name = "read_user",
.mode = COMMAND_EXEC,
.handler = gowin_read_user_register_command_handler,
.help = "reading user register from FPGA",
.usage = "pld_name",
}, {
.name = "refresh",
.mode = COMMAND_EXEC,
.handler = gowin_reload_command_handler,
.help = "reload bitstream from flash to SRAM",
.usage = "pld_name",
},
}
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 518 of file gowin.c.

◆ gowin_pld

struct pld_driver gowin_pld
Initial value:
= {
.name = "gowin",
.commands = gowin_command_handler,
.pld_create_command = &gowin_pld_create_command,
.get_ipdbg_hub = gowin_get_ipdbg_hub,
}
static int gowin_get_ipdbg_hub(int user_num, struct pld_device *pld_device, struct pld_ipdbg_hub *hub)
Definition: gowin.c:455
static int gowin_load_to_sram(struct pld_device *pld_device, const char *filename)
Definition: gowin.c:344
static const struct command_registration gowin_command_handler[]
Definition: gowin.c:555

Definition at line 566 of file gowin.c.