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

Go to the source code of this file.

Data Structures

struct  archnames
 
struct  sam4_bank_private
 
struct  sam4_cfg
 
struct  sam4_chip
 
struct  sam4_chip_details
 
struct  sam4_reg_list
 

Macros

#define AT91C_EFC_FCMD_CFB   (0xC) /* (EFC) Clear Fuse Bit */
 
#define AT91C_EFC_FCMD_CLB   (0x9) /* (EFC) Clear Lock Bit */
 
#define AT91C_EFC_FCMD_EA   (0x5) /* (EFC) Erase All */
 
#define AT91C_EFC_FCMD_EPA   (0x7) /* (EFC) Erase pages */
 
#define AT91C_EFC_FCMD_EWP   (0x3) /* (EFC) Erase Page and Write Page */
 
#define AT91C_EFC_FCMD_EWPL   (0x4) /* (EFC) Erase Page and Write Page then Lock */
 
#define AT91C_EFC_FCMD_GETD   (0x0) /* (EFC) Get Flash Descriptor */
 
#define AT91C_EFC_FCMD_GFB   (0xD) /* (EFC) Get Fuse Bit */
 
#define AT91C_EFC_FCMD_GLB   (0xA) /* (EFC) Get Lock Bit */
 
#define AT91C_EFC_FCMD_SFB   (0xB) /* (EFC) Set Fuse Bit */
 
#define AT91C_EFC_FCMD_SLB   (0x8) /* (EFC) Set Lock Bit */
 
#define AT91C_EFC_FCMD_SPUI   (0xF) /* (EFC) Stop Read Unique ID */
 
#define AT91C_EFC_FCMD_STUI   (0xE) /* (EFC) Start Read Unique ID */
 
#define AT91C_EFC_FCMD_WP   (0x1) /* (EFC) Write Page */
 
#define AT91C_EFC_FCMD_WPL   (0x2) /* (EFC) Write Page and Lock */
 
#define FLASH_BANK0_BASE_C32   FLASH_BANK_BASE_C
 
#define FLASH_BANK0_BASE_SD   FLASH_BANK_BASE_S
 
#define FLASH_BANK1_BASE_1024K_SD   (FLASH_BANK0_BASE_SD+(1024*1024/2))
 
#define FLASH_BANK1_BASE_2048K_SD   (FLASH_BANK0_BASE_SD+(2048*1024/2))
 
#define FLASH_BANK1_BASE_C32   (FLASH_BANK_BASE_C+(2048*1024/2))
 
#define FLASH_BANK_BASE_C   0x01000000
 
#define FLASH_BANK_BASE_S   0x00400000
 
#define nvpsize2   nvpsize /* these two tables are identical */
 
#define OFFSET_EFC_FCR   4
 
#define OFFSET_EFC_FMR   0
 
#define OFFSET_EFC_FRR   12
 
#define OFFSET_EFC_FSR   8
 
#define REG_NAME_WIDTH   (12)
 
#define SAM4_CHIPID_CIDR   (0x400E0740)
 
#define SAM4_CHIPID_EXID   (0x400E0744)
 
#define SAM4_CKGR_MCFR   (SAM4_PMC_BASE + 0x0024)
 
#define SAM4_CKGR_MOR   (SAM4_PMC_BASE + 0x0020)
 
#define SAM4_CKGR_PLLAR   (SAM4_PMC_BASE + 0x0028)
 
#define SAM4_CKGR_UCKR   (SAM4_PMC_BASE + 0x001c)
 
#define SAM4_ENTRY(NAME, FUNC)
 
#define SAM4_MAX_FLASH_BANKS   2
 
#define SAM4_N_NVM_BITS   3
 
#define SAM4_PMC_BASE   (0x400E0400)
 
#define SAM4_PMC_FSMR   (SAM4_PMC_BASE + 0x0070)
 
#define SAM4_PMC_FSPR   (SAM4_PMC_BASE + 0x0074)
 
#define SAM4_PMC_IMR   (SAM4_PMC_BASE + 0x006c)
 
#define SAM4_PMC_MCKR   (SAM4_PMC_BASE + 0x0030)
 
#define SAM4_PMC_PCK0   (SAM4_PMC_BASE + 0x0040)
 
#define SAM4_PMC_PCK1   (SAM4_PMC_BASE + 0x0044)
 
#define SAM4_PMC_PCK2   (SAM4_PMC_BASE + 0x0048)
 
#define SAM4_PMC_PCSR   (SAM4_PMC_BASE + 0x0018)
 
#define SAM4_PMC_SCSR   (SAM4_PMC_BASE + 0x0008)
 
