bhnd(4): Fix a SPROM identification regression introduced in r315866
In r315866, we introduced a direct read of the 8-bit sromrev field from the memory mapped SPROM/OTP device. On OTP devices that require 16-bit access alignment, this read fails, preventing identification of the SPROM layout. So, let's perform an aligned read of the combined 16-bit sromrev/crc field instead. Approved by: adrian (mentor, implicit)
This commit is contained in:
parent
c1c12fb80b
commit
f7cde62b72
@ -184,6 +184,7 @@ bhnd_nvram_sprom_ident(struct bhnd_nvram_io *io,
|
||||
u_char buf[512];
|
||||
size_t nread;
|
||||
uint16_t magic;
|
||||
uint8_t srevcrc[2];
|
||||
uint8_t srev;
|
||||
bool crc_valid;
|
||||
bool have_magic;
|
||||
@ -224,12 +225,15 @@ bhnd_nvram_sprom_ident(struct bhnd_nvram_io *io,
|
||||
nbytes += nr;
|
||||
}
|
||||
|
||||
/* Read SPROM revision */
|
||||
error = bhnd_nvram_io_read(io, layout->srev_offset, &srev,
|
||||
sizeof(srev));
|
||||
/* Read 8-bit SPROM revision, maintaining 16-bit size alignment
|
||||
* required by some OTP/SPROM chipsets. */
|
||||
error = bhnd_nvram_io_read(io, layout->srev_offset, &srevcrc,
|
||||
sizeof(srevcrc));
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
srev = srevcrc[0];
|
||||
|
||||
/* Early sromrev 1 devices (specifically some BCM440x enet
|
||||
* cards) are reported to have been incorrectly programmed
|
||||
* with a revision of 0x10. */
|
||||
|
@ -120,9 +120,9 @@ bhnd_sprom_attach(device_t dev, bus_size_t offset)
|
||||
|
||||
sprom_size = r_size - offset;
|
||||
|
||||
/* Allocate an I/O context for the SPROM parser. SPROM reads do not
|
||||
* appear to require any specific alignment. */
|
||||
io = bhnd_nvram_iores_new(r, offset, sprom_size, 1);
|
||||
/* Allocate an I/O context for the SPROM parser. All SPROM reads
|
||||
* must be 16-bit aligned */
|
||||
io = bhnd_nvram_iores_new(r, offset, sprom_size, sizeof(uint16_t));
|
||||
if (io == NULL) {
|
||||
error = ENXIO;
|
||||
goto failed;
|
||||
|
Loading…
x
Reference in New Issue
Block a user