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

Go to the source code of this file.

Data Structures

struct  mini51_cpu_type
 
struct  mini51_flash_bank
 
struct  mini51_flash_bank_type
 

Macros

#define ENSURE_OK(status)   if (status != ERROR_OK) return status
 
#define IPRSTC1   0x50000008
 
#define IPRSTC_CPU_RST   0x02
 
#define ISPADR   0x5000C004
 
#define ISPCMD   0x5000C00C
 
#define ISPCMD_CHIP_ERASE   0x26
 
#define ISPCMD_ERASE   0x22
 
#define ISPCMD_PROGRAM   0x21
 
#define ISPCMD_READ   0x00
 
#define ISPCON   0x5000C000
 
#define ISPCON_APUEN   0x08
 
#define ISPCON_BS_LDROM   0x02
 
#define ISPCON_CFGUEN   0x10
 
#define ISPCON_ISPEN   0x01
 
#define ISPCON_ISPFF   0x40
 
#define ISPCON_LDUEN   0x20
 
#define ISPDAT   0x5000C008
 
#define ISPTRG   0x5000C010
 
#define ISPTRG_ISPGO   0x01
 
#define ISPUNKNOWN   0x5000C01C
 
#define MINI51_APROM_BASE   0x00000000
 
#define MINI51_BANKS_M051(aprom_size)
 
#define MINI51_BANKS_MINI51(aprom_size)
 
#define MINI51_CONFIG_BASE   0x00300000
 
#define MINI51_DATA_BASE   0x0001F000
 
#define MINI51_KB   1024
 
#define MINI51_LDROM_BASE   0x00100000
 
#define MINI51_MAX_FLASH_BANKS   4
 
#define MINI51_PAGE_SIZE   512
 
#define MINI51_TIMEOUT   1000
 
#define PART_ID_REG   0x50000000
 
#define REGLOCKADDR   0x50000100
 

Functions

 COMMAND_HANDLER (mini51_handle_read_isp_command)
 
 COMMAND_HANDLER (mini51_handle_write_isp_command)
 
 COMMAND_HANDLER (mini51_handle_chip_erase_command)
 
 FLASH_BANK_COMMAND_HANDLER (mini51_flash_bank_command)
 
static int mini51_auto_probe (struct flash_bank *bank)
 
static int mini51_erase (struct flash_bank *bank, int first, int last)
 
static int mini51_get_cpu_type (struct target *target, const struct mini51_cpu_type **cpu)
 
static int mini51_get_flash_size (struct flash_bank *bank, const struct mini51_cpu_type *cpu, uint32_t *flash_size)
 
static int mini51_get_part_id (struct target *target, uint32_t *part_id)
 
static int mini51_isp_enable (struct target *target)
 
static int mini51_isp_execute (struct target *target)
 
static int mini51_isp_execute_cmd (struct target *target, uint32_t cmd, uint32_t address, uint32_t data)
 
static int mini51_isp_execute_cmd_read (struct target *target, uint32_t cmd, uint32_t address, uint32_t *data)
 
static int mini51_probe (struct flash_bank *bank)
 
static int mini51_protect (struct flash_bank *bank, int set, int first, int last)
 
static int mini51_protect_check (struct flash_bank *bank)
 
