main: Improve support for existing and new driver semantics

The current Nuvoton driver will emit multiple post codes per read, but is buggy
and can send part of a post code if more than one is read at a time.
This means our current code will put the driver into a confused state if
we are using 4 byte post codes and the driver happens to have only
process 7 bytes of 8 bytes worth of codes in its internal fifo. This
leaves one byte in the fifo which cannot be read again until another 4
bytes are ready. Limiting our read size will prevent this issue as a
workaround until the new driver code can be submitted.

A driver re-work is in progress that will limit the output to a single
post code, and will only write the number of bytes needed for the
io_write transaction on the other end of the bus. Our change trivially
supports this by populating the post code as zero before writing out the
little endian value so that the upper bits are zero if a short post code
is emitted by the driver. Eventually we can get rid of the bytes runtime
flag altogether and rely on the driver returning a single post code per
read.

Change-Id: Ia2e6dc0761a6dd8ddb7cf1194a4230686a7a3d6d
Signed-off-by: William A. Kennington III <wak@google.com>
1 file changed