From patchwork Fri Nov 27 18:53:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 39637 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 1B9B91007D1 for ; Sat, 28 Nov 2009 05:59:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751169AbZK0S6S (ORCPT ); Fri, 27 Nov 2009 13:58:18 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751732AbZK0S6S (ORCPT ); Fri, 27 Nov 2009 13:58:18 -0500 Received: from ey-out-2122.google.com ([74.125.78.25]:11529 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169AbZK0S6N (ORCPT ); Fri, 27 Nov 2009 13:58:13 -0500 Received: by ey-out-2122.google.com with SMTP id 4so491073eyf.19 for ; Fri, 27 Nov 2009 10:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:cc:mime-version:message-id:content-type :content-transfer-encoding; bh=KzLErJDJvEAnKTqjmbBJy07b+tkgtz0R+HGL9HMGl7c=; b=EKzKr0muB1Y62myXjgt95AeM5EUJGPtSduzBuiywB9NqdtIJ+dFDwK+6MHqjaFmxBd k9aCuTxa+V5t8RMWUEHdTVpc0p7aoftX5U8INBHyZklLKhoO0NkkxHEfbo7a+sjlvFFY bFFw+RbN6sYxxrvk1QoDv9qjaKSG/Cevpx9+w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:mime-version:message-id :content-type:content-transfer-encoding; b=LlJ0c2JS/J/e35uwgwVSmA/z/aCLDyvFALbx/ydzA8iAor7QW9VtV4NnKq3emmveD7 WqOgetWE4C6dmQDBlHbZ1gWak46yIFYDnwoInyY83UDLt6UyUsYnNmX/WppDE9t6K46Y 0cnw++PPCESAt27hrLPLTe8hd0YKcZlH1MVmU= Received: by 10.216.89.213 with SMTP id c63mr460617wef.211.1259348297581; Fri, 27 Nov 2009 10:58:17 -0800 (PST) Received: from szaki.localnet (chello089079027028.chello.pl [89.79.27.28]) by mx.google.com with ESMTPS id t12sm4513208gvd.20.2009.11.27.10.58.16 (version=SSLv3 cipher=RC4-MD5); Fri, 27 Nov 2009 10:58:17 -0800 (PST) From: Bartlomiej Zolnierkiewicz To: linux-ide@vger.kernel.org Subject: [PATCH] pata_hpt366: add enablebits checking Date: Fri, 27 Nov 2009 19:53:51 +0100 User-Agent: KMail/1.12.2 (Linux/2.6.31.5-0.1-desktop; KDE/4.3.1; x86_64; ; ) Cc: linux-kernel@vger.kernel.org, Sergei Shtylyov MIME-Version: 1.0 Message-Id: <200911271953.51400.bzolnier@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org Based on Sergei's older work on IDE hpt366 host driver. Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ata/pata_hpt366.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/ata/pata_hpt366.c =================================================================== --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c @@ -204,6 +204,37 @@ static int hpt36x_cable_detect(struct at return ATA_CBL_PATA80; } +/** + * hpt36x_prereset - perform reset handling + * @link: ATA link to reset + * @deadline: deadline jiffies for the operation + * + * Perform the initial reset handling for the HPT36x. + */ + +static int hpt36x_prereset(struct ata_link *link, unsigned long deadline) +{ + static const struct pci_bits hpt36x_enable_bits[] = { + { 0x50, 1, 0x10, 0x10 }, + { 0x50, 1, 0x20, 0x20 } + }; + + struct ata_port *ap = link->ap; + struct pci_dev *pdev = to_pci_dev(ap->host->dev); + + /* + * HPT36x chips have one channel per function and have + * both channel enable bits located differently and visible + * to both functions -- really stupid design decision... :-( + * Bit 4 is for the primary channel, bit 5 for the secondary. + */ + if (!pci_test_config_bits(pdev, + &hpt36x_enable_bits[PCI_FUNC(pdev->devfn) & 1])) + return -ENOENT; + + return ata_sff_prereset(link, deadline); +} + static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mode) { @@ -284,6 +315,7 @@ static struct scsi_host_template hpt36x_ static struct ata_port_operations hpt366_port_ops = { .inherits = &ata_bmdma32_port_ops, + .prereset = hpt36x_prereset, .cable_detect = hpt36x_cable_detect, .mode_filter = hpt366_filter, .set_piomode = hpt366_set_piomode,