#define SAM4_PMC_SR   (SAM4_PMC_BASE + 0x0068)
 

Functions

static float _tomhz (uint32_t freq_hz)
 
static const char * _yes_or_no (uint32_t v)
 
 COMMAND_HANDLER (sam4_handle_gpnvm_command)
 
 COMMAND_HANDLER (sam4_handle_info_command)
 
 COMMAND_HANDLER (sam4_handle_slowclk_command)
 
static int efc_get_result (struct sam4_bank_private *private, uint32_t *v)
 Get the result of the last executed command. More...
 
static int efc_get_status (struct sam4_bank_private *private, uint32_t *v)
 Get the current status of the EEFC and the value of some status bits (LOCKE, PROGE). More...
 
static int efc_perform_command (struct sam4_bank_private *private, unsigned int command, unsigned int argument, uint32_t *status)
 Performs the given command and wait until its completion (or an error). More...
 
static int efc_start_command (struct sam4_bank_private *private, unsigned int command, unsigned int argument)
 
 FLASH_BANK_COMMAND_HANDLER (sam4_flash_bank_command)
 
static int flashd_clr_gpnvm (struct sam4_bank_private *private, unsigned int gpnvm)
 Clears the selected GPNVM bit. More...
 
static int flashd_erase_entire_bank (struct sam4_bank_private *private)
 Erases the entire flash. More...
 
static int flashd_erase_pages (struct sam4_bank_private *private, int first_page, int num_pages, uint32_t *status)
 Erases the entire flash. More...
 
static int flashd_get_gpnvm (struct sam4_bank_private *private, unsigned int gpnvm, unsigned int *puthere)
 Gets current GPNVM state. More...
 
static int flashd_get_lock_bits (struct sam4_bank_private *private, uint32_t *v)
 Returns a bit field (at most 64) of locked regions within a page. More...
 
static int flashd_lock (struct sam4_bank_private *private, unsigned int start_sector, unsigned int end_sector)
 Locks regions. More...
 
static int flashd_read_uid (struct sam4_bank_private *private)
 Read the unique ID. More...
 
static int flashd_set_gpnvm (struct sam4_bank_private *private, unsigned int gpnvm)
 Sets the selected GPNVM bit. More...
 
static int flashd_unlock (struct sam4_bank_private *private, unsigned int start_sector, unsigned int end_sector)
 Unlocks all the regions in the given address range. More...
 
static struct sam4_chipget_current_sam4 (struct command_invocation *cmd)
 
static struct sam4_bank_privateget_sam4_bank_private (struct flash_bank *bank)
 
static int sam4_auto_probe (struct flash_bank *bank)
 
static int sam4_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static void sam4_explain_chipid_cidr (struct sam4_chip *chip)
 
static void sam4_explain_ckgr_mcfr (struct sam4_chip *chip)
 
static void sam4_explain_ckgr_mor (struct sam4_chip *chip)
 
static void sam4_explain_ckgr_plla (struct sam4_chip *chip)
 
static void sam4_explain_mckr (struct sam4_chip *chip)
 
static void sam4_free_driver_priv (struct flash_bank *bank)
 Remove all chips from the internal list without distinguishing which one is owned by this bank. More...
 
static int sam4_get_details (struct sam4_bank_private *private)
 
static int sam4_get_info (struct sam4_chip *chip)
 
static const struct sam4_reg_listsam4_get_reg (struct sam4_chip *chip, uint32_t *goes_here)
 Given a pointer to where it goes in the structure, determine the register name, address from the all registers table. More...
 
static uint32_t * sam4_get_reg_ptr (struct sam4_cfg *cfg, const struct sam4_reg_list *list)
 
static int sam4_info (struct flash_bank *bank, struct command_invocation *cmd)
 
static int sam4_page_read (struct sam4_bank_private *private, unsigned int pagenum, uint8_t *buf)
 
static int sam4_page_write (struct sam4_bank_private *private, unsigned int pagenum, const uint8_t *buf)
 
static int sam4_probe (struct flash_bank *bank)
 
static int sam4_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int sam4_protect_check (struct flash_bank *bank)
 
static int sam4_read_all_regs (struct sam4_chip *chip)
 
static int sam4_read_this_reg (struct sam4_chip *chip, uint32_t *goes_here)
 
static uint32_t sam4_reg_fieldname (struct sam4_chip *chip, const char *regname, uint32_t value, unsigned int shift, unsigned int width)
 
static int sam4_set_wait (struct sam4_bank_private *private)
 
static int sam4_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 

Variables

static const char *const _rc_freq []
 
