All pastes #736237 Raw Edit

dewi ahci new patch

public diff v1 · immutable
·published 2007-10-14 10:55 UTC
rendered paste body
Index: ahci.c===================================================================RCS file: /cvs/src/sys/dev/pci/ahci.c,vretrieving revision 1.129diff -u -r1.129 ahci.c--- ahci.c	1 Oct 2007 15:34:48 -0000	1.129+++ ahci.c	14 Oct 2007 10:54:07 -0000@@ -1,4 +1,4 @@-/*	$OpenBSD: ahci.c,v 1.128 2007/07/03 22:33:20 dlg Exp $ */+/*	$OpenBSD: ahci.c,v 1.129 2007/10/01 15:34:48 krw Exp $ */  /*  * Copyright (c) 2006 David Gwynne <dlg@openbsd.org>@@ -34,7 +34,7 @@ #include <dev/ata/atascsi.h>  /* change to AHCI_DEBUG for dmesg spam */-#define NO_AHCI_DEBUG+#define AHCI_DEBUG  #ifdef AHCI_DEBUG #define DPRINTF(m, f...) do { if ((ahcidebug & (m)) == (m)) printf(f); } \@@ -49,8 +49,16 @@ #endif  #define AHCI_PCI_BAR		0x24+#define AHCI_PCI_ATI_IXP600_MAGIC	0x40+#define AHCI_PCI_ATI_IXP600_LOCKED	0x01 #define AHCI_PCI_INTERFACE	0x01 +/*+ * config(1) flags argument for ahci(4), to force ATI IXP600 into+ * AHCI mode, if the BIOS does not allow it to be setup that way.+ */+#define AHCI_FLAGS_FORCE_ATI_IXP600	0x01+ #define AHCI_REG_CAP		0x000 /* HBA Capabilities */ #define  AHCI_REG_CAP_NP(_r)		(((_r) & 0x1f)+1) /* Number of Ports */ #define  AHCI_REG_CAP_SXS		(1<<5) /* External SATA */@@ -386,6 +394,7 @@  	int			sc_flags; #define AHCI_F_NO_NCQ			(1<<0)+#define AHCI_F_NO_FER			(1<<1)  	u_int			sc_ncmds; @@ -414,10 +423,14 @@ int			ahci_no_match(struct pci_attach_args *); int			ahci_vt8251_attach(struct ahci_softc *, 			    struct pci_attach_args *);+int			ahci_ati_ixp600_attach(struct ahci_softc *,+			    struct pci_attach_args *);  static const struct ahci_device ahci_devices[] = { 	{ PCI_VENDOR_VIATECH,	PCI_PRODUCT_VIATECH_VT8251_SATA,-	    ahci_no_match,	ahci_vt8251_attach }+	    ahci_no_match,	ahci_vt8251_attach },+	{ PCI_VENDOR_ATI,	PCI_PRODUCT_ATI_IXP_SATA_600,+	    NULL,		ahci_ati_ixp600_attach } };  int			ahci_pci_match(struct device *, void *, void *);@@ -546,6 +559,14 @@ }  int+ahci_ati_ixp600_attach(struct ahci_softc *sc, struct pci_attach_args *pa)+{+	sc->sc_flags |= AHCI_F_NO_FER;++	return (0);+}++int ahci_pci_match(struct device *parent, void *match, void *aux) { 	struct pci_attach_args		*pa = aux;@@ -1069,7 +1090,8 @@  	/* Turn on FRE (and ST) */ 	r = ahci_pread(ap, AHCI_PREG_CMD) & ~AHCI_PREG_CMD_ICC;-	r |= AHCI_PREG_CMD_FRE;+	if (!(ap->ap_sc->sc_flags & AHCI_F_NO_FER))+	    r |= AHCI_PREG_CMD_FRE; 	if (!fre_only) 		r |= AHCI_PREG_CMD_ST; 	ahci_pwrite(ap, AHCI_PREG_CMD, r);@@ -1083,9 +1105,10 @@ 	} #endif -	/* Wait for FR to come on */-	if (ahci_pwait_set(ap, AHCI_PREG_CMD, AHCI_PREG_CMD_FR))-		return (2);+	if (!(ap->ap_sc->sc_flags & AHCI_F_NO_FER))+		/* Wait for FR to come on */+		if (ahci_pwait_set(ap, AHCI_PREG_CMD, AHCI_PREG_CMD_FR))+			return (2);  	/* Wait for CR to come on */ 	if (!fre_only && ahci_pwait_set(ap, AHCI_PREG_CMD, AHCI_PREG_CMD_CR))