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

Go to the source code of this file.

Data Structures

struct  lpc2900_flash_bank
 Private data for lpc2900 flash driver. More...
 

Macros

#define CHIPID   0xE0000000 /* Chip ID */
 
#define EEADDR   0x20200084 /* EEPROM address */
 
#define EECLKDIV   0x20200094 /* EEPROM clock divider */
 
#define EECMD   0x20200080 /* EEPROM command */
 
#define EEMSSIG   0x202000A4 /* EEPROM 24-bit BIST signature */
 
#define EEMSSTART   0x2020009C /* EEPROM BIST start address */
 
#define EEMSSTOP   0x202000A0 /* EEPROM BIST stop address */
 
#define EEMSSTOP_STRTBIST   (1 << 31)
 
#define EEPWRDWN   0x20200098 /* EEPROM power-down/start */
 
#define EERDATA   0x2020008C /* EEPROM read data */
 
#define EEWDATA   0x20200088 /* EEPROM write data */
 
#define EEWSTATE   0x20200090 /* EEPROM wait state */
 
#define EXPECTED_CHIPID   0x209CE02B /* Chip ID of all LPC2900 devices */
 
#define FBWST   0x20200010 /* Flash bridge wait-state */
 
#define FCRA   0x2020001C /* Flash clock divider */
 
#define FCTR   0x20200000 /* Flash control */
 
#define FCTR_FS_CACHEBYP   (1 << 13)
 
#define FCTR_FS_CACHECLR   (1 << 14)
 
#define FCTR_FS_CS   (1 << 0)
 
#define FCTR_FS_DCR   (1 << 4)
 
#define FCTR_FS_ISS   (1 << 6)
 
#define FCTR_FS_LOADREQ   (1 << 15)
 
#define FCTR_FS_PD   (1 << 9)
 
#define FCTR_FS_PDL   (1 << 10)
 
#define FCTR_FS_PROGREQ   (1 << 12)
 
#define FCTR_FS_RLD   (1 << 5)
 
#define FCTR_FS_RLS   (1 << 11)
 
#define FCTR_FS_WEB   (1 << 2)
 
#define FCTR_FS_WPB   (1 << 7)
 
#define FCTR_FS_WRE   (1 << 1)
 
#define FEAT0   0xE0000100 /* Chip feature 0 */
 
#define FEAT1   0xE0000104 /* Chip feature 1 */
 
#define FEAT2   0xE0000108 /* Chip feature 2 (contains flash size indicator) */
 
#define FEAT3   0xE000010C /* Chip feature 3 */
 
#define FLASH_ERASE_TIME   100000 /* microseconds */
 
#define FLASH_PAGE_SIZE   512 /* bytes */
 
#define FLASH_PROGRAM_TIME   1000 /* microseconds */
 
#define FMS16   0x20200028 /* Flash 16-bit signature */
 
#define FMSSTART   0x20200020 /* Flash Built-In Self Test start address */
 
#define FMSSTOP   0x20200024 /* Flash Built-In Self Test stop address */
 
#define FMSSTOP_MISR_START   (1 << 17)
 
#define FMSW0   0x2020002C /* Flash 128-bit signature Word 0 */
 
#define FMSW1   0x20200030 /* Flash 128-bit signature Word 1 */
 
#define FMSW2   0x20200034 /* Flash 128-bit signature Word 2 */
 
#define FMSW3   0x20200038 /* Flash 128-bit signature Word 3 */
 
#define FPTR   0x20200008 /* Flash program-time */
 
#define FPTR_EN_T   (1 << 15)
 
#define FTCTR   0x2020000C /* Flash test control */
 
#define FTCTR_FS_BYPASS_R   (1 << 29)
 
#define FTCTR_FS_BYPASS_W   (1 << 28)
 
#define INT_CLR_ENABLE   0x20200FD8 /* Flash/EEPROM interrupt clear enable */
 
#define INT_CLR_STATUS   0x20200FE8 /* Flash/EEPROM interrupt clear status */
 
#define INT_ENABLE   0x20200FE4 /* Flash/EEPROM interrupt enable */
 
