##############################
# Target:    Atmel AT91SAM7L128
##############################

if { [info exists CHIPNAME] } {
	set _CHIPNAME $CHIPNAME
} else {
	set _CHIPNAME at91sam7l128
}

if { [info exists ENDIAN] } {
   set  _ENDIAN $ENDIAN
} else {
   set  _ENDIAN little
}

if { [info exists CPUTAPID ] } {
   set _CPUTAPID $CPUTAPID
} else {
   set _CPUTAPID 0x3f0f0f0f
}

# The lengthy datasheet for the chip specifies the minimum JTAG clock
# period (actually ICE) as 100ns = 10 MHz

#adapter_khz 10000
# 0.5.0 uses "adapter_khz"; 0.4.0 uses "jtag_khz"
jtag_khz 3000

jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf \
     -expected-id $_CPUTAPID

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME arm7tdmi -endian $_ENDIAN \
       -chain-position $_TARGETNAME -variant arm7tdmi
$_TARGETNAME configure -work-area-phys 0x00200000 -work-area-size 0x1000 \
	     -work-area-backup 0

# 128 Kbytes of Flash Memory (AT91SAM7L128)
# – Single plane
# – One bank of 512 pages of 256 bytes
# – 16 lock bits, each protecting 16 lock regions of 32 pages
set _FLASHNAME $_CHIPNAME.flash
# flash bank name driver base size chip_width bus_width target
flash bank $_FLASHNAME at91sam7 0x100000 0x20000 4 32 0 $_TARGETNAME \
    at91sam7l128 1 16 32 256 2

arm7_9 dcc_downloads enable
arm7_9 fast_memory_access enable


