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

Go to the source code of this file.

Data Structures

struct  stmsmi_flash_bank
 
struct  stmsmi_target
 

Macros

#define SMI_BANK_SIZE   (0x01000000)
 
#define SMI_CLEAR_TFF()   SMI_WRITE_REG(SMI_SR, ~SMI_TFF)
 
#define SMI_CMD_TIMEOUT   (100)
 
#define SMI_CR1   (0x00) /* Control register 1 */
 
#define SMI_CR2   (0x04) /* Control register 2 */
 
#define SMI_MAX_TIMEOUT   (3000)
 
#define SMI_POLL_TFF(timeout)
 
#define SMI_PROBE_TIMEOUT   (100)
 
#define SMI_READ_ID   0x0000009F /* Read Flash Identification */
 
#define SMI_READ_REG(a)
 
#define SMI_RR   (0x10) /* RX */
 
#define SMI_RSR   0x00000400 /* reads status reg */
 
#define SMI_RX_LEN_3   0x00000030 /* data length = 3 byte */
 
#define SMI_SEL_BANK0   0x00000000 /* Select Bank0 */
 
#define SMI_SEL_BANK1   0x00001000 /* Select Bank1 */
 
#define SMI_SEL_BANK2   0x00002000 /* Select Bank2 */
 
#define SMI_SEL_BANK3   0x00003000 /* Select Bank3 */
 
#define SMI_SEND   0x00000080 /* Send data */
 
#define SMI_SET_HW_MODE()
 
#define SMI_SET_HWWB_MODE()
 
#define SMI_SET_SW_MODE()
 
#define SMI_SR   (0x08) /* Status register */
 
#define SMI_SW_MODE   0x10000000 /* set to enable SW Mode */
 
#define SMI_TFF   0x00000100 /* Transfer Finished Flag */
 
#define SMI_TR   (0x0c) /* TX */
 
#define SMI_TX_LEN_1   0x00000001 /* data length = 1 byte */
 
#define SMI_TX_LEN_4   0x00000004 /* data length = 4 byte */
 
#define SMI_WB_MODE   0x20000000 /* Write Burst Mode */
 
#define SMI_WE   0x00000800 /* Write Enable */
 
#define SMI_WRITE_REG(a, v)
 

Functions

static uint32_t erase_command (struct stmsmi_flash_bank *stmsmi_info, uint32_t offset)
 
 FLASH_BANK_COMMAND_HANDLER (stmsmi_flash_bank_command)
 
static int get_stmsmi_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int poll_tff (struct target *target, uint32_t io_base, int timeout)
 
static int read_flash_id (struct flash_bank *bank, uint32_t *id)
 
static int read_status_reg (struct flash_bank *bank, uint32_t *status)
 
static int smi_erase_sector (struct flash_bank *bank, int sector)
 
static int smi_write_buffer (struct flash_bank *bank, const uint8_t *buffer, uint32_t address, uint32_t len)
 
static int smi_write_enable (struct flash_bank *bank)
 
static int stmsmi_auto_probe (struct flash_bank *bank)
 
static int stmsmi_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int stmsmi_probe (struct flash_bank *bank)
 
static int stmsmi_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int stmsmi_protect_check (struct flash_bank *bank)
 
static int stmsmi_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int wait_till_ready (struct flash_bank *bank, int timeout)
 

Variables

const struct flash_driver stmsmi_flash
 
static const struct stmsmi_target target_devices []
 

Macro Definition Documentation

◆ SMI_BANK_SIZE

#define SMI_BANK_SIZE   (0x01000000)

Definition at line 70 of file stmsmi.c.

◆ SMI_CLEAR_TFF

#define SMI_CLEAR_TFF ( )    SMI_WRITE_REG(SMI_SR, ~SMI_TFF)

Definition at line 68 of file stmsmi.c.

◆ SMI_CMD_TIMEOUT

#define SMI_CMD_TIMEOUT   (100)

Definition at line 101 of file stmsmi.c.

◆ SMI_CR1

#define SMI_CR1   (0x00) /* Control register 1 */

Definition at line 72 of file stmsmi.c.