#define INT_SET_ENABLE   0x20200FDC /* Flash/EEPROM interrupt set enable */
 
#define INT_SET_STATUS   0x20200FEC /* Flash/EEPROM interrupt set status */
 
#define INT_STATUS   0x20200FE0 /* Flash/EEPROM interrupt status */
 
#define INTSRC_END_OF_BIST   (1 << 27)
 
#define INTSRC_END_OF_BURN   (1 << 1)
 
#define INTSRC_END_OF_ERASE   (1 << 0)
 
#define INTSRC_END_OF_MISR   (1 << 2)
 
#define INTSRC_END_OF_PROG   (1 << 28)
 
#define INTSRC_END_OF_RDWR   (1 << 26)
 
#define ISS_CUSTOMER_END1   (0xA00)
 
#define ISS_CUSTOMER_END2   (0xC00)
 
#define ISS_CUSTOMER_NWORDS1   (ISS_CUSTOMER_SIZE1 / 4)
 
#define ISS_CUSTOMER_NWORDS2   (ISS_CUSTOMER_SIZE2 / 4)
 
#define ISS_CUSTOMER_SIZE   (ISS_CUSTOMER_SIZE1 + ISS_CUSTOMER_SIZE2)
 
#define ISS_CUSTOMER_SIZE1   (ISS_CUSTOMER_END1 - ISS_CUSTOMER_START1)
 
#define ISS_CUSTOMER_SIZE2   (ISS_CUSTOMER_END2 - ISS_CUSTOMER_START2)
 
#define ISS_CUSTOMER_START1   (0x830)
 
#define ISS_CUSTOMER_START2   (0xA40)
 
#define ISS_PASSWORD   "I_know_what_I_am_doing"
 
#define KiB   1024
 

Functions

 COMMAND_HANDLER (lpc2900_handle_password_command)
 Enter password to enable potentially dangerous options. More...
 
 COMMAND_HANDLER (lpc2900_handle_read_custom_command)
 Store customer info in file. More...
 
 COMMAND_HANDLER (lpc2900_handle_secure_jtag_command)
 Activate JTAG protection. More...
 
 COMMAND_HANDLER (lpc2900_handle_secure_sector_command)
 Activate 'sector security' for a range of sectors. More...
 
 COMMAND_HANDLER (lpc2900_handle_signature_command)
 Command to determine the signature of the whole flash. More...
 
 COMMAND_HANDLER (lpc2900_handle_write_custom_command)
 Write customer info from file to the index sector. More...
 
 FLASH_BANK_COMMAND_HANDLER (lpc2900_flash_bank_command)
 Evaluate flash bank command. More...
 
static unsigned int lpc2900_address2sector (struct flash_bank *bank, uint32_t offset)
 Return sector number for given address. More...
 
static uint32_t lpc2900_calc_tr (uint32_t clock_var, uint32_t time_var)
 Calculate FPTR.TR register value for desired program/erase time. More...
 
static int lpc2900_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 Erase sector(s). More...
 
static int lpc2900_erase_check (struct flash_bank *bank)
 Run a blank check for each sector. More...
 
static uint32_t lpc2900_is_ready (struct flash_bank *bank)
 Check if device is ready. More...
 
static int lpc2900_probe (struct flash_bank *bank)
 Try and identify the device. More...
 
static int lpc2900_protect_check (struct flash_bank *bank)
 Get protection (sector security) status. More...
 
static uint32_t lpc2900_read_security_status (struct flash_bank *bank)
 Read the status of sector security from the index sector. More...
 
static uint32_t lpc2900_run_bist128 (struct flash_bank *bank, uint32_t addr_from, uint32_t addr_to, uint32_t signature[4])
 Use BIST to calculate a 128-bit hash value over a range of flash. More...
 
static void lpc2900_setup (struct flash_bank *bank)
 Set up the flash for erase/program operations. More...
 
static uint32_t lpc2900_wait_status (struct flash_bank *bank, uint32_t mask, int timeout)
 Wait for an event in mask to occur in INT_STATUS. More...
 
