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

Go to the source code of this file.

Data Structures

struct  mspm0_family_info
 
struct  mspm0_flash_bank
 
struct  mspm0_part_info
 

Macros

#define ERR_STRING_MAX   255
 
#define FCTL_CMDEXEC_VAL_EXECUTE   0x00000001
 
#define FCTL_CMDTYPE_COMMAND_ERASE   0x00000002
 
#define FCTL_CMDTYPE_COMMAND_PROGRAM   0x00000001
 
#define FCTL_CMDTYPE_SIZE_ONEWORD   0x00000000
 
#define FCTL_CMDTYPE_SIZE_SECTOR   0x00000040
 
#define FCTL_FEATURE_VER_B   0xA
 
#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_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_DESC   (FLASH_CONTROL_BASE + 0x10FC)
 
#define FCTL_REG_STATCMD   (FLASH_CONTROL_BASE + 0x13D0)
 
#define FCTL_STATCMD_CMDDONE_MASK   0x00000001
 
#define FCTL_STATCMD_CMDDONE_STATDONE   0x00000001
 
#define FCTL_STATCMD_CMDPASS_MASK   0x00000002
 
#define FCTL_STATCMD_CMDPASS_STATPASS   0x00000002
 
#define FLASH_CONTROL_BASE   0x400CD000
 
#define MSPM0_DEV_ID_FOUND   1
 
#define MSPM0_DEV_PART_ID_FOUND   2
 
#define MSPM0_DID   (MSPM0_FACTORYREGION + 0x004)
 
#define MSPM0_FACTORYREGION   0x41C40000
 
#define MSPM0_FLASH_BASE_DATA   0x41D00000
 
#define MSPM0_FLASH_BASE_MAIN   0x0
 
#define MSPM0_FLASH_BASE_NONMAIN   0x41C00000
 
#define MSPM0_FLASH_END_NONMAIN   0x41C00400
 
#define MSPM0_FLASH_TIMEOUT_MS   8000
 
#define MSPM0_MAX_PROTREGS   3
 
#define MSPM0_NO_ID_FOUND   0
 
#define MSPM0_SRAMFLASH   (MSPM0_FACTORYREGION + 0x018)
 
#define MSPM0_TRACEID   (MSPM0_FACTORYREGION + 0x000)
 
#define MSPM0_USERID   (MSPM0_FACTORYREGION + 0x008)
 
#define SYSCTL_BASE   0x400AF000
 
#define SYSCTL_SECCFG_SECSTATUS   (SYSCTL_BASE + 0x00003048)
 
#define TI_MANUFACTURER_ID   0x17
 

Functions

 FLASH_BANK_COMMAND_HANDLER (mspm0_flash_bank_command)
 
static int get_mspm0_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int mspm0_address_check (struct flash_bank *bank, unsigned int addr)
 
static int mspm0_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static unsigned int mspm0_extract_val (unsigned int var, unsigned char hi, unsigned char lo)
 
static int mspm0_fctl_cfg_command (struct flash_bank *bank, uint32_t addr, uint32_t cmd, uint32_t byte_en)
 
static int mspm0_fctl_get_sector_reg (struct flash_bank *bank, unsigned int addr, unsigned int *reg, unsigned int *sector_mask)
 
static int mspm0_fctl_sector_erase (struct flash_bank *bank, uint32_t addr)
 
static const char * mspm0_fctl_translate_ret_err (unsigned int return_code)
 
static int mspm0_fctl_unprotect_sector (struct flash_bank *bank, unsigned int addr)
 
static int mspm0_fctl_wait_cmd_ok (struct flash_bank *bank)
 
static int mspm0_probe (struct flash_bank *bank)
 
static int mspm0_protect_check (struct flash_bank *bank)
 
static int mspm0_read_part_info (struct flash_bank *bank)
 
static int mspm0_write (struct flash_bank *bank, const unsigned char *buffer, unsigned int offset, unsigned int count)
 

Variables

struct {
   const unsigned char   bit_offset
 
