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

Go to the source code of this file.

Data Structures

struct  psoc4_chip_family
 
struct  psoc4_flash_bank
 

Macros

#define PSOC4_CHIP_PROT_KILL   0x4
 
#define PSOC4_CHIP_PROT_OPEN   0x1
 
#define PSOC4_CHIP_PROT_PROTECTED   0x2
 
#define PSOC4_CHIP_PROT_VIRGIN   0x0
 
#define PSOC4_CMD_CHECKSUM   0xb
 
#define PSOC4_CMD_ERASE_ALL   0xa
 
#define PSOC4_CMD_GET_SILICON_ID   0
 
#define PSOC4_CMD_LOAD_LATCH   4
 
#define PSOC4_CMD_PROGRAM_ROW   6
 
#define PSOC4_CMD_SET_IMO48   0x15
 
#define PSOC4_CMD_WRITE_PROTECTION   0xd
 
#define PSOC4_CMD_WRITE_ROW   5
 
#define PSOC4_CMD_WRITE_SFLASH_ROW   0x18
 
#define PSOC4_CPUSS_SYSARG_LEGACY   0x40000008
 
#define PSOC4_CPUSS_SYSARG_NEW   0x40100008
 
#define PSOC4_CPUSS_SYSREQ_LEGACY   0x40000004
 
#define PSOC4_CPUSS_SYSREQ_NEW   0x40100004
 
#define PSOC4_FAMILY_FLAG_LEGACY   1
 
#define PSOC4_ROMTABLE_DESIGNER_CHECK   0xb4
 
#define PSOC4_ROMTABLE_PID0   0xF0000FE0
 
#define PSOC4_ROWS_PER_MACRO   512
 
#define PSOC4_SFLASH_MACRO0   0x0FFFF000
 
#define PSOC4_SFLASH_MACRO_SIZE   0x800
 
#define PSOC4_SPCIF_GEOMETRY_LEGACY   0x400E0000
 
#define PSOC4_SPCIF_GEOMETRY_NEW   0x40110000
 
#define PSOC4_SROM_ERR_IMO_NOT_IMPLEM   0xf0000013
 
#define PSOC4_SROM_HMASTER_BIT   (1<<30)
 
#define PSOC4_SROM_KEY1   0xb6
 
#define PSOC4_SROM_KEY2   0xd3
 
#define PSOC4_SROM_PRIVILEGED_BIT   (1<<28)
 
#define PSOC4_SROM_STATUS_FAILED   0xf0000000
 
#define PSOC4_SROM_STATUS_MASK   0xf0000000
 
#define PSOC4_SROM_STATUS_SUCCEEDED   0xa0000000
 
#define PSOC4_SROM_SYSREQ_BIT   (1<<31)
 
#define PSOC4_TEST_MODE   0x40030014
 

Functions

 COMMAND_HANDLER (psoc4_handle_flash_autoerase_command)
 
 COMMAND_HANDLER (psoc4_handle_mass_erase_command)
 
 FLASH_BANK_COMMAND_HANDLER (psoc4_flash_bank_command)
 
static int get_psoc4_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int psoc4_auto_probe (struct flash_bank *bank)
 
static const char * psoc4_decode_chip_protection (uint8_t protection)
 
static int psoc4_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static const struct psoc4_chip_familypsoc4_family_by_id (uint16_t family_id)
 
static int psoc4_flash_prepare (struct flash_bank *bank)
 
static int psoc4_get_family (struct target *target, uint16_t *family_id)
 
static int psoc4_get_silicon_id (struct flash_bank *bank, uint32_t *silicon_id, uint16_t *family_id, uint8_t *protection)
 
static int psoc4_mass_erase (struct flash_bank *bank)
 
static int psoc4_probe (struct flash_bank *bank)
 
static int psoc4_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int psoc4_protect_check (struct flash_bank *bank)
 
static int psoc4_sysreq (struct flash_bank *bank, uint8_t cmd, uint16_t cmd_param, uint32_t *sysreq_params, uint32_t sysreq_params_size, uint32_t *sysarg_out)
 