static int lpc2900_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 Write data to flash. More...
 
static int lpc2900_write_index_page (struct flash_bank *bank, int pagenum, uint8_t page[FLASH_PAGE_SIZE])
 Write one page to the index sector. More...
 

Variables

static const struct command_registration lpc2900_command_handlers []
 
static const struct command_registration lpc2900_exec_command_handlers []
 
const struct flash_driver lpc2900_flash
 

Macro Definition Documentation

◆ CHIPID

#define CHIPID   0xE0000000 /* Chip ID */

Definition at line 27 of file lpc2900.c.

◆ EEADDR

#define EEADDR   0x20200084 /* EEPROM address */

Definition at line 50 of file lpc2900.c.

◆ EECLKDIV

#define EECLKDIV   0x20200094 /* EEPROM clock divider */

Definition at line 54 of file lpc2900.c.

◆ EECMD

#define EECMD   0x20200080 /* EEPROM command */

Definition at line 49 of file lpc2900.c.

◆ EEMSSIG

#define EEMSSIG   0x202000A4 /* EEPROM 24-bit BIST signature */

Definition at line 58 of file lpc2900.c.

◆ EEMSSTART

#define EEMSSTART   0x2020009C /* EEPROM BIST start address */

Definition at line 56 of file lpc2900.c.

◆ EEMSSTOP

#define EEMSSTOP   0x202000A0 /* EEPROM BIST stop address */

Definition at line 57 of file lpc2900.c.

◆ EEMSSTOP_STRTBIST

#define EEMSSTOP_STRTBIST   (1 << 31)

Definition at line 98 of file lpc2900.c.

◆ EEPWRDWN

#define EEPWRDWN   0x20200098 /* EEPROM power-down/start */

Definition at line 55 of file lpc2900.c.

◆ EERDATA

#define EERDATA   0x2020008C /* EEPROM read data */

Definition at line 52 of file lpc2900.c.

◆ EEWDATA

#define EEWDATA   0x20200088 /* EEPROM write data */

Definition at line 51 of file lpc2900.c.

◆ EEWSTATE

#define EEWSTATE   0x20200090 /* EEPROM wait state */

Definition at line 53 of file lpc2900.c.

◆ EXPECTED_CHIPID

#define EXPECTED_CHIPID   0x209CE02B /* Chip ID of all LPC2900 devices */

Definition at line 33 of file lpc2900.c.

◆ FBWST

#define FBWST   0x20200010 /* Flash bridge wait-state */

Definition at line 39 of file lpc2900.c.

◆ FCRA

#define FCRA   0x2020001C /* Flash clock divider */

Definition at line 40 of file lpc2900.c.

◆ FCTR

#define FCTR   0x20200000 /* Flash control */

Definition at line 36 of file lpc2900.c.

◆ FCTR_FS_CACHEBYP

#define FCTR_FS_CACHEBYP   (1 << 13)

Definition at line 78 of file lpc2900.c.

◆ FCTR_FS_CACHECLR

#define FCTR_FS_CACHECLR   (1 << 14)

Definition at line 77 of file lpc2900.c.

◆ FCTR_FS_CS

#define FCTR_FS_CS   (1 << 0)

Definition at line 89 of file lpc2900.c.

◆ FCTR_FS_DCR

#define FCTR_FS_DCR   (1 << 4)

Definition at line 86 of file lpc2900.c.

◆ FCTR_FS_ISS

#define FCTR_FS_ISS   (1 << 6)

Definition at line 84 of file lpc2900.c.

◆ FCTR_FS_LOADREQ

#define FCTR_FS_LOADREQ   (1 << 15)

Definition at line 76 of file lpc2900.c.

◆ FCTR_FS_PD

#define FCTR_FS_PD   (1 << 9)

Definition at line 82 of file lpc2900.c.

◆ FCTR_FS_PDL

#define FCTR_FS_PDL   (1 << 10)

Definition at line 81 of file lpc2900.c.

◆ FCTR_FS_PROGREQ

