
For example, to perform a basic read of four bytes to a flash device that has three address bytes, software
must write a total of eight bytes to the TX FIFO buffer. The first byte would be the instruction opcode, the
next three bytes are the address, and the final four bytes would be dummy data to ensure the chip select stays
active while the read data is returned. Similarly, because eight bytes were written to the TX FIFO buffer,
software should expect eight bytes to be returned in the RX FIFO buffer. The first four bytes of this would
be discarded, leaving the final four bytes holding the data read from the device.
Because the TX FIFO and RX FIFO buffers are four bytes deep each, software must maintain the FIFO buffer
levels to ensure the TX FIFO buffer does not underflow and the RX FIFO buffer does not overflow. Interrupts
are provided to indicate when the fill levels pass the watermark levels, which are configurable through the
TX threshold register (
txtresh
) and RX threshold register (
rxtresh
).
Configuring the Flash Device
For read and write accesses, software must initialize the device read instruction register (
devrd
) and the
device write instruction register (
devwr
). These registers include fields to initialize the instruction opcodes
that should be used as well as the instruction type, and whether the instruction uses single, dual or quad pins
for address and data transfer. To ensure the quad SPI controller can operate from a reset state, the opcode
registers reset to opcodes compatible with single I/O flash devices.
The quad SPI flash controller uses the instruction transfer width field (
instwidth
) of the
devrd
register
to set the instruction transfer width for both reads and writes. There is no
instwidth
field in the
devwr
register. If instruction type is set to dual or quad mode, the address transfer width (
addrwidth
) and data
transfer width (
datawidth
) fields of both registers are redundant because the address and data type is
based on the instruction type. Thus, software can support the less common flash instructions where the
opcode, address, and data are sent on two or four lanes. For most instructions, the opcodes are sent serially
to the flash device, even for dual and quad instructions. One of the flash devices that supports instructions
that can send the opcode over two or four lanes is the Micron N25Q128. For reference,
and
show how software should configure the quad SPI controller for each specific read and write instruction,
respectively, supported by the Micron N25Q128 device.
Table 12-1: Quad SPI Configuration for Micron N25Q128 Device (Read Instructions)
datawidth
Value
addrwidth
Value
instwidth Value
Lanes Used to
Send Data
Lanes Used to
Send Address
Lanes Used By
Opcode
Instruction
0
0
0
1
1
1
Read
0
0
0
1
1
1
Fast read
1
0
0
2
1
1
Dual
output fast
read
(DOFR)
1
1
0
2
2
1
Dual I/O
fast read
(DIOFR)
2
0
0
4
1
1
Quad
output fast
read
(QOFR)
2
2
0
4
4
1
Quad I/O
fast read
(QIOFR)
Altera Corporation
Quad SPI Flash Controller
12-9
Configuring the Flash Device
cv_54012
2013.12.30