static int psoc4_test_flash_wounding (struct target *target, uint32_t flash_size)
 
static int psoc4_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 

Variables

static const struct command_registration psoc4_command_handlers []
 
static const struct command_registration psoc4_exec_command_handlers []
 
static const struct psoc4_chip_family psoc4_families []
 
const struct flash_driver psoc4_flash
 

Macro Definition Documentation

◆ PSOC4_CHIP_PROT_KILL

#define PSOC4_CHIP_PROT_KILL   0x4

Definition at line 119 of file psoc4.c.

◆ PSOC4_CHIP_PROT_OPEN

#define PSOC4_CHIP_PROT_OPEN   0x1

Definition at line 117 of file psoc4.c.

◆ PSOC4_CHIP_PROT_PROTECTED

#define PSOC4_CHIP_PROT_PROTECTED   0x2

Definition at line 118 of file psoc4.c.

◆ PSOC4_CHIP_PROT_VIRGIN

#define PSOC4_CHIP_PROT_VIRGIN   0x0

Definition at line 116 of file psoc4.c.

◆ PSOC4_CMD_CHECKSUM

#define PSOC4_CMD_CHECKSUM   0xb

Definition at line 111 of file psoc4.c.

◆ PSOC4_CMD_ERASE_ALL

#define PSOC4_CMD_ERASE_ALL   0xa

Definition at line 110 of file psoc4.c.

◆ PSOC4_CMD_GET_SILICON_ID

#define PSOC4_CMD_GET_SILICON_ID   0

Definition at line 106 of file psoc4.c.

◆ PSOC4_CMD_LOAD_LATCH

#define PSOC4_CMD_LOAD_LATCH   4

Definition at line 107 of file psoc4.c.

◆ PSOC4_CMD_PROGRAM_ROW

#define PSOC4_CMD_PROGRAM_ROW   6

Definition at line 109 of file psoc4.c.

◆ PSOC4_CMD_SET_IMO48

#define PSOC4_CMD_SET_IMO48   0x15

Definition at line 113 of file psoc4.c.

◆ PSOC4_CMD_WRITE_PROTECTION

#define PSOC4_CMD_WRITE_PROTECTION   0xd

Definition at line 112 of file psoc4.c.

◆ PSOC4_CMD_WRITE_ROW

#define PSOC4_CMD_WRITE_ROW   5

Definition at line 108 of file psoc4.c.

◆ PSOC4_CMD_WRITE_SFLASH_ROW

#define PSOC4_CMD_WRITE_SFLASH_ROW   0x18

Definition at line 114 of file psoc4.c.

◆ PSOC4_CPUSS_SYSARG_LEGACY

#define PSOC4_CPUSS_SYSARG_LEGACY   0x40000008

Definition at line 78 of file psoc4.c.

◆ PSOC4_CPUSS_SYSARG_NEW

#define PSOC4_CPUSS_SYSARG_NEW   0x40100008

Definition at line 82 of file psoc4.c.

◆ PSOC4_CPUSS_SYSREQ_LEGACY

#define PSOC4_CPUSS_SYSREQ_LEGACY   0x40000004

Definition at line 77 of file psoc4.c.

◆ PSOC4_CPUSS_SYSREQ_NEW

#define PSOC4_CPUSS_SYSREQ_NEW   0x40100004

Definition at line 81 of file psoc4.c.

◆ PSOC4_FAMILY_FLAG_LEGACY

#define PSOC4_FAMILY_FLAG_LEGACY   1

Definition at line 123 of file psoc4.c.

◆ PSOC4_ROMTABLE_DESIGNER_CHECK

#define PSOC4_ROMTABLE_DESIGNER_CHECK   0xb4

Definition at line 121 of file psoc4.c.

◆ PSOC4_ROMTABLE_PID0

#define PSOC4_ROMTABLE_PID0   0xF0000FE0

Definition at line 87 of file psoc4.c.

◆ PSOC4_ROWS_PER_MACRO

#define PSOC4_ROWS_PER_MACRO   512

Definition at line 92 of file psoc4.c.

◆ PSOC4_SFLASH_MACRO0