static const char _unknown [] = "unknown"
 
static struct sam4_chipall_sam4_chips
 
static const struct sam4_chip_details all_sam4_details []
 
static const struct archnames archnames []
 
static const struct command_registration at91sam4_command_handlers []
 
static const struct command_registration at91sam4_exec_command_handlers []
 
const struct flash_driver at91sam4_flash
 
static const char *const eproc_names []
 
static const char *const nvpsize []
 
static const char *const nvptype []
 
static const struct sam4_reg_list sam4_all_regs []
 
static const char *const sramsize []
 

Macro Definition Documentation

◆ AT91C_EFC_FCMD_CFB

#define AT91C_EFC_FCMD_CFB   (0xC) /* (EFC) Clear Fuse Bit */

Definition at line 55 of file at91sam4.c.

◆ AT91C_EFC_FCMD_CLB

#define AT91C_EFC_FCMD_CLB   (0x9) /* (EFC) Clear Lock Bit */

Definition at line 52 of file at91sam4.c.

◆ AT91C_EFC_FCMD_EA

#define AT91C_EFC_FCMD_EA   (0x5) /* (EFC) Erase All */

Definition at line 47 of file at91sam4.c.

◆ AT91C_EFC_FCMD_EPA

#define AT91C_EFC_FCMD_EPA   (0x7) /* (EFC) Erase pages */

Definition at line 50 of file at91sam4.c.

◆ AT91C_EFC_FCMD_EWP

#define AT91C_EFC_FCMD_EWP   (0x3) /* (EFC) Erase Page and Write Page */

Definition at line 45 of file at91sam4.c.

◆ AT91C_EFC_FCMD_EWPL

#define AT91C_EFC_FCMD_EWPL   (0x4) /* (EFC) Erase Page and Write Page then Lock */

Definition at line 46 of file at91sam4.c.

◆ AT91C_EFC_FCMD_GETD

#define AT91C_EFC_FCMD_GETD   (0x0) /* (EFC) Get Flash Descriptor */

Definition at line 42 of file at91sam4.c.

◆ AT91C_EFC_FCMD_GFB

#define AT91C_EFC_FCMD_GFB   (0xD) /* (EFC) Get Fuse Bit */

Definition at line 56 of file at91sam4.c.

◆ AT91C_EFC_FCMD_GLB

#define AT91C_EFC_FCMD_GLB   (0xA) /* (EFC) Get Lock Bit */

Definition at line 53 of file at91sam4.c.

◆ AT91C_EFC_FCMD_SFB

#define AT91C_EFC_FCMD_SFB   (0xB) /* (EFC) Set Fuse Bit */

Definition at line 54 of file at91sam4.c.

◆ AT91C_EFC_FCMD_SLB

#define AT91C_EFC_FCMD_SLB   (0x8) /* (EFC) Set Lock Bit */

Definition at line 51 of file at91sam4.c.

◆ AT91C_EFC_FCMD_SPUI

#define AT91C_EFC_FCMD_SPUI   (0xF) /* (EFC) Stop Read Unique ID */

Definition at line 58 of file at91sam4.c.

◆ AT91C_EFC_FCMD_STUI

#define AT91C_EFC_FCMD_STUI   (0xE) /* (EFC) Start Read Unique ID */

Definition at line 57 of file at91sam4.c.

◆ AT91C_EFC_FCMD_WP

#define AT91C_EFC_FCMD_WP   (0x1) /* (EFC) Write Page */

Definition at line 43 of file at91sam4.c.

◆ AT91C_EFC_FCMD_WPL

#define AT91C_EFC_FCMD_WPL   (0x2) /* (EFC) Write Page and Lock */

Definition at line 44 of file at91sam4.c.

◆ FLASH_BANK0_BASE_C32

#define FLASH_BANK0_BASE_C32   FLASH_BANK_BASE_C

Definition at line 39 of file at91sam4.c.

◆ FLASH_BANK0_BASE_SD

#define FLASH_BANK0_BASE_SD   FLASH_BANK_BASE_S

Definition at line 32 of file at91sam4.c.

◆ FLASH_BANK1_BASE_1024K_SD

#define FLASH_BANK1_BASE_1024K_SD   (FLASH_BANK0_BASE_SD+(1024*1024/2))

Definition at line 34 of file at91sam4.c.

◆ FLASH_BANK1_BASE_2048K_SD

#define FLASH_BANK1_BASE_2048K_SD   (FLASH_BANK0_BASE_SD+(2048*1024/2))

Definition at line 36 of file at91sam4.c.

◆ FLASH_BANK1_BASE_C32

