From patchwork Tue Oct 6 22:27:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 35161 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 E1DA3B7BC2 for ; Wed, 7 Oct 2009 09:45:38 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933442AbZJFW1w (ORCPT ); Tue, 6 Oct 2009 18:27:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S933465AbZJFW1w (ORCPT ); Tue, 6 Oct 2009 18:27:52 -0400 Received: from mail-bw0-f210.google.com ([209.85.218.210]:57767 "EHLO mail-bw0-f210.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933442AbZJFW1u (ORCPT ); Tue, 6 Oct 2009 18:27:50 -0400 Received: by bwz6 with SMTP id 6so3689755bwz.37 for ; Tue, 06 Oct 2009 15:27:12 -0700 (PDT) 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=VZin3YUU/kDKJ5hmRpAaPvGgpzgD6sEHH4aPmFyE5co=; b=aDNVoZ7wwCBQ5GPdDzshplm1YyqXVbHwyGNr1zQgZkAvZbyPsCyiL7vKCvvIut690F ncN81gf2wa+YL8f9VBq3XzsOO5fj8RFJg9H5Uo3g4WabNmkzaMIKkF8sn64O2h/LS4Tx UizxGxL+C1SSR665ZUzxqpf1xFtyfXIdEFR2g= 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=FTpW/Z6zfk5oqy8j8woCv1O1d+MzauInu7hrJCkeEOCAkyyT816Lkw+mTwZbAPJV7Z scx5WJ77J8xp2yxu8T1oaUlUUFB/kBMU53t2dAw7t+WtOcwAWGRKulttMLugHoMmAoi5 7XfragbScxPTz+vDyjiB6r8dS7JC0DTNDgPZA= Received: by 10.103.86.34 with SMTP id o34mr923822mul.118.1254868032665; Tue, 06 Oct 2009 15:27:12 -0700 (PDT) Received: from szaki.localnet (chello089077034197.chello.pl [89.77.34.197]) by mx.google.com with ESMTPS id 14sm990013muo.15.2009.10.06.15.27.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 06 Oct 2009 15:27:11 -0700 (PDT) From: Bartlomiej Zolnierkiewicz To: Jeff Garzik Subject: [PATCH 2/4] pata_atp867x: clarifications in timings calculations and cable detection Date: Wed, 7 Oct 2009 00:27:03 +0200 User-Agent: KMail/1.12.1 (Linux/2.6.31.1-56.fc12.x86_64; KDE/4.3.1; x86_64; ; ) Cc: John Lee (Jung-Ik) , linux-ide@vger.kernel.org MIME-Version: 1.0 Message-Id: <200910070027.04071.bzolnier@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: John(Jung-Ik) Lee Subject: [PATCH] pata_atp867x: clarifications in timings calculations and cable detection Signed-off-by: John(Jung-Ik) Lee Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ata/pata_atp867x.c | 52 ++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 14 deletions(-) -- 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_atp867x.c =================================================================== --- a/drivers/ata/pata_atp867x.c +++ b/drivers/ata/pata_atp867x.c @@ -149,8 +149,10 @@ static void atp867x_set_dmamode(struct a iowrite8(b, dp->dma_mode); } -static int atp867x_get_active_clocks_shifted(unsigned int clk) +static int atp867x_get_active_clocks_shifted(struct ata_port *ap, + unsigned int clk) { + struct atp867x_priv *dp = ap->private_data; unsigned char clocks = clk; switch (clocks) { @@ -159,15 +161,25 @@ static int atp867x_get_active_clocks_shi break; case 1 ... 7: break; - case 8 ... 12: + case 9 ... 12: clocks = 7; break; default: printk(KERN_WARNING "ATP867X: active %dclk is invalid. " "Using default 8clk.\n", clk); - clocks = 0; /* 8 clk */ - break; + case 8: /* default 8 clk */ + clocks = 0; + goto active_clock_shift_done; } + + /* + * Doc 6.6.9: increase the clock value by 1 for safer PIO speed + * on 66MHz bus + */ + if (dp->pci66mhz && clocks < 7) + clocks++; + +active_clock_shift_done: return clocks << ATP867X_IO_PIOSPD_ACTIVE_SHIFT; } @@ -181,20 +193,19 @@ static int atp867x_get_recover_clocks_sh break; case 1 ... 11: break; - case 12: - clocks = 0; - break; case 13: case 14: - --clocks; + --clocks; /* by the spec */ break; case 15: break; default: printk(KERN_WARNING "ATP867X: recover %dclk is invalid. " - "Using default 15clk.\n", clk); - clocks = 0; /* 12 clk */ + "Using default 12clk.\n", clk); + case 12: /* default 12 clk */ + clocks = 0; break; } + return clocks << ATP867X_IO_PIOSPD_RECOVER_SHIFT; } @@ -223,10 +234,8 @@ static void atp867x_set_piomode(struct a b = (b & ~ATP867X_IO_DMAMODE_MSTR_MASK); iowrite8(b, dp->dma_mode); - b = atp867x_get_active_clocks_shifted(t.active) | + b = atp867x_get_active_clocks_shifted(ap, t.active) | atp867x_get_recover_clocks_shifted(t.recover); - if (dp->pci66mhz) - b += 0x10; if (adev->devno & 1) iowrite8(b, dp->slave_piospd); @@ -239,9 +248,24 @@ static void atp867x_set_piomode(struct a iowrite8(b, dp->eightb_piospd); } +static int atp867x_cable_override(struct pci_dev *pdev) +{ + if (pdev->subsystem_vendor == PCI_VENDOR_ID_ARTOP && + (pdev->subsystem_device == PCI_DEVICE_ID_ARTOP_ATP867A || + pdev->subsystem_device == PCI_DEVICE_ID_ARTOP_ATP867B)) { + return 1; + } + return 0; +} + static int atp867x_cable_detect(struct ata_port *ap) { - return ATA_CBL_PATA40_SHORT; + struct pci_dev *pdev = to_pci_dev(ap->host->dev); + + if (atp867x_cable_override(pdev)) + return ATA_CBL_PATA40_SHORT; + + return ATA_CBL_PATA_UNK; } static struct scsi_host_template atp867x_sht = {