svn commit: r295284 - in head/sys: conf dev/cfi

Adrian Chadd adrian at FreeBSD.org
Thu Feb 4 22:39:29 UTC 2016


Author: adrian
Date: Thu Feb  4 22:39:27 2016
New Revision: 295284
URL: https://svnweb.freebsd.org/changeset/base/295284

Log:
  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 at yahoo.co.jp>

Modified:
  head/sys/conf/options
  head/sys/dev/cfi/cfi_core.c

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Thu Feb  4 21:46:37 2016	(r295283)
+++ head/sys/conf/options	Thu Feb  4 22:39:27 2016	(r295284)
@@ -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

Modified: head/sys/dev/cfi/cfi_core.c
==============================================================================
--- head/sys/dev/cfi/cfi_core.c	Thu Feb  4 21:46:37 2016	(r295283)
+++ head/sys/dev/cfi/cfi_core.c	Thu Feb  4 22:39:27 2016	(r295284)
@@ -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 of
 		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;
 	}
 }


More information about the svn-src-head mailing list