#define FCTR_FS_PROGREQ   (1 << 12)

Definition at line 79 of file lpc2900.c.

◆ FCTR_FS_RLD

#define FCTR_FS_RLD   (1 << 5)

Definition at line 85 of file lpc2900.c.

◆ FCTR_FS_RLS

#define FCTR_FS_RLS   (1 << 11)

Definition at line 80 of file lpc2900.c.

◆ FCTR_FS_WEB

#define FCTR_FS_WEB   (1 << 2)

Definition at line 87 of file lpc2900.c.

◆ FCTR_FS_WPB

#define FCTR_FS_WPB   (1 << 7)

Definition at line 83 of file lpc2900.c.

◆ FCTR_FS_WRE

#define FCTR_FS_WRE   (1 << 1)

Definition at line 88 of file lpc2900.c.

◆ FEAT0

#define FEAT0   0xE0000100 /* Chip feature 0 */

Definition at line 28 of file lpc2900.c.

◆ FEAT1

#define FEAT1   0xE0000104 /* Chip feature 1 */

Definition at line 29 of file lpc2900.c.

◆ FEAT2

#define FEAT2   0xE0000108 /* Chip feature 2 (contains flash size indicator) */

Definition at line 30 of file lpc2900.c.

◆ FEAT3

#define FEAT3   0xE000010C /* Chip feature 3 */

Definition at line 31 of file lpc2900.c.

◆ FLASH_ERASE_TIME

#define FLASH_ERASE_TIME   100000 /* microseconds */

Definition at line 23 of file lpc2900.c.

◆ FLASH_PAGE_SIZE

#define FLASH_PAGE_SIZE   512 /* bytes */

Definition at line 22 of file lpc2900.c.

◆ FLASH_PROGRAM_TIME

#define FLASH_PROGRAM_TIME   1000 /* microseconds */

Definition at line 24 of file lpc2900.c.

◆ FMS16

#define FMS16   0x20200028 /* Flash 16-bit signature */

Definition at line 43 of file lpc2900.c.

◆ FMSSTART

#define FMSSTART   0x20200020 /* Flash Built-In Self Test start address */

Definition at line 41 of file lpc2900.c.

◆ FMSSTOP

#define FMSSTOP   0x20200024 /* Flash Built-In Self Test stop address */

Definition at line 42 of file lpc2900.c.

◆ FMSSTOP_MISR_START

#define FMSSTOP_MISR_START   (1 << 17)

Definition at line 96 of file lpc2900.c.

◆ FMSW0

#define FMSW0   0x2020002C /* Flash 128-bit signature Word 0 */

Definition at line 44 of file lpc2900.c.

◆ FMSW1

#define FMSW1   0x20200030 /* Flash 128-bit signature Word 1 */

Definition at line 45 of file lpc2900.c.

◆ FMSW2

#define FMSW2   0x20200034 /* Flash 128-bit signature Word 2 */

Definition at line 46 of file lpc2900.c.

◆ FMSW3

#define FMSW3   0x20200038 /* Flash 128-bit signature Word 3 */

Definition at line 47 of file lpc2900.c.

◆ FPTR

#define FPTR   0x20200008 /* Flash program-time */

Definition at line 37 of file lpc2900.c.

◆ FPTR_EN_T

#define FPTR_EN_T   (1 << 15)

Definition at line 91 of file lpc2900.c.

◆ FTCTR

#define FTCTR   0x2020000C /* Flash test control */

Definition at line 38 of file lpc2900.c.

◆ FTCTR_FS_BYPASS_R

#define FTCTR_FS_BYPASS_R   (1 << 29)

Definition at line 93 of file lpc2900.c.

◆ FTCTR_FS_BYPASS_W

#define FTCTR_FS_BYPASS_W   (1 << 28)

Definition at line 94 of file lpc2900.c.

◆ INT_CLR_ENABLE

#define INT_CLR_ENABLE   0x20200FD8 /* Flash/EEPROM interrupt clear enable */

Definition at line 60 of file lpc2900.c.

◆ INT_CLR_STATUS

