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

Go to the source code of this file.

Data Structures

struct  archnames
 
struct  sam3_bank_private
 
struct  sam3_cfg
 
struct  sam3_chip
 
struct  sam3_chip_details
 
struct  sam3_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_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_AX   0x00080000
 
#define FLASH_BANK0_BASE_SD   FLASH_BANK_BASE_S
 
#define FLASH_BANK0_BASE_U   0x00080000
 
#define FLASH_BANK1_BASE_256K_AX   0x000A0000
 
#define FLASH_BANK1_BASE_512K_AX   0x000C0000
 
#define FLASH_BANK1_BASE_512K_SD   (FLASH_BANK0_BASE_SD+(512*1024/2))
 
#define FLASH_BANK1_BASE_U   0x00100000
 
#define FLASH_BANK_BASE_N   0x00400000
 
#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 SAM3_CHIPID_CIDR   (0x400E0740)
 
#define SAM3_CHIPID_CIDR2   (0x400E0940) /*SAM3X and SAM3A cidr at this address*/
 
#define SAM3_CHIPID_EXID   (0x400E0744)
 
#define SAM3_CHIPID_EXID2   (0x400E0944) /*SAM3X and SAM3A cidr at this address*/
 
#define SAM3_CKGR_MCFR   (SAM3_PMC_BASE + 0x0024)
 
#define SAM3_CKGR_MOR   (SAM3_PMC_BASE + 0x0020)
 
#define SAM3_CKGR_PLLAR   (SAM3_PMC_BASE + 0x0028)
 
#define SAM3_CKGR_UCKR   (SAM3_PMC_BASE + 0x001c)
 
#define SAM3_ENTRY(NAME, FUNC)
 
#define SAM3_MAX_FLASH_BANKS   2
 
#define SAM3_N_NVM_BITS   3
 
#define SAM3_PMC_BASE   (0x400E0400)
 
#define SAM3_PMC_FSMR   (SAM3_PMC_BASE + 0x0070)
 
#define SAM3_PMC_FSPR   (SAM3_PMC_BASE + 0x0074)
 
#define SAM3_PMC_IMR   (SAM3_PMC_BASE + 0x006c)
 
#define SAM3_PMC_MCKR   (SAM3_PMC_BASE + 0x0030)
 
#define SAM3_PMC_PCK0   (SAM3_PMC_BASE + 0x0040)
 
#define SAM3_PMC_PCK1   (SAM3_PMC_BASE + 0x0044)
 
#define SAM3_PMC_PCK2   (SAM3_PMC_BASE + 0x0048)
 
#define SAM3_PMC_PCSR   (SAM3_PMC_BASE + 0x0018)
 
#define SAM3_PMC_SCSR   (SAM3_PMC_BASE + 0x0008)
 
#define SAM3_PMC_SR   (SAM3_PMC_BASE + 0x0068)
 

Functions

static int _sam3_probe (struct flash_bank *bank, int noise)
 
static float _tomhz (uint32_t freq_hz)
 
static const char * _yes_or_no (uint32_t v)
 
 COMMAND_HANDLER (sam3_handle_gpnvm_command)
 
 COMMAND_HANDLER (sam3_handle_info_command)
 
 COMMAND_HANDLER (sam3_handle_slowclk_command)
 
static int efc_get_result (struct sam3_bank_private *private, uint32_t *v)
 Get the result of the last executed command. More...
 
static int efc_get_status (struct sam3_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 sam3_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 sam3_bank_private *private, unsigned int command, unsigned int argument)
 
 FLASH_BANK_COMMAND_HANDLER (sam3_flash_bank_command)
 
static int flashd_clr_gpnvm (struct sam3_bank_private *private, unsigned int gpnvm)
 Clears the selected GPNVM bit. More...
 
static int flashd_erase_entire_bank (struct sam3_bank_private *private)
 Erases the entire flash. More...
 
static int flashd_get_gpnvm (struct sam3_bank_private *private, unsigned int gpnvm, unsigned int *puthere)
 Gets current GPNVM state. More...
 
static int flashd_get_lock_bits (struct sam3_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 sam3_bank_private *private, unsigned int start_sector, unsigned int end_sector)
 Locks regions. More...
 
