diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2010-03-03 12:17:45 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2010-05-14 17:08:01 -0400 |
commit | 0cbb0e774b0ea0547ec1b9e795637e309327ae27 (patch) | |
tree | 383b5c40d5efa1f2fb86a2a7cfee1a9d2fc621a4 | |
parent | 439fcaec10cef14a08557623d6f5fa240aaf3e2b (diff) |
ahci: Introduce ahci_set_em_messages()
Factor out some ahci_em_messages handling code from ahci_init_one().
We would like to reuse it for non-PCI devices.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
-rw-r--r-- | drivers/ata/ahci.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index a69e5b03429f..d5dc1238a88d 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -3270,6 +3270,29 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host) | |||
3270 | {} | 3270 | {} |
3271 | #endif | 3271 | #endif |
3272 | 3272 | ||
3273 | static void ahci_set_em_messages(struct ahci_host_priv *hpriv, | ||
3274 | struct ata_port_info *pi) | ||
3275 | { | ||
3276 | u8 messages; | ||
3277 | void __iomem *mmio = hpriv->mmio; | ||
3278 | u32 em_loc = readl(mmio + HOST_EM_LOC); | ||
3279 | u32 em_ctl = readl(mmio + HOST_EM_CTL); | ||
3280 | |||
3281 | if (!ahci_em_messages || !(hpriv->cap & HOST_CAP_EMS)) | ||
3282 | return; | ||
3283 | |||
3284 | messages = (em_ctl & EM_CTRL_MSG_TYPE) >> 16; | ||
3285 | |||
3286 | /* we only support LED message type right now */ | ||
3287 | if ((messages & 0x01) && (ahci_em_messages == 1)) { | ||
3288 | /* store em_loc */ | ||
3289 | hpriv->em_loc = ((em_loc >> 16) * 4); | ||
3290 | pi->flags |= ATA_FLAG_EM; | ||
3291 | if (!(em_ctl & EM_CTL_ALHD)) | ||
3292 | pi->flags |= ATA_FLAG_SW_ACTIVITY; | ||
3293 | } | ||
3294 | } | ||
3295 | |||
3273 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 3296 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
3274 | { | 3297 | { |
3275 | static int printed_version; | 3298 | static int printed_version; |
@@ -3373,23 +3396,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3373 | if (hpriv->cap & HOST_CAP_PMP) | 3396 | if (hpriv->cap & HOST_CAP_PMP) |
3374 | pi.flags |= ATA_FLAG_PMP; | 3397 | pi.flags |= ATA_FLAG_PMP; |
3375 | 3398 | ||
3376 | if (ahci_em_messages && (hpriv->cap & HOST_CAP_EMS)) { | 3399 | ahci_set_em_messages(hpriv, &pi); |
3377 | u8 messages; | ||
3378 | void __iomem *mmio = hpriv->mmio; | ||
3379 | u32 em_loc = readl(mmio + HOST_EM_LOC); | ||
3380 | u32 em_ctl = readl(mmio + HOST_EM_CTL); | ||
3381 | |||
3382 | messages = (em_ctl & EM_CTRL_MSG_TYPE) >> 16; | ||
3383 | |||
3384 | /* we only support LED message type right now */ | ||
3385 | if ((messages & 0x01) && (ahci_em_messages == 1)) { | ||
3386 | /* store em_loc */ | ||
3387 | hpriv->em_loc = ((em_loc >> 16) * 4); | ||
3388 | pi.flags |= ATA_FLAG_EM; | ||
3389 | if (!(em_ctl & EM_CTL_ALHD)) | ||
3390 | pi.flags |= ATA_FLAG_SW_ACTIVITY; | ||
3391 | } | ||
3392 | } | ||
3393 | 3400 | ||
3394 | if (ahci_broken_system_poweroff(pdev)) { | 3401 | if (ahci_broken_system_poweroff(pdev)) { |
3395 | pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN; | 3402 | pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN; |