#define INT_CLR_STATUS   0x20200FE8 /* Flash/EEPROM interrupt clear status */

Definition at line 64 of file lpc2900.c.

◆ INT_ENABLE

#define INT_ENABLE   0x20200FE4 /* Flash/EEPROM interrupt enable */

Definition at line 63 of file lpc2900.c.

◆ INT_SET_ENABLE

#define INT_SET_ENABLE   0x20200FDC /* Flash/EEPROM interrupt set enable */

Definition at line 61 of file lpc2900.c.

◆ INT_SET_STATUS

#define INT_SET_STATUS   0x20200FEC /* Flash/EEPROM interrupt set status */

Definition at line 65 of file lpc2900.c.

◆ INT_STATUS

#define INT_STATUS   0x20200FE0 /* Flash/EEPROM interrupt status */

Definition at line 62 of file lpc2900.c.

◆ INTSRC_END_OF_BIST

#define INTSRC_END_OF_BIST   (1 << 27)

Definition at line 69 of file lpc2900.c.

◆ INTSRC_END_OF_BURN

#define INTSRC_END_OF_BURN   (1 << 1)

Definition at line 72 of file lpc2900.c.

◆ INTSRC_END_OF_ERASE

#define INTSRC_END_OF_ERASE   (1 << 0)

Definition at line 73 of file lpc2900.c.

◆ INTSRC_END_OF_MISR

#define INTSRC_END_OF_MISR   (1 << 2)

Definition at line 71 of file lpc2900.c.

◆ INTSRC_END_OF_PROG

#define INTSRC_END_OF_PROG   (1 << 28)

Definition at line 68 of file lpc2900.c.

◆ INTSRC_END_OF_RDWR

#define INTSRC_END_OF_RDWR   (1 << 26)

Definition at line 70 of file lpc2900.c.

◆ ISS_CUSTOMER_END1

#define ISS_CUSTOMER_END1   (0xA00)

Definition at line 102 of file lpc2900.c.

◆ ISS_CUSTOMER_END2

#define ISS_CUSTOMER_END2   (0xC00)

Definition at line 106 of file lpc2900.c.

◆ ISS_CUSTOMER_NWORDS1

#define ISS_CUSTOMER_NWORDS1   (ISS_CUSTOMER_SIZE1 / 4)

Definition at line 104 of file lpc2900.c.

◆ ISS_CUSTOMER_NWORDS2

#define ISS_CUSTOMER_NWORDS2   (ISS_CUSTOMER_SIZE2 / 4)

Definition at line 108 of file lpc2900.c.

◆ ISS_CUSTOMER_SIZE

#define ISS_CUSTOMER_SIZE   (ISS_CUSTOMER_SIZE1 + ISS_CUSTOMER_SIZE2)

Definition at line 109 of file lpc2900.c.

◆ ISS_CUSTOMER_SIZE1

#define ISS_CUSTOMER_SIZE1   (ISS_CUSTOMER_END1 - ISS_CUSTOMER_START1)

Definition at line 103 of file lpc2900.c.

◆ ISS_CUSTOMER_SIZE2

#define ISS_CUSTOMER_SIZE2   (ISS_CUSTOMER_END2 - ISS_CUSTOMER_START2)

Definition at line 107 of file lpc2900.c.

◆ ISS_CUSTOMER_START1

#define ISS_CUSTOMER_START1   (0x830)

Definition at line 101 of file lpc2900.c.

◆ ISS_CUSTOMER_START2

#define ISS_CUSTOMER_START2   (0xA40)

Definition at line 105 of file lpc2900.c.

◆ ISS_PASSWORD

#define ISS_PASSWORD   "I_know_what_I_am_doing"

◆ KiB

#define KiB   1024

Definition at line 19 of file lpc2900.c.

Function Documentation

◆ COMMAND_HANDLER() [1/6]

COMMAND_HANDLER ( lpc2900_handle_password_command  )

Enter password to enable potentially dangerous options.

Definition at line 569 of file lpc2900.c.