static int flashd_read_uid (struct sam3_bank_private *private)
 Read the unique ID. More...
 
static int flashd_set_gpnvm (struct sam3_bank_private *private, unsigned int gpnvm)
 Sets the selected GPNVM bit. More...
 
static int flashd_unlock (struct sam3_bank_private *private, unsigned int start_sector, unsigned int end_sector)
 Unlocks all the regions in the given address range. More...
 
static struct sam3_chipget_current_sam3 (struct command_invocation *cmd)
 
static struct sam3_bank_privateget_sam3_bank_private (struct flash_bank *bank)
 
static int sam3_auto_probe (struct flash_bank *bank)
 
static int sam3_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static void sam3_explain_chipid_cidr (struct sam3_chip *chip)
 
static void sam3_explain_ckgr_mcfr (struct sam3_chip *chip)
 
static void sam3_explain_ckgr_mor (struct sam3_chip *chip)
 
static void sam3_explain_ckgr_plla (struct sam3_chip *chip)
 
static void sam3_explain_mckr (struct sam3_chip *chip)
 
static void sam3_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 sam3_get_details (struct sam3_bank_private *private)
 
static int sam3_get_info (struct sam3_chip *chip)
 
static const struct sam3_reg_listsam3_get_reg (struct sam3_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 * sam3_get_reg_ptr (struct sam3_cfg *cfg, const struct sam3_reg_list *list)
 
static int sam3_page_read (struct sam3_bank_private *private, unsigned int pagenum, uint8_t *buf)
 
static int sam3_page_write (struct sam3_bank_private *private, unsigned int pagenum, const uint8_t *buf)
 
static int sam3_probe (struct flash_bank *bank)
 
static int sam3_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int sam3_protect_check (struct flash_bank *bank)
 
static int sam3_read_all_regs (struct sam3_chip *chip)
 
static int sam3_read_this_reg (struct sam3_chip *chip, uint32_t *goes_here)
 
static uint32_t sam3_reg_fieldname (struct sam3_chip *chip, const char *regname, uint32_t value, unsigned int shift, unsigned int width)
 
static int sam3_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 sam3_chipall_sam3_chips
 
static const struct sam3_chip_details all_sam3_details []
 
static const struct archnames archnames []
 
static const struct command_registration at91sam3_command_handlers []
 
static const struct command_registration at91sam3_exec_command_handlers []
 
const struct flash_driver at91sam3_flash
 
static const char *const eproc_names []
 
static const char *const nvpsize []
 
static const char *const nvptype []
 
static const struct sam3_reg_list sam3_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 60 of file at91sam3.c.

◆ AT91C_EFC_FCMD_CLB

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

Definition at line 57 of file at91sam3.c.

◆ AT91C_EFC_FCMD_EA

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

Definition at line 51 of file at91sam3.c.

◆ AT91C_EFC_FCMD_EWP

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

Definition at line 49 of file at91sam3.c.

◆ AT91C_EFC_FCMD_EWPL

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

Definition at line 50 of file at91sam3.c.

◆ AT91C_EFC_FCMD_GETD

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

Definition at line 46 of file at91sam3.c.

◆ AT91C_EFC_FCMD_GFB

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

Definition at line 61 of file at91sam3.c.

◆ AT91C_EFC_FCMD_GLB

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

Definition at line 58 of file at91sam3.c.

◆ AT91C_EFC_FCMD_SFB

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

Definition at line 59 of file at91sam3.c.

◆ AT91C_EFC_FCMD_SLB

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

Definition at line 56 of file at91sam3.c.

◆ AT91C_EFC_FCMD_SPUI

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

Definition at line 63 of file at91sam3.c.

◆ AT91C_EFC_FCMD_STUI

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

Definition at line 62 of file at91sam3.c.

◆ AT91C_EFC_FCMD_WP

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

Definition at line 47 of file at91sam3.c.

◆ AT91C_EFC_FCMD_WPL

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

Definition at line 48 of file at91sam3.c.

◆ FLASH_BANK0_BASE_AX

#define FLASH_BANK0_BASE_AX   0x00080000

Definition at line 41 of file at91sam3.c.

◆ FLASH_BANK0_BASE_SD

#define FLASH_BANK0_BASE_SD   FLASH_BANK_BASE_S

Definition at line 33 of file at91sam3.c.

◆ FLASH_BANK0_BASE_U

#define FLASH_BANK0_BASE_U   0x00080000

Definition at line 26 of file at91sam3.c.

◆ FLASH_BANK1_BASE_256K_AX

#define FLASH_BANK1_BASE_256K_AX   0x000A0000

Definition at line 43 of file at91sam3.c.

◆ FLASH_BANK1_BASE_512K_AX

#define FLASH_BANK1_BASE_512K_AX   0x000C0000

Definition at line 44 of file at91sam3.c.

◆ FLASH_BANK1_BASE_512K_SD

#define FLASH_BANK1_BASE_512K_SD   (FLASH_BANK0_BASE_SD+(512*1024/2))

Definition at line 34 of file at91sam3.c.

◆ FLASH_BANK1_BASE_U

#define FLASH_BANK1_BASE_U   0x00100000

Definition at line 27 of file at91sam3.c.

◆ FLASH_BANK_BASE_N

#define FLASH_BANK_BASE_N   0x00400000

Definition at line 38 of file at91sam3.c.

◆ FLASH_BANK_BASE_S

#define FLASH_BANK_BASE_S   0x00400000

Definition at line 30 of file at91sam3.c.

◆ nvpsize2

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

Definition at line 2454 of file at91sam3.c.

◆ OFFSET_EFC_FCR

#define OFFSET_EFC_FCR   4

Definition at line 66 of file at91sam3.c.

◆ OFFSET_EFC_FMR

#define OFFSET_EFC_FMR   0

Definition at line 65 of file at91sam3.c.

◆ OFFSET_EFC_FRR

#define OFFSET_EFC_FRR   12

Definition at line 68 of file at91sam3.c.

◆ OFFSET_EFC_FSR

#define OFFSET_EFC_FSR   8

Definition at line 67 of file at91sam3.c.

◆ REG_NAME_WIDTH

#define REG_NAME_WIDTH   (12)

Definition at line 23 of file at91sam3.c.

◆ SAM3_CHIPID_CIDR

#define SAM3_CHIPID_CIDR   (0x400E0740)

Definition at line 94 of file at91sam3.c.

◆ SAM3_CHIPID_CIDR2

#define SAM3_CHIPID_CIDR2   (0x400E0940) /*SAM3X and SAM3A cidr at this address*/

Definition at line 96 of file at91sam3.c.

◆ SAM3_CHIPID_EXID

#define SAM3_CHIPID_EXID   (0x400E0744)

Definition at line 98 of file at91sam3.c.

◆ SAM3_CHIPID_EXID2

#define SAM3_CHIPID_EXID2   (0x400E0944) /*SAM3X and SAM3A cidr at this address*/

Definition at line 100 of file at91sam3.c.

◆ SAM3_CKGR_MCFR

#define SAM3_CKGR_MCFR   (SAM3_PMC_BASE + 0x0024)

Definition at line 113 of file at91sam3.c.

◆ SAM3_CKGR_MOR

#define SAM3_CKGR_MOR   (SAM3_PMC_BASE + 0x0020)

Definition at line 111 of file at91sam3.c.

◆ SAM3_CKGR_PLLAR

#define SAM3_CKGR_PLLAR   (SAM3_PMC_BASE + 0x0028)

Definition at line 115 of file at91sam3.c.

◆ SAM3_CKGR_UCKR

#define SAM3_CKGR_UCKR   (SAM3_PMC_BASE + 0x001c)

Definition at line 109 of file at91sam3.c.

◆ SAM3_ENTRY

#define SAM3_ENTRY (   NAME,
  FUNC 
)
Value:
{ .address = SAM3_ ## NAME, .struct_offset = offsetof( \
struct sam3_cfg, \
NAME), # NAME, FUNC }