#define PSOC4_SFLASH_MACRO0   0x0FFFF000

Definition at line 75 of file psoc4.c.

◆ PSOC4_SFLASH_MACRO_SIZE

#define PSOC4_SFLASH_MACRO_SIZE   0x800

Definition at line 91 of file psoc4.c.

◆ PSOC4_SPCIF_GEOMETRY_LEGACY

#define PSOC4_SPCIF_GEOMETRY_LEGACY   0x400E0000

Definition at line 79 of file psoc4.c.

◆ PSOC4_SPCIF_GEOMETRY_NEW

#define PSOC4_SPCIF_GEOMETRY_NEW   0x40110000

Definition at line 83 of file psoc4.c.

◆ PSOC4_SROM_ERR_IMO_NOT_IMPLEM

#define PSOC4_SROM_ERR_IMO_NOT_IMPLEM   0xf0000013

Definition at line 104 of file psoc4.c.

◆ PSOC4_SROM_HMASTER_BIT

#define PSOC4_SROM_HMASTER_BIT   (1<<30)

Definition at line 97 of file psoc4.c.

◆ PSOC4_SROM_KEY1

#define PSOC4_SROM_KEY1   0xb6

Definition at line 94 of file psoc4.c.

◆ PSOC4_SROM_KEY2

#define PSOC4_SROM_KEY2   0xd3

Definition at line 95 of file psoc4.c.

◆ PSOC4_SROM_PRIVILEGED_BIT

#define PSOC4_SROM_PRIVILEGED_BIT   (1<<28)

Definition at line 98 of file psoc4.c.

◆ PSOC4_SROM_STATUS_FAILED

#define PSOC4_SROM_STATUS_FAILED   0xf0000000

Definition at line 100 of file psoc4.c.

◆ PSOC4_SROM_STATUS_MASK

#define PSOC4_SROM_STATUS_MASK   0xf0000000

Definition at line 101 of file psoc4.c.

◆ PSOC4_SROM_STATUS_SUCCEEDED

#define PSOC4_SROM_STATUS_SUCCEEDED   0xa0000000

Definition at line 99 of file psoc4.c.

◆ PSOC4_SROM_SYSREQ_BIT

#define PSOC4_SROM_SYSREQ_BIT   (1<<31)

Definition at line 96 of file psoc4.c.

◆ PSOC4_TEST_MODE

#define PSOC4_TEST_MODE   0x40030014

Definition at line 85 of file psoc4.c.

Function Documentation

◆ COMMAND_HANDLER() [1/2]

COMMAND_HANDLER ( psoc4_handle_flash_autoerase_command  )

◆ COMMAND_HANDLER() [2/2]

COMMAND_HANDLER ( psoc4_handle_mass_erase_command  )

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( psoc4_flash_bank_command  )

◆ get_psoc4_info()

◆ psoc4_auto_probe()

static int psoc4_auto_probe ( struct flash_bank bank)
static

Definition at line 822 of file psoc4.c.

References bank, ERROR_OK, psoc4_flash_bank::probed, and psoc4_probe().

◆ psoc4_decode_chip_protection()

static const char* psoc4_decode_chip_protection ( uint8_t  protection)
static

◆ psoc4_erase()

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

◆ psoc4_family_by_id()

static const struct psoc4_chip_family* psoc4_family_by_id ( uint16_t  family_id)
static

Definition at line 160 of file psoc4.c.

References psoc4_chip_family::id, and psoc4_families.

Referenced by get_psoc4_info(), and psoc4_probe().

◆ psoc4_flash_prepare()

◆ psoc4_get_family()

static int psoc4_get_family ( struct target target,
uint16_t *  family_id 
)
static

◆ psoc4_get_silicon_id()

static int psoc4_get_silicon_id ( struct flash_bank bank,
uint32_t *  silicon_id,
uint16_t *  family_id,
uint8_t *  protection 
)
static

◆ psoc4_mass_erase()

static int psoc4_mass_erase ( struct flash_bank bank)
static

Definition at line 504 of file psoc4.c.