#define FLASH_BANK1_BASE_C32   (FLASH_BANK_BASE_C+(2048*1024/2))

Definition at line 40 of file at91sam4.c.

◆ FLASH_BANK_BASE_C

#define FLASH_BANK_BASE_C   0x01000000

Definition at line 29 of file at91sam4.c.

◆ FLASH_BANK_BASE_S

#define FLASH_BANK_BASE_S   0x00400000

Definition at line 28 of file at91sam4.c.

◆ nvpsize2

#define nvpsize2   nvpsize /* these two tables are identical */

Definition at line 1954 of file at91sam4.c.

◆ OFFSET_EFC_FCR

#define OFFSET_EFC_FCR   4

Definition at line 61 of file at91sam4.c.

◆ OFFSET_EFC_FMR

#define OFFSET_EFC_FMR   0

Definition at line 60 of file at91sam4.c.

◆ OFFSET_EFC_FRR

#define OFFSET_EFC_FRR   12

Definition at line 63 of file at91sam4.c.

◆ OFFSET_EFC_FSR

#define OFFSET_EFC_FSR   8

Definition at line 62 of file at91sam4.c.

◆ REG_NAME_WIDTH

#define REG_NAME_WIDTH   (12)

Definition at line 25 of file at91sam4.c.

◆ SAM4_CHIPID_CIDR

#define SAM4_CHIPID_CIDR   (0x400E0740)

Definition at line 89 of file at91sam4.c.

◆ SAM4_CHIPID_EXID

#define SAM4_CHIPID_EXID   (0x400E0744)

Definition at line 91 of file at91sam4.c.

◆ SAM4_CKGR_MCFR

#define SAM4_CKGR_MCFR   (SAM4_PMC_BASE + 0x0024)

Definition at line 103 of file at91sam4.c.

◆ SAM4_CKGR_MOR

#define SAM4_CKGR_MOR   (SAM4_PMC_BASE + 0x0020)

Definition at line 101 of file at91sam4.c.

◆ SAM4_CKGR_PLLAR

#define SAM4_CKGR_PLLAR   (SAM4_PMC_BASE + 0x0028)

Definition at line 105 of file at91sam4.c.

◆ SAM4_CKGR_UCKR

#define SAM4_CKGR_UCKR   (SAM4_PMC_BASE + 0x001c)

Definition at line 99 of file at91sam4.c.

◆ SAM4_ENTRY

#define SAM4_ENTRY (   NAME,
  FUNC 
)
Value:
{ .address = SAM4_ ## NAME, .struct_offset = offsetof( \
struct sam4_cfg, \
NAME), # NAME, FUNC }

Definition at line 2305 of file at91sam4.c.

◆ SAM4_MAX_FLASH_BANKS

#define SAM4_MAX_FLASH_BANKS   2

Definition at line 165 of file at91sam4.c.

◆ SAM4_N_NVM_BITS

#define SAM4_N_NVM_BITS   3

Definition at line 160 of file at91sam4.c.

◆ SAM4_PMC_BASE

#define SAM4_PMC_BASE   (0x400E0400)

Definition at line 94 of file at91sam4.c.

◆ SAM4_PMC_FSMR

#define SAM4_PMC_FSMR   (SAM4_PMC_BASE + 0x0070)

Definition at line 119 of file at91sam4.c.

◆ SAM4_PMC_FSPR

#define SAM4_PMC_FSPR   (SAM4_PMC_BASE + 0x0074)

Definition at line 121 of file at91sam4.c.

◆ SAM4_PMC_IMR

#define SAM4_PMC_IMR   (SAM4_PMC_BASE + 0x006c)

Definition at line 117 of file at91sam4.c.

◆ SAM4_PMC_MCKR

#define SAM4_PMC_MCKR   (SAM4_PMC_BASE + 0x0030)

Definition at line 107 of file at91sam4.c.

◆ SAM4_PMC_PCK0

#define SAM4_PMC_PCK0   (SAM4_PMC_BASE + 0x0040)

Definition at line 109 of file at91sam4.c.

◆ SAM4_PMC_PCK1

#define SAM4_PMC_PCK1   (SAM4_PMC_BASE + 0x0044)

Definition at line 111 of file at91sam4.c.

◆ SAM4_PMC_PCK2

#define SAM4_PMC_PCK2   (SAM4_PMC_BASE + 0x0048)

Definition at line 113 of file at91sam4.c.

◆ SAM4_PMC_PCSR

#define SAM4_PMC_PCSR   (SAM4_PMC_BASE + 0x0018)

Definition at line 97 of file at91sam4.c.

◆ SAM4_PMC_SCSR