Definition at line 2796 of file at91sam3.c.

◆ SAM3_MAX_FLASH_BANKS

#define SAM3_MAX_FLASH_BANKS   2

Definition at line 185 of file at91sam3.c.

◆ SAM3_N_NVM_BITS

#define SAM3_N_NVM_BITS   3

Definition at line 180 of file at91sam3.c.

◆ SAM3_PMC_BASE

#define SAM3_PMC_BASE   (0x400E0400)

Definition at line 104 of file at91sam3.c.

◆ SAM3_PMC_FSMR

#define SAM3_PMC_FSMR   (SAM3_PMC_BASE + 0x0070)

Definition at line 129 of file at91sam3.c.

◆ SAM3_PMC_FSPR

#define SAM3_PMC_FSPR   (SAM3_PMC_BASE + 0x0074)

Definition at line 131 of file at91sam3.c.

◆ SAM3_PMC_IMR

#define SAM3_PMC_IMR   (SAM3_PMC_BASE + 0x006c)

Definition at line 127 of file at91sam3.c.

◆ SAM3_PMC_MCKR

#define SAM3_PMC_MCKR   (SAM3_PMC_BASE + 0x0030)

Definition at line 117 of file at91sam3.c.

◆ SAM3_PMC_PCK0

#define SAM3_PMC_PCK0   (SAM3_PMC_BASE + 0x0040)

