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

Go to the source code of this file.

Data Structures

struct  lpcspifi_flash_bank
 

Macros

#define SPIFI_INIT_STACK_SIZE   512
 
#define SSP_BSY   (0x00000010)
 
#define SSP_CMD_TIMEOUT   (100)
 
#define SSP_CPSR   (0x10) /* Clock prescale register */
 
#define SSP_CR0   (0x00) /* Control register 0 */
 
#define SSP_CR1   (0x04) /* Control register 1 */
 
#define SSP_DATA   (0x08) /* Data register (TX and RX) */
 
#define SSP_MAX_TIMEOUT   (3000)
 
#define SSP_PROBE_TIMEOUT   (100)
 
#define SSP_SR   (0x0C) /* Status register */
 

Functions

 FLASH_BANK_COMMAND_HANDLER (lpcspifi_flash_bank_command)
 
static int get_lpcspifi_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int io_write_reg (struct target *target, uint32_t io_base, uint32_t offset, uint32_t value)
 
static int ioconfig_write_reg (struct target *target, uint32_t ioconfig_base, uint32_t offset, uint32_t value)
 
static int lpcspifi_auto_probe (struct flash_bank *bank)
 
static int lpcspifi_bulk_erase (struct flash_bank *bank)
 
static int lpcspifi_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int lpcspifi_probe (struct flash_bank *bank)
 
static int lpcspifi_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int lpcspifi_protect_check (struct flash_bank *bank)
 
static int lpcspifi_read_flash_id (struct flash_bank *bank, uint32_t *id)
 
static int lpcspifi_set_hw_mode (struct flash_bank *bank)
 
static int lpcspifi_set_sw_mode (struct flash_bank *bank)
 
static int lpcspifi_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int lpcspifi_write_enable (struct flash_bank *bank)
 
static int poll_ssp_busy (struct target *target, uint32_t ssp_base, int timeout)
 
static int read_status_reg (struct flash_bank *bank, uint32_t *status)
 
static int ssp_read_reg (struct target *target, uint32_t ssp_base, uint32_t offset, uint32_t *value)
 
static int ssp_setcs (struct target *target, uint32_t io_base, unsigned int value)
 
static int ssp_write_reg (struct target *target, uint32_t ssp_base, uint32_t offset, uint32_t value)
 
static int wait_till_ready (struct flash_bank *bank, int timeout)
 

Variables

const struct flash_driver lpcspifi_flash
 

Macro Definition Documentation

◆ SPIFI_INIT_STACK_SIZE

#define SPIFI_INIT_STACK_SIZE   512

Definition at line 36 of file lpcspifi.c.

◆ SSP_BSY

#define SSP_BSY   (0x00000010)

Definition at line 27 of file lpcspifi.c.

◆ SSP_CMD_TIMEOUT

#define SSP_CMD_TIMEOUT   (100)

Definition at line 30 of file lpcspifi.c.

◆ SSP_CPSR

#define SSP_CPSR   (0x10) /* Clock prescale register */

Definition at line 24 of file lpcspifi.c.

◆ SSP_CR0

#define SSP_CR0   (0x00) /* Control register 0 */

Definition at line 20 of file lpcspifi.c.

◆ SSP_CR1

#define SSP_CR1   (0x04) /* Control register 1 */

Definition at line 21 of file lpcspifi.c.

◆ SSP_DATA

#define SSP_DATA   (0x08) /* Data register (TX and RX) */

Definition at line 22 of file lpcspifi.c.

◆ SSP_MAX_TIMEOUT

#define SSP_MAX_TIMEOUT   (3000)

Definition at line 32 of file lpcspifi.c.

◆ SSP_PROBE_TIMEOUT

#define SSP_PROBE_TIMEOUT   (100)

Definition at line 31 of file lpcspifi.c.

◆ SSP_SR

#define SSP_SR   (0x0C) /* Status register */

Definition at line 23 of file lpcspifi.c.

Function Documentation

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( lpcspifi_flash_bank_command  )

◆ get_lpcspifi_info()

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

◆ io_write_reg()

static int io_write_reg ( struct target target,
uint32_t  io_base,
uint32_t  offset,
uint32_t  value 
)
inlinestatic

Definition at line 79 of file lpcspifi.c.

References lpcspifi_flash_bank::io_base, offset, and target_write_u32().

Referenced by lpcspifi_set_sw_mode(), and ssp_setcs().

◆ ioconfig_write_reg()

static int ioconfig_write_reg ( struct target target,
uint32_t  ioconfig_base,
uint32_t  offset,
uint32_t  value 
)
inlinestatic

Definition at line 69 of file lpcspifi.c.

References lpcspifi_flash_bank::ioconfig_base, offset, and target_write_u32().

Referenced by lpcspifi_set_sw_mode().

◆ lpcspifi_auto_probe()

static int lpcspifi_auto_probe ( struct flash_bank bank)
static

Definition at line 904 of file lpcspifi.c.

References bank, ERROR_OK, lpcspifi_probe(), and lpcspifi_flash_bank::probed.

◆ lpcspifi_bulk_erase()

◆ lpcspifi_erase()

◆ lpcspifi_probe()

◆ lpcspifi_protect()

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

Definition at line 562 of file lpcspifi.c.

References bank, and ERROR_OK.

◆ lpcspifi_protect_check()

static int lpcspifi_protect_check ( struct flash_bank bank)
static

Definition at line 912 of file lpcspifi.c.

References ERROR_OK.

◆ lpcspifi_read_flash_id()

◆ lpcspifi_set_hw_mode()

◆ lpcspifi_set_sw_mode()

◆ lpcspifi_write()

◆ lpcspifi_write_enable()

◆ poll_ssp_busy()

static int poll_ssp_busy ( struct target target,
uint32_t  ssp_base,
int  timeout 
)
static

◆ read_status_reg()

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

◆ ssp_read_reg()

static int ssp_read_reg ( struct target target,
uint32_t  ssp_base,
uint32_t  offset,
uint32_t *  value 
)
inlinestatic

◆ ssp_setcs()

static int ssp_setcs ( struct target target,
uint32_t  io_base,
unsigned int  value 
)
static

◆ ssp_write_reg()

static int ssp_write_reg ( struct target target,
uint32_t  ssp_base,
uint32_t  offset,
uint32_t  value 
)
inlinestatic

◆ wait_till_ready()

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

Variable Documentation

◆ lpcspifi_flash

const struct flash_driver lpcspifi_flash
Initial value:
= {
.name = "lpcspifi",
.flash_bank_command = lpcspifi_flash_bank_command,
.erase = lpcspifi_erase,
.protect = lpcspifi_protect,
.write = lpcspifi_write,
.probe = lpcspifi_probe,
.auto_probe = lpcspifi_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = lpcspifi_protect_check,
.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 lpcspifi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: lpcspifi.c:570
static int get_lpcspifi_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: lpcspifi.c:918
static int lpcspifi_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: lpcspifi.c:562
static int lpcspifi_auto_probe(struct flash_bank *bank)
Definition: lpcspifi.c:904
static int lpcspifi_protect_check(struct flash_bank *bank)
Definition: lpcspifi.c:912
static int lpcspifi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: lpcspifi.c:406
static int lpcspifi_probe(struct flash_bank *bank)
Definition: lpcspifi.c:830

Definition at line 918 of file lpcspifi.c.