#define SAM4_PMC_SCSR   (SAM4_PMC_BASE + 0x0008)

Definition at line 95 of file at91sam4.c.

◆ SAM4_PMC_SR

#define SAM4_PMC_SR   (SAM4_PMC_BASE + 0x0068)

Definition at line 115 of file at91sam4.c.

Function Documentation

◆ _tomhz()

static float _tomhz ( uint32_t  freq_hz)
static

◆ _yes_or_no()

static const char* _yes_or_no ( uint32_t  v)
static

◆ COMMAND_HANDLER() [1/3]

◆ COMMAND_HANDLER() [2/3]

◆ COMMAND_HANDLER() [3/3]

COMMAND_HANDLER ( sam4_handle_slowclk_command  )

Definition at line 3183 of file at91sam4.c.

◆ efc_get_result()

static int efc_get_result ( struct sam4_bank_private private,
uint32_t *  v 
)
static

Get the result of the last executed command.

Parameters
private- info about the bank
v- result goes here

Definition at line 1468 of file at91sam4.c.

References LOG_DEBUG, OFFSET_EFC_FRR, and target_read_u32().

Referenced by flashd_get_gpnvm(), and flashd_get_lock_bits().

◆ efc_get_status()

static int efc_get_status ( struct sam4_bank_private private,
uint32_t *  v 
)
static

Get the current status of the EEFC and the value of some status bits (LOCKE, PROGE).

Parameters
private- info about the bank
v- result goes here

Definition at line 1448 of file at91sam4.c.

References LOG_DEBUG, OFFSET_EFC_FSR, and target_read_u32().

Referenced by efc_perform_command(), and efc_start_command().

◆ efc_perform_command()

static int efc_perform_command ( struct sam4_bank_private private,
unsigned int  command,
unsigned int  argument,
uint32_t *  status 
)
static

Performs the given command and wait until its completion (or an error).

Parameters
private- info about the bank
command- Command to perform.
argument- Optional command argument.
status- put command status bits here

Definition at line 1576 of file at91sam4.c.

References efc_get_status(), efc_start_command(), ERROR_FAIL, ERROR_OK, LOG_ERROR, status, and timeval_ms().

Referenced by flashd_clr_gpnvm(), flashd_erase_entire_bank(), flashd_erase_pages(), flashd_get_gpnvm(), flashd_get_lock_bits(), flashd_lock(), flashd_read_uid(), flashd_set_gpnvm(), flashd_unlock(), and sam4_page_write().

◆ efc_start_command()

◆ FLASH_BANK_COMMAND_HANDLER()

◆ flashd_clr_gpnvm()

static int flashd_clr_gpnvm ( struct sam4_bank_private private,
unsigned int  gpnvm 
)
static

Clears the selected GPNVM bit.

Parameters
privateinfo about the bank
gpnvmGPNVM index.
Returns
0 if successful; otherwise returns an error code.

Definition at line 1760 of file at91sam4.c.

References AT91C_EFC_FCMD_CFB, efc_perform_command(), ERROR_FAIL, ERROR_OK, flashd_get_gpnvm(), sam4_chip_details::gpnvm, LOG_DEBUG, LOG_ERROR, and NULL.

Referenced by COMMAND_HANDLER().

◆ flashd_erase_entire_bank()

static int flashd_erase_entire_bank ( struct sam4_bank_private private)
static

Erases the entire flash.

Parameters
private- the info about the bank.

Definition at line 1660 of file at91sam4.c.

References AT91C_EFC_FCMD_EA, efc_perform_command(), LOG_DEBUG, and NULL.

Referenced by sam4_erase().

◆ flashd_erase_pages()

static int flashd_erase_pages ( struct sam4_bank_private private,
int  first_page,
int  num_pages,
uint32_t *  status 
)
static

Erases the entire flash.

Parameters
private- the info about the bank.
first_page
num_pages
status

Definition at line 1673 of file at91sam4.c.

References AT91C_EFC_FCMD_EPA, efc_perform_command(), LOG_DEBUG, and status.

Referenced by sam4_erase().

◆ flashd_get_gpnvm()

static int flashd_get_gpnvm ( struct sam4_bank_private private,
unsigned int  gpnvm,
unsigned int *  puthere 
)
static

Gets current GPNVM state.

Parameters
private- info about the bank.
gpnvm- GPNVM bit index.
puthere- result stored here.

Definition at line 1719 of file at91sam4.c.

References AT91C_EFC_FCMD_GFB, efc_get_result(), efc_perform_command(), ERROR_FAIL, ERROR_OK, sam4_chip_details::gpnvm, LOG_DEBUG, LOG_ERROR, and NULL.