References bank, ERROR_OK, NULL, PSOC4_CMD_ERASE_ALL, psoc4_flash_prepare(), and psoc4_sysreq().

Referenced by COMMAND_HANDLER(), and psoc4_erase().

◆ psoc4_probe()

◆ psoc4_protect()

static int psoc4_protect ( struct flash_bank bank,
int  set,
unsigned int  first,
unsigned int  last 
)
static

◆ psoc4_protect_check()

static int psoc4_protect_check ( struct flash_bank bank)
static

◆ psoc4_sysreq()

◆ psoc4_test_flash_wounding()

static int psoc4_test_flash_wounding ( struct target target,
uint32_t  flash_size 
)
static

Definition at line 700 of file psoc4.c.

References addr, dummy, ERROR_OK, and target_read_u32().

Referenced by psoc4_probe().

◆ psoc4_write()

static int psoc4_write ( struct flash_bank bank,
const uint8_t *  buffer,
uint32_t  offset,
uint32_t  count 
)
static

Variable Documentation

◆ psoc4_command_handlers

const struct command_registration psoc4_command_handlers[]
static
Initial value:
= {
{
.name = "psoc4",
.mode = COMMAND_ANY,
.help = "PSoC 4 flash command group",
.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 psoc4_exec_command_handlers[]
Definition: psoc4.c:891

Definition at line 871 of file psoc4.c.

◆ psoc4_exec_command_handlers

const struct command_registration psoc4_exec_command_handlers[]
static
Initial value:
= {
{
.name = "mass_erase",
.handler = psoc4_handle_mass_erase_command,
.mode = COMMAND_EXEC,
.usage = "bank_id",
.help = "Erase entire flash device.",
},
{
.name = "flash_autoerase",
.handler = psoc4_handle_flash_autoerase_command,
.mode = COMMAND_EXEC,
.usage = "bank_id on|off",
.help = "Set autoerase mode for flash bank.",
},
}
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 871 of file psoc4.c.

◆ psoc4_families

const struct psoc4_chip_family psoc4_families[]
static
Initial value:
= {
{ 0x93, "PSoC4100/4200", .flags = PSOC4_FAMILY_FLAG_LEGACY },
{ 0x9A, "PSoC4000", .flags = 0 },
{ 0x9E, "PSoC/PRoC BLE (119E)", .flags = 0 },
{ 0xA0, "PSoC4200L", .flags = 0 },
{ 0xA1, "PSoC4100M/4200M", .flags = 0 },
{ 0xA3, "PSoC/PRoC BLE (11A3)", .flags = 0 },
{ 0xA9, "PSoC4000S", .flags = 0 },
{ 0xAA, "PSoC/PRoC BLE (11AA)", .flags = 0 },
{ 0xAB, "PSoC4100S", .flags = 0 },
{ 0xAC, "PSoC Analog Coprocessor", .flags = 0 },
{ 0, "Unknown", .flags = 0 }
}
#define PSOC4_FAMILY_FLAG_LEGACY
Definition: psoc4.c:123

Definition at line 1 of file psoc4.c.

Referenced by psoc4_family_by_id().

◆ psoc4_flash

const struct flash_driver psoc4_flash
Initial value:
= {
.name = "psoc4",
.flash_bank_command = psoc4_flash_bank_command,
.erase = psoc4_erase,
.protect = psoc4_protect,
.write = psoc4_write,
.probe = psoc4_probe,
.auto_probe = psoc4_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = psoc4_protect_check,
.info = get_psoc4_info,
.free_driver_priv = default_flash_free_driver_priv,
}
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.
static int psoc4_probe(struct flash_bank *bank)
Definition: psoc4.c:714
static int psoc4_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: psoc4.c:518
static int get_psoc4_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: psoc4.c:831
static int psoc4_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: psoc4.c:630
static int psoc4_protect_check(struct flash_bank *bank)
Definition: psoc4.c:481
static const struct command_registration psoc4_command_handlers[]
Definition: psoc4.c:909
static int psoc4_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: psoc4.c:536
static int psoc4_auto_probe(struct flash_bank *bank)
Definition: psoc4.c:822

Definition at line 871 of file psoc4.c.