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

Go to the source code of this file.

Data Structures

struct  am13_algo_params
 
struct  am13_flash_bank
 

Macros

#define AM13_ALGO_BASE   0x20000000
 
#define AM13_ALGO_BUFFER_0   0x20002100
 
#define AM13_ALGO_BUFFER_1   0x20002900
 
#define AM13_ALGO_PARAMS_0   0x20002000
 
#define AM13_ALGO_PARAMS_1   0x20002014
 
#define AM13_ALGO_WORKING_SIZE   (AM13_ALGO_BUFFER_1 + 0x800 - AM13_ALGO_BASE)
 
#define AM13_BUFFER_EMPTY   0x00000000
 
#define AM13_BUFFER_FULL   0xFFFFFFFF
 
#define AM13_CMD_ERASE_AND_PROGRAM   2
 
#define AM13_CMD_ERASE_SECTORS   3
 
#define AM13_CMD_NO_ACTION   0
 
#define AM13_CMD_PROGRAM   1
 
#define AM13_DID   (AM13_FACTORYREGION + 0x004) /* JTAGIDCODE */
 
#define AM13_FACTORYREGION   0x60111000
 
#define AM13_FLASH_BASE_MAIN   0x00000000
 
#define AM13_FLASH_BASE_NONMAIN   0x60100000
 
#define AM13_FLASH_TIMEOUT_MS   8000
 
#define AM13_FLASH_WORD_SIZE   16
 
#define AM13_NONMAIN_SIZE_PER_BANK   0x1000
 
#define AM13_SECTOR_SIZE_BYTES   0x800
 
#define AM13_SRAMFLASH   (AM13_FACTORYREGION + 0x01C)
 
#define AM13_STATUS_OFFSET   0x0C
 
#define AM13_TRACEID   (AM13_FACTORYREGION + 0x000)
 
#define FCTL_CMDEXEC_EXECUTE   0x00000001
 
#define FCTL_CMDTYPE_CLEARSTATUS   0x00000005
 
#define FCTL_CMDTYPE_ERASE   0x00000002
 
#define FCTL_CMDTYPE_PROGRAM   0x00000001
 
#define FCTL_CMDTYPE_SIZE_ONEWORD   0x00000000
 
#define FCTL_CMDTYPE_SIZE_SECTOR   0x00000040
 
#define FCTL_REG_CMDADDR   (FLASH_CONTROL_BASE + 0x1120)
 
#define FCTL_REG_CMDBYTEN   (FLASH_CONTROL_BASE + 0x1124)
 
#define FCTL_REG_CMDDATA0   (FLASH_CONTROL_BASE + 0x1130)
 
#define FCTL_REG_CMDDATAINDEX   (FLASH_CONTROL_BASE + 0x112C)
 
#define FCTL_REG_CMDEXEC   (FLASH_CONTROL_BASE + 0x1100)
 
#define FCTL_REG_CMDTYPE   (FLASH_CONTROL_BASE + 0x1104)
 
#define FCTL_REG_CMDWEPROTA   (FLASH_CONTROL_BASE + 0x11D0)
 
#define FCTL_REG_CMDWEPROTB   (FLASH_CONTROL_BASE + 0x11D4)
 
#define FCTL_REG_CMDWEPROTNM   (FLASH_CONTROL_BASE + 0x1210)
 
#define FCTL_REG_STATCMD   (FLASH_CONTROL_BASE + 0x13D0)
 
#define FCTL_STATCMD_CMDDONE   0x00000001
 
#define FCTL_STATCMD_CMDINPROGRESS   0x00000004
 
#define FCTL_STATCMD_CMDPASS   0x00000002
 
#define FLASH_CONTROL_BASE   0x40042000
 
#define GSC_BASE   0x40046000
 
#define GSC_REG_FPC_FLSEMCLR   (GSC_BASE + 0x1804)
 
#define GSC_REG_FPC_FLSEMREQ   (GSC_BASE + 0x1800)
 
#define TI_MANUFACTURER_ID   0x17
 

Functions

static int am13_algo_init (struct flash_bank *bank)
 
static int am13_algo_quit (struct flash_bank *bank)
 
static int am13_algo_wait_done (struct flash_bank *bank, uint32_t params_addr)
 
static int am13_auto_probe (struct flash_bank *bank)
 
static int am13_clear_gsc_semaphore (struct flash_bank *bank)
 
static int am13_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int am13_fctl_clear_status (struct flash_bank *bank)
 
static int am13_fctl_erase (struct flash_bank *bank, uint32_t addr, uint32_t cmd_size)
 
static const char * am13_fctl_strerror (uint32_t status)
 
static int am13_fctl_unprotect (struct flash_bank *bank)
 
static int am13_fctl_wait_done (struct flash_bank *bank)
 
