aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/ahci.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 5326af28a410..c720c2c5cefe 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -295,6 +295,7 @@ struct ahci_em_priv {
295}; 295};
296 296
297struct ahci_host_priv { 297struct ahci_host_priv {
298 void __iomem * mmio; /* bus-independant mem map */
298 unsigned int flags; /* AHCI_HFLAG_* */ 299 unsigned int flags; /* AHCI_HFLAG_* */
299 u32 cap; /* cap to use */ 300 u32 cap; /* cap to use */
300 u32 cap2; /* cap2 to use */ 301 u32 cap2; /* cap2 to use */
@@ -760,7 +761,8 @@ static inline int ahci_nr_ports(u32 cap)
760static inline void __iomem *__ahci_port_base(struct ata_host *host, 761static inline void __iomem *__ahci_port_base(struct ata_host *host,
761 unsigned int port_no) 762 unsigned int port_no)
762{ 763{
763 void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; 764 struct ahci_host_priv *hpriv = host->private_data;
765 void __iomem *mmio = hpriv->mmio;
764 766
765 return mmio + 0x100 + (port_no * 0x80); 767 return mmio + 0x100 + (port_no * 0x80);
766} 768}
@@ -820,7 +822,8 @@ static ssize_t ahci_show_host_version(struct device *dev,
820{ 822{
821 struct Scsi_Host *shost = class_to_shost(dev); 823 struct Scsi_Host *shost = class_to_shost(dev);
822 struct ata_port *ap = ata_shost_to_port(shost); 824 struct ata_port *ap = ata_shost_to_port(shost);
823 void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR]; 825 struct ahci_host_priv *hpriv = ap->host->private_data;
826 void __iomem *mmio = hpriv->mmio;
824 827
825 return sprintf(buf, "%x\n", readl(mmio + HOST_VERSION)); 828 return sprintf(buf, "%x\n", readl(mmio + HOST_VERSION));
826} 829}
@@ -853,7 +856,7 @@ static ssize_t ahci_show_port_cmd(struct device *dev,
853static void ahci_save_initial_config(struct pci_dev *pdev, 856static void ahci_save_initial_config(struct pci_dev *pdev,
854 struct ahci_host_priv *hpriv) 857 struct ahci_host_priv *hpriv)
855{ 858{
856 void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; 859 void __iomem *mmio = hpriv->mmio;
857 u32 cap, cap2, vers, port_map; 860 u32 cap, cap2, vers, port_map;
858 int i; 861 int i;
859 int mv; 862 int mv;
@@ -982,7 +985,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
982static void ahci_restore_initial_config(struct ata_host *host) 985static void ahci_restore_initial_config(struct ata_host *host)
983{ 986{
984 struct ahci_host_priv *hpriv = host->private_data; 987 struct ahci_host_priv *hpriv = host->private_data;
985 void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; 988 void __iomem *mmio = hpriv->mmio;
986 989
987 writel(hpriv->saved_cap, mmio + HOST_CAP); 990 writel(hpriv->saved_cap, mmio + HOST_CAP);
988 if (hpriv->saved_cap2) 991 if (hpriv->saved_cap2)
@@ -1341,7 +1344,7 @@ static int ahci_reset_controller(struct ata_host *host)
1341{ 1344{
1342 struct pci_dev *pdev = to_pci_dev(host->dev); 1345 struct pci_dev *pdev = to_pci_dev(host->dev);
1343 struct ahci_host_priv *hpriv = host->private_data; 1346 struct ahci_host_priv *hpriv = host->private_data;
1344 void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; 1347 void __iomem *mmio = hpriv->mmio;
1345 u32 tmp; 1348 u32 tmp;
1346 1349
1347 /* we must be in AHCI mode, before using anything 1350 /* we must be in AHCI mode, before using anything
@@ -1472,7 +1475,8 @@ static void ahci_init_sw_activity(struct ata_link *link)
1472 1475
1473static int ahci_reset_em(struct ata_host *host) 1476static int ahci_reset_em(struct ata_host *host)
1474{ 1477{
1475 void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; 1478 struct ahci_host_priv *hpriv = host->private_data;
1479 void __iomem *mmio = hpriv->mmio;
1476 u32 em_ctl; 1480 u32 em_ctl;
1477 1481
1478 em_ctl = readl(mmio + HOST_EM_CTL); 1482 em_ctl = readl(mmio + HOST_EM_CTL);
@@ -1488,7 +1492,7 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
1488{ 1492{
1489 struct ahci_host_priv *hpriv = ap->host->private_data; 1493 struct ahci_host_priv *hpriv = ap->host->private_data;
1490 struct ahci_port_priv *pp = ap->private_data; 1494 struct ahci_port_priv *pp = ap->private_data;
1491 void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR]; 1495 void __iomem *mmio = hpriv->mmio;
1492 u32 em_ctl; 1496 u32 em_ctl;
1493 u32 message[] = {0, 0}; 1497 u32 message[] = {0, 0};
1494 unsigned long flags; 1498 unsigned long flags;
@@ -1656,7 +1660,7 @@ static void ahci_init_controller(struct ata_host *host)
1656{ 1660{
1657 struct ahci_host_priv *hpriv = host->private_data; 1661 struct ahci_host_priv *hpriv = host->private_data;
1658 struct pci_dev *pdev = to_pci_dev(host->dev); 1662 struct pci_dev *pdev = to_pci_dev(host->dev);
1659 void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; 1663 void __iomem *mmio = hpriv->mmio;
1660 int i; 1664 int i;
1661 void __iomem *port_mmio; 1665 void __iomem *port_mmio;
1662 u32 tmp; 1666 u32 tmp;
@@ -2375,7 +2379,7 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
2375 VPRINTK("ENTER\n"); 2379 VPRINTK("ENTER\n");
2376 2380
2377 hpriv = host->private_data; 2381 hpriv = host->private_data;
2378 mmio = host->iomap[AHCI_PCI_BAR]; 2382 mmio = hpriv->mmio;
2379 2383
2380 /* sigh. 0xffffffff is a valid return from h/w */ 2384 /* sigh. 0xffffffff is a valid return from h/w */
2381 irq_stat = readl(mmio + HOST_IRQ_STAT); 2385 irq_stat = readl(mmio + HOST_IRQ_STAT);
@@ -2476,7 +2480,8 @@ static void ahci_freeze(struct ata_port *ap)
2476 2480
2477static void ahci_thaw(struct ata_port *ap) 2481static void ahci_thaw(struct ata_port *ap)
2478{ 2482{
2479 void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR]; 2483 struct ahci_host_priv *hpriv = ap->host->private_data;
2484 void __iomem *mmio = hpriv->mmio;
2480 void __iomem *port_mmio = ahci_port_base(ap); 2485 void __iomem *port_mmio = ahci_port_base(ap);
2481 u32 tmp; 2486 u32 tmp;
2482 struct ahci_port_priv *pp = ap->private_data; 2487 struct ahci_port_priv *pp = ap->private_data;
@@ -2641,7 +2646,7 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
2641{ 2646{
2642 struct ata_host *host = dev_get_drvdata(&pdev->dev); 2647 struct ata_host *host = dev_get_drvdata(&pdev->dev);
2643 struct ahci_host_priv *hpriv = host->private_data; 2648 struct ahci_host_priv *hpriv = host->private_data;
2644 void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; 2649 void __iomem *mmio = hpriv->mmio;
2645 u32 ctl; 2650 u32 ctl;
2646 2651
2647 if (mesg.event & PM_EVENT_SUSPEND && 2652 if (mesg.event & PM_EVENT_SUSPEND &&
@@ -2810,7 +2815,7 @@ static void ahci_print_info(struct ata_host *host)
2810{ 2815{
2811 struct ahci_host_priv *hpriv = host->private_data; 2816 struct ahci_host_priv *hpriv = host->private_data;
2812 struct pci_dev *pdev = to_pci_dev(host->dev); 2817 struct pci_dev *pdev = to_pci_dev(host->dev);
2813 void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; 2818 void __iomem *mmio = hpriv->mmio;
2814 u32 vers, cap, cap2, impl, speed; 2819 u32 vers, cap, cap2, impl, speed;
2815 const char *speed_s; 2820 const char *speed_s;
2816 u16 cc; 2821 u16 cc;
@@ -3308,6 +3313,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3308 if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev)) 3313 if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev))
3309 pci_intx(pdev, 1); 3314 pci_intx(pdev, 1);
3310 3315
3316 hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
3317
3311 /* save initial config */ 3318 /* save initial config */
3312 ahci_save_initial_config(pdev, hpriv); 3319 ahci_save_initial_config(pdev, hpriv);
3313 3320
@@ -3328,7 +3335,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3328 3335
3329 if (ahci_em_messages && (hpriv->cap & HOST_CAP_EMS)) { 3336 if (ahci_em_messages && (hpriv->cap & HOST_CAP_EMS)) {
3330 u8 messages; 3337 u8 messages;
3331 void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; 3338 void __iomem *mmio = hpriv->mmio;
3332 u32 em_loc = readl(mmio + HOST_EM_LOC); 3339 u32 em_loc = readl(mmio + HOST_EM_LOC);
3333 u32 em_ctl = readl(mmio + HOST_EM_CTL); 3340 u32 em_ctl = readl(mmio + HOST_EM_CTL);
3334 3341
@@ -3372,7 +3379,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3372 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); 3379 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
3373 if (!host) 3380 if (!host)
3374 return -ENOMEM; 3381 return -ENOMEM;
3375 host->iomap = pcim_iomap_table(pdev);
3376 host->private_data = hpriv; 3382 host->private_data = hpriv;
3377 3383
3378 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) 3384 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)