[U-Boot-Users] Reg in SPI problem

Liew Tsi Chung Tsi-chung.Liew at freescale.com
Tue May 13 22:37:27 CEST 2008


Karthikeyan,

DSPI read:

- Check status (sr & 0x0000F000), continue if >= 4
- Write 0x800n0003 to pop register (0xfc05c038) where n is chipsel (1 << chipsel), 3 is perform read (AT25080A does not have fast read feature)
- dummy read
- write 0x800n00xx to popr, address byte 2
- dummy read
- write 0x800n00xx to popr, address byte 1
- dummy read
- write 0x800n00xx to popr, address byte 0
- dummy read
- write 0x800n0000 to popr, ready for read
- read a byte

Hope this help.

[snip - assembly]
	move.l	#0xFC05C034, %a2	/* dtfr */
	move.l	#0xFC05C03B, %a3	/* drfr */

	move.l	#0x2a000, %d5
	move.l	#(TEXT_BASE), %a4

	move.l	#0xFC05C02C, %a1	/* dspi status */

	/* Issue commands and address */
	move.l	#0x80020003, %d2	/* Fast Read Cmd */
	jsr	asm_dspi_wr_status
	jsr	asm_dspi_rd_status

	move.l	#0x80020000, %d2	/* Address byte 2 */
	jsr	asm_dspi_wr_status
	jsr	asm_dspi_rd_status

	move.l	#0x80020000, %d2	/* Address byte 1 */
	jsr	asm_dspi_wr_status
	jsr	asm_dspi_rd_status

	move.l	#0x80020003, %d2	/* Address byte 0 */
	jsr	asm_dspi_wr_status
	jsr	asm_dspi_rd_status

	/* Transfer u-boot from serial flash to memory */
asm_dspi_rd_loop2:
	move.l	#0x80020000, %d2
	jsr	asm_dspi_wr_status
	jsr	asm_dspi_rd_status

	move.b	%d1, (%a4)		/* read, copy to dst */

	add.l	#1, %a4			/* inc dst by 1 */
	sub.l	#1, %d5			/* dec cnt by 1 */
	bne	asm_dspi_rd_loop2

	move.l	#0x00020000, %d2	/* Terminate */
	jsr	asm_dspi_wr_status
	jsr	asm_dspi_rd_status

asm_dspi_wr_status:
	move.l	(%a1), %d0		/* status */
	and.l	#0x0000F000, %d0
	cmp.l	#0x00003000, %d0
	bgt	asm_dspi_wr_status

	move.l	%d2, (%a2)
	rts

asm_dspi_rd_status:
	move.l	(%a1), %d0		/* status */
	and.l	#0x000000F0, %d0
	lsr.l	#4, %d0
	cmp.l	#0, %d0
	beq	asm_dspi_rd_status

	move.b	(%a3), %d1
	rts


[snip - c]
	do {
		dspi_tx(chipsel, 0x80, SER_RDSR);
		dspi_rx();
		dspi_tx(chipsel, 0x00, 0);
		temp = dspi_rx();
	} while (temp & 0x01);

	dspi_tx(chipsel, 0x80, SER_READ);
	dspi_rx();
	dspi_tx(chipsel, 0x80, 0);
	dspi_rx();
	dspi_tx(chipsel, 0x80, 0);
	dspi_rx();
	dspi_tx(chipsel, 0x80, 0);
	dspi_rx();

	for (i = 0; i < bytes; i++) {
		dspi_tx(chipsel, 0x80, 0);
		buf[i] = dspi_rx();
	}
	dspi_tx(chipsel, 0x00, 0);
	dspi_rx();

	for (i = 0; i < bytes; i++) {
		if ((i % 16) == 0)
			printf("\n");
		printf("%02x ", buf[i]);
	}

Regards,
TsiChung
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.denx.de/pipermail/u-boot/attachments/20080513/45e9ac9e/attachment.htm 


More information about the U-Boot mailing list