<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.2">
<TITLE>RE: [U-Boot-Users] Reg in SPI problem</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Karthikeyan,<BR>
<BR>
DSPI read:<BR>
<BR>
- Check status (sr & 0x0000F000), continue if >= 4<BR>
- Write 0x800n0003 to pop register (0xfc05c038) where n is chipsel (1 << chipsel), 3 is perform read (AT25080A does not have fast read feature)<BR>
- dummy read<BR>
- write 0x800n00xx to popr, address byte 2<BR>
- dummy read<BR>
- write 0x800n00xx to popr, address byte 1<BR>
- dummy read<BR>
- write 0x800n00xx to popr, address byte 0<BR>
- dummy read<BR>
- write 0x800n0000 to popr, ready for read<BR>
- read a byte<BR>
<BR>
Hope this help.<BR>
<BR>
[snip - assembly]<BR>
move.l #0xFC05C034, %a2 /* dtfr */<BR>
move.l #0xFC05C03B, %a3 /* drfr */<BR>
<BR>
move.l #0x2a000, %d5<BR>
move.l #(TEXT_BASE), %a4<BR>
<BR>
move.l #0xFC05C02C, %a1 /* dspi status */<BR>
<BR>
/* Issue commands and address */<BR>
move.l #0x80020003, %d2 /* Fast Read Cmd */<BR>
jsr asm_dspi_wr_status<BR>
jsr asm_dspi_rd_status<BR>
<BR>
move.l #0x80020000, %d2 /* Address byte 2 */<BR>
jsr asm_dspi_wr_status<BR>
jsr asm_dspi_rd_status<BR>
<BR>
move.l #0x80020000, %d2 /* Address byte 1 */<BR>
jsr asm_dspi_wr_status<BR>
jsr asm_dspi_rd_status<BR>
<BR>
move.l #0x80020003, %d2 /* Address byte 0 */<BR>
jsr asm_dspi_wr_status<BR>
jsr asm_dspi_rd_status<BR>
<BR>
/* Transfer u-boot from serial flash to memory */<BR>
asm_dspi_rd_loop2:<BR>
move.l #0x80020000, %d2<BR>
jsr asm_dspi_wr_status<BR>
jsr asm_dspi_rd_status<BR>
<BR>
move.b %d1, (%a4) /* read, copy to dst */<BR>
<BR>
add.l #1, %a4 /* inc dst by 1 */<BR>
sub.l #1, %d5 /* dec cnt by 1 */<BR>
bne asm_dspi_rd_loop2<BR>
<BR>
move.l #0x00020000, %d2 /* Terminate */<BR>
jsr asm_dspi_wr_status<BR>
jsr asm_dspi_rd_status<BR>
<BR>
asm_dspi_wr_status:<BR>
move.l (%a1), %d0 /* status */<BR>
and.l #0x0000F000, %d0<BR>
cmp.l #0x00003000, %d0<BR>
bgt asm_dspi_wr_status<BR>
<BR>
move.l %d2, (%a2)<BR>
rts<BR>
<BR>
asm_dspi_rd_status:<BR>
move.l (%a1), %d0 /* status */<BR>
and.l #0x000000F0, %d0<BR>
lsr.l #4, %d0<BR>
cmp.l #0, %d0<BR>
beq asm_dspi_rd_status<BR>
<BR>
move.b (%a3), %d1<BR>
rts<BR>
<BR>
<BR>
[snip - c]<BR>
do {<BR>
dspi_tx(chipsel, 0x80, SER_RDSR);<BR>
dspi_rx();<BR>
dspi_tx(chipsel, 0x00, 0);<BR>
temp = dspi_rx();<BR>
} while (temp & 0x01);<BR>
<BR>
dspi_tx(chipsel, 0x80, SER_READ);<BR>
dspi_rx();<BR>
dspi_tx(chipsel, 0x80, 0);<BR>
dspi_rx();<BR>
dspi_tx(chipsel, 0x80, 0);<BR>
dspi_rx();<BR>
dspi_tx(chipsel, 0x80, 0);<BR>
dspi_rx();<BR>
<BR>
for (i = 0; i < bytes; i++) {<BR>
dspi_tx(chipsel, 0x80, 0);<BR>
buf[i] = dspi_rx();<BR>
}<BR>
dspi_tx(chipsel, 0x00, 0);<BR>
dspi_rx();<BR>
<BR>
for (i = 0; i < bytes; i++) {<BR>
if ((i % 16) == 0)<BR>
printf("\n");<BR>
printf("%02x ", buf[i]);<BR>
}<BR>
<BR>
Regards,<BR>
TsiChung</FONT>
</P>
</BODY>
</HTML>