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

Go to the source code of this file.

Data Structures

struct  at91sam7_flash_bank
 

Macros

#define CGPB   0x0D
 
#define CKGR_MCFR   0xFFFFFC24
 
#define CKGR_MCFR_MAINRDY   0x10000
 
#define CKGR_MOR   0xFFFFFC20
 
#define CKGR_PLLR   0xFFFFFC2c
 
#define CKGR_PLLR_DIV   0xff
 
#define CKGR_PLLR_MUL   0x07ff0000
 
#define CLB   0x04
 
#define DBGU_CIDR   0xFFFFF240
 
#define EA   0x08
 
#define FLASH_SIZE_1024KB   12
 
#define FLASH_SIZE_128KB   7
 
#define FLASH_SIZE_16KB   2
 
#define FLASH_SIZE_2048KB   14
 
#define FLASH_SIZE_256KB   9
 
#define FLASH_SIZE_32KB   3
 
#define FLASH_SIZE_512KB   10
 
#define FLASH_SIZE_64KB   5
 
#define FLASH_SIZE_8KB   1
 
#define FMR_TIMING_FLASH   2
 
#define FMR_TIMING_NONE   0
 
#define FMR_TIMING_NVBITS   1
 
#define MC_FSR_EOL   2
 
#define MC_FSR_FRDY   1
 
#define PMC_MCKR   0xFFFFFC30
 
#define PMC_MCKR_CSS   0x03
 
#define PMC_MCKR_PRES   0x1c
 
#define RC_FREQ   32000
 
#define SGPB   0x0B
 
#define SLB   0x02
 
#define SSB   0x0F
 
#define WP   0x01
 
#define WPL   0x03
 

Functions

static int at91sam7_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int at91sam7_erase_check (struct flash_bank *bank)
 
static int at91sam7_flash_command (struct flash_bank *bank, uint8_t cmd, uint16_t pagen)
 
static uint32_t at91sam7_get_flash_status (struct target *target, int bank_number)
 
static int at91sam7_probe (struct flash_bank *bank)
 
static int at91sam7_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int at91sam7_protect_check (struct flash_bank *bank)
 
static void at91sam7_read_clock_info (struct flash_bank *bank)
 
static int at91sam7_read_part_info (struct flash_bank *bank)
 
static void at91sam7_set_flash_mode (struct flash_bank *bank, int mode)
 
static uint32_t at91sam7_wait_status_busy (struct flash_bank *bank, uint32_t waitbits, int timeout)
 
static int at91sam7_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
 COMMAND_HANDLER (at91sam7_handle_gpnvm_command)
 
 FLASH_BANK_COMMAND_HANDLER (at91sam7_flash_bank_command)
 
static int get_at91sam7_info (struct flash_bank *bank, struct command_invocation *cmd)
 

Variables

static const struct command_registration at91sam7_command_handlers []
 
static const struct command_registration at91sam7_exec_command_handlers []
 
const struct flash_driver at91sam7_flash
 
static const char * eproc [8]
 
static const uint32_t mc_fcr [4] = { 0xFFFFFF64, 0xFFFFFF74, 0xFFFFFF84, 0xFFFFFF94 }
 
static const uint32_t mc_fmr [4] = { 0xFFFFFF60, 0xFFFFFF70, 0xFFFFFF80, 0xFFFFFF90 }
 
static const uint32_t mc_fsr [4] = { 0xFFFFFF68, 0xFFFFFF78, 0xFFFFFF88, 0xFFFFFF98 }
 

Macro Definition Documentation

◆ CGPB

#define CGPB   0x0D

Definition at line 61 of file at91sam7.c.

◆ CKGR_MCFR

#define CKGR_MCFR   0xFFFFFC24

Definition at line 44 of file at91sam7.c.

◆ CKGR_MCFR_MAINRDY

#define CKGR_MCFR_MAINRDY   0x10000

Definition at line 46 of file at91sam7.c.

◆ CKGR_MOR

#define CKGR_MOR   0xFFFFFC20

Definition at line 45 of file at91sam7.c.

◆ CKGR_PLLR

#define CKGR_PLLR   0xFFFFFC2c

Definition at line 47 of file at91sam7.c.