static int am13_probe (struct flash_bank *bank)
 
static int am13_request_gsc_semaphore (struct flash_bank *bank)
 
static int am13_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int am13_write_direct (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
 FLASH_BANK_COMMAND_HANDLER (am13_flash_bank_command)
 
static int get_am13_info (struct flash_bank *bank, struct command_invocation *cmd)
 

Variables

static const uint8_t am13_algo []
 
struct {
   unsigned char   bit
 
   const char *   name
 
am13_fctl_errors []
 
const struct flash_driver am13_flash
 

Macro Definition Documentation

◆ AM13_ALGO_BASE

#define AM13_ALGO_BASE   0x20000000

Definition at line 85 of file am13e230x.c.

◆ AM13_ALGO_BUFFER_0

#define AM13_ALGO_BUFFER_0   0x20002100

Definition at line 92 of file am13e230x.c.

◆ AM13_ALGO_BUFFER_1

#define AM13_ALGO_BUFFER_1   0x20002900

Definition at line 93 of file am13e230x.c.

◆ AM13_ALGO_PARAMS_0

#define AM13_ALGO_PARAMS_0   0x20002000

Definition at line 88 of file am13e230x.c.

◆ AM13_ALGO_PARAMS_1

#define AM13_ALGO_PARAMS_1   0x20002014

Definition at line 89 of file am13e230x.c.

◆ AM13_ALGO_WORKING_SIZE

#define AM13_ALGO_WORKING_SIZE   (AM13_ALGO_BUFFER_1 + 0x800 - AM13_ALGO_BASE)

Definition at line 96 of file am13e230x.c.

◆ AM13_BUFFER_EMPTY

#define AM13_BUFFER_EMPTY   0x00000000

Definition at line 99 of file am13e230x.c.

◆ AM13_BUFFER_FULL

#define AM13_BUFFER_FULL   0xFFFFFFFF

Definition at line 100 of file am13e230x.c.

◆ AM13_CMD_ERASE_AND_PROGRAM

#define AM13_CMD_ERASE_AND_PROGRAM   2

Definition at line 108 of file am13e230x.c.

◆ AM13_CMD_ERASE_SECTORS

#define AM13_CMD_ERASE_SECTORS   3

Definition at line 109 of file am13e230x.c.

◆ AM13_CMD_NO_ACTION

#define AM13_CMD_NO_ACTION   0

Definition at line 106 of file am13e230x.c.

◆ AM13_CMD_PROGRAM

#define AM13_CMD_PROGRAM   1

Definition at line 107 of file am13e230x.c.

◆ AM13_DID

#define AM13_DID   (AM13_FACTORYREGION + 0x004) /* JTAGIDCODE */

Definition at line 44 of file am13e230x.c.

◆ AM13_FACTORYREGION

#define AM13_FACTORYREGION   0x60111000

Definition at line 42 of file am13e230x.c.

◆ AM13_FLASH_BASE_MAIN

#define AM13_FLASH_BASE_MAIN   0x00000000

Definition at line 25 of file am13e230x.c.

◆ AM13_FLASH_BASE_NONMAIN

#define AM13_FLASH_BASE_NONMAIN   0x60100000

Definition at line 26 of file am13e230x.c.

◆ AM13_FLASH_TIMEOUT_MS

#define AM13_FLASH_TIMEOUT_MS   8000

Definition at line 80 of file am13e230x.c.

◆ AM13_FLASH_WORD_SIZE

#define AM13_FLASH_WORD_SIZE   16

Definition at line 78 of file am13e230x.c.

◆ AM13_NONMAIN_SIZE_PER_BANK

#define AM13_NONMAIN_SIZE_PER_BANK   0x1000

Definition at line 27 of file am13e230x.c.

◆ AM13_SECTOR_SIZE_BYTES

#define AM13_SECTOR_SIZE_BYTES   0x800

Definition at line 81 of file am13e230x.c.

◆ AM13_SRAMFLASH

#define AM13_SRAMFLASH   (AM13_FACTORYREGION + 0x01C)

Definition at line 45 of file am13e230x.c.

◆ AM13_STATUS_OFFSET

#define AM13_STATUS_OFFSET   0x0C

Definition at line 103 of file am13e230x.c.

◆ AM13_TRACEID

#define AM13_TRACEID   (AM13_FACTORYREGION + 0x000)

Definition at line 43 of file am13e230x.c.

◆ FCTL_CMDEXEC_EXECUTE

#define FCTL_CMDEXEC_EXECUTE   0x00000001

Definition at line 71 of file am13e230x.c.

◆ FCTL_CMDTYPE_CLEARSTATUS

#define FCTL_CMDTYPE_CLEARSTATUS   0x00000005

Definition at line 74 of file am13e230x.c.

◆ FCTL_CMDTYPE_ERASE

#define FCTL_CMDTYPE_ERASE   0x00000002

Definition at line 73 of file am13e230x.c.

◆ FCTL_CMDTYPE_PROGRAM

#define FCTL_CMDTYPE_PROGRAM   0x00000001

Definition at line 72 of file am13e230x.c.

◆ FCTL_CMDTYPE_SIZE_ONEWORD

#define FCTL_CMDTYPE_SIZE_ONEWORD   0x00000000

Definition at line 75 of file am13e230x.c.

◆ FCTL_CMDTYPE_SIZE_SECTOR

#define FCTL_CMDTYPE_SIZE_SECTOR   0x00000040

Definition at line 76 of file am13e230x.c.

◆ FCTL_REG_CMDADDR

#define FCTL_REG_CMDADDR   (FLASH_CONTROL_BASE + 0x1120)

Definition at line 51 of file am13e230x.c.

◆ FCTL_REG_CMDBYTEN

#define FCTL_REG_CMDBYTEN   (FLASH_CONTROL_BASE + 0x1124)

Definition at line 52 of file am13e230x.c.

◆ FCTL_REG_CMDDATA0

#define FCTL_REG_CMDDATA0   (FLASH_CONTROL_BASE + 0x1130)

Definition at line 54 of file am13e230x.c.

◆ FCTL_REG_CMDDATAINDEX

#define FCTL_REG_CMDDATAINDEX   (FLASH_CONTROL_BASE + 0x112C)

Definition at line 53 of file am13e230x.c.

◆ FCTL_REG_CMDEXEC

#define FCTL_REG_CMDEXEC   (FLASH_CONTROL_BASE + 0x1100)

Definition at line 49 of file am13e230x.c.

◆ FCTL_REG_CMDTYPE

#define FCTL_REG_CMDTYPE   (FLASH_CONTROL_BASE + 0x1104)

Definition at line 50 of file am13e230x.c.

◆ FCTL_REG_CMDWEPROTA

#define FCTL_REG_CMDWEPROTA   (FLASH_CONTROL_BASE + 0x11D0)

Definition at line 55 of file am13e230x.c.

◆ FCTL_REG_CMDWEPROTB

#define FCTL_REG_CMDWEPROTB   (FLASH_CONTROL_BASE + 0x11D4)

Definition at line 56 of file am13e230x.c.

◆ FCTL_REG_CMDWEPROTNM

#define FCTL_REG_CMDWEPROTNM   (FLASH_CONTROL_BASE + 0x1210)

Definition at line 57 of file am13e230x.c.

◆ FCTL_REG_STATCMD

#define FCTL_REG_STATCMD   (FLASH_CONTROL_BASE + 0x13D0)

Definition at line 58 of file am13e230x.c.

◆ FCTL_STATCMD_CMDDONE

#define FCTL_STATCMD_CMDDONE   0x00000001

Definition at line 66 of file am13e230x.c.

◆ FCTL_STATCMD_CMDINPROGRESS

#define FCTL_STATCMD_CMDINPROGRESS   0x00000004

Definition at line 68 of file am13e230x.c.

◆ FCTL_STATCMD_CMDPASS

#define FCTL_STATCMD_CMDPASS   0x00000002

Definition at line 67 of file am13e230x.c.

◆ FLASH_CONTROL_BASE

#define FLASH_CONTROL_BASE   0x40042000

Definition at line 48 of file am13e230x.c.

◆ GSC_BASE

#define GSC_BASE   0x40046000

Definition at line 61 of file am13e230x.c.

◆ GSC_REG_FPC_FLSEMCLR

#define GSC_REG_FPC_FLSEMCLR   (GSC_BASE + 0x1804)

Definition at line 63 of file am13e230x.c.

◆ GSC_REG_FPC_FLSEMREQ

#define GSC_REG_FPC_FLSEMREQ   (GSC_BASE + 0x1800)

Definition at line 62 of file am13e230x.c.

◆ TI_MANUFACTURER_ID

#define TI_MANUFACTURER_ID   0x17

Definition at line 82 of file am13e230x.c.

Function Documentation

◆ am13_algo_init()

◆ am13_algo_quit()

◆ am13_algo_wait_done()

static int am13_algo_wait_done ( struct flash_bank bank,
uint32_t  params_addr 
)
static

◆ am13_auto_probe()

static int am13_auto_probe ( struct flash_bank bank)
static

Definition at line 722 of file am13e230x.c.

References am13_probe(), bank, am13_flash_bank::did, and ERROR_OK.

◆ am13_clear_gsc_semaphore()

static int am13_clear_gsc_semaphore ( struct flash_bank bank)
static

◆ am13_erase()

static int am13_erase ( struct flash_bank bank,
unsigned int  first,
unsigned int  last 
)
static

◆ am13_fctl_clear_status()

◆ am13_fctl_erase()

static int am13_fctl_erase ( struct flash_bank bank,
uint32_t  addr,
uint32_t  cmd_size 
)
static

◆ am13_fctl_strerror()

static const char* am13_fctl_strerror ( uint32_t  status)
static

Definition at line 177 of file am13e230x.c.

References am13_fctl_errors, ARRAY_SIZE, bit, BIT, name, and status.

Referenced by am13_fctl_wait_done().

◆ am13_fctl_unprotect()

static int am13_fctl_unprotect ( struct flash_bank bank)
static

◆ am13_fctl_wait_done()

◆ am13_probe()

◆ am13_request_gsc_semaphore()

static int am13_request_gsc_semaphore ( struct flash_bank bank)
static

Definition at line 147 of file am13e230x.c.

References bank, ERROR_OK, GSC_REG_FPC_FLSEMREQ, LOG_ERROR, and target_write_u32().

Referenced by am13_erase(), and am13_write_direct().

◆ am13_write()

◆ am13_write_direct()

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( am13_flash_bank_command  )

◆ get_am13_info()

static int get_am13_info ( struct flash_bank bank,
struct command_invocation cmd 
)
static

Definition at line 732 of file am13e230x.c.

Variable Documentation

◆ am13_algo

const uint8_t am13_algo[]
static
Initial value:
= {
}

Definition at line 121 of file am13e230x.c.

Referenced by am13_algo_init().

◆ 

const { ... } am13_fctl_errors[]
Initial value:
= {
{ 2, "CMDINPROGRESS" },
{ 4, "FAILWEPROT" },
{ 5, "FAILVERIFY" },
{ 6, "FAILILLADDR" },
{ 7, "FAILMODE" },
{ 12, "FAILMISC" },
}

Referenced by am13_fctl_strerror().

◆ am13_flash

const struct flash_driver am13_flash
Initial value:
= {
.name = "am13",
.flash_bank_command = am13_flash_bank_command,
.erase = am13_erase,
.protect = NULL,
.write = am13_write,
.probe = am13_probe,
.auto_probe = am13_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = NULL,
.info = get_am13_info,
.free_driver_priv = default_flash_free_driver_priv,
}
static int am13_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: am13e230x.c:560
static int am13_probe(struct flash_bank *bank)
Definition: am13e230x.c:635
static int am13_auto_probe(struct flash_bank *bank)
Definition: am13e230x.c:722
static int get_am13_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: am13e230x.c:732
static int am13_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: am13e230x.c:318
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.
#define NULL
Definition: usb.h:16

Definition at line 732 of file am13e230x.c.

◆ bit

◆ name

const char* name

Definition at line 167 of file am13e230x.c.

Referenced by __attribute__(), __register_commands(), am13_fctl_strerror(), arc_build_bcr_reg_cache(), arc_build_reg_cache(), arc_reg_get_by_name(), arm_tpiu_swo_handle_event(), command_find_from_name(), COMMAND_HANDLER(), COMMAND_HELPER(), create_default_signal(), create_signal(), cti_find_reg_offset(), cti_instance_by_jim_obj(), dap_instance_by_jim_obj(), dw_spi_spiflash_search(), find_signal_by_name(), find_target(), flash_driver_find_by_name(), flash_driver_name_matches(), fm4_get_info_command(), ft232r_bit_name_to_number(), gdb_generate_target_description(), gdb_get_register_packet(), gdb_get_registers_packet(), gdb_set_register_packet(), gdb_set_registers_packet(), get_flash_bank_by_name(), get_flash_bank_by_name_noprobe(), get_flash_name_index(), get_gpio_index(), get_nand_device_by_name(), get_pld_device_by_name(), hwthread_get_thread_reg_list(), init_reg_name(), ipdbg_allocate_hub(), ipdbg_create_hub(), ipdbg_get_hub_by_name(), jim_nvp_name2value(), jim_nvp_name2value_nocase(), jim_nvp_name2value_nocase_simple(), jim_nvp_name2value_simple(), jim_set_result_nvp_unknown(), jlink_open_device(), jtag_examine_chain_display(), kinetis_create_missing_banks(), kinetis_probe_chip(), msp432_probe(), nand_driver_find_by_name(), nvp_name2value(), nvp_unknown_command_print(), open_write_close(), or1k_create_reg_list(), parse_reg_ranges_impl(), pic32mx_info(), pic32mx_probe(), read_channel_name(), register_get_by_name(), remove_service(), riot_get_thread_reg_list(), riot_update_threads(), rtkernel_add_task(), rtos_create(), target_call_reset_callbacks(), target_wait_state(), telnet_auto_complete(), ublast_init(), unregister_command(), xtensa_build_reg_cache(), xtensa_fetch_all_regs(), xtensa_write_dirty_registers(), and zephyr_create().