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_READ_REG(a)
 
#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)   (_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, char *buf, int buf_size)
 
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, int first, int last)
 
static int stmsmi_probe (struct flash_bank *bank)
 
static int stmsmi_protect (struct flash_bank *bank, int set, int first, 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

struct flash_driver stmsmi_flash
 
static const struct stmsmi_target target_devices []
 

Macro Definition Documentation

#define _SMI_READ_REG (   a)
Value:
{ \
int __a; \
uint32_t __v; \
\
__a = target_read_u32(target, io_base + (a), &__v); \
if (__a != ERROR_OK) \
return __a; \
__v; \
}
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
#define ERROR_OK
Definition: log.h:144
Definition: target.h:126

Definition at line 45 of file stmsmi.c.

#define SMI_BANK_SIZE   (0x01000000)

Definition at line 82 of file stmsmi.c.

Referenced by stmsmi_probe().

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

Definition at line 80 of file stmsmi.c.

Referenced by read_flash_id(), read_status_reg(), smi_erase_sector(), and smi_write_enable().

#define SMI_CMD_TIMEOUT   (100)

Definition at line 113 of file stmsmi.c.

Referenced by read_flash_id(), read_status_reg(), smi_erase_sector(), and smi_write_enable().

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

Definition at line 84 of file stmsmi.c.

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

Definition at line 85 of file stmsmi.c.

Referenced by read_flash_id(), read_status_reg(), smi_erase_sector(), and smi_write_enable().

#define SMI_MAX_TIMEOUT   (3000)

Definition at line 115 of file stmsmi.c.

Referenced by smi_erase_sector().

#define SMI_POLL_TFF (   timeout)
Value:
{ \
int __r; \
\
__r = poll_tff(target, io_base, timeout); \
if (__r != ERROR_OK) \
return __r; \
}
static int poll_tff(struct target *target, uint32_t io_base, int timeout)
Definition: stmsmi.c:161
#define ERROR_OK
Definition: log.h:144
Definition: target.h:126

Definition at line 65 of file stmsmi.c.

Referenced by read_flash_id(), read_status_reg(), smi_erase_sector(), and smi_write_enable().

#define SMI_PROBE_TIMEOUT   (100)

Definition at line 114 of file stmsmi.c.

Referenced by read_flash_id().

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

Definition at line 110 of file stmsmi.c.

Referenced by read_flash_id().

#define SMI_READ_REG (   a)    (_SMI_READ_REG(a))

Definition at line 44 of file stmsmi.c.

Referenced by poll_tff(), read_flash_id(), and read_status_reg().

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

Definition at line 88 of file stmsmi.c.

Referenced by read_flash_id().

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

Definition at line 99 of file stmsmi.c.

Referenced by read_status_reg().

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

Definition at line 97 of file stmsmi.c.

Referenced by read_flash_id().

#define SMI_SEL_BANK0   0x00000000 /* Select Bank0 */

Definition at line 101 of file stmsmi.c.

Referenced by stmsmi_probe().

#define SMI_SEL_BANK1   0x00001000 /* Select Bank1 */

Definition at line 102 of file stmsmi.c.

Referenced by stmsmi_probe().

#define SMI_SEL_BANK2   0x00002000 /* Select Bank2 */

Definition at line 103 of file stmsmi.c.

Referenced by stmsmi_probe().

#define SMI_SEL_BANK3   0x00003000 /* Select Bank3 */

Definition at line 104 of file stmsmi.c.

Referenced by stmsmi_probe().

#define SMI_SEND   0x00000080 /* Send data */

Definition at line 98 of file stmsmi.c.

Referenced by read_flash_id(), and smi_erase_sector().

#define SMI_SET_HW_MODE ( )
Value:
#define SMI_WB_MODE
Definition: stmsmi.c:92
#define SMI_SW_MODE
Definition: stmsmi.c:91
#define SMI_CR1
Definition: stmsmi.c:84
#define SMI_WRITE_REG(a, v)
Definition: stmsmi.c:56
#define SMI_READ_REG(a)
Definition: stmsmi.c:44

Definition at line 78 of file stmsmi.c.

Referenced by smi_write_enable(), stmsmi_erase(), stmsmi_probe(), and stmsmi_write().

#define SMI_SET_HWWB_MODE ( )
Value:
#define SMI_WB_MODE
Definition: stmsmi.c:92
#define SMI_SW_MODE
Definition: stmsmi.c:91
#define SMI_CR1
Definition: stmsmi.c:84
#define SMI_WRITE_REG(a, v)
Definition: stmsmi.c:56
#define SMI_READ_REG(a)
Definition: stmsmi.c:44

Definition at line 76 of file stmsmi.c.

Referenced by smi_write_buffer().

#define SMI_SET_SW_MODE ( )
Value:
#define SMI_SW_MODE
Definition: stmsmi.c:91
#define SMI_CR1
Definition: stmsmi.c:84
#define SMI_WRITE_REG(a, v)
Definition: stmsmi.c:56
#define SMI_READ_REG(a)
Definition: stmsmi.c:44

Definition at line 74 of file stmsmi.c.

Referenced by read_flash_id(), and smi_erase_sector().

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

Definition at line 86 of file stmsmi.c.

Referenced by poll_tff(), and read_status_reg().

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

Definition at line 91 of file stmsmi.c.

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

Definition at line 107 of file stmsmi.c.

Referenced by poll_tff().

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

Definition at line 87 of file stmsmi.c.

Referenced by read_flash_id(), and smi_erase_sector().

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

Definition at line 95 of file stmsmi.c.

Referenced by read_flash_id().

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

Definition at line 96 of file stmsmi.c.

Referenced by smi_erase_sector().

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

Definition at line 92 of file stmsmi.c.

#define SMI_WE   0x00000800 /* Write Enable */

Definition at line 100 of file stmsmi.c.

Referenced by smi_write_enable().

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

Definition at line 56 of file stmsmi.c.

Referenced by read_flash_id(), read_status_reg(), smi_erase_sector(), and smi_write_enable().

Function Documentation

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

Definition at line 269 of file stmsmi.c.

References stmsmi_flash_bank::dev, and flash_device::erase_cmd.

Referenced by smi_erase_sector().

FLASH_BANK_COMMAND_HANDLER ( stmsmi_flash_bank_command  )
static int get_stmsmi_info ( struct flash_bank bank,
char *  buf,
int  buf_size 
)
static
static int poll_tff ( struct target target,
uint32_t  io_base,
int  timeout 
)
static
static int read_status_reg ( struct flash_bank bank,
uint32_t *  status 
)
static
static int smi_write_buffer ( struct flash_bank bank,
const uint8_t *  buffer,
uint32_t  address,
uint32_t  len 
)
static
static int stmsmi_auto_probe ( struct flash_bank bank)
static

Definition at line 614 of file stmsmi.c.

References flash_bank::driver_priv, ERROR_OK, stmsmi_flash_bank::probed, and stmsmi_probe().

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

Definition at line 363 of file stmsmi.c.

References ERROR_OK, flash_sector::is_protected, and flash_bank::sectors.

static int stmsmi_protect_check ( struct flash_bank bank)
static

Definition at line 622 of file stmsmi.c.

References ERROR_OK.

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

Variable Documentation

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,
}
static int stmsmi_erase(struct flash_bank *bank, int first, int last)
Definition: stmsmi.c:319
static int stmsmi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: stmsmi.c:398
static int stmsmi_probe(struct flash_bank *bank)
Definition: stmsmi.c:523
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
static int get_stmsmi_info(struct flash_bank *bank, char *buf, int buf_size)
Definition: stmsmi.c:628
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
static int stmsmi_auto_probe(struct flash_bank *bank)
Definition: stmsmi.c:614
static int stmsmi_protect(struct flash_bank *bank, int set, int first, int last)
Definition: stmsmi.c:363
static int stmsmi_protect_check(struct flash_bank *bank)
Definition: stmsmi.c:622

Definition at line 645 of file stmsmi.c.

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:27

Definition at line 131 of file stmsmi.c.