◆ CKGR_PLLR_DIV

#define CKGR_PLLR_DIV   0xff

Definition at line 48 of file at91sam7.c.

◆ CKGR_PLLR_MUL

#define CKGR_PLLR_MUL   0x07ff0000

Definition at line 49 of file at91sam7.c.

◆ CLB

#define CLB   0x04

Definition at line 58 of file at91sam7.c.

◆ DBGU_CIDR

#define DBGU_CIDR   0xFFFFF240

Definition at line 43 of file at91sam7.c.

◆ EA

#define EA   0x08

Definition at line 59 of file at91sam7.c.

◆ FLASH_SIZE_1024KB

#define FLASH_SIZE_1024KB   12

Definition at line 84 of file at91sam7.c.

◆ FLASH_SIZE_128KB

#define FLASH_SIZE_128KB   7

Definition at line 81 of file at91sam7.c.

◆ FLASH_SIZE_16KB

#define FLASH_SIZE_16KB   2

Definition at line 78 of file at91sam7.c.

◆ FLASH_SIZE_2048KB

#define FLASH_SIZE_2048KB   14

Definition at line 85 of file at91sam7.c.

◆ FLASH_SIZE_256KB

#define FLASH_SIZE_256KB   9

Definition at line 82 of file at91sam7.c.

◆ FLASH_SIZE_32KB

#define FLASH_SIZE_32KB   3

Definition at line 79 of file at91sam7.c.

◆ FLASH_SIZE_512KB

#define FLASH_SIZE_512KB   10

Definition at line 83 of file at91sam7.c.

◆ FLASH_SIZE_64KB

#define FLASH_SIZE_64KB   5

Definition at line 80 of file at91sam7.c.

◆ FLASH_SIZE_8KB

#define FLASH_SIZE_8KB   1

Definition at line 77 of file at91sam7.c.

◆ FMR_TIMING_FLASH

#define FMR_TIMING_FLASH   2

Definition at line 74 of file at91sam7.c.

◆ FMR_TIMING_NONE

#define FMR_TIMING_NONE   0

Definition at line 72 of file at91sam7.c.

◆ FMR_TIMING_NVBITS

#define FMR_TIMING_NVBITS   1

Definition at line 73 of file at91sam7.c.

◆ MC_FSR_EOL

#define MC_FSR_EOL   2

Definition at line 66 of file at91sam7.c.

◆ MC_FSR_FRDY

#define MC_FSR_FRDY   1

Definition at line 65 of file at91sam7.c.

◆ PMC_MCKR

#define PMC_MCKR   0xFFFFFC30

Definition at line 50 of file at91sam7.c.

◆ PMC_MCKR_CSS

#define PMC_MCKR_CSS   0x03

Definition at line 51 of file at91sam7.c.

◆ PMC_MCKR_PRES

#define PMC_MCKR_PRES   0x1c

Definition at line 52 of file at91sam7.c.

◆ RC_FREQ

#define RC_FREQ   32000

Definition at line 69 of file at91sam7.c.

◆ SGPB

#define SGPB   0x0B

Definition at line 60 of file at91sam7.c.

◆ SLB

#define SLB   0x02

Definition at line 56 of file at91sam7.c.

◆ SSB

#define SSB   0x0F

Definition at line 62 of file at91sam7.c.

◆ WP

#define WP   0x01

Definition at line 55 of file at91sam7.c.

◆ WPL

#define WPL   0x03

Definition at line 57 of file at91sam7.c.

Function Documentation

◆ at91sam7_erase()

◆ at91sam7_erase_check()

static int at91sam7_erase_check ( struct flash_bank bank)
static

◆ at91sam7_flash_command()

static int at91sam7_flash_command ( struct flash_bank bank,
uint8_t  cmd,
uint16_t  pagen 
)
static

◆ at91sam7_get_flash_status()

static uint32_t at91sam7_get_flash_status ( struct target target,
int  bank_number 
)
static

Definition at line 168 of file at91sam7.c.

References mc_fsr, and target_read_u32().

Referenced by at91sam7_protect_check(), and at91sam7_wait_status_busy().

◆ at91sam7_probe()