◆ SMI_CR2

#define SMI_CR2   (0x04) /* Control register 2 */

Definition at line 73 of file stmsmi.c.

◆ SMI_MAX_TIMEOUT

#define SMI_MAX_TIMEOUT   (3000)

Definition at line 103 of file stmsmi.c.

◆ SMI_POLL_TFF

#define SMI_POLL_TFF (   timeout)
Value:
{ \
int _retval; \
\
_retval = poll_tff(target, io_base, timeout); \
if (_retval != ERROR_OK) \
return _retval; \
}
#define ERROR_OK
Definition: log.h:164
static int poll_tff(struct target *target, uint32_t io_base, int timeout)
Definition: stmsmi.c:149
Definition: target.h:116
Definition: psoc6.c:83

Definition at line 53 of file stmsmi.c.

◆ SMI_PROBE_TIMEOUT

#define SMI_PROBE_TIMEOUT   (100)

Definition at line 102 of file stmsmi.c.

◆ SMI_READ_ID

#define SMI_READ_ID   0x0000009F /* Read Flash Identification */

Definition at line 98 of file stmsmi.c.

◆ SMI_READ_REG

#define SMI_READ_REG (   a)
Value:
({ \
int _ret; \
uint32_t _value; \
\
_ret = target_read_u32(target, io_base + (a), &_value); \
if (_ret != ERROR_OK) \
return _ret; \
_value; \
})
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
Definition: target.c:2550

Definition at line 33 of file stmsmi.c.

◆ SMI_RR

#define SMI_RR   (0x10) /* RX */

Definition at line 76 of file stmsmi.c.

◆ SMI_RSR

#define SMI_RSR   0x00000400 /* reads status reg */

Definition at line 87 of file stmsmi.c.

◆ SMI_RX_LEN_3

#define SMI_RX_LEN_3   0x00000030 /* data length = 3 byte */

Definition at line 85 of file stmsmi.c.

◆ SMI_SEL_BANK0

#define SMI_SEL_BANK0   0x00000000 /* Select Bank0 */

Definition at line 89 of file stmsmi.c.

◆ SMI_SEL_BANK1

#define SMI_SEL_BANK1   0x00001000 /* Select Bank1 */

Definition at line 90 of file stmsmi.c.

◆ SMI_SEL_BANK2

#define SMI_SEL_BANK2   0x00002000 /* Select Bank2 */

Definition at line 91 of file stmsmi.c.

◆ SMI_SEL_BANK3

#define SMI_SEL_BANK3   0x00003000 /* Select Bank3 */

Definition at line 92 of file stmsmi.c.

◆ SMI_SEND

#define SMI_SEND   0x00000080 /* Send data */

Definition at line 86 of file stmsmi.c.

◆ SMI_SET_HW_MODE

#define SMI_SET_HW_MODE ( )
Value:
#define SMI_WRITE_REG(a, v)
Definition: stmsmi.c:44
#define SMI_WB_MODE
Definition: stmsmi.c:80
#define SMI_CR1
Definition: stmsmi.c:72
#define SMI_READ_REG(a)
Definition: stmsmi.c:33
#define SMI_SW_MODE
Definition: stmsmi.c:79

Definition at line 66 of file stmsmi.c.

◆ SMI_SET_HWWB_MODE

#define SMI_SET_HWWB_MODE ( )
Value:

Definition at line 64 of file stmsmi.c.

◆ SMI_SET_SW_MODE

#define SMI_SET_SW_MODE ( )
Value:

Definition at line 62 of file stmsmi.c.

◆ SMI_SR

#define SMI_SR   (0x08) /* Status register */

Definition at line 74 of file stmsmi.c.

◆ SMI_SW_MODE

#define SMI_SW_MODE   0x10000000 /* set to enable SW Mode */

Definition at line 79 of file stmsmi.c.

◆ SMI_TFF

#define SMI_TFF   0x00000100 /* Transfer Finished Flag */

Definition at line 95 of file stmsmi.c.

◆ SMI_TR

#define SMI_TR   (0x0c) /* TX */

Definition at line 75 of file stmsmi.c.