Referenced by COMMAND_HANDLER(), flashd_clr_gpnvm(), and flashd_set_gpnvm().

◆ flashd_get_lock_bits()

static int flashd_get_lock_bits ( struct sam4_bank_private private,
uint32_t *  v 
)
static

Returns a bit field (at most 64) of locked regions within a page.

Parameters
privateinfo about the bank
vwhere to store locked bits

Definition at line 1826 of file at91sam4.c.

References AT91C_EFC_FCMD_GLB, efc_get_result(), efc_perform_command(), ERROR_OK, LOG_DEBUG, and NULL.

Referenced by sam4_protect_check().

◆ flashd_lock()

static int flashd_lock ( struct sam4_bank_private private,
unsigned int  start_sector,
unsigned int  end_sector 
)
static

Locks regions.

Parameters
private- info about the bank
start_sector- first sector to lock
end_sector- last sector (inclusive) to lock

Definition at line 1878 of file at91sam4.c.

References AT91C_EFC_FCMD_SLB, efc_perform_command(), ERROR_OK, and status.

Referenced by sam4_protect().

◆ flashd_read_uid()

static int flashd_read_uid ( struct sam4_bank_private private)
static

Read the unique ID.

Parameters
private- info about the bank The unique ID is stored in the 'private' structure.

Definition at line 1620 of file at91sam4.c.

References AT91C_EFC_FCMD_SPUI, AT91C_EFC_FCMD_STUI, efc_perform_command(), efc_start_command(), LOG_DEBUG, NULL, and target_read_u32().

Referenced by sam4_probe().

◆ flashd_set_gpnvm()

static int flashd_set_gpnvm ( struct sam4_bank_private private,
unsigned int  gpnvm 
)
static

Sets the selected GPNVM bit.

Parameters
privateinfo about the bank
gpnvmGPNVM index.

Definition at line 1792 of file at91sam4.c.

References AT91C_EFC_FCMD_SFB, efc_perform_command(), ERROR_FAIL, ERROR_OK, flashd_get_gpnvm(), sam4_chip_details::gpnvm, LOG_ERROR, and NULL.

Referenced by COMMAND_HANDLER().

◆ flashd_unlock()

static int flashd_unlock ( struct sam4_bank_private private,
unsigned int  start_sector,
unsigned int  end_sector 
)
static

Unlocks all the regions in the given address range.

Parameters
privateinfo about the bank
start_sectorfirst sector to unlock
end_sectorlast (inclusive) to unlock

Definition at line 1848 of file at91sam4.c.

References AT91C_EFC_FCMD_CLB, efc_perform_command(), ERROR_OK, and status.

Referenced by sam4_protect().

◆ get_current_sam4()

static struct sam4_chip* get_current_sam4 ( struct command_invocation cmd)
static

Definition at line 188 of file at91sam4.c.

Referenced by COMMAND_HANDLER().

◆ get_sam4_bank_private()

static struct sam4_bank_private* get_sam4_bank_private ( struct flash_bank bank)
static

◆ sam4_auto_probe()

static int sam4_auto_probe ( struct flash_bank bank)
static

Definition at line 2709 of file at91sam4.c.

References bank, ERROR_OK, get_sam4_bank_private(), and sam4_probe().

Referenced by COMMAND_HANDLER(), and sam4_erase().

◆ sam4_erase()

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

◆ sam4_explain_chipid_cidr()

static void sam4_explain_chipid_cidr ( struct sam4_chip chip)
static

◆ sam4_explain_ckgr_mcfr()

static void sam4_explain_ckgr_mcfr ( struct sam4_chip chip)
static

◆ sam4_explain_ckgr_mor()

static void sam4_explain_ckgr_mor ( struct sam4_chip chip)
static

◆ sam4_explain_ckgr_plla()

static void sam4_explain_ckgr_plla ( struct sam4_chip chip)
static

◆ sam4_explain_mckr()

◆ sam4_free_driver_priv()

static void sam4_free_driver_priv ( struct flash_bank bank)
static

Remove all chips from the internal list without distinguishing which one is owned by this bank.

This simplification works only for one shot deallocation like current flash_free_all_banks()

Definition at line 2544 of file at91sam4.c.

References all_sam4_chips, sam4_chip::next, and NULL.

◆ sam4_get_details()

◆ sam4_get_info()

◆ sam4_get_reg()

static const struct sam4_reg_list* sam4_get_reg ( struct sam4_chip chip,
uint32_t *  goes_here 
)
static

Given a pointer to where it goes in the structure, determine the register name, address from the all registers table.