static int at91sam7_probe ( struct flash_bank bank)
static

◆ at91sam7_protect()

◆ at91sam7_protect_check()

◆ at91sam7_read_clock_info()

◆ at91sam7_read_part_info()

◆ at91sam7_set_flash_mode()

◆ at91sam7_wait_status_busy()

static uint32_t at91sam7_wait_status_busy ( struct flash_bank bank,
uint32_t  waitbits,
int  timeout 
)
static

Definition at line 288 of file at91sam7.c.

References alive_sleep(), at91sam7_get_flash_status(), bank, LOG_DEBUG, LOG_ERROR, and status.

Referenced by at91sam7_flash_command().

◆ at91sam7_write()

◆ COMMAND_HANDLER()

COMMAND_HANDLER ( at91sam7_handle_gpnvm_command  )

Definition at line 1030 of file at91sam7.c.

◆ FLASH_BANK_COMMAND_HANDLER()

◆ get_at91sam7_info()

Variable Documentation

◆ at91sam7_command_handlers

const struct command_registration at91sam7_command_handlers[]
static
Initial value:
= {
{
.name = "at91sam7",
.mode = COMMAND_ANY,
.help = "at91sam7 flash command group",
.usage = "",
},
}
static const struct command_registration at91sam7_exec_command_handlers[]
Definition: at91sam7.c:1097
#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 1030 of file at91sam7.c.

◆ at91sam7_exec_command_handlers

const struct command_registration at91sam7_exec_command_handlers[]
static
Initial value:
= {
{
.name = "gpnvm",
.handler = at91sam7_handle_gpnvm_command,
.mode = COMMAND_EXEC,
.help = "set or clear one General Purpose Non-Volatile Memory "
"(gpnvm) bit",
.usage = "bitnum ('set'|'clear')",
},
}
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 1030 of file at91sam7.c.

◆ at91sam7_flash

const struct flash_driver at91sam7_flash
Initial value:
= {
.name = "at91sam7",
.usage = "gpnvm <bit> <set | clear>",
.flash_bank_command = at91sam7_flash_bank_command,
.erase = at91sam7_erase,
.protect = at91sam7_protect,
.write = at91sam7_write,
.probe = at91sam7_probe,
.auto_probe = at91sam7_probe,
.erase_check = at91sam7_erase_check,
.protect_check = at91sam7_protect_check,
}
static int get_at91sam7_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: at91sam7.c:981
static const struct command_registration at91sam7_command_handlers[]
Definition: at91sam7.c:1108
static int at91sam7_erase_check(struct flash_bank *bank)
Definition: at91sam7.c:637
static int at91sam7_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: at91sam7.c:854
static int at91sam7_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: at91sam7.c:896
static int at91sam7_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: at91sam7.c:802
static int at91sam7_protect_check(struct flash_bank *bank)
Definition: at91sam7.c:651
static int at91sam7_probe(struct flash_bank *bank)
Definition: at91sam7.c:963
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 1030 of file at91sam7.c.

◆ eproc

const char* eproc[8]
static
Initial value:
= {
"Unknown", "ARM946-E", "ARM7TDMI", "Unknown", "ARM920T", "ARM926EJ-S", "Unknown", "Unknown"
}

Definition at line 100 of file at91sam7.c.

Referenced by get_at91sam7_info(), and samv_probe().

◆ mc_fcr

const uint32_t mc_fcr[4] = { 0xFFFFFF64, 0xFFFFFF74, 0xFFFFFF84, 0xFFFFFF94 }
static

Definition at line 97 of file at91sam7.c.

Referenced by at91sam7_flash_command().

◆ mc_fmr

const uint32_t mc_fmr[4] = { 0xFFFFFF60, 0xFFFFFF70, 0xFFFFFF80, 0xFFFFFF90 }
static

Definition at line 96 of file at91sam7.c.

Referenced by at91sam7_set_flash_mode().

◆ mc_fsr

const uint32_t mc_fsr[4] = { 0xFFFFFF68, 0xFFFFFF78, 0xFFFFFF88, 0xFFFFFF98 }
static

Definition at line 98 of file at91sam7.c.

Referenced by at91sam7_get_flash_status().