◆ SMI_TX_LEN_1

#define SMI_TX_LEN_1   0x00000001 /* data length = 1 byte */

Definition at line 83 of file stmsmi.c.

◆ SMI_TX_LEN_4

#define SMI_TX_LEN_4   0x00000004 /* data length = 4 byte */

Definition at line 84 of file stmsmi.c.

◆ SMI_WB_MODE

#define SMI_WB_MODE   0x20000000 /* Write Burst Mode */

Definition at line 80 of file stmsmi.c.

◆ SMI_WE

#define SMI_WE   0x00000800 /* Write Enable */

Definition at line 88 of file stmsmi.c.

◆ SMI_WRITE_REG

#define SMI_WRITE_REG (   a,
 
)
Value:
{ \
int _retval; \
\
_retval = target_write_u32(target, io_base + (a), (v)); \
if (_retval != ERROR_OK) \
return _retval; \
}
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
Definition: target.c:2641

Definition at line 44 of file stmsmi.c.

Function Documentation

◆ erase_command()

static uint32_t erase_command ( struct stmsmi_flash_bank stmsmi_info,
uint32_t  offset 
)
static

Definition at line 257 of file stmsmi.c.

References stmsmi_flash_bank::dev, flash_device::erase_cmd, le_to_h_u32(), and offset.

Referenced by smi_erase_sector().

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( stmsmi_flash_bank_command  )

◆ get_stmsmi_info()

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

◆ poll_tff()

static int poll_tff ( struct target target,
uint32_t  io_base,
int  timeout 
)
static

◆ read_flash_id()

◆ read_status_reg()

static int read_status_reg ( struct flash_bank bank,
uint32_t *  status 
)
static

◆ smi_erase_sector()

◆ smi_write_buffer()

static int smi_write_buffer ( struct flash_bank bank,
const uint8_t *  buffer,
uint32_t  address,
uint32_t  len 
)
static

◆ smi_write_enable()

◆ stmsmi_auto_probe()

static int stmsmi_auto_probe ( struct flash_bank bank)
static

Definition at line 609 of file stmsmi.c.

References bank, ERROR_OK, stmsmi_flash_bank::probed, and stmsmi_probe().

◆ stmsmi_erase()

◆ stmsmi_probe()

◆ stmsmi_protect()

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

Definition at line 351 of file stmsmi.c.

References bank, and ERROR_OK.

◆ stmsmi_protect_check()

static int stmsmi_protect_check ( struct flash_bank bank)
static

Definition at line 617 of file stmsmi.c.

References ERROR_OK.

◆ stmsmi_write()

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

◆ wait_till_ready()

static int wait_till_ready ( struct flash_bank bank,
int  timeout 
)
static

Variable Documentation

◆ stmsmi_flash

const struct flash_driver stmsmi_flash
Initial value:
= {
.name = "stmsmi",
.flash_bank_command = stmsmi_flash_bank_command,
.erase = stmsmi_erase,
.protect = stmsmi_protect,
.write = stmsmi_write,
.probe = stmsmi_probe,
.auto_probe = stmsmi_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = stmsmi_protect_check,
.info = get_stmsmi_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 stmsmi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: stmsmi.c:304
static int stmsmi_auto_probe(struct flash_bank *bank)
Definition: stmsmi.c:609
static int stmsmi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: stmsmi.c:384
static int stmsmi_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: stmsmi.c:351
static int get_stmsmi_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: stmsmi.c:623
static int stmsmi_probe(struct flash_bank *bank)
Definition: stmsmi.c:510
static int stmsmi_protect_check(struct flash_bank *bank)
Definition: stmsmi.c:617

Definition at line 623 of file stmsmi.c.

◆ target_devices

const struct stmsmi_target target_devices[]
static
Initial value:
= {
{ "SPEAr3xx/6xx", 0x07926041, 0xf8000000, 0xfc000000 },
{ "STR75x", 0x4f1f0041, 0x80000000, 0x90000000 },
{ NULL, 0, 0, 0 }
}
#define NULL
Definition: usb.h:16

Definition at line 1 of file stmsmi.c.

Referenced by stmsmi_probe().