aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/ahci.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-04-23 07:52:58 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-25 00:45:13 -0400
commit15fe982e429e0e6b7466719acb6cfd9dbfe47f0c (patch)
treede5ac9b692257050bf8dbdb6ebe02e780fddad46 /drivers/ata/ahci.c
parent411cb3869afd91ed40e8f12df64cd9e315356305 (diff)
ahci: retry enabling AHCI a few times before spitting out WARN_ON()
Some chips need AHCI_EN set more than once to actually set it. Try a few times before giving up and spitting out WARN_ON(). Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Peer Chen <pchen@nvidia.com> Cc: Volker Armin Hemmann <volker.armin.hemmann@tu-clausthal.de> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/ahci.c')
-rw-r--r--drivers/ata/ahci.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 986e3324e302..7c4f886f1f16 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -556,16 +556,27 @@ static inline void __iomem *ahci_port_base(struct ata_port *ap)
556 556
557static void ahci_enable_ahci(void __iomem *mmio) 557static void ahci_enable_ahci(void __iomem *mmio)
558{ 558{
559 int i;
559 u32 tmp; 560 u32 tmp;
560 561
561 /* turn on AHCI_EN */ 562 /* turn on AHCI_EN */
562 tmp = readl(mmio + HOST_CTL); 563 tmp = readl(mmio + HOST_CTL);
563 if (!(tmp & HOST_AHCI_EN)) { 564 if (tmp & HOST_AHCI_EN)
565 return;
566
567 /* Some controllers need AHCI_EN to be written multiple times.
568 * Try a few times before giving up.
569 */
570 for (i = 0; i < 5; i++) {
564 tmp |= HOST_AHCI_EN; 571 tmp |= HOST_AHCI_EN;
565 writel(tmp, mmio + HOST_CTL); 572 writel(tmp, mmio + HOST_CTL);
566 tmp = readl(mmio + HOST_CTL); /* flush && sanity check */ 573 tmp = readl(mmio + HOST_CTL); /* flush && sanity check */
567 WARN_ON(!(tmp & HOST_AHCI_EN)); 574 if (tmp & HOST_AHCI_EN)
575 return;
576 msleep(10);
568 } 577 }
578
579 WARN_ON(1);
569} 580}
570 581
571/** 582/**