Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Apr 2020 13:59:52 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r359972 - stable/12/sys/dev/ahci
Message-ID:  <202004151359.03FDxqLc051856@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Apr 15 13:59:51 2020
New Revision: 359972
URL: https://svnweb.freebsd.org/changeset/base/359972

Log:
  MFC r359499: Add ID for JMicron JMB582/JMB585 AHCI controller.
  
  JMB582 has 2 6Gbps SATA ports and PCIe 3.0 x1.
  JMB585 has 5 6Gbps SATA ports and PCIe 3.0 x2.
  
  Both chips support AHCI v1.31, Port Multiplier with FBS and 8 MSI vectors.

Modified:
  stable/12/sys/dev/ahci/ahci.c
  stable/12/sys/dev/ahci/ahci.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/ahci/ahci.c
==============================================================================
--- stable/12/sys/dev/ahci/ahci.c	Wed Apr 15 13:59:09 2020	(r359971)
+++ stable/12/sys/dev/ahci/ahci.c	Wed Apr 15 13:59:51 2020	(r359972)
@@ -141,7 +141,27 @@ int
 ahci_ctlr_reset(device_t dev)
 {
 	struct ahci_controller *ctlr = device_get_softc(dev);
+	uint32_t v;
 	int timeout;
+
+	/* BIOS/OS Handoff */
+	if ((ATA_INL(ctlr->r_mem, AHCI_VS) >= 0x00010200) &&
+	    (ATA_INL(ctlr->r_mem, AHCI_CAP2) & AHCI_CAP2_BOH) &&
+	    ((v = ATA_INL(ctlr->r_mem, AHCI_BOHC)) & AHCI_BOHC_OOS) == 0) {
+
+		/* Request OS ownership. */
+		ATA_OUTL(ctlr->r_mem, AHCI_BOHC, v | AHCI_BOHC_OOS);
+
+		/* Wait up to 2s for BIOS ownership release. */
+		for (timeout = 0; timeout < 80; timeout++) {
+			DELAY(25000);
+			v = ATA_INL(ctlr->r_mem, AHCI_BOHC);
+			if ((v & AHCI_BOHC_BOS) == 0)
+				break;
+			if ((v & AHCI_BOHC_BB) == 0)
+				break;
+		}
+	}
 
 	/* Enable AHCI mode */
 	ATA_OUTL(ctlr->r_mem, AHCI_GHC, AHCI_GHC_AE);

Modified: stable/12/sys/dev/ahci/ahci.h
==============================================================================
--- stable/12/sys/dev/ahci/ahci.h	Wed Apr 15 13:59:09 2020	(r359971)
+++ stable/12/sys/dev/ahci/ahci.h	Wed Apr 15 13:59:51 2020	(r359972)
@@ -214,6 +214,13 @@
 #define		AHCI_CAP2_SADM	0x00000010
 #define		AHCI_CAP2_DESO	0x00000020
 
+#define AHCI_BOHC                   0x28
+#define		AHCI_BOHC_BOS	0x00000001
+#define		AHCI_BOHC_OOS	0x00000002
+#define		AHCI_BOHC_SOOE	0x00000004
+#define		AHCI_BOHC_OOC	0x00000008
+#define		AHCI_BOHC_BB	0x00000010
+
 #define AHCI_VSCAP                  0xa4
 #define AHCI_OFFSET                 0x100
 #define AHCI_STEP                   0x80



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004151359.03FDxqLc051856>