Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Don't force using SMBUS0SEL register.
details: https://anonhg.NetBSD.org/src/rev/67798c5ed4ef
branches: trunk
changeset: 847489:67798c5ed4ef
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Tue Dec 24 03:43:34 2019 +0000
description:
Don't force using SMBUS0SEL register.
- Use it depending on USE_SMBUS0SEL bit.
- If we use SMBUS0EN_LO register to select the port, update the port
select bits only.
diffstat:
sys/dev/pci/piixpm.c | 61 ++++++++++++++++++++++++++++++++++++------------
sys/dev/pci/piixpmreg.h | 16 ++++++++----
2 files changed, 56 insertions(+), 21 deletions(-)
diffs (144 lines):
diff -r fc792e289dd2 -r 67798c5ed4ef sys/dev/pci/piixpm.c
--- a/sys/dev/pci/piixpm.c Mon Dec 23 23:41:43 2019 +0000
+++ b/sys/dev/pci/piixpm.c Tue Dec 24 03:43:34 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.58 2019/12/23 23:41:43 msaitoh Exp $ */
+/* $NetBSD: piixpm.c,v 1.59 2019/12/24 03:43:34 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.58 2019/12/23 23:41:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.59 2019/12/24 03:43:34 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -86,6 +86,7 @@
bus_space_handle_t sc_smb_ioh;
void * sc_smb_ih;
int sc_poll;
+ bool sc_sb800_selen; /* Use SMBUS0SEL */
pci_chipset_tag_t sc_pc;
pcitag_t sc_pcitag;
@@ -419,6 +420,8 @@
val = bus_space_read_1(iot, ioh, SB800_INDIRECTIO_DATA) << 8;
base_addr = val;
} else {
+ uint8_t data;
+
bus_space_write_1(iot, ioh, SB800_INDIRECTIO_INDEX,
SB800_PM_SMBUS0EN_LO);
val = bus_space_read_1(iot, ioh, SB800_INDIRECTIO_DATA);
@@ -433,8 +436,9 @@
bus_space_write_1(iot, ioh, SB800_INDIRECTIO_INDEX,
SB800_PM_SMBUS0SELEN);
- bus_space_write_1(iot, ioh, SB800_INDIRECTIO_DATA,
- SB800_PM_SMBUS0EN_ENABLE);
+ data = bus_space_read_1(iot, ioh, SB800_INDIRECTIO_DATA);
+ if ((data & SB800_PM_USE_SMBUS0SEL) != 0)
+ sc->sc_sb800_selen = true;
}
sc->sc_sb800_ioh = ioh;
@@ -482,10 +486,23 @@
bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
SB800_INDIRECTIO_DATA, smbus->sda << 3);
} else if (PIIXPM_IS_SB800GRP(sc) || PIIXPM_IS_HUDSON(sc)) {
- bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
- SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0SEL);
- bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
- SB800_INDIRECTIO_DATA, smbus->sda << 1);
+ if (sc->sc_sb800_selen) {
+ bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0SEL);
+ bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_DATA,
+ __SHIFTIN(smbus->sda, SB800_PM_SMBUS0_MASK_E));
+ } else {
+ uint8_t data;
+
+ bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0EN_LO);
+ data = bus_space_read_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_DATA) & ~SB800_PM_SMBUS0_MASK_C;
+ data |= __SHIFTIN(smbus->sda, SB800_PM_SMBUS0_MASK_C);
+ bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_DATA, data);
+ }
}
return 0;
@@ -500,17 +517,29 @@
if (PIIXPM_IS_KERNCZ(sc)) {
bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
SB800_INDIRECTIO_INDEX, AMDFCH41_PM_PORT_INDEX);
+ /* Set to port 0 */
bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
SB800_INDIRECTIO_DATA, 0);
} else if (PIIXPM_IS_SB800GRP(sc) || PIIXPM_IS_HUDSON(sc)) {
- /*
- * HP Microserver hangs after reboot if not set to SDA0.
- * Also add shutdown hook?
- */
- bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
- SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0SEL);
- bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
- SB800_INDIRECTIO_DATA, 0);
+ if (sc->sc_sb800_selen) {
+ bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0SEL);
+
+ /* Set to port 0 */
+ bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_DATA, 0);
+ } else {
+ uint8_t data;
+
+ bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_INDEX, SB800_PM_SMBUS0EN_LO);
+
+ /* Set to port 0 */
+ data = bus_space_read_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_DATA) & ~SB800_PM_SMBUS0_MASK_C;
+ bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh,
+ SB800_INDIRECTIO_DATA, data);
+ }
}
}
diff -r fc792e289dd2 -r 67798c5ed4ef sys/dev/pci/piixpmreg.h
--- a/sys/dev/pci/piixpmreg.h Mon Dec 23 23:41:43 2019 +0000
+++ b/sys/dev/pci/piixpmreg.h Tue Dec 24 03:43:34 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpmreg.h,v 1.9 2019/12/23 23:41:43 msaitoh Exp $ */
+/* $NetBSD: piixpmreg.h,v 1.10 2019/12/24 03:43:34 msaitoh Exp $ */
/* $OpenBSD: piixreg.h,v 1.3 2006/01/03 22:39:03 grange Exp $ */
/*-
@@ -116,11 +116,17 @@
#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 __BIT(0) /* Function enable */
+#define SB800_PM_SMBUS0_MASK_C __BITS(2, 1) /* Port mask (PMIO2C) */
+#define SB800_PM_SMBUS0EN_BADDR __BITS(15, 5) /* Base address */
-#define SB800_PM_SMBUS0EN_ENABLE 0x0001
-#define SB800_PM_SMBUS0EN_BADDR 0xffe0
+#define SB800_PM_SMBUS0SEL 0x2e
+#define SB800_PM_SMBUS0_MASK_E __BITS(2, 1) /* Port mask (PMIO2E) */
+#define SB800_PM_SMBUS0SELEN 0x2f
+#define SB800_PM_USE_SMBUS0SEL __BIT(0) /*
+ * If the bit is set, SMBUS0SEL is
+ * used to select the port.
+ */
/* In the SMBus I/O space */
#define SB800_SMB_HOSTC 0x10 /* I2C bus configuration */
Home |
Main Index |
Thread Index |
Old Index