aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_qstor.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_qstor.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_qstor.c')
-rw-r--r--drivers/ata/sata_qstor.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c
index 339f61648af6..cd579b180274 100644
--- a/drivers/ata/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -43,6 +43,8 @@
43#define DRV_VERSION "0.06" 43#define DRV_VERSION "0.06"
44 44
45enum { 45enum {
46 QS_MMIO_BAR = 4,
47
46 QS_PORTS = 4, 48 QS_PORTS = 4,
47 QS_MAX_PRD = LIBATA_MAX_PRD, 49 QS_MAX_PRD = LIBATA_MAX_PRD,
48 QS_CPB_ORDER = 6, 50 QS_CPB_ORDER = 6,
@@ -155,7 +157,7 @@ static const struct ata_port_operations qs_ata_ops = {
155 .phy_reset = qs_phy_reset, 157 .phy_reset = qs_phy_reset,
156 .qc_prep = qs_qc_prep, 158 .qc_prep = qs_qc_prep,
157 .qc_issue = qs_qc_issue, 159 .qc_issue = qs_qc_issue,
158 .data_xfer = ata_mmio_data_xfer, 160 .data_xfer = ata_data_xfer,
159 .eng_timeout = qs_eng_timeout, 161 .eng_timeout = qs_eng_timeout,
160 .irq_handler = qs_intr, 162 .irq_handler = qs_intr,
161 .irq_clear = qs_irq_clear, 163 .irq_clear = qs_irq_clear,
@@ -194,6 +196,11 @@ static struct pci_driver qs_ata_pci_driver = {
194 .remove = ata_pci_remove_one, 196 .remove = ata_pci_remove_one,
195}; 197};
196 198
199static void __iomem *qs_mmio_base(struct ata_host *host)
200{
201 return host->iomap[QS_MMIO_BAR];
202}
203
197static int qs_check_atapi_dma(struct ata_queued_cmd *qc) 204static int qs_check_atapi_dma(struct ata_queued_cmd *qc)
198{ 205{
199 return 1; /* ATAPI DMA not supported */ 206 return 1; /* ATAPI DMA not supported */
@@ -216,7 +223,7 @@ static void qs_irq_clear(struct ata_port *ap)
216 223
217static inline void qs_enter_reg_mode(struct ata_port *ap) 224static inline void qs_enter_reg_mode(struct ata_port *ap)
218{ 225{
219 u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000); 226 u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
220 227
221 writeb(QS_CTR0_REG, chan + QS_CCT_CTR0); 228 writeb(QS_CTR0_REG, chan + QS_CCT_CTR0);
222 readb(chan + QS_CCT_CTR0); /* flush */ 229 readb(chan + QS_CCT_CTR0); /* flush */
@@ -224,7 +231,7 @@ static inline void qs_enter_reg_mode(struct ata_port *ap)
224 231
225static inline void qs_reset_channel_logic(struct ata_port *ap) 232static inline void qs_reset_channel_logic(struct ata_port *ap)
226{ 233{
227 u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000); 234 u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
228 235
229 writeb(QS_CTR1_RCHN, chan + QS_CCT_CTR1); 236 writeb(QS_CTR1_RCHN, chan + QS_CCT_CTR1);
230 readb(chan + QS_CCT_CTR0); /* flush */ 237 readb(chan + QS_CCT_CTR0); /* flush */
@@ -254,14 +261,14 @@ static u32 qs_scr_read (struct ata_port *ap, unsigned int sc_reg)
254{ 261{
255 if (sc_reg > SCR_CONTROL) 262 if (sc_reg > SCR_CONTROL)
256 return ~0U; 263 return ~0U;
257 return readl((void __iomem *)(ap->ioaddr.scr_addr + (sc_reg * 8))); 264 return readl(ap->ioaddr.scr_addr + (sc_reg * 8));
258} 265}
259 266
260static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) 267static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
261{ 268{
262 if (sc_reg > SCR_CONTROL) 269 if (sc_reg > SCR_CONTROL)
263 return; 270 return;
264 writel(val, (void __iomem *)(ap->ioaddr.scr_addr + (sc_reg * 8))); 271 writel(val, ap->ioaddr.scr_addr + (sc_reg * 8));
265} 272}
266 273
267static unsigned int qs_fill_sg(struct ata_queued_cmd *qc) 274static unsigned int qs_fill_sg(struct ata_queued_cmd *qc)
@@ -338,7 +345,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
338static inline void qs_packet_start(struct ata_queued_cmd *qc) 345static inline void qs_packet_start(struct ata_queued_cmd *qc)
339{ 346{
340 struct ata_port *ap = qc->ap; 347 struct ata_port *ap = qc->ap;
341 u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000); 348 u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
342 349
343 VPRINTK("ENTER, ap %p\n", ap); 350 VPRINTK("ENTER, ap %p\n", ap);
344 351
@@ -375,7 +382,7 @@ static inline unsigned int qs_intr_pkt(struct ata_host *host)
375{ 382{
376 unsigned int handled = 0; 383 unsigned int handled = 0;
377 u8 sFFE; 384 u8 sFFE;
378 u8 __iomem *mmio_base = host->mmio_base; 385 u8 __iomem *mmio_base = qs_mmio_base(host);
379 386
380 do { 387 do {
381 u32 sff0 = readl(mmio_base + QS_HST_SFF); 388 u32 sff0 = readl(mmio_base + QS_HST_SFF);
@@ -467,7 +474,7 @@ static irqreturn_t qs_intr(int irq, void *dev_instance)
467 return IRQ_RETVAL(handled); 474 return IRQ_RETVAL(handled);
468} 475}
469 476
470static void qs_ata_setup_port(struct ata_ioports *port, unsigned long base) 477static void qs_ata_setup_port(struct ata_ioports *port, void __iomem *base)
471{ 478{
472 port->cmd_addr = 479 port->cmd_addr =
473 port->data_addr = base + 0x400; 480 port->data_addr = base + 0x400;
@@ -489,7 +496,7 @@ static int qs_port_start(struct ata_port *ap)
489{ 496{
490 struct device *dev = ap->host->dev; 497 struct device *dev = ap->host->dev;
491 struct qs_port_priv *pp; 498 struct qs_port_priv *pp;
492 void __iomem *mmio_base = ap->host->mmio_base; 499 void __iomem *mmio_base = qs_mmio_base(ap->host);
493 void __iomem *chan = mmio_base + (ap->port_no * 0x4000); 500 void __iomem *chan = mmio_base + (ap->port_no * 0x4000);
494 u64 addr; 501 u64 addr;
495 int rc; 502 int rc;
@@ -516,7 +523,7 @@ static int qs_port_start(struct ata_port *ap)
516 523
517static void qs_host_stop(struct ata_host *host) 524static void qs_host_stop(struct ata_host *host)
518{ 525{
519 void __iomem *mmio_base = host->mmio_base; 526 void __iomem *mmio_base = qs_mmio_base(host);
520 527
521 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ 528 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
522 writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */ 529 writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */
@@ -524,7 +531,7 @@ static void qs_host_stop(struct ata_host *host)
524 531
525static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe) 532static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
526{ 533{
527 void __iomem *mmio_base = pe->mmio_base; 534 void __iomem *mmio_base = pe->iomap[QS_MMIO_BAR];
528 unsigned int port_no; 535 unsigned int port_no;
529 536
530 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ 537 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
@@ -599,8 +606,8 @@ static int qs_ata_init_one(struct pci_dev *pdev,
599 const struct pci_device_id *ent) 606 const struct pci_device_id *ent)
600{ 607{
601 static int printed_version; 608 static int printed_version;
602 struct ata_probe_ent *probe_ent = NULL; 609 struct ata_probe_ent *probe_ent;
603 void __iomem *mmio_base; 610 void __iomem * const *iomap;
604 unsigned int board_idx = (unsigned int) ent->driver_data; 611 unsigned int board_idx = (unsigned int) ent->driver_data;
605 int rc, port_no; 612 int rc, port_no;
606 613
@@ -611,18 +618,15 @@ static int qs_ata_init_one(struct pci_dev *pdev,
611 if (rc) 618 if (rc)
612 return rc; 619 return rc;
613 620
614 rc = pci_request_regions(pdev, DRV_NAME); 621 if ((pci_resource_flags(pdev, QS_MMIO_BAR) & IORESOURCE_MEM) == 0)
615 if (rc)
616 return rc;
617
618 if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0)
619 return -ENODEV; 622 return -ENODEV;
620 623
621 mmio_base = pcim_iomap(pdev, 4, 0); 624 rc = pcim_iomap_regions(pdev, 1 << QS_MMIO_BAR, DRV_NAME);
622 if (mmio_base == NULL) 625 if (rc)
623 return -ENOMEM; 626 return rc;
627 iomap = pcim_iomap_table(pdev);
624 628
625 rc = qs_set_dma_masks(pdev, mmio_base); 629 rc = qs_set_dma_masks(pdev, iomap[QS_MMIO_BAR]);
626 if (rc) 630 if (rc)
627 return rc; 631 return rc;
628 632
@@ -642,12 +646,12 @@ static int qs_ata_init_one(struct pci_dev *pdev,
642 646
643 probe_ent->irq = pdev->irq; 647 probe_ent->irq = pdev->irq;
644 probe_ent->irq_flags = IRQF_SHARED; 648 probe_ent->irq_flags = IRQF_SHARED;
645 probe_ent->mmio_base = mmio_base; 649 probe_ent->iomap = iomap;
646 probe_ent->n_ports = QS_PORTS; 650 probe_ent->n_ports = QS_PORTS;
647 651
648 for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) { 652 for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) {
649 unsigned long chan = (unsigned long)mmio_base + 653 void __iomem *chan =
650 (port_no * 0x4000); 654 probe_ent->iomap[QS_MMIO_BAR] + (port_no * 0x4000);
651 qs_ata_setup_port(&probe_ent->port[port_no], chan); 655 qs_ata_setup_port(&probe_ent->port[port_no], chan);
652 } 656 }
653 657