Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Make the SMbus Send/Receive functions work.



details:   https://anonhg.NetBSD.org/src/rev/daed7dbad85e
branches:  trunk
changeset: 761907:daed7dbad85e
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Feb 10 13:52:36 2011 +0000

description:
Make the SMbus Send/Receive functions work.

If cmdlen = 0 and len = 1 use the XXX_HC_CMD_BYTE protocol, send
data through XXX_SMB_HCMD or receive data from XXX_SMB_HD0.

Ok: Paul Goyette

diffstat:

 sys/dev/pci/alipm.c  |  16 ++++++++++------
 sys/dev/pci/ichsmb.c |  16 ++++++++++------
 sys/dev/pci/piixpm.c |  16 ++++++++++------
 3 files changed, 30 insertions(+), 18 deletions(-)

diffs (153 lines):

diff -r 0ea66f7b215b -r daed7dbad85e sys/dev/pci/alipm.c
--- a/sys/dev/pci/alipm.c       Thu Feb 10 13:49:10 2011 +0000
+++ b/sys/dev/pci/alipm.c       Thu Feb 10 13:52:36 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: alipm.c,v 1.7 2010/03/11 04:00:36 mrg Exp $ */
+/*     $NetBSD: alipm.c,v 1.8 2011/02/10 13:52:36 hannken Exp $ */
 /*     $OpenBSD: alipm.c,v 1.13 2007/05/03 12:19:01 dlg Exp $  */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: alipm.c,v 1.7 2010/03/11 04:00:36 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: alipm.c,v 1.8 2011/02/10 13:52:36 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -255,7 +255,8 @@
            "flags 0x%x\n", device_xname(&sc->sc_dev), op, addr, cmdlen,
            len, flags));
 
-       if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2)
+       if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2 ||
+           (cmdlen == 0 && len > 1))
                return (EOPNOTSUPP);
 
        /* Clear status bits */
@@ -298,7 +299,10 @@
        if (I2C_OP_WRITE_P(op)) {
                /* Write data. */
                b = buf;
-               if (len > 0)
+               if (cmdlen == 0 && len == 1)
+                       bus_space_write_1(sc->sc_iot, sc->sc_ioh,
+                           ALIPM_SMB_HCMD, b[0]);
+               else if (len > 0)
                        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
                            ALIPM_SMB_HD0, b[0]);
                if (len > 1)
@@ -307,8 +311,8 @@
        }
 
        /* Set SMBus command */
-       if (len == 0) {
-               if (cmdlen == 0)
+       if (cmdlen == 0) {
+               if (len == 0)
                        ctl = ALIPM_SMB_HC_CMD_QUICK;
                else
                        ctl = ALIPM_SMB_HC_CMD_BYTE;
diff -r 0ea66f7b215b -r daed7dbad85e sys/dev/pci/ichsmb.c
--- a/sys/dev/pci/ichsmb.c      Thu Feb 10 13:49:10 2011 +0000
+++ b/sys/dev/pci/ichsmb.c      Thu Feb 10 13:52:36 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ichsmb.c,v 1.23 2010/07/30 15:28:09 njoly Exp $        */
+/*     $NetBSD: ichsmb.c,v 1.24 2011/02/10 13:52:36 hannken Exp $      */
 /*     $OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $ */
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.23 2010/07/30 15:28:09 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.24 2011/02/10 13:52:36 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -238,7 +238,8 @@
        if (cold || sc->sc_poll)
                flags |= I2C_F_POLL;
 
-       if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2)
+       if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2 ||
+           (cmdlen == 0 && len > 1))
                return (1);
 
        /* Setup transfer */
@@ -261,7 +262,10 @@
        if (I2C_OP_WRITE_P(op)) {
                /* Write data */
                b = buf;
-               if (len > 0)
+               if (cmdlen == 0 && len == 1)
+                       bus_space_write_1(sc->sc_iot, sc->sc_ioh,
+                           LPCIB_SMB_HCMD, b[0]);
+               else if (len > 0)
                        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
                            LPCIB_SMB_HD0, b[0]);
                if (len > 1)
@@ -270,8 +274,8 @@
        }
 
        /* Set SMBus command */
-       if (len == 0) {
-               if (cmdlen == 0)
+       if (cmdlen == 0) {
+               if (len == 0)
                        ctl = LPCIB_SMB_HC_CMD_QUICK;
                else
                        ctl = LPCIB_SMB_HC_CMD_BYTE;
diff -r 0ea66f7b215b -r daed7dbad85e sys/dev/pci/piixpm.c
--- a/sys/dev/pci/piixpm.c      Thu Feb 10 13:49:10 2011 +0000
+++ b/sys/dev/pci/piixpm.c      Thu Feb 10 13:52:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.33 2010/07/27 05:29:05 jakllsch Exp $ */
+/* $NetBSD: piixpm.c,v 1.34 2011/02/10 13:52:36 hannken Exp $ */
 /*     $OpenBSD: piixpm.c,v 1.20 2006/02/27 08:25:02 grange Exp $      */
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.33 2010/07/27 05:29:05 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.34 2011/02/10 13:52:36 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -316,7 +316,8 @@
        if (cold || sc->sc_poll)
                flags |= I2C_F_POLL;
 
-       if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2)
+       if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2 ||
+           (cmdlen == 0 && len > 1))
                return (1);
 
        /* Setup transfer */
@@ -340,7 +341,10 @@
        if (I2C_OP_WRITE_P(op)) {
                /* Write data */
                b = buf;
-               if (len > 0)
+               if (cmdlen == 0 && len == 1)
+                       bus_space_write_1(sc->sc_smb_iot, sc->sc_smb_ioh,
+                           PIIX_SMB_HCMD, b[0]);
+               else if (len > 0)
                        bus_space_write_1(sc->sc_smb_iot, sc->sc_smb_ioh,
                            PIIX_SMB_HD0, b[0]);
                if (len > 1)
@@ -349,8 +353,8 @@
        }
 
        /* Set SMBus command */
-       if (len == 0) {
-               if (cmdlen == 0)
+       if (cmdlen == 0) {
+               if (len == 0)
                        ctl = PIIX_SMB_HC_CMD_QUICK;
                else
                        ctl = PIIX_SMB_HC_CMD_BYTE;



Home | Main Index | Thread Index | Old Index