Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Aug 2011 11:07:48 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r224603 - in head/sys/dev: ahci ata/chipsets
Message-ID:  <201108021107.p72B7m69047149@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Tue Aug  2 11:07:47 2011
New Revision: 224603
URL: http://svn.freebsd.org/changeset/base/224603

Log:
  Do not force AHCI mode on NVIDIA MCP89 SATA controllers.  Recent Apple
  Mac with this chipset does not initialize AHCI mode unless it is started
  from EFI loader.  However, legacy ATA mode works.
  
  Submitted by:	jkim@ (original version)
  Approved by:	re (kib)
  MFC after:	1 week

Modified:
  head/sys/dev/ahci/ahci.c
  head/sys/dev/ata/chipsets/ata-nvidia.c

Modified: head/sys/dev/ahci/ahci.c
==============================================================================
--- head/sys/dev/ahci/ahci.c	Tue Aug  2 09:43:27 2011	(r224602)
+++ head/sys/dev/ahci/ahci.c	Tue Aug  2 11:07:47 2011	(r224603)
@@ -264,7 +264,7 @@ static struct {
 	{0x0abe10de, 0x00, "NVIDIA MCP79",	AHCI_Q_NOAA},
 	{0x0abf10de, 0x00, "NVIDIA MCP79",	AHCI_Q_NOAA},
 	{0x0d8410de, 0x00, "NVIDIA MCP89",	AHCI_Q_NOAA},
-	{0x0d8510de, 0x00, "NVIDIA MCP89",	AHCI_Q_NOAA},
+	{0x0d8510de, 0x00, "NVIDIA MCP89",	AHCI_Q_NOFORCE|AHCI_Q_NOAA},
 	{0x0d8610de, 0x00, "NVIDIA MCP89",	AHCI_Q_NOAA},
 	{0x0d8710de, 0x00, "NVIDIA MCP89",	AHCI_Q_NOAA},
 	{0x0d8810de, 0x00, "NVIDIA MCP89",	AHCI_Q_NOAA},

Modified: head/sys/dev/ata/chipsets/ata-nvidia.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-nvidia.c	Tue Aug  2 09:43:27 2011	(r224602)
+++ head/sys/dev/ata/chipsets/ata-nvidia.c	Tue Aug  2 11:07:47 2011	(r224603)
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
 /* local prototypes */
 static int ata_nvidia_chipinit(device_t dev);
 static int ata_nvidia_ch_attach(device_t dev);
+static int ata_nvidia_ch_attach_dumb(device_t dev);
 static int ata_nvidia_status(device_t dev);
 static void ata_nvidia_reset(device_t dev);
 static int ata_nvidia_setmode(device_t dev, int target, int mode);
@@ -62,6 +63,7 @@ static int ata_nvidia_setmode(device_t d
 #define NV4             0x01
 #define NVQ             0x02
 #define NVAHCI          0x04
+#define NVNOFORCE       0x08
 
 
 /*
@@ -158,7 +160,7 @@ ata_nvidia_probe(device_t dev)
      { ATA_NFORCE_MCP79_AA, 0, NVAHCI,  0, ATA_SA300, "nForce MCP79" },
      { ATA_NFORCE_MCP79_AB, 0, NVAHCI,  0, ATA_SA300, "nForce MCP79" },
      { ATA_NFORCE_MCP89_A0, 0, NVAHCI,  0, ATA_SA300, "nForce MCP89" },
-     { ATA_NFORCE_MCP89_A1, 0, NVAHCI,  0, ATA_SA300, "nForce MCP89" },
+     { ATA_NFORCE_MCP89_A1, 0, NVAHCI|NVNOFORCE, 0, ATA_SA300, "nForce MCP89" },
      { ATA_NFORCE_MCP89_A2, 0, NVAHCI,  0, ATA_SA300, "nForce MCP89" },
      { ATA_NFORCE_MCP89_A3, 0, NVAHCI,  0, ATA_SA300, "nForce MCP89" },
      { ATA_NFORCE_MCP89_A4, 0, NVAHCI,  0, ATA_SA300, "nForce MCP89" },
@@ -178,7 +180,9 @@ ata_nvidia_probe(device_t dev)
 	return ENXIO;
 
     ata_set_desc(dev);
-    if (ctlr->chip->cfg1 & NVAHCI)
+    if ((ctlr->chip->cfg1 & NVAHCI) &&
+	((ctlr->chip->cfg1 & NVNOFORCE) == 0 ||
+	 pci_get_subclass(dev) != PCIS_STORAGE_IDE))
 	ctlr->chipinit = ata_ahci_chipinit;
     else
 	ctlr->chipinit = ata_nvidia_chipinit;
@@ -193,7 +197,10 @@ ata_nvidia_chipinit(device_t dev)
     if (ata_setup_interrupt(dev, ata_generic_intr))
 	return ENXIO;
 
-    if (ctlr->chip->max_dma >= ATA_SA150) {
+    if (ctlr->chip->cfg1 & NVAHCI) {
+	ctlr->ch_attach = ata_nvidia_ch_attach_dumb;
+	ctlr->setmode = ata_sata_setmode;
+    } else if (ctlr->chip->max_dma >= ATA_SA150) {
 	if (pci_read_config(dev, PCIR_BAR(5), 1) & 1)
 	    ctlr->r_type2 = SYS_RES_IOPORT;
 	else
@@ -264,6 +271,17 @@ ata_nvidia_ch_attach(device_t dev)
     return 0;
 }
 
+static int
+ata_nvidia_ch_attach_dumb(device_t dev)
+{
+    struct ata_channel *ch = device_get_softc(dev);
+
+    if (ata_pci_ch_attach(dev))
+	return ENXIO;
+    ch->flags |= ATA_SATA;
+    return 0;
+}
+
 static int 
 ata_nvidia_status(device_t dev)
 {



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