   const char *   fail_string
 
mspm0_fctl_fail_decode_strings []
 
static const struct mspm0_family_info mspm0_finf []
 
const struct flash_driver mspm0_flash
 
static const struct mspm0_part_info mspm0c_parts []
 
static const struct mspm0_part_info mspm0g_parts []
 
static const struct mspm0_part_info mspm0l_parts []
 
static const struct mspm0_part_info mspm0lx22x_parts []
 

Macro Definition Documentation

◆ ERR_STRING_MAX

#define ERR_STRING_MAX   255

Definition at line 74 of file mspm0.c.

◆ FCTL_CMDEXEC_VAL_EXECUTE

#define FCTL_CMDEXEC_VAL_EXECUTE   0x00000001

Definition at line 58 of file mspm0.c.

◆ FCTL_CMDTYPE_COMMAND_ERASE

#define FCTL_CMDTYPE_COMMAND_ERASE   0x00000002

Definition at line 62 of file mspm0.c.

◆ FCTL_CMDTYPE_COMMAND_PROGRAM

#define FCTL_CMDTYPE_COMMAND_PROGRAM   0x00000001

Definition at line 61 of file mspm0.c.

◆ FCTL_CMDTYPE_SIZE_ONEWORD

#define FCTL_CMDTYPE_SIZE_ONEWORD   0x00000000

Definition at line 65 of file mspm0.c.

◆ FCTL_CMDTYPE_SIZE_SECTOR

#define FCTL_CMDTYPE_SIZE_SECTOR   0x00000040

Definition at line 66 of file mspm0.c.

◆ FCTL_FEATURE_VER_B

#define FCTL_FEATURE_VER_B   0xA

Definition at line 69 of file mspm0.c.

◆ FCTL_REG_CMDADDR

#define FCTL_REG_CMDADDR   (FLASH_CONTROL_BASE + 0x1120)

Definition at line 38 of file mspm0.c.

◆ FCTL_REG_CMDBYTEN

#define FCTL_REG_CMDBYTEN   (FLASH_CONTROL_BASE + 0x1124)

Definition at line 39 of file mspm0.c.

◆ FCTL_REG_CMDDATA0

#define FCTL_REG_CMDDATA0   (FLASH_CONTROL_BASE + 0x1130)

Definition at line 40 of file mspm0.c.

◆ FCTL_REG_CMDEXEC

#define FCTL_REG_CMDEXEC   (FLASH_CONTROL_BASE + 0x1100)

Definition at line 36 of file mspm0.c.

◆ FCTL_REG_CMDTYPE

#define FCTL_REG_CMDTYPE   (FLASH_CONTROL_BASE + 0x1104)

Definition at line 37 of file mspm0.c.

◆ FCTL_REG_CMDWEPROTA

#define FCTL_REG_CMDWEPROTA   (FLASH_CONTROL_BASE + 0x11D0)

Definition at line 41 of file mspm0.c.

◆ FCTL_REG_CMDWEPROTB

#define FCTL_REG_CMDWEPROTB   (FLASH_CONTROL_BASE + 0x11D4)

Definition at line 42 of file mspm0.c.

◆ FCTL_REG_CMDWEPROTNM

#define FCTL_REG_CMDWEPROTNM   (FLASH_CONTROL_BASE + 0x1210)

Definition at line 43 of file mspm0.c.

◆ FCTL_REG_DESC

#define FCTL_REG_DESC   (FLASH_CONTROL_BASE + 0x10FC)

Definition at line 35 of file mspm0.c.

◆ FCTL_REG_STATCMD

#define FCTL_REG_STATCMD   (FLASH_CONTROL_BASE + 0x13D0)

Definition at line 44 of file mspm0.c.

◆ FCTL_STATCMD_CMDDONE_MASK

#define FCTL_STATCMD_CMDDONE_MASK   0x00000001

Definition at line 47 of file mspm0.c.

◆ FCTL_STATCMD_CMDDONE_STATDONE

#define FCTL_STATCMD_CMDDONE_STATDONE   0x00000001

Definition at line 48 of file mspm0.c.

◆ FCTL_STATCMD_CMDPASS_MASK

#define FCTL_STATCMD_CMDPASS_MASK   0x00000002

Definition at line 51 of file mspm0.c.

◆ FCTL_STATCMD_CMDPASS_STATPASS

#define FCTL_STATCMD_CMDPASS_STATPASS   0x00000002

Definition at line 52 of file mspm0.c.

◆ FLASH_CONTROL_BASE

#define FLASH_CONTROL_BASE   0x400CD000

Definition at line 34 of file mspm0.c.

◆ MSPM0_DEV_ID_FOUND

#define MSPM0_DEV_ID_FOUND   1

Definition at line 85 of file mspm0.c.

◆ MSPM0_DEV_PART_ID_FOUND

#define MSPM0_DEV_PART_ID_FOUND   2

Definition at line 86 of file mspm0.c.

◆ MSPM0_DID

#define MSPM0_DID   (MSPM0_FACTORYREGION + 0x004)

Definition at line 29 of file mspm0.c.

◆ MSPM0_FACTORYREGION

#define MSPM0_FACTORYREGION   0x41C40000

Definition at line 27 of file mspm0.c.

◆ MSPM0_FLASH_BASE_DATA

#define MSPM0_FLASH_BASE_DATA   0x41D00000

Definition at line 24 of file mspm0.c.

◆ MSPM0_FLASH_BASE_MAIN

#define MSPM0_FLASH_BASE_MAIN   0x0

Definition at line 23 of file mspm0.c.

◆ MSPM0_FLASH_BASE_NONMAIN

#define MSPM0_FLASH_BASE_NONMAIN   0x41C00000

Definition at line 21 of file mspm0.c.

◆ MSPM0_FLASH_END_NONMAIN

#define MSPM0_FLASH_END_NONMAIN   0x41C00400

Definition at line 22 of file mspm0.c.

◆ MSPM0_FLASH_TIMEOUT_MS

#define MSPM0_FLASH_TIMEOUT_MS   8000

Definition at line 73 of file mspm0.c.

◆ MSPM0_MAX_PROTREGS

#define MSPM0_MAX_PROTREGS   3

Definition at line 71 of file mspm0.c.

◆ MSPM0_NO_ID_FOUND

#define MSPM0_NO_ID_FOUND   0

Definition at line 84 of file mspm0.c.

◆ MSPM0_SRAMFLASH

#define MSPM0_SRAMFLASH   (MSPM0_FACTORYREGION + 0x018)

Definition at line 31 of file mspm0.c.

◆ MSPM0_TRACEID

#define MSPM0_TRACEID   (MSPM0_FACTORYREGION + 0x000)

Definition at line 28 of file mspm0.c.

◆ MSPM0_USERID

#define MSPM0_USERID   (MSPM0_FACTORYREGION + 0x008)

Definition at line 30 of file mspm0.c.

◆ SYSCTL_BASE

#define SYSCTL_BASE   0x400AF000

Definition at line 77 of file mspm0.c.

◆ SYSCTL_SECCFG_SECSTATUS

#define SYSCTL_SECCFG_SECSTATUS   (SYSCTL_BASE + 0x00003048)

Definition at line 78 of file mspm0.c.

◆ TI_MANUFACTURER_ID

#define TI_MANUFACTURER_ID   0x17

Definition at line 81 of file mspm0.c.

Function Documentation

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( mspm0_flash_bank_command  )

◆ get_mspm0_info()

◆ mspm0_address_check()

◆ mspm0_erase()

◆ mspm0_extract_val()

static unsigned int mspm0_extract_val ( unsigned int  var,
unsigned char  hi,
unsigned char  lo 
)
static

Definition at line 371 of file mspm0.c.

References GENMASK.

Referenced by mspm0_fctl_get_sector_reg(), and mspm0_read_part_info().

◆ mspm0_fctl_cfg_command()

static int mspm0_fctl_cfg_command ( struct flash_bank bank,
uint32_t  addr,
uint32_t  cmd,
uint32_t  byte_en 
)
static

◆ mspm0_fctl_get_sector_reg()

◆ mspm0_fctl_sector_erase()

static int mspm0_fctl_sector_erase ( struct flash_bank bank,
uint32_t  addr 
)
static

◆ mspm0_fctl_translate_ret_err()

static const char* mspm0_fctl_translate_ret_err ( unsigned int  return_code)
static

Definition at line 544 of file mspm0.c.

References ARRAY_SIZE, BIT, bit_offset, fail_string, and mspm0_fctl_fail_decode_strings.

Referenced by mspm0_fctl_wait_cmd_ok().

◆ mspm0_fctl_unprotect_sector()

static int mspm0_fctl_unprotect_sector ( struct flash_bank bank,
unsigned int  addr 
)
static

◆ mspm0_fctl_wait_cmd_ok()

◆ mspm0_probe()

static int mspm0_probe ( struct flash_bank bank)
static

Definition at line 1029 of file mspm0.c.

◆ mspm0_protect_check()

static int mspm0_protect_check ( struct flash_bank bank)
static

Definition at line 789 of file mspm0.c.

References bank, mspm0_flash_bank::did, ERROR_FLASH_BANK_NOT_PROBED, and ERROR_OK.

◆ mspm0_read_part_info()

◆ mspm0_write()

Variable Documentation

◆ bit_offset

const unsigned char bit_offset

Definition at line 533 of file mspm0.c.

Referenced by mspm0_fctl_translate_ret_err().

◆ fail_string

const char* fail_string

Definition at line 534 of file mspm0.c.

Referenced by mspm0_fctl_translate_ret_err().

◆ 

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

Referenced by mspm0_fctl_translate_ret_err().

◆ mspm0_finf

const struct mspm0_family_info mspm0_finf[]
static
Initial value:
= {
{ "MSPM0L", 0xbb82, ARRAY_SIZE(mspm0l_parts), mspm0l_parts },
{ "MSPM0Lx22x", 0xbb9f, ARRAY_SIZE(mspm0lx22x_parts), mspm0lx22x_parts },
{ "MSPM0G", 0xbb88, ARRAY_SIZE(mspm0g_parts), mspm0g_parts },
{ "MSPM0C", 0xbba1, ARRAY_SIZE(mspm0c_parts), mspm0c_parts },
}
static const struct mspm0_part_info mspm0lx22x_parts[]
Definition: mspm0.c:280
static const struct mspm0_part_info mspm0g_parts[]
Definition: mspm0.c:192
static const struct mspm0_part_info mspm0l_parts[]
Definition: mspm0.c:130
static const struct mspm0_part_info mspm0c_parts[]
Definition: mspm0.c:270
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
Definition: types.h:57

Definition at line 1 of file mspm0.c.

Referenced by mspm0_read_part_info().

◆ mspm0_flash

const struct flash_driver mspm0_flash
Initial value:
= {
.name = "mspm0",
.flash_bank_command = mspm0_flash_bank_command,
.erase = mspm0_erase,
.protect = NULL,
.write = mspm0_write,
.probe = mspm0_probe,
.auto_probe = mspm0_probe,
.erase_check = default_flash_blank_check,
.protect_check = mspm0_protect_check,
.info = get_mspm0_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 get_mspm0_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: mspm0.c:349
static int mspm0_write(struct flash_bank *bank, const unsigned char *buffer, unsigned int offset, unsigned int count)
Definition: mspm0.c:903
static int mspm0_protect_check(struct flash_bank *bank)
Definition: mspm0.c:789
static int mspm0_probe(struct flash_bank *bank)
Definition: mspm0.c:1029
static int mspm0_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: mspm0.c:821
#define NULL
Definition: usb.h:16

Definition at line 1029 of file mspm0.c.

◆ mspm0c_parts

const struct mspm0_part_info mspm0c_parts[]
static
Initial value:
= {
{ "MSPS003F4SPW20R", 0x57b3, 0x70},
{ "MSPM0C1104SDGS20R", 0x57b3, 0x71},
{ "MSPM0C1104SRUKR", 0x57b3, 0x73},
{ "MSPM0C1104SDYYR", 0x57b3, 0x75},
{ "MSPM0C1104SDDFR", 0x57b3, 0x77},
{ "MSPM0C1104SDSGR", 0x57b3, 0x79},
}

Definition at line 1 of file mspm0.c.

◆ mspm0g_parts

const struct mspm0_part_info mspm0g_parts[]
static

Definition at line 1 of file mspm0.c.

◆ mspm0l_parts

const struct mspm0_part_info mspm0l_parts[]
static

Definition at line 1 of file mspm0.c.

◆ mspm0lx22x_parts

const struct mspm0_part_info mspm0lx22x_parts[]
static
Initial value:
= {
{ "MSPM0L1227SRGER", 0x7C32, 0xF1},
{ "MSPM0L1227SPTR", 0x7C32, 0xC9},
{ "MSPM0L1227SPMR", 0x7C32, 0x1C},
{ "MSPM0L1227SPNAR", 0x7C32, 0x91},
{ "MSPM0L1227SPNR", 0x7C32, 0x39},
{ "MSPM0L1228SRGER", 0x33F7, 0x13},
{ "MSPM0L1228SRHBR", 0x33F7, 0x3A},
{ "MSPM0L1228SRGZR", 0x33F7, 0xBC},
{ "MSPM0L1228SPTR", 0x33F7, 0xF8},
{ "MSPM0L1228SPMR", 0x33F7, 0xCE},
{ "MSPM0L1228SPNAR", 0x33F7, 0x59},
{ "MSPM0L1228SPNR", 0x33F7, 0x7},
{ "MSPM0L2227SRGZR", 0x5E8F, 0x90},
{ "MSPM0L2227SPTR", 0x5E8F, 0xA},
{ "MSPM0L2227SPMR", 0x5E8F, 0x6D},
{ "MSPM0L2227SPNAR", 0x5E8F, 0x24},
{ "MSPM0L2227SPNR", 0x5E8F, 0x68},
{ "MSPM0L2228SRGZR", 0x2C38, 0xB8},
{ "MSPM0L2228SPTR", 0x2C38, 0x25},
{ "MSPM0L2228SPMR", 0x2C38, 0x6E},
{ "MSPM0L2228SPNAR", 0x2C38, 0x63},
{ "MSPM0L2228SPNR", 0x2C38, 0x3C},
}

Definition at line 1 of file mspm0.c.