aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_mv.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-02-01 01:06:36 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-09 17:39:38 -0500
commit0d5ff566779f894ca9937231a181eb31e4adff0e (patch)
treed1c7495c932581c1d41aa7f0fdb303348da49106 /drivers/ata/sata_mv.c
parent1a68ff13c8a9b517de3fd4187dc525412a6eba1b (diff)
libata: convert to iomap
Convert libata core layer and LLDs to use iomap. * managed iomap is used. Pointer to pcim_iomap_table() is cached at host->iomap and used through out LLDs. This basically replaces host->mmio_base. * if possible, pcim_iomap_regions() is used Most iomap operation conversions are taken from Jeff Garzik <jgarzik@pobox.com>'s iomap branch. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/sata_mv.c')
-rw-r--r--drivers/ata/sata_mv.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index c073e453dcdd..7c578c275db0 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -404,7 +404,7 @@ static const struct ata_port_operations mv5_ops = {
404 404
405 .qc_prep = mv_qc_prep, 405 .qc_prep = mv_qc_prep,
406 .qc_issue = mv_qc_issue, 406 .qc_issue = mv_qc_issue,
407 .data_xfer = ata_mmio_data_xfer, 407 .data_xfer = ata_data_xfer,
408 408
409 .eng_timeout = mv_eng_timeout, 409 .eng_timeout = mv_eng_timeout,
410 410
@@ -431,7 +431,7 @@ static const struct ata_port_operations mv6_ops = {
431 431
432 .qc_prep = mv_qc_prep, 432 .qc_prep = mv_qc_prep,
433 .qc_issue = mv_qc_issue, 433 .qc_issue = mv_qc_issue,
434 .data_xfer = ata_mmio_data_xfer, 434 .data_xfer = ata_data_xfer,
435 435
436 .eng_timeout = mv_eng_timeout, 436 .eng_timeout = mv_eng_timeout,
437 437
@@ -458,7 +458,7 @@ static const struct ata_port_operations mv_iie_ops = {
458 458
459 .qc_prep = mv_qc_prep_iie, 459 .qc_prep = mv_qc_prep_iie,
460 .qc_issue = mv_qc_issue, 460 .qc_issue = mv_qc_issue,
461 .data_xfer = ata_mmio_data_xfer, 461 .data_xfer = ata_data_xfer,
462 462
463 .eng_timeout = mv_eng_timeout, 463 .eng_timeout = mv_eng_timeout,
464 464
@@ -615,7 +615,7 @@ static inline void __iomem *mv_port_base(void __iomem *base, unsigned int port)
615 615
616static inline void __iomem *mv_ap_base(struct ata_port *ap) 616static inline void __iomem *mv_ap_base(struct ata_port *ap)
617{ 617{
618 return mv_port_base(ap->host->mmio_base, ap->port_no); 618 return mv_port_base(ap->host->iomap[MV_PRIMARY_BAR], ap->port_no);
619} 619}
620 620
621static inline int mv_get_hc_count(unsigned long port_flags) 621static inline int mv_get_hc_count(unsigned long port_flags)
@@ -1299,7 +1299,7 @@ static void mv_err_intr(struct ata_port *ap, int reset_allowed)
1299 */ 1299 */
1300static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc) 1300static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc)
1301{ 1301{
1302 void __iomem *mmio = host->mmio_base; 1302 void __iomem *mmio = host->iomap[MV_PRIMARY_BAR];
1303 void __iomem *hc_mmio = mv_hc_base(mmio, hc); 1303 void __iomem *hc_mmio = mv_hc_base(mmio, hc);
1304 struct ata_queued_cmd *qc; 1304 struct ata_queued_cmd *qc;
1305 u32 hc_irq_cause; 1305 u32 hc_irq_cause;
@@ -1342,8 +1342,7 @@ static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc)
1342 } else { 1342 } else {
1343 /* PIO: check for device (drive) interrupt */ 1343 /* PIO: check for device (drive) interrupt */
1344 if ((DEV_IRQ << hard_port) & hc_irq_cause) { 1344 if ((DEV_IRQ << hard_port) & hc_irq_cause) {
1345 ata_status = readb((void __iomem *) 1345 ata_status = readb(ap->ioaddr.status_addr);
1346 ap->ioaddr.status_addr);
1347 handled = 1; 1346 handled = 1;
1348 /* ignore spurious intr if drive still BUSY */ 1347 /* ignore spurious intr if drive still BUSY */
1349 if (ata_status & ATA_BUSY) { 1348 if (ata_status & ATA_BUSY) {
@@ -1403,7 +1402,7 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance)
1403{ 1402{
1404 struct ata_host *host = dev_instance; 1403 struct ata_host *host = dev_instance;
1405 unsigned int hc, handled = 0, n_hcs; 1404 unsigned int hc, handled = 0, n_hcs;
1406 void __iomem *mmio = host->mmio_base; 1405 void __iomem *mmio = host->iomap[MV_PRIMARY_BAR];
1407 struct mv_host_priv *hpriv; 1406 struct mv_host_priv *hpriv;
1408 u32 irq_stat; 1407 u32 irq_stat;
1409 1408
@@ -1479,22 +1478,24 @@ static unsigned int mv5_scr_offset(unsigned int sc_reg_in)
1479 1478
1480static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in) 1479static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in)
1481{ 1480{
1482 void __iomem *mmio = mv5_phy_base(ap->host->mmio_base, ap->port_no); 1481 void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
1482 void __iomem *addr = mv5_phy_base(mmio, ap->port_no);
1483 unsigned int ofs = mv5_scr_offset(sc_reg_in); 1483 unsigned int ofs = mv5_scr_offset(sc_reg_in);
1484 1484
1485 if (ofs != 0xffffffffU) 1485 if (ofs != 0xffffffffU)
1486 return readl(mmio + ofs); 1486 return readl(addr + ofs);
1487 else 1487 else
1488 return (u32) ofs; 1488 return (u32) ofs;
1489} 1489}
1490 1490
1491static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) 1491static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
1492{ 1492{
1493 void __iomem *mmio = mv5_phy_base(ap->host->mmio_base, ap->port_no); 1493 void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
1494 void __iomem *addr = mv5_phy_base(mmio, ap->port_no);
1494 unsigned int ofs = mv5_scr_offset(sc_reg_in); 1495 unsigned int ofs = mv5_scr_offset(sc_reg_in);
1495 1496
1496 if (ofs != 0xffffffffU) 1497 if (ofs != 0xffffffffU)
1497 writelfl(val, mmio + ofs); 1498 writelfl(val, addr + ofs);
1498} 1499}
1499 1500
1500static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio) 1501static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio)
@@ -1856,7 +1857,7 @@ static void mv_channel_reset(struct mv_host_priv *hpriv, void __iomem *mmio,
1856static void mv_stop_and_reset(struct ata_port *ap) 1857static void mv_stop_and_reset(struct ata_port *ap)
1857{ 1858{
1858 struct mv_host_priv *hpriv = ap->host->private_data; 1859 struct mv_host_priv *hpriv = ap->host->private_data;
1859 void __iomem *mmio = ap->host->mmio_base; 1860 void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
1860 1861
1861 mv_stop_dma(ap); 1862 mv_stop_dma(ap);
1862 1863
@@ -1954,10 +1955,10 @@ comreset_retry:
1954 break; 1955 break;
1955 } 1956 }
1956 1957
1957 tf.lbah = readb((void __iomem *) ap->ioaddr.lbah_addr); 1958 tf.lbah = readb(ap->ioaddr.lbah_addr);
1958 tf.lbam = readb((void __iomem *) ap->ioaddr.lbam_addr); 1959 tf.lbam = readb(ap->ioaddr.lbam_addr);
1959 tf.lbal = readb((void __iomem *) ap->ioaddr.lbal_addr); 1960 tf.lbal = readb(ap->ioaddr.lbal_addr);
1960 tf.nsect = readb((void __iomem *) ap->ioaddr.nsect_addr); 1961 tf.nsect = readb(ap->ioaddr.nsect_addr);
1961 1962
1962 dev->class = ata_dev_classify(&tf); 1963 dev->class = ata_dev_classify(&tf);
1963 if (!ata_dev_enabled(dev)) { 1964 if (!ata_dev_enabled(dev)) {
@@ -1989,17 +1990,17 @@ static void mv_phy_reset(struct ata_port *ap)
1989 */ 1990 */
1990static void mv_eng_timeout(struct ata_port *ap) 1991static void mv_eng_timeout(struct ata_port *ap)
1991{ 1992{
1993 void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
1992 struct ata_queued_cmd *qc; 1994 struct ata_queued_cmd *qc;
1993 unsigned long flags; 1995 unsigned long flags;
1994 1996
1995 ata_port_printk(ap, KERN_ERR, "Entering mv_eng_timeout\n"); 1997 ata_port_printk(ap, KERN_ERR, "Entering mv_eng_timeout\n");
1996 DPRINTK("All regs @ start of eng_timeout\n"); 1998 DPRINTK("All regs @ start of eng_timeout\n");
1997 mv_dump_all_regs(ap->host->mmio_base, ap->port_no, 1999 mv_dump_all_regs(mmio, ap->port_no, to_pci_dev(ap->host->dev));
1998 to_pci_dev(ap->host->dev));
1999 2000
2000 qc = ata_qc_from_tag(ap, ap->active_tag); 2001 qc = ata_qc_from_tag(ap, ap->active_tag);
2001 printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n", 2002 printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n",
2002 ap->host->mmio_base, ap, qc, qc->scsicmd, &qc->scsicmd->cmnd); 2003 mmio, ap, qc, qc->scsicmd, &qc->scsicmd->cmnd);
2003 2004
2004 spin_lock_irqsave(&ap->host->lock, flags); 2005 spin_lock_irqsave(&ap->host->lock, flags);
2005 mv_err_intr(ap, 0); 2006 mv_err_intr(ap, 0);
@@ -2027,7 +2028,7 @@ static void mv_eng_timeout(struct ata_port *ap)
2027 */ 2028 */
2028static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio) 2029static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio)
2029{ 2030{
2030 unsigned long shd_base = (unsigned long) port_mmio + SHD_BLK_OFS; 2031 void __iomem *shd_base = port_mmio + SHD_BLK_OFS;
2031 unsigned serr_ofs; 2032 unsigned serr_ofs;
2032 2033
2033 /* PIO related setup 2034 /* PIO related setup
@@ -2175,7 +2176,7 @@ static int mv_init_host(struct pci_dev *pdev, struct ata_probe_ent *probe_ent,
2175 unsigned int board_idx) 2176 unsigned int board_idx)
2176{ 2177{
2177 int rc = 0, n_hc, port, hc; 2178 int rc = 0, n_hc, port, hc;
2178 void __iomem *mmio = probe_ent->mmio_base; 2179 void __iomem *mmio = probe_ent->iomap[MV_PRIMARY_BAR];
2179 struct mv_host_priv *hpriv = probe_ent->private_data; 2180 struct mv_host_priv *hpriv = probe_ent->private_data;
2180 2181
2181 /* global interrupt mask */ 2182 /* global interrupt mask */
@@ -2297,7 +2298,6 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2297 struct ata_probe_ent *probe_ent; 2298 struct ata_probe_ent *probe_ent;
2298 struct mv_host_priv *hpriv; 2299 struct mv_host_priv *hpriv;
2299 unsigned int board_idx = (unsigned int)ent->driver_data; 2300 unsigned int board_idx = (unsigned int)ent->driver_data;
2300 void __iomem *mmio_base;
2301 int rc; 2301 int rc;
2302 2302
2303 if (!printed_version++) 2303 if (!printed_version++)
@@ -2308,11 +2308,11 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2308 return rc; 2308 return rc;
2309 pci_set_master(pdev); 2309 pci_set_master(pdev);
2310 2310
2311 rc = pci_request_regions(pdev, DRV_NAME); 2311 rc = pcim_iomap_regions(pdev, 1 << MV_PRIMARY_BAR, DRV_NAME);
2312 if (rc) { 2312 if (rc == -EBUSY)
2313 pcim_pin_device(pdev); 2313 pcim_pin_device(pdev);
2314 if (rc)
2314 return rc; 2315 return rc;
2315 }
2316 2316
2317 probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); 2317 probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
2318 if (probe_ent == NULL) 2318 if (probe_ent == NULL)
@@ -2321,10 +2321,6 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2321 probe_ent->dev = pci_dev_to_dev(pdev); 2321 probe_ent->dev = pci_dev_to_dev(pdev);
2322 INIT_LIST_HEAD(&probe_ent->node); 2322 INIT_LIST_HEAD(&probe_ent->node);
2323 2323
2324 mmio_base = pcim_iomap(pdev, MV_PRIMARY_BAR, 0);
2325 if (mmio_base == NULL)
2326 return -ENOMEM;
2327
2328 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); 2324 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
2329 if (!hpriv) 2325 if (!hpriv)
2330 return -ENOMEM; 2326 return -ENOMEM;
@@ -2337,7 +2333,7 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2337 2333
2338 probe_ent->irq = pdev->irq; 2334 probe_ent->irq = pdev->irq;
2339 probe_ent->irq_flags = IRQF_SHARED; 2335 probe_ent->irq_flags = IRQF_SHARED;
2340 probe_ent->mmio_base = mmio_base; 2336 probe_ent->iomap = pcim_iomap_table(pdev);
2341 probe_ent->private_data = hpriv; 2337 probe_ent->private_data = hpriv;
2342 2338
2343 /* initialize adapter */ 2339 /* initialize adapter */