static int mini51_read (struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int mini51_unlock_reg (struct target *target)
 
static int mini51_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 

Variables

static struct command_registration mini51_command_handlers []
 
static struct mini51_cpu_type mini51_cpu []
 
static struct command_registration mini51_exec_command_handlers []
 
struct flash_driver mini51_flash
 

Macro Definition Documentation

#define ENSURE_OK (   status)    if (status != ERROR_OK) return status
#define IPRSTC1   0x50000008

Definition at line 89 of file mini51.c.

#define IPRSTC_CPU_RST   0x02

Definition at line 99 of file mini51.c.

#define ISPADR   0x5000C004

Definition at line 92 of file mini51.c.

Referenced by mini51_isp_execute_cmd(), and mini51_isp_execute_cmd_read().

#define ISPCMD   0x5000C00C

Definition at line 94 of file mini51.c.

Referenced by mini51_isp_execute_cmd(), and mini51_isp_execute_cmd_read().

#define ISPCMD_CHIP_ERASE   0x26

Definition at line 111 of file mini51.c.

Referenced by COMMAND_HANDLER().

#define ISPCMD_ERASE   0x22

Definition at line 110 of file mini51.c.

Referenced by mini51_erase().

#define ISPCMD_PROGRAM   0x21

Definition at line 109 of file mini51.c.

Referenced by COMMAND_HANDLER(), and mini51_write().

#define ISPCMD_READ   0x00

Definition at line 108 of file mini51.c.

Referenced by COMMAND_HANDLER(), and mini51_read().

#define ISPCON   0x5000C000

Definition at line 91 of file mini51.c.

Referenced by mini51_isp_enable(), and mini51_isp_execute().

#define ISPCON_APUEN   0x08

Definition at line 104 of file mini51.c.

Referenced by mini51_isp_enable().

#define ISPCON_BS_LDROM   0x02

Definition at line 105 of file mini51.c.

#define ISPCON_CFGUEN   0x10

Definition at line 103 of file mini51.c.

Referenced by mini51_isp_enable().

#define ISPCON_ISPEN   0x01

Definition at line 106 of file mini51.c.

Referenced by mini51_isp_enable().

#define ISPCON_ISPFF   0x40

Definition at line 101 of file mini51.c.

Referenced by mini51_isp_execute().

#define ISPCON_LDUEN   0x20

Definition at line 102 of file mini51.c.

Referenced by mini51_isp_enable().

#define ISPDAT   0x5000C008

Definition at line 93 of file mini51.c.

Referenced by mini51_isp_execute_cmd(), and mini51_isp_execute_cmd_read().

#define ISPTRG   0x5000C010

Definition at line 95 of file mini51.c.

Referenced by mini51_isp_execute().

#define ISPTRG_ISPGO   0x01

Definition at line 113 of file mini51.c.

Referenced by mini51_isp_execute().

#define ISPUNKNOWN   0x5000C01C

Definition at line 97 of file mini51.c.

Referenced by COMMAND_HANDLER().

#define MINI51_APROM_BASE   0x00000000

Definition at line 115 of file mini51.c.

#define MINI51_BANKS_M051 (   aprom_size)
Value:
.n_banks = 4, \
{ {MINI51_APROM_BASE, (aprom_size)}, {MINI51_DATA_BASE, 4*1024}, {MINI51_LDROM_BASE, 4*1024}, \

Definition at line 145 of file mini51.c.

#define MINI51_BANKS_MINI51 (   aprom_size)
Value:
.n_banks = 3, \
{ {MINI51_APROM_BASE, (aprom_size)}, {MINI51_LDROM_BASE, 2*1024}, {MINI51_CONFIG_BASE, 512} }

Definition at line 141 of file mini51.c.

#define MINI51_CONFIG_BASE   0x00300000

Definition at line 118 of file mini51.c.

#define MINI51_DATA_BASE   0x0001F000

Definition at line 116 of file mini51.c.

#define MINI51_KB   1024

Definition at line 120 of file mini51.c.

#define MINI51_LDROM_BASE   0x00100000

Definition at line 117 of file mini51.c.

#define MINI51_MAX_FLASH_BANKS   4

Definition at line 127 of file mini51.c.

#define MINI51_PAGE_SIZE   512

Definition at line 121 of file mini51.c.

Referenced by mini51_erase(), and mini51_probe().

#define MINI51_TIMEOUT   1000

Definition at line 122 of file mini51.c.

Referenced by mini51_isp_execute().

#define PART_ID_REG   0x50000000

Definition at line 88 of file mini51.c.

Referenced by mini51_get_part_id().

#define REGLOCKADDR   0x50000100

Definition at line 90 of file mini51.c.

Referenced by mini51_unlock_reg().

Function Documentation

COMMAND_HANDLER ( mini51_handle_read_isp_command  )
COMMAND_HANDLER ( mini51_handle_write_isp_command  )
COMMAND_HANDLER ( mini51_handle_chip_erase_command  )
FLASH_BANK_COMMAND_HANDLER ( mini51_flash_bank_command  )

Definition at line 333 of file mini51.c.

References ERROR_OK, and mini51_flash_bank::probed.

static int mini51_auto_probe ( struct flash_bank bank)
static

Definition at line 467 of file mini51.c.

References flash_bank::driver_priv, ERROR_OK, mini51_probe(), and mini51_flash_bank::probed.

static int mini51_erase ( struct flash_bank bank,
int  first,
int  last 
)
static
static int mini51_get_cpu_type ( struct target target,
const struct mini51_cpu_type **  cpu 
)
static
static int mini51_get_flash_size ( struct flash_bank bank,
const struct mini51_cpu_type cpu,
uint32_t *  flash_size 
)
static
static int mini51_get_part_id ( struct target target,
uint32_t *  part_id 
)
static

Definition at line 211 of file mini51.c.

References LOG_INFO, PART_ID_REG, and target_read_u32().

Referenced by mini51_get_cpu_type().

static int mini51_isp_execute ( struct target target)
static
static int mini51_isp_execute_cmd ( struct target target,
uint32_t  cmd,
uint32_t  address,
uint32_t  data 
)
static

Definition at line 281 of file mini51.c.

References ENSURE_OK, ISPADR, ISPCMD, ISPDAT, mini51_isp_execute(), and target_write_u32().

Referenced by COMMAND_HANDLER(), mini51_erase(), and mini51_write().

static int mini51_isp_execute_cmd_read ( struct target target,
uint32_t  cmd,
uint32_t  address,
uint32_t *  data 
)
static

Definition at line 295 of file mini51.c.

References ENSURE_OK, ISPADR, ISPCMD, ISPDAT, mini51_isp_execute(), target_read_u32(), and target_write_u32().

Referenced by COMMAND_HANDLER(), and mini51_read().

static int mini51_protect ( struct flash_bank bank,
int  set,
int  first,
int  last 
)
static

Definition at line 394 of file mini51.c.

References ERROR_FLASH_OPERATION_FAILED, and LOG_WARNING.

static int mini51_protect_check ( struct flash_bank bank)
static

Definition at line 343 of file mini51.c.

References ERROR_FLASH_OPERATION_FAILED, and LOG_WARNING.

static int mini51_read ( struct flash_bank bank,
uint8_t *  buffer,
uint32_t  offset,
uint32_t  count 
)
static
static int mini51_unlock_reg ( struct target target)
static

Definition at line 194 of file mini51.c.

References ERROR_OK, REGLOCKADDR, and target_write_u32().

Referenced by mini51_isp_enable().

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

Variable Documentation

struct command_registration mini51_command_handlers[]
static
Initial value:
= {
{
.name = "mini51",
.mode = COMMAND_ANY,
.help = "mini51 flash command group",
.usage = "",
},
}

Definition at line 561 of file mini51.c.

struct mini51_cpu_type mini51_cpu[]
static

Definition at line 150 of file mini51.c.

Referenced by mini51_get_cpu_type().

struct command_registration mini51_exec_command_handlers[]
static
Initial value:
= {
{
.name = "read_isp",
.handler = mini51_handle_read_isp_command,
.usage = "address",
.mode = COMMAND_EXEC,
.help = "read flash through ISP.",
},
{
.name = "write_isp",
.handler = mini51_handle_write_isp_command,
.usage = "address value",
.mode = COMMAND_EXEC,
.help = "write flash through ISP.",
},
{
.name = "chip_erase",
.handler = mini51_handle_chip_erase_command,
.mode = COMMAND_EXEC,
.help = "chip erase.",
},
}

Definition at line 537 of file mini51.c.

struct flash_driver mini51_flash
Initial value:
= {
.name = "mini51",
.flash_bank_command = mini51_flash_bank_command,
.erase = mini51_erase,
.protect = mini51_protect,
.write = mini51_write,
.read = mini51_read,
.probe = mini51_probe,
.auto_probe = mini51_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = mini51_protect_check,
}

Definition at line 572 of file mini51.c.