130 lines
3.3 KiB
Plaintext
130 lines
3.3 KiB
Plaintext
; --------------------------------------------------------------------------------
|
|
; @Title: R-CAR-H2 SPI FLASH Program script
|
|
; @Description:
|
|
; Serial FLASH(ST,25P64) is connected
|
|
;
|
|
; SRAM: 0xE63A0000
|
|
; SPI(controller) Base: 0xE6B10000
|
|
;
|
|
; @Author: jjeong
|
|
; @Chip: R8A7790X
|
|
; @Keywords: RCAR RCARH2 Flash SPI
|
|
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
|
|
; --------------------------------------------------------------------------------
|
|
; $Id: rcarh2-spi.cmm 11733 2023-01-16 08:55:12Z bschroefel $
|
|
|
|
LOCAL &arg1
|
|
ENTRY &arg1
|
|
&arg1=STRing.UPpeR("&arg1") // for example "PREPAREONLY"
|
|
|
|
&SPI_BASE=0xE6B10000
|
|
|
|
&pfc_base=0xE6060000
|
|
&GPSR1=&pfc_base+0x0008
|
|
&IPSR3=&pfc_base+0x002C
|
|
&IPSR4=&pfc_base+0x0030
|
|
|
|
DO ~~/demo/arm/hardware/r_carh2/r-carh2_a7_smp_sieve.cmm ; or DO ~~/demo/arm/hardware/r_carh2/r-carh2_a15_smp_sieve.cmm
|
|
|
|
GOSUB QSPI_INIT
|
|
|
|
GOSUB READ_ID_TEST
|
|
|
|
FLASHFILE.RESet
|
|
|
|
//FLASHFILE.CONFIG <SPI Base AddRESs> ,, ,,
|
|
FLASHFILE.CONFIG &SPI_BASE
|
|
|
|
//FLASHFILE.TARGET <code range> <data range> <Algorithm file>
|
|
FLASHFILE.TARGET 0xE63A0000++0x1FFF 0xE63A2000++0x21FF ~~/demo/arm/flash/byte/spi64_rcarh2.bin /KEEP
|
|
|
|
//Read FLASH Manufacture and Device ID
|
|
FLASHFILE.GETID
|
|
|
|
//End of the test prepareonly
|
|
IF "&arg1"=="PREPAREONLY"
|
|
ENDDO
|
|
|
|
|
|
//Read FLASH
|
|
FLASHFILE.DUMP 0x0
|
|
|
|
//Erase FLASH
|
|
; FLASHFILE.ERASE 0x0--0xFFFFFF /EraseBadBlocks
|
|
|
|
//Write FLASH
|
|
; FLASHFILE.LOAD * 0x0
|
|
; FLASHFILE.LOAD * 0x0 /ComPare ;verify
|
|
|
|
|
|
ENDDO
|
|
|
|
QSPI_INIT:
|
|
|
|
GOSUB WRITE_AND &IPSR3 0x3FFFFFFF
|
|
GOSUB WRITE_OR &IPSR3 0x20000000
|
|
GOSUB WRITE_OR &GPSR1 0x10
|
|
GOSUB WRITE_AND &IPSR4 0xFFFFFFF9
|
|
GOSUB WRITE_OR &IPSR4 0x1
|
|
GOSUB WRITE_OR &GPSR1 0x20
|
|
|
|
GOSUB WRITE_AND &IPSR4 0xFFFFFFCF
|
|
GOSUB WRITE_OR &IPSR4 0x00000008
|
|
GOSUB WRITE_OR &GPSR1 0x00000040
|
|
GOSUB WRITE_AND &IPSR4 0xFFFFFE7F
|
|
GOSUB WRITE_OR &IPSR4 0x00000040
|
|
GOSUB WRITE_OR &GPSR1 0x00000080
|
|
GOSUB WRITE_AND &IPSR4 0xFFFFF3FF
|
|
GOSUB WRITE_OR &IPSR4 0x00000200
|
|
GOSUB WRITE_OR &GPSR1 0x00000100
|
|
GOSUB WRITE_AND &IPSR4 0xFFFF9FFF
|
|
GOSUB WRITE_OR &IPSR4 0x00001000
|
|
GOSUB WRITE_OR &GPSR1 0x00000200
|
|
|
|
Data.Set AZSD:&SPI_BASE+0x00 %LE 0xE8 //SPCR, Recive/Transmit Interrupt enable,Function Enable, Master Mode
|
|
Data.Set AZSD:&SPI_BASE+0x02 %LE 0x6
|
|
Data.Set AZSD:&SPI_BASE+0x0A %LE 0x1
|
|
Data.Set AZSD:&SPI_BASE+0x10 %Word 0xe084
|
|
|
|
RETURN
|
|
|
|
WRITE_AND:
|
|
ENTRY &addr &data
|
|
&data=((&data)&(Data.Long(A:&addr)))
|
|
¬_data=~(&data)
|
|
Data.Set &pfc_base %Long ¬_data
|
|
Data.Set &addr %Long &data
|
|
RETURN
|
|
|
|
WRITE_OR:
|
|
ENTRY &addr &data
|
|
&data=((&data)|(Data.Long(A:&addr)))
|
|
¬_data=~(&data)
|
|
Data.Set &pfc_base %Long ¬_data
|
|
Data.Set &addr %Long &data
|
|
RETURN
|
|
|
|
READ_ID_TEST:
|
|
(
|
|
|
|
PER.Set.simple A:&SPI_BASE 0xA8 ; SPCR, Recive/Transmit Interrupt enable,Function Enable, Master Mode
|
|
PER.Set.simple A:&SPI_BASE+0x18 0xC0 ; SPBFCR
|
|
PER.Set.simple A:&SPI_BASE+0x18 0x00 ; SPBFCR
|
|
PER.Set.simple A:&SPI_BASE 0xE8 ; SPCR, cs low
|
|
|
|
PER.Set.simple A:&SPI_BASE+0x04 0x9F
|
|
PRINT "1st 0x" Data.Byte(A:&SPI_BASE+0x04) " (dummy)"
|
|
|
|
PER.Set.simple A:&SPI_BASE+0x04 0x9F
|
|
PRINT "2nd 0x" Data.Byte(A:&SPI_BASE+0x04) " (Manufacturer)"
|
|
|
|
PER.Set.simple A:&SPI_BASE+0x04 0x9F
|
|
PRINT "3rd 0x" Data.Byte(A:&SPI_BASE+0x04) " (Device ID)"
|
|
|
|
PER.Set.simple A:&SPI_BASE+0x04 0x9F
|
|
PRINT "4th 0x" Data.Byte(A:&SPI_BASE+0x04)
|
|
|
|
PER.Set.simple A:&SPI_BASE 0xA8 ; cs high
|
|
|
|
RETURN
|
|
) |