From owner-svn-src-stable-8@FreeBSD.ORG Tue Nov 17 12:25:34 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 768A51065679; Tue, 17 Nov 2009 12:25:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4BE428FC14; Tue, 17 Nov 2009 12:25:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nAHCPYY3006686; Tue, 17 Nov 2009 12:25:34 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nAHCPYxR006684; Tue, 17 Nov 2009 12:25:34 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200911171225.nAHCPYxR006684@svn.freebsd.org> From: Alexander Motin Date: Tue, 17 Nov 2009 12:25:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199362 - stable/8/sys/dev/ata/chipsets X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2009 12:25:34 -0000 Author: mav Date: Tue Nov 17 12:25:34 2009 New Revision: 199362 URL: http://svn.freebsd.org/changeset/base/199362 Log: MFC r198583: Add some magic taken from OS X and Linux to support early revision K2 SATA controllers, like those found on the G5 Xserve. Modified: stable/8/sys/dev/ata/chipsets/ata-serverworks.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet6/ (props changed) Modified: stable/8/sys/dev/ata/chipsets/ata-serverworks.c ============================================================================== --- stable/8/sys/dev/ata/chipsets/ata-serverworks.c Tue Nov 17 12:23:14 2009 (r199361) +++ stable/8/sys/dev/ata/chipsets/ata-serverworks.c Tue Nov 17 12:25:34 2009 (r199362) @@ -41,6 +41,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef __powerpc__ +#include +#endif #include #include #include @@ -106,6 +109,13 @@ static int ata_serverworks_status(device_t dev) { struct ata_channel *ch = device_get_softc(dev); + struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); + + /* + * Check if this interrupt belongs to our channel. + */ + if (!(ATA_INL(ctlr->r_res2, 0x1f80) & (1 << ch->unit))) + return (0); /* * We need to do a 4-byte read on the status reg before the values @@ -208,8 +218,29 @@ ata_serverworks_ch_attach(device_t dev) ch->hw.tf_write = ata_serverworks_tf_write; #ifdef __powerpc__ ch->hw.status = ata_serverworks_status; + + /* Make sure that our interrupt is edge triggered */ + powerpc_config_intr(bus_get_resource_start(device_get_parent(dev), + SYS_RES_IRQ, 0), INTR_TRIGGER_EDGE, INTR_POLARITY_HIGH); #endif + if (ctlr->chip->chipid == ATA_K2) { + /* + * The revision 1 K2 SATA controller has interesting bugs. Patch them. + * These magic numbers regulate interrupt delivery in the first few + * cases and are pure magic in the last case. + * + * Values obtained from the Darwin driver. + */ + + ATA_IDX_OUTB(ch, ATA_BMSTAT_PORT, 0x04); + ATA_IDX_OUTL(ch, ATA_SERROR, 0xffffffff); + ATA_IDX_OUTL(ch, ATA_SCONTROL, 0x00000300); + ATA_OUTL(ctlr->r_res2, ch_offset + 0x88, 0); + ATA_OUTL(ctlr->r_res2, ch_offset + 0x80, + ATA_INL(ctlr->r_res2, ch_offset + 0x80) & ~0x00040000); + } + /* chip does not reliably do 64K DMA transfers */ ch->dma.max_iosize = 64 * DEV_BSIZE;