* ahci: factor out AHCI enabling and enable AHCI before reading CAP
@ 2008-01-05 14:11 Tejun Heo
2008-01-18 9:37 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Tejun Heo @ 2008-01-05 14:11 UTC (permalink / raw)
To: Jeff Garzik, IDE/ATA development list
Factor out AHCI enabling into ahci_enable_ahci() and enabling AHCI
before reading CAP in ahci_save_initial_config() as the spec requires
enabling AHCI mode before accessing any other registers.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
drivers/ata/ahci.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
Index: work/drivers/ata/ahci.c
===================================================================
--- work.orig/drivers/ata/ahci.c
+++ work/drivers/ata/ahci.c
@@ -597,6 +597,20 @@ static inline void __iomem *ahci_port_ba
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
@@ -619,6 +633,9 @@ static void ahci_save_initial_config(str
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.
*/
@@ -1042,13 +1059,10 @@ static int ahci_reset_controller(struct
/* 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 */
@@ -1067,8 +1081,7 @@ static int ahci_reset_controller(struct
}
/* 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: ahci: factor out AHCI enabling and enable AHCI before reading CAP
2008-01-05 14:11 ahci: factor out AHCI enabling and enable AHCI before reading CAP Tejun Heo
@ 2008-01-18 9:37 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2008-01-18 9:37 UTC (permalink / raw)
To: Jeff Garzik, IDE/ATA development list
Tejun Heo wrote:
> Factor out AHCI enabling into ahci_enable_ahci() and enabling AHCI
> before reading CAP in ahci_save_initial_config() as the spec requires
> enabling AHCI mode before accessing any other registers.
>
> Signed-off-by: Tejun Heo <htejun@gmail.com>
Ping. Sorry about the missing [PATCH] header.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-01-18 9:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-05 14:11 ahci: factor out AHCI enabling and enable AHCI before reading CAP Tejun Heo
2008-01-18 9:37 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).