Definition at line 2339 of file at91sam4.c.

References sam4_chip::cfg, LOG_ERROR, reg::name, NULL, and sam4_all_regs.

Referenced by sam4_read_this_reg().

◆ sam4_get_reg_ptr()

static uint32_t* sam4_get_reg_ptr ( struct sam4_cfg cfg,
const struct sam4_reg_list list 
)
static

Definition at line 2292 of file at91sam4.c.

Referenced by sam4_get_info(), and sam4_read_all_regs().

◆ sam4_info()

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

◆ sam4_page_read()

static int sam4_page_read ( struct sam4_bank_private private,
unsigned int  pagenum,
uint8_t *  buf 
)
static

Definition at line 2799 of file at91sam4.c.

References ERROR_OK, LOG_ERROR, and target_read_memory().

Referenced by sam4_write().

◆ sam4_page_write()

static int sam4_page_write ( struct sam4_bank_private private,
unsigned int  pagenum,
const uint8_t *  buf 
)
static

◆ sam4_probe()

◆ sam4_protect()

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

◆ sam4_protect_check()

static int sam4_protect_check ( struct flash_bank bank)
static

◆ sam4_read_all_regs()

static int sam4_read_all_regs ( struct sam4_chip chip)
static

◆ sam4_read_this_reg()

static int sam4_read_this_reg ( struct sam4_chip chip,
uint32_t *  goes_here 
)
static

◆ sam4_reg_fieldname()

static uint32_t sam4_reg_fieldname ( struct sam4_chip chip,
const char *  regname,
uint32_t  value,
unsigned int  shift,
unsigned int  width 
)
static

◆ sam4_set_wait()

static int sam4_set_wait ( struct sam4_bank_private private)
static

Definition at line 2818 of file at91sam4.c.

References ERROR_OK, LOG_DEBUG, LOG_ERROR, target_read_u32(), and target_write_u32().

Referenced by sam4_write().

◆ sam4_write()

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

Variable Documentation

◆ _rc_freq

const char* const _rc_freq[]
static
Initial value:
= {
"4 MHz", "8 MHz", "12 MHz", "reserved"
}

Definition at line 2062 of file at91sam4.c.

Referenced by sam4_explain_ckgr_mor().

◆ _unknown

const char _unknown[] = "unknown"
static

Definition at line 1934 of file at91sam4.c.

Referenced by sam4_explain_chipid_cidr().

◆ all_sam4_chips

struct sam4_chip* all_sam4_chips
static

Definition at line 186 of file at91sam4.c.

Referenced by FLASH_BANK_COMMAND_HANDLER(), and sam4_free_driver_priv().

◆ all_sam4_details

const struct sam4_chip_details all_sam4_details[]
static

Definition at line 188 of file at91sam4.c.

Referenced by sam4_get_details().

◆ archnames

const struct archnames archnames[]
static

◆ at91sam4_command_handlers

const struct command_registration at91sam4_command_handlers[]
static
Initial value:
= {
{
.name = "at91sam4",
.mode = COMMAND_ANY,
.help = "at91sam4 flash command group",
.usage = "",
},
}
static const struct command_registration at91sam4_exec_command_handlers[]
Definition: at91sam4.c:3219
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_ANY
Definition: command.h:42

Definition at line 3183 of file at91sam4.c.

◆ at91sam4_exec_command_handlers

const struct command_registration at91sam4_exec_command_handlers[]
static
Initial value:
= {
{
.name = "gpnvm",
.handler = sam4_handle_gpnvm_command,
.mode = COMMAND_EXEC,
.usage = "[('clr'|'set'|'show') bitnum]",
.help = "Without arguments, shows all bits in the gpnvm "
"register. Otherwise, clears, sets, or shows one "
"General Purpose Non-Volatile Memory (gpnvm) bit.",
},
{
.name = "info",
.handler = sam4_handle_info_command,
.mode = COMMAND_EXEC,
.help = "Print information about the current at91sam4 chip "
"and its flash configuration.",
.usage = "",
},
{
.name = "slowclk",
.handler = sam4_handle_slowclk_command,
.mode = COMMAND_EXEC,
.usage = "[clock_hz]",
.help = "Display or set the slowclock frequency "
"(default 32768 Hz).",
},
}
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 3183 of file at91sam4.c.

◆ at91sam4_flash

const struct flash_driver at91sam4_flash
Initial value:
= {
.name = "at91sam4",
.flash_bank_command = sam4_flash_bank_command,
.erase = sam4_erase,
.protect = sam4_protect,
.write = sam4_write,
.probe = sam4_probe,
.auto_probe = sam4_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = sam4_protect_check,
.info = sam4_info,
.free_driver_priv = sam4_free_driver_priv,
}
static int sam4_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: at91sam4.c:2888
static int sam4_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: at91sam4.c:2616
static int sam4_auto_probe(struct flash_bank *bank)
Definition: at91sam4.c:2709
static int sam4_protect_check(struct flash_bank *bank)
Definition: at91sam4.c:2443
static const struct command_registration at91sam4_command_handlers[]
Definition: at91sam4.c:3247
static void sam4_free_driver_priv(struct flash_bank *bank)
Remove all chips from the internal list without distinguishing which one is owned by this bank.
Definition: at91sam4.c:2544
static int sam4_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: at91sam4.c:2773
static int sam4_probe(struct flash_bank *bank)
Definition: at91sam4.c:2634
static int sam4_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: at91sam4.c:2720
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.

Definition at line 3183 of file at91sam4.c.

Referenced by COMMAND_HANDLER().

◆ eproc_names

const char* const eproc_names[]
static
Initial value:
= {
"Cortex-M7",
"arm946es",
"arm7tdmi",
"Cortex-M3",
"arm920t",
"arm926ejs",
"Cortex-A5",
"Cortex-M4",
}
static const char _unknown[]
Definition: at91sam4.c:1934

Definition at line 1935 of file at91sam4.c.

Referenced by sam4_explain_chipid_cidr().

◆ nvpsize

const char* const nvpsize[]
static
Initial value:
= {
"none",
"8K bytes",
"16K bytes",
"32K bytes",
"64K bytes",
"128K bytes",
"160K bytes",
"256K bytes",
"512K bytes",
"1024K bytes",
"2048K bytes",
}

Definition at line 1955 of file at91sam4.c.

Referenced by sam4_explain_chipid_cidr().

◆ nvptype

const char* const nvptype[]
static
Initial value:
= {
"rom",
"romless or onchip flash",
"embedded flash memory",
"rom(nvpsiz) + embedded flash (nvpsiz2)",
"sram emulating flash",
}

Definition at line 2043 of file at91sam4.c.

Referenced by sam4_explain_chipid_cidr().

◆ sam4_all_regs

const struct sam4_reg_list sam4_all_regs[]
static
Initial value:
= {
SAM4_ENTRY(CKGR_UCKR, NULL),
SAM4_ENTRY(PMC_FSMR, NULL),
SAM4_ENTRY(PMC_FSPR, NULL),
SAM4_ENTRY(PMC_IMR, NULL),
SAM4_ENTRY(PMC_PCK0, NULL),
SAM4_ENTRY(PMC_PCK1, NULL),
SAM4_ENTRY(PMC_PCK2, NULL),
SAM4_ENTRY(PMC_PCSR, NULL),
SAM4_ENTRY(PMC_SCSR, NULL),
SAM4_ENTRY(PMC_SR, NULL),
SAM4_ENTRY(CHIPID_EXID, NULL),
{ .name = NULL }
}
static void sam4_explain_chipid_cidr(struct sam4_chip *chip)
Definition: at91sam4.c:2110
static void sam4_explain_ckgr_plla(struct sam4_chip *chip)
Definition: at91sam4.c:2167
static void sam4_explain_ckgr_mor(struct sam4_chip *chip)
Definition: at91sam4.c:2066
#define SAM4_ENTRY(NAME, FUNC)
Definition: at91sam4.c:2305
static void sam4_explain_mckr(struct sam4_chip *chip)
Definition: at91sam4.c:2187
static void sam4_explain_ckgr_mcfr(struct sam4_chip *chip)
Definition: at91sam4.c:2149
#define CKGR_MOR
Definition: at91sam7.c:45
#define PMC_MCKR
Definition: at91sam7.c:50
#define CKGR_MCFR
Definition: at91sam7.c:44
#define NULL
Definition: usb.h:16

Definition at line 2292 of file at91sam4.c.

Referenced by sam4_get_info(), sam4_get_reg(), and sam4_read_all_regs().

◆ sramsize

const char* const sramsize[]
static
Initial value:
= {
"48K Bytes",
"1K Bytes",
"2K Bytes",
"6K Bytes",
"112K Bytes",
"4K Bytes",
"80K Bytes",
"160K Bytes",
"8K Bytes",
"16K Bytes",
"32K Bytes",
"64K Bytes",
"128K Bytes",
"256K Bytes",
"96K Bytes",
"512K Bytes",
}

Definition at line 1974 of file at91sam4.c.

Referenced by sam4_explain_chipid_cidr().