References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, CMD_ARGV, command_print(), ERROR_COMMAND_ARGUMENT_INVALID, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ISS_PASSWORD, and lpc2900_flash_bank::risky.

◆ COMMAND_HANDLER() [2/6]

COMMAND_HANDLER ( lpc2900_handle_read_custom_command  )

◆ COMMAND_HANDLER() [3/6]

COMMAND_HANDLER ( lpc2900_handle_secure_jtag_command  )

◆ COMMAND_HANDLER() [4/6]

◆ COMMAND_HANDLER() [5/6]

COMMAND_HANDLER ( lpc2900_handle_signature_command  )

Command to determine the signature of the whole flash.

Uses the Built-In-Self-Test (BIST) to generate a 128-bit hash value of the flash content.

Definition at line 469 of file lpc2900.c.

References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, lpc2900_run_bist128(), status, and TARGET_HALTED.

◆ COMMAND_HANDLER() [6/6]

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( lpc2900_flash_bank_command  )

◆ lpc2900_address2sector()

static unsigned int lpc2900_address2sector ( struct flash_bank bank,
uint32_t  offset 
)
static

Return sector number for given address.

Return the (logical) sector number for a given relative address. No sanity check is done. It assumed that the address is valid.

Parameters
bankPointer to the flash bank descriptor
offsetOffset address relative to bank start

Definition at line 348 of file lpc2900.c.

References bank, and offset.

Referenced by lpc2900_write().

◆ lpc2900_calc_tr()

static uint32_t lpc2900_calc_tr ( uint32_t  clock_var,
uint32_t  time_var 
)
static

Calculate FPTR.TR register value for desired program/erase time.

Parameters
clock_varSystem clock in Hz
time_varProgram/erase time in µs

Definition at line 448 of file lpc2900.c.

Referenced by lpc2900_erase(), lpc2900_write(), and lpc2900_write_index_page().

◆ lpc2900_erase()

static int lpc2900_erase ( struct flash_bank bank,
unsigned int  first,
unsigned int  last 
)
static

◆ lpc2900_erase_check()

static int lpc2900_erase_check ( struct flash_bank bank)
static

Run a blank check for each sector.

For speed reasons, the device isn't read word by word. A hash value is calculated by the hardware ("BIST") for each sector. This value is then compared against the known hash of an empty sector.

Parameters
bankPointer to the flash bank descriptor

Definition at line 1519 of file lpc2900.c.

References bank, ERROR_OK, KiB, LOG_INFO, lpc2900_is_ready(), lpc2900_run_bist128(), and status.

◆ lpc2900_is_ready()

static uint32_t lpc2900_is_ready ( struct flash_bank bank)
static

Check if device is ready.

Check if device is ready for flash operation: Must have been successfully probed. Must be halted.

Definition at line 227 of file lpc2900.c.

References bank, ERROR_FLASH_BANK_NOT_PROBED, ERROR_OK, ERROR_TARGET_NOT_HALTED, lpc2900_flash_bank::is_probed, LOG_ERROR, and TARGET_HALTED.

Referenced by lpc2900_erase(), lpc2900_erase_check(), lpc2900_read_security_status(), and lpc2900_write().

◆ lpc2900_probe()

static int lpc2900_probe ( struct flash_bank bank)
static

◆ lpc2900_protect_check()

static int lpc2900_protect_check ( struct flash_bank bank)
static

Get protection (sector security) status.

Determine the status of "sector security" for each sector. A secured sector is one that can never be erased/programmed again.

Parameters
bankPointer to the flash bank descriptor

Definition at line 1567 of file lpc2900.c.

◆ lpc2900_read_security_status()

static uint32_t lpc2900_read_security_status ( struct flash_bank bank)
static

Read the status of sector security from the index sector.

Parameters
bankPointer to the flash bank descriptor

Definition at line 247 of file lpc2900.c.

References bank, ERROR_OK, FCTR, FCTR_FS_CS, FCTR_FS_ISS, FCTR_FS_WEB, lpc2900_is_ready(), status, target_read_memory(), and target_write_u32().

Referenced by COMMAND_HANDLER(), lpc2900_erase(), lpc2900_probe(), and lpc2900_write().

◆ lpc2900_run_bist128()

static uint32_t lpc2900_run_bist128 ( struct flash_bank bank,
uint32_t  addr_from,
uint32_t  addr_to,
uint32_t  signature[4] 
)
static

Use BIST to calculate a 128-bit hash value over a range of flash.

Parameters
bankPointer to the flash bank descriptor
addr_from
addr_to
signature

Definition at line 312 of file lpc2900.c.

References bank, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, FMSSTART, FMSSTOP, FMSSTOP_MISR_START, FMSW0, INT_CLR_STATUS, INTSRC_END_OF_MISR, lpc2900_wait_status(), target_buffer_get_u32_array(), target_read_memory(), and target_write_u32().

Referenced by COMMAND_HANDLER(), and lpc2900_erase_check().

◆ lpc2900_setup()

static void lpc2900_setup ( struct flash_bank bank)
static

Set up the flash for erase/program operations.

Enable the flash, and set the correct CRA clock of 66 kHz.

Parameters
bankPointer to the flash bank descriptor

Definition at line 208 of file lpc2900.c.

References bank, lpc2900_flash_bank::clk_sys_fmc, FCRA, FCTR, FCTR_FS_CS, FCTR_FS_WEB, and target_write_u32().

Referenced by lpc2900_erase(), lpc2900_write(), and lpc2900_write_index_page().

◆ lpc2900_wait_status()

static uint32_t lpc2900_wait_status ( struct flash_bank bank,
uint32_t  mask,
int  timeout 
)
static

Wait for an event in mask to occur in INT_STATUS.

Return when an event occurs, or after a timeout.

Parameters
[in]bankPointer to the flash bank descriptor
[in]maskMask to be used for INT_STATUS
[in]timeoutTimeout in ms

Definition at line 180 of file lpc2900.c.

References alive_sleep(), bank, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, INT_STATUS, LOG_DEBUG, mask, and target_read_u32().

Referenced by lpc2900_erase(), lpc2900_run_bist128(), lpc2900_write(), and lpc2900_write_index_page().

◆ lpc2900_write()

◆ lpc2900_write_index_page()

static int lpc2900_write_index_page ( struct flash_bank bank,
int  pagenum,
uint8_t  page[FLASH_PAGE_SIZE] 
)
static

Variable Documentation

◆ lpc2900_command_handlers

const struct command_registration lpc2900_command_handlers[]
static
Initial value:
= {
{
.name = "lpc2900",
.mode = COMMAND_ANY,
.help = "LPC2900 flash command group",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration lpc2900_exec_command_handlers[]
Definition: lpc2900.c:824

Definition at line 778 of file lpc2900.c.

◆ lpc2900_exec_command_handlers

const struct command_registration lpc2900_exec_command_handlers[]
static

Definition at line 778 of file lpc2900.c.

◆ lpc2900_flash

const struct flash_driver lpc2900_flash
Initial value:
= {
.name = "lpc2900",
.flash_bank_command = lpc2900_flash_bank_command,
.erase = lpc2900_erase,
.write = lpc2900_write,
.probe = lpc2900_probe,
.auto_probe = lpc2900_probe,
.erase_check = lpc2900_erase_check,
.protect_check = lpc2900_protect_check,
.free_driver_priv = default_flash_free_driver_priv,
}
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 lpc2900_probe(struct flash_bank *bank)
Try and identify the device.
Definition: lpc2900.c:1360
static const struct command_registration lpc2900_command_handlers[]
Definition: lpc2900.c:874
static int lpc2900_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Erase sector(s).
Definition: lpc2900.c:935
static int lpc2900_erase_check(struct flash_bank *bank)
Run a blank check for each sector.
Definition: lpc2900.c:1519
static int lpc2900_protect_check(struct flash_bank *bank)
Get protection (sector security) status.
Definition: lpc2900.c:1567
static int lpc2900_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Write data to flash.
Definition: lpc2900.c:1045

Definition at line 1567 of file lpc2900.c.