Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Fix a bug that wm_sgmii_writereg() function does...



details:   https://anonhg.NetBSD.org/src/rev/5f3034fc5b24
branches:  trunk
changeset: 336972:5f3034fc5b24
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Sat Mar 28 17:35:59 2015 +0000

description:
Fix a bug that wm_sgmii_writereg() function doesn't pass the "val" argument
to the I2CCMD register. Reported by Bernard Merindol in PR#49789.

diffstat:

 sys/dev/pci/if_wm.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 75bd1fd0f95f -r 5f3034fc5b24 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Sat Mar 28 17:25:33 2015 +0000
+++ b/sys/dev/pci/if_wm.c       Sat Mar 28 17:35:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.313 2015/02/16 00:25:52 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.314 2015/03/28 17:35:59 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.313 2015/02/16 00:25:52 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.314 2015/03/28 17:35:59 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -7407,16 +7407,18 @@
        struct wm_softc *sc = device_private(self);
        uint32_t i2ccmd;
        int i;
+       int val_swapped;
 
        if (wm_get_swfw_semaphore(sc, swfwphysem[sc->sc_funcid])) {
                aprint_error_dev(sc->sc_dev, "%s: failed to get semaphore\n",
                    __func__);
                return;
        }
-
+       /* Swap the data bytes for the I2C interface */
+       val_swapped = ((val >> 8) & 0x00FF) | ((val << 8) & 0xFF00);
        i2ccmd = (reg << I2CCMD_REG_ADDR_SHIFT)
            | (phy << I2CCMD_PHY_ADDR_SHIFT)
-           | I2CCMD_OPCODE_WRITE;
+           | I2CCMD_OPCODE_WRITE | val_swapped;
        CSR_WRITE(sc, WMREG_I2CCMD, i2ccmd);
 
        /* Poll the ready bit */



Home | Main Index | Thread Index | Old Index