Definition at line 119 of file at91sam3.c.

◆ SAM3_PMC_PCK1

#define SAM3_PMC_PCK1   (SAM3_PMC_BASE + 0x0044)

Definition at line 121 of file at91sam3.c.

◆ SAM3_PMC_PCK2

#define SAM3_PMC_PCK2   (SAM3_PMC_BASE + 0x0048)

Definition at line 123 of file at91sam3.c.

◆ SAM3_PMC_PCSR

#define SAM3_PMC_PCSR   (SAM3_PMC_BASE + 0x0018)

Definition at line 107 of file at91sam3.c.

◆ SAM3_PMC_SCSR

#define SAM3_PMC_SCSR   (SAM3_PMC_BASE + 0x0008)

Definition at line 105 of file at91sam3.c.

◆ SAM3_PMC_SR

#define SAM3_PMC_SR   (SAM3_PMC_BASE + 0x0068)

Definition at line 125 of file at91sam3.c.

Function Documentation

◆ _sam3_probe()

◆ _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 ( sam3_handle_slowclk_command  )

Definition at line 3635 of file at91sam3.c.

◆ efc_get_result()

static int efc_get_result ( struct sam3_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 2018 of file at91sam3.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 sam3_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 1998 of file at91sam3.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 sam3_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 2126 of file at91sam3.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_get_gpnvm(), flashd_get_lock_bits(), flashd_lock(), flashd_read_uid(), flashd_set_gpnvm(), flashd_unlock(), and sam3_page_write().

◆ efc_start_command()

◆ FLASH_BANK_COMMAND_HANDLER()

◆ flashd_clr_gpnvm()

static int flashd_clr_gpnvm ( struct sam3_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 2264 of file at91sam3.c.

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

Referenced by COMMAND_HANDLER().

◆ flashd_erase_entire_bank()

static int flashd_erase_entire_bank ( struct sam3_bank_private private)
static

Erases the entire flash.

Parameters
private- the info about the bank.

Definition at line 2210 of file at91sam3.c.

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

Referenced by sam3_erase().

◆ flashd_get_gpnvm()

static int flashd_get_gpnvm ( struct sam3_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 2223 of file at91sam3.c.

References AT91C_EFC_FCMD_GFB, efc_get_result(), efc_perform_command(), ERROR_FAIL, ERROR_OK, sam3_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 sam3_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 2330 of file at91sam3.c.

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

Referenced by sam3_protect_check().

◆ flashd_lock()

static int flashd_lock ( struct sam3_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 2378 of file at91sam3.c.

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

Referenced by sam3_protect().

◆ flashd_read_uid()

static int flashd_read_uid ( struct sam3_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 2170 of file at91sam3.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 _sam3_probe().

◆ flashd_set_gpnvm()

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

Sets the selected GPNVM bit.

Parameters
privateinfo about the bank
gpnvmGPNVM index.

Definition at line 2296 of file at91sam3.c.

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

Referenced by COMMAND_HANDLER().

◆ flashd_unlock()

static int flashd_unlock ( struct sam3_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 2348 of file at91sam3.c.

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

Referenced by sam3_protect().

◆ get_current_sam3()

static struct sam3_chip* get_current_sam3 ( struct command_invocation cmd)
static

Definition at line 208 of file at91sam3.c.

Referenced by COMMAND_HANDLER().

◆ get_sam3_bank_private()

static struct sam3_bank_private* get_sam3_bank_private ( struct flash_bank bank)
static

Definition at line 2823 of file at91sam3.c.

References bank.

Referenced by _sam3_probe(), sam3_erase(), sam3_protect(), sam3_protect_check(), and sam3_write().

◆ sam3_auto_probe()

static int sam3_auto_probe ( struct flash_bank bank)
static

Definition at line 3205 of file at91sam3.c.

References _sam3_probe(), and bank.

Referenced by COMMAND_HANDLER(), and sam3_erase().

◆ sam3_erase()

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

◆ sam3_explain_chipid_cidr()

static void sam3_explain_chipid_cidr ( struct sam3_chip chip)
static

◆ sam3_explain_ckgr_mcfr()

static void sam3_explain_ckgr_mcfr ( struct sam3_chip chip)
static

◆ sam3_explain_ckgr_mor()

static void sam3_explain_ckgr_mor ( struct sam3_chip chip)
static

◆ sam3_explain_ckgr_plla()

static void sam3_explain_ckgr_plla ( struct sam3_chip chip)
static

◆ sam3_explain_mckr()

◆ sam3_free_driver_priv()

static void sam3_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 3058 of file at91sam3.c.

References all_sam3_chips, sam3_chip::next, and NULL.

◆ sam3_get_details()

◆ sam3_get_info()

◆ sam3_get_reg()

static const struct sam3_reg_list* sam3_get_reg ( struct sam3_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 2832 of file at91sam3.c.

References sam3_chip::cfg, LOG_ERROR, reg::name, NULL, and sam3_all_regs.

Referenced by sam3_read_this_reg().

◆ sam3_get_reg_ptr()

static uint32_t* sam3_get_reg_ptr ( struct sam3_cfg cfg,
const struct sam3_reg_list list 
)
static

Definition at line 2783 of file at91sam3.c.

Referenced by sam3_get_info(), and sam3_read_all_regs().

◆ sam3_page_read()

static int sam3_page_read ( struct sam3_bank_private private,
unsigned int  pagenum,
uint8_t *  buf 
)
static

Definition at line 3267 of file at91sam3.c.

References ERROR_OK, LOG_ERROR, and target_read_memory().

Referenced by sam3_write().

◆ sam3_page_write()

static int sam3_page_write ( struct sam3_bank_private private,
unsigned int  pagenum,
const uint8_t *  buf 
)
static

◆ sam3_probe()

static int sam3_probe ( struct flash_bank bank)
static

Definition at line 3200 of file at91sam3.c.

References _sam3_probe(), and bank.

◆ sam3_protect()

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

◆ sam3_protect_check()

static int sam3_protect_check ( struct flash_bank bank)
static

◆ sam3_read_all_regs()

◆ sam3_read_this_reg()

static int sam3_read_this_reg ( struct sam3_chip chip,
uint32_t *  goes_here 
)
static

◆ sam3_reg_fieldname()

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

◆ sam3_write()

static int sam3_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 2553 of file at91sam3.c.

Referenced by sam3_explain_ckgr_mor().

◆ _unknown

const char _unknown[] = "unknown"
static

Definition at line 2434 of file at91sam3.c.

Referenced by sam3_explain_chipid_cidr().

◆ all_sam3_chips

struct sam3_chip* all_sam3_chips
static

Definition at line 206 of file at91sam3.c.

Referenced by FLASH_BANK_COMMAND_HANDLER(), and sam3_free_driver_priv().

◆ all_sam3_details

const struct sam3_chip_details all_sam3_details[]
static

Definition at line 208 of file at91sam3.c.

Referenced by sam3_get_details().

◆ archnames

const struct archnames archnames[]
static

◆ at91sam3_command_handlers

const struct command_registration at91sam3_command_handlers[]
static
Initial value:
= {
{
.name = "at91sam3",
.mode = COMMAND_ANY,
.help = "at91sam3 flash command group",
.usage = "",
},
}
static const struct command_registration at91sam3_exec_command_handlers[]
Definition: at91sam3.c:3671
#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 3635 of file at91sam3.c.

◆ at91sam3_exec_command_handlers

const struct command_registration at91sam3_exec_command_handlers[]
static
Initial value:
= {
{
.name = "gpnvm",
.handler = sam3_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 = sam3_handle_info_command,
.mode = COMMAND_EXEC,
.help = "Print information about the current at91sam3 chip "
"and its flash configuration.",
.usage = "",
},
{
.name = "slowclk",
.handler = sam3_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 3635 of file at91sam3.c.

◆ at91sam3_flash

const struct flash_driver at91sam3_flash
Initial value:
= {
.name = "at91sam3",
.flash_bank_command = sam3_flash_bank_command,
.erase = sam3_erase,
.protect = sam3_protect,
.write = sam3_write,
.probe = sam3_probe,
.auto_probe = sam3_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = sam3_protect_check,
.free_driver_priv = sam3_free_driver_priv,
}
static int sam3_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: at91sam3.c:3344
static int sam3_probe(struct flash_bank *bank)
Definition: at91sam3.c:3200
static int sam3_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: at91sam3.c:3241
static const struct command_registration at91sam3_command_handlers[]
Definition: at91sam3.c:3699
static void sam3_free_driver_priv(struct flash_bank *bank)
Remove all chips from the internal list without distinguishing which one is owned by this bank.
Definition: at91sam3.c:3058
static int sam3_auto_probe(struct flash_bank *bank)
Definition: at91sam3.c:3205
static int sam3_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: at91sam3.c:3210
static int sam3_protect_check(struct flash_bank *bank)
Definition: at91sam3.c:2950
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 3635 of file at91sam3.c.

Referenced by COMMAND_HANDLER().

◆ eproc_names

const char* const eproc_names[]
static
Initial value:
= {
"arm946es",
"arm7tdmi",
"Cortex-M3",
"arm920t",
"arm926ejs",
}
static const char _unknown[]
Definition: at91sam3.c:2434

Definition at line 2435 of file at91sam3.c.

Referenced by sam3_explain_chipid_cidr().

◆ nvpsize

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

Definition at line 2455 of file at91sam3.c.

Referenced by sam3_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 2534 of file at91sam3.c.

Referenced by sam3_explain_chipid_cidr().

◆ sam3_all_regs

const struct sam3_reg_list sam3_all_regs[]
static
Initial value:
= {
SAM3_ENTRY(CKGR_UCKR, NULL),
SAM3_ENTRY(PMC_FSMR, NULL),
SAM3_ENTRY(PMC_FSPR, NULL),
SAM3_ENTRY(PMC_IMR, NULL),
SAM3_ENTRY(PMC_PCK0, NULL),
SAM3_ENTRY(PMC_PCK1, NULL),
SAM3_ENTRY(PMC_PCK2, NULL),
SAM3_ENTRY(PMC_PCSR, NULL),
SAM3_ENTRY(PMC_SCSR, NULL),
SAM3_ENTRY(PMC_SR, NULL),
SAM3_ENTRY(CHIPID_EXID, NULL),
SAM3_ENTRY(CHIPID_EXID2, NULL),
{ .name = NULL }
}
static void sam3_explain_ckgr_mcfr(struct sam3_chip *chip)
Definition: at91sam3.c:2640
static void sam3_explain_mckr(struct sam3_chip *chip)
Definition: at91sam3.c:2678
static void sam3_explain_ckgr_plla(struct sam3_chip *chip)
Definition: at91sam3.c:2658
static void sam3_explain_chipid_cidr(struct sam3_chip *chip)
Definition: at91sam3.c:2601
static void sam3_explain_ckgr_mor(struct sam3_chip *chip)
Definition: at91sam3.c:2557
#define SAM3_ENTRY(NAME, FUNC)
Definition: at91sam3.c:2796
#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 2783 of file at91sam3.c.

Referenced by sam3_get_info(), sam3_get_reg(), and sam3_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 2474 of file at91sam3.c.

Referenced by sam3_explain_chipid_cidr().