Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/rockchip fix to work on big endian



details:   https://anonhg.NetBSD.org/src/rev/cdb463c2d715
branches:  trunk
changeset: 955110:cdb463c2d715
user:      ryo <ryo%NetBSD.org@localhost>
date:      Sat Sep 19 18:19:09 2020 +0000

description:
fix to work on big endian

diffstat:

 sys/arch/arm/rockchip/rk_i2c.c |  13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diffs (41 lines):

diff -r 9d9c58d657a1 -r cdb463c2d715 sys/arch/arm/rockchip/rk_i2c.c
--- a/sys/arch/arm/rockchip/rk_i2c.c    Sat Sep 19 16:54:34 2020 +0000
+++ b/sys/arch/arm/rockchip/rk_i2c.c    Sat Sep 19 18:19:09 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_i2c.c,v 1.7 2019/12/22 23:23:29 thorpej Exp $ */
+/* $NetBSD: rk_i2c.c,v 1.8 2020/09/19 18:19:09 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: rk_i2c.c,v 1.7 2019/12/22 23:23:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_i2c.c,v 1.8 2020/09/19 18:19:09 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -251,6 +251,10 @@
        txdata.data8[0] = addr << 1;
        memcpy(&txdata.data8[1], cmd, cmdlen);
        memcpy(&txdata.data8[1 + cmdlen], buf, buflen);
+#if _BYTE_ORDER == _BIG_ENDIAN
+       for (int i = 0; i < howmany(len + 1, 4); i++)
+               LE32TOH(txdata.data32[i]);
+#endif
        bus_space_write_region_4(sc->sc_bst, sc->sc_bsh, RKI2C_TXDATA(0),
            txdata.data32, howmany(len + 1, 4));
        WR4(sc, RKI2C_MTXCNT, __SHIFTIN(len + 1, RKI2C_MTXCNT_MTXCNT));
@@ -312,6 +316,11 @@
                rxdata[n/4] = RD4(sc, RKI2C_RXDATA(n/4));
 #endif
 
+#if _BYTE_ORDER == _BIG_ENDIAN
+       for (int i = 0; i < howmany(buflen, 4); i++)
+               HTOLE32(rxdata[i]);
+#endif
+
        memcpy(buf, rxdata, buflen);
 
        return 0;



Home | Main Index | Thread Index | Old Index