Module Name:    src
Committed By:   msaitoh
Date:           Mon Dec 23 23:41:43 UTC 2019

Modified Files:
        src/sys/dev/pci: piixpm.c piixpmreg.h

Log Message:
- Read SB800_SMB_HOSTC correctly. This register is not in the PCI config space
  but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI or 1 on IRQ, so invert the check.
- Modify comment.
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/dev/pci/piixpm.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/piixpmreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/piixpm.c
diff -u src/sys/dev/pci/piixpm.c:1.57 src/sys/dev/pci/piixpm.c:1.58
--- src/sys/dev/pci/piixpm.c:1.57	Mon Dec 23 23:31:23 2019
+++ src/sys/dev/pci/piixpm.c	Mon Dec 23 23:41:43 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.57 2019/12/23 23:31:23 msaitoh Exp $ */
+/* $NetBSD: piixpm.c,v 1.58 2019/12/23 23:41:43 msaitoh Exp $ */
 /*	$OpenBSD: piixpm.c,v 1.39 2013/10/01 20:06:02 sf Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.57 2019/12/23 23:31:23 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.58 2019/12/23 23:41:43 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -231,12 +231,9 @@ nopowermanagement:
 	if (PIIXPM_IS_FCHGRP(sc) || PIIXPM_IS_SB800GRP(sc)) {
 		if (piixpm_sb800_init(sc) == 0) {
 			/* Read configuration */
-			conf = pci_conf_read(pa->pa_pc, pa->pa_tag,
-			    SB800_SMB_HOSTC);
-			DPRINTF(("%s: conf 0x%08x\n", device_xname(self),
-				conf));
-
-			usesmi = conf & SB800_SMB_HOSTC_SMI;
+			conf = bus_space_read_1(sc->sc_iot,
+			    sc->sc_smb_ioh, SB800_SMB_HOSTC);
+			usesmi = ((conf & SB800_SMB_HOSTC_IRQ) == 0);
 			goto setintr;
 		}
 		aprint_normal_dev(self, "SMBus initialization failed\n");
@@ -444,7 +441,7 @@ piixpm_sb800_init(struct piixpm_softc *s
 	aprint_debug_dev(sc->sc_dev, "SMBus @ 0x%04x\n", base_addr);
 
 	if (bus_space_map(iot, PCI_MAPREG_IO_ADDR(base_addr),
-	    PIIX_SMB_SIZE, 0, &sc->sc_smb_ioh)) {
+	    SB800_SMB_SIZE, 0, &sc->sc_smb_ioh)) {
 		aprint_error_dev(sc->sc_dev, "can't map smbus I/O space\n");
 		return EBUSY;
 	}

Index: src/sys/dev/pci/piixpmreg.h
diff -u src/sys/dev/pci/piixpmreg.h:1.8 src/sys/dev/pci/piixpmreg.h:1.9
--- src/sys/dev/pci/piixpmreg.h:1.8	Sat Jul 13 09:24:17 2019
+++ src/sys/dev/pci/piixpmreg.h	Mon Dec 23 23:41:43 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpmreg.h,v 1.8 2019/07/13 09:24:17 msaitoh Exp $ */
+/* $NetBSD: piixpmreg.h,v 1.9 2019/12/23 23:41:43 msaitoh Exp $ */
 /*	$OpenBSD: piixreg.h,v 1.3 2006/01/03 22:39:03 grange Exp $	*/
 
 /*-
@@ -66,7 +66,7 @@
 #define PIIX_SMB_HOSTC	0xd0		/* SMBus host configuration */
 #define PIIX_SMB_HOSTC_HSTEN	(1 << 16)	/* enable host controller */
 #define PIIX_SMB_HOSTC_SMI	(0 << 17)	/* SMI */
-#define PIIX_SMB_HOSTC_IRQ	(4 << 17)	/* IRQ */
+#define PIIX_SMB_HOSTC_IRQ	(4 << 17)	/* IRQ 9 */
 #define PIIX_SMB_HOSTC_INTMASK	(7 << 17)
 
 /* SMBus I/O registers */
@@ -113,18 +113,21 @@
 #define SB800_INDIRECTIO_SIZE	2 
 #define SB800_INDIRECTIO_INDEX	0
 #define SB800_INDIRECTIO_DATA	1
- 
+
 #define SB800_PM_SMBUS0EN_LO	0x2c
 #define SB800_PM_SMBUS0EN_HI	0x2d
 #define SB800_PM_SMBUS0SEL	0x2e 
 #define SB800_PM_SMBUS0SELEN	0x2f 
-                                      
+
 #define SB800_PM_SMBUS0EN_ENABLE 0x0001
 #define SB800_PM_SMBUS0EN_BADDR	0xffe0
 
-/* In the PCI config space */
+/* In the SMBus I/O space */
 #define SB800_SMB_HOSTC		0x10	/* I2C bus configuration */
-#define SB800_SMB_HOSTC_SMI	(1 << 0)	/* SMI */
+#define SB800_SMB_HOSTC_IRQ	(1 << 0)	/* 0:SMI 1:IRQ */
+
+/* Misc */
+#define SB800_SMB_SIZE	0x11		/* SMBus I/O space size */
 
 /*
  * Newer FCH registers in the PMIO space.

Reply via email to