[Midnightbsd-cvs] src [11930] trunk/sys/dev/amdsbwd: fix reboot status reporting
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Fri Jul 20 18:42:34 EDT 2018
Revision: 11930
http://svnweb.midnightbsd.org/src/?rev=11930
Author: laffer1
Date: 2018-07-20 18:42:34 -0400 (Fri, 20 Jul 2018)
Log Message:
-----------
fix reboot status reporting
Modified Paths:
--------------
trunk/sys/dev/amdsbwd/amd_chipset.h
trunk/sys/dev/amdsbwd/amdsbwd.c
Modified: trunk/sys/dev/amdsbwd/amd_chipset.h
===================================================================
--- trunk/sys/dev/amdsbwd/amd_chipset.h 2018-07-20 22:40:53 UTC (rev 11929)
+++ trunk/sys/dev/amdsbwd/amd_chipset.h 2018-07-20 22:42:34 UTC (rev 11930)
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: stable/10/sys/dev/amdsbwd/amd_chipset.h 306817 2016-10-07 18:53:28Z avg $
+ * $FreeBSD: stable/10/sys/dev/amdsbwd/amd_chipset.h 335543 2018-06-22 09:26:05Z avg $
*/
/*
@@ -96,9 +96,10 @@
#define AMDSB8_WDT_32KHZ 0x00
#define AMDSB8_WDT_1HZ 0x03
#define AMDSB8_WDT_RES_MASK 0x03
-#define AMDSB8_PM_RESET_STATUS0 0xc0
-#define AMDSB8_PM_RESET_STATUS1 0xc1
-#define AMDSB8_WD_RST_STS 0x20
+#define AMDSB8_PM_RESET_STATUS 0xc0 /* 32 bit wide */
+#define AMDSB8_WD_RST_STS 0x2000000
+#define AMDSB8_PM_RESET_CTRL 0xc4
+#define AMDSB8_RST_STS_DIS 0x04
/*
* Newer FCH registers in the PMIO space.
Modified: trunk/sys/dev/amdsbwd/amdsbwd.c
===================================================================
--- trunk/sys/dev/amdsbwd/amdsbwd.c 2018-07-20 22:40:53 UTC (rev 11929)
+++ trunk/sys/dev/amdsbwd/amdsbwd.c 2018-07-20 22:42:34 UTC (rev 11930)
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/10/sys/dev/amdsbwd/amdsbwd.c 328845 2018-02-04 13:58:29Z avg $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/amdsbwd/amdsbwd.c 335543 2018-06-22 09:26:05Z avg $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -101,6 +101,8 @@
static int amdsbwd_probe(device_t dev);
static int amdsbwd_attach(device_t dev);
static int amdsbwd_detach(device_t dev);
+static int amdsbwd_suspend(device_t dev);
+static int amdsbwd_resume(device_t dev);
static device_method_t amdsbwd_methods[] = {
DEVMETHOD(device_identify, amdsbwd_identify),
@@ -107,6 +109,8 @@
DEVMETHOD(device_probe, amdsbwd_probe),
DEVMETHOD(device_attach, amdsbwd_attach),
DEVMETHOD(device_detach, amdsbwd_detach),
+ DEVMETHOD(device_suspend, amdsbwd_suspend),
+ DEVMETHOD(device_resume, amdsbwd_resume),
#if 0
DEVMETHOD(device_shutdown, amdsbwd_detach),
#endif
@@ -314,16 +318,23 @@
static void
amdsbwd_probe_sb8xx(device_t dev, struct resource *pmres, uint32_t *addr)
{
- uint8_t val;
- int i;
+ uint32_t val;
+ int i;
/* Report cause of previous reset for user's convenience. */
- val = pmio_read(pmres, AMDSB8_PM_RESET_STATUS0);
+
+ val = pmio_read(pmres, AMDSB8_PM_RESET_CTRL);
+ if ((val & AMDSB8_RST_STS_DIS) != 0) {
+ val &= ~AMDSB8_RST_STS_DIS;
+ pmio_write(pmres, AMDSB8_PM_RESET_CTRL, val);
+ }
+ val = 0;
+ for (i = 3; i >= 0; i--) {
+ val <<= 8;
+ val |= pmio_read(pmres, AMDSB8_PM_RESET_STATUS + i);
+ }
if (val != 0)
- amdsbwd_verbose_printf(dev, "ResetStatus0 = %#04x\n", val);
- val = pmio_read(pmres, AMDSB8_PM_RESET_STATUS1);
- if (val != 0)
- amdsbwd_verbose_printf(dev, "ResetStatus1 = %#04x\n", val);
+ amdsbwd_verbose_printf(dev, "ResetStatus = 0x%08x\n", val);
if ((val & AMDSB8_WD_RST_STS) != 0)
device_printf(dev, "Previous Reset was caused by Watchdog\n");
@@ -550,3 +561,30 @@
return (0);
}
+static int
+amdsbwd_suspend(device_t dev)
+{
+ struct amdsbwd_softc *sc;
+ uint32_t val;
+
+ sc = device_get_softc(dev);
+ val = wdctrl_read(sc);
+ val &= ~AMDSB_WD_RUN;
+ wdctrl_write(sc, val);
+ return (0);
+}
+
+static int
+amdsbwd_resume(device_t dev)
+{
+ struct amdsbwd_softc *sc;
+
+ sc = device_get_softc(dev);
+ wdctrl_write(sc, AMDSB_WD_FIRED);
+ if (sc->active) {
+ amdsbwd_tmr_set(sc, sc->timeout);
+ amdsbwd_tmr_enable(sc);
+ amdsbwd_tmr_reload(sc);
+ }
+ return (0);
+}
More information about the Midnightbsd-cvs
mailing list