diff options
author | adrian <adrian@FreeBSD.org> | 2016-02-04 22:39:27 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2016-02-04 22:39:27 +0000 |
commit | 1a98ff983495d0d6b92bcce40e94a080aa22bab7 (patch) | |
tree | 0c9d4cc6fc2f5093ab12798df0abd6ce8bf1ff52 /sys | |
parent | 8f5a4a0c37a15b8926c68a84deed6a9239093d32 (diff) | |
download | FreeBSD-src-1a98ff983495d0d6b92bcce40e94a080aa22bab7.zip FreeBSD-src-1a98ff983495d0d6b92bcce40e94a080aa22bab7.tar.gz |
Provide a workaround for setting the correct endianness when doing CFI on
a mips big-endian board.
This is (hopefully! ish!) a temporary change until a slightly better way
can be found to express this without a config option.
Tested:
* BUFFALO WZR-HP-G300NH 1stGen (by submitter)
Submitted by: Mori Hiroki <yamori813@yahoo.co.jp>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/conf/options | 1 | ||||
-rw-r--r-- | sys/dev/cfi/cfi_core.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/sys/conf/options b/sys/conf/options index c7cd5818..f1b2af4 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -918,6 +918,7 @@ VNET_DEBUG opt_global.h # Common Flash Interface (CFI) options CFI_SUPPORT_STRATAFLASH opt_cfi.h CFI_ARMEDANDDANGEROUS opt_cfi.h +CFI_HARDWAREBYTESWAP opt_cfi.h # Sound options SND_DEBUG opt_snd.h diff --git a/sys/dev/cfi/cfi_core.c b/sys/dev/cfi/cfi_core.c index 5150b77..d292e1a 100644 --- a/sys/dev/cfi/cfi_core.c +++ b/sys/dev/cfi/cfi_core.c @@ -99,11 +99,17 @@ cfi_read(struct cfi_softc *sc, u_int ofs) break; case 2: sval = bus_space_read_2(sc->sc_tag, sc->sc_handle, ofs); +#ifdef CFI_HARDWAREBYTESWAP + val = sval; +#else val = le16toh(sval); +#endif break; case 4: val = bus_space_read_4(sc->sc_tag, sc->sc_handle, ofs); +#ifndef CFI_HARDWAREBYTESWAP val = le32toh(val); +#endif break; default: val = ~0; @@ -122,10 +128,19 @@ cfi_write(struct cfi_softc *sc, u_int ofs, u_int val) bus_space_write_1(sc->sc_tag, sc->sc_handle, ofs, val); break; case 2: +#ifdef CFI_HARDWAREBYTESWAP + bus_space_write_2(sc->sc_tag, sc->sc_handle, ofs, val); +#else bus_space_write_2(sc->sc_tag, sc->sc_handle, ofs, htole16(val)); + +#endif break; case 4: +#ifdef CFI_HARDWAREBYTESWAP + bus_space_write_4(sc->sc_tag, sc->sc_handle, ofs, val); +#else bus_space_write_4(sc->sc_tag, sc->sc_handle, ofs, htole32(val)); +#endif break; } } |