Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 76924
b: refs/heads/master
c: b710a1f
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Jan 23, 2008
1 parent 0437e4d commit 3d69fb1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c729072459446885c5c200137de1db32da5db4dc
refs/heads/master: b710a1f4b34438b624e9c6c2dc8bcf54b0b0ba27
27 changes: 20 additions & 7 deletions trunk/drivers/ata/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,20 @@ static inline void __iomem *ahci_port_base(struct ata_port *ap)
return __ahci_port_base(ap->host, ap->port_no);
}

static void ahci_enable_ahci(void __iomem *mmio)
{
u32 tmp;

/* turn on AHCI_EN */
tmp = readl(mmio + HOST_CTL);
if (!(tmp & HOST_AHCI_EN)) {
tmp |= HOST_AHCI_EN;
writel(tmp, mmio + HOST_CTL);
tmp = readl(mmio + HOST_CTL); /* flush && sanity check */
WARN_ON(!(tmp & HOST_AHCI_EN));
}
}

/**
* ahci_save_initial_config - Save and fixup initial config values
* @pdev: target PCI device
Expand All @@ -619,6 +633,9 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
u32 cap, port_map;
int i;

/* make sure AHCI mode is enabled before accessing CAP */
ahci_enable_ahci(mmio);

/* Values prefixed with saved_ are written back to host after
* reset. Values without are used for driver operation.
*/
Expand Down Expand Up @@ -1043,13 +1060,10 @@ static int ahci_reset_controller(struct ata_host *host)
/* we must be in AHCI mode, before using anything
* AHCI-specific, such as HOST_RESET.
*/
tmp = readl(mmio + HOST_CTL);
if (!(tmp & HOST_AHCI_EN)) {
tmp |= HOST_AHCI_EN;
writel(tmp, mmio + HOST_CTL);
}
ahci_enable_ahci(mmio);

/* global controller reset */
tmp = readl(mmio + HOST_CTL);
if ((tmp & HOST_RESET) == 0) {
writel(tmp | HOST_RESET, mmio + HOST_CTL);
readl(mmio + HOST_CTL); /* flush */
Expand All @@ -1068,8 +1082,7 @@ static int ahci_reset_controller(struct ata_host *host)
}

/* turn on AHCI mode */
writel(HOST_AHCI_EN, mmio + HOST_CTL);
(void) readl(mmio + HOST_CTL); /* flush */
ahci_enable_ahci(mmio);

/* some registers might be cleared on reset. restore initial values */
ahci_restore_initial_config(host);
Expand Down

0 comments on commit 3d69fb1

Please sign in to comment.