diff options
author | Tejun Heo <htejun@gmail.com> | 2007-02-01 01:06:36 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-09 17:39:38 -0500 |
commit | 0d5ff566779f894ca9937231a181eb31e4adff0e (patch) | |
tree | d1c7495c932581c1d41aa7f0fdb303348da49106 /drivers/ata/sata_sx4.c | |
parent | 1a68ff13c8a9b517de3fd4187dc525412a6eba1b (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_sx4.c')
-rw-r--r-- | drivers/ata/sata_sx4.c | 88 |
1 files changed, 36 insertions, 52 deletions
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c index d9838dcb4b01..f83038cf1b35 100644 --- a/drivers/ata/sata_sx4.c +++ b/drivers/ata/sata_sx4.c | |||
@@ -49,6 +49,9 @@ | |||
49 | 49 | ||
50 | 50 | ||
51 | enum { | 51 | enum { |
52 | PDC_MMIO_BAR = 3, | ||
53 | PDC_DIMM_BAR = 4, | ||
54 | |||
52 | PDC_PRD_TBL = 0x44, /* Direct command DMA table addr */ | 55 | PDC_PRD_TBL = 0x44, /* Direct command DMA table addr */ |
53 | 56 | ||
54 | PDC_PKT_SUBMIT = 0x40, /* Command packet pointer addr */ | 57 | PDC_PKT_SUBMIT = 0x40, /* Command packet pointer addr */ |
@@ -137,8 +140,6 @@ struct pdc_port_priv { | |||
137 | }; | 140 | }; |
138 | 141 | ||
139 | struct pdc_host_priv { | 142 | struct pdc_host_priv { |
140 | void __iomem *dimm_mmio; | ||
141 | |||
142 | unsigned int doing_hdma; | 143 | unsigned int doing_hdma; |
143 | unsigned int hdma_prod; | 144 | unsigned int hdma_prod; |
144 | unsigned int hdma_cons; | 145 | unsigned int hdma_cons; |
@@ -202,7 +203,7 @@ static const struct ata_port_operations pdc_20621_ops = { | |||
202 | .phy_reset = pdc_20621_phy_reset, | 203 | .phy_reset = pdc_20621_phy_reset, |
203 | .qc_prep = pdc20621_qc_prep, | 204 | .qc_prep = pdc20621_qc_prep, |
204 | .qc_issue = pdc20621_qc_issue_prot, | 205 | .qc_issue = pdc20621_qc_issue_prot, |
205 | .data_xfer = ata_mmio_data_xfer, | 206 | .data_xfer = ata_data_xfer, |
206 | .eng_timeout = pdc_eng_timeout, | 207 | .eng_timeout = pdc_eng_timeout, |
207 | .irq_handler = pdc20621_interrupt, | 208 | .irq_handler = pdc20621_interrupt, |
208 | .irq_clear = pdc20621_irq_clear, | 209 | .irq_clear = pdc20621_irq_clear, |
@@ -411,9 +412,8 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc) | |||
411 | struct scatterlist *sg; | 412 | struct scatterlist *sg; |
412 | struct ata_port *ap = qc->ap; | 413 | struct ata_port *ap = qc->ap; |
413 | struct pdc_port_priv *pp = ap->private_data; | 414 | struct pdc_port_priv *pp = ap->private_data; |
414 | void __iomem *mmio = ap->host->mmio_base; | 415 | void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR]; |
415 | struct pdc_host_priv *hpriv = ap->host->private_data; | 416 | void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR]; |
416 | void __iomem *dimm_mmio = hpriv->dimm_mmio; | ||
417 | unsigned int portno = ap->port_no; | 417 | unsigned int portno = ap->port_no; |
418 | unsigned int i, idx, total_len = 0, sgt_len; | 418 | unsigned int i, idx, total_len = 0, sgt_len; |
419 | u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; | 419 | u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; |
@@ -472,9 +472,8 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc) | |||
472 | { | 472 | { |
473 | struct ata_port *ap = qc->ap; | 473 | struct ata_port *ap = qc->ap; |
474 | struct pdc_port_priv *pp = ap->private_data; | 474 | struct pdc_port_priv *pp = ap->private_data; |
475 | void __iomem *mmio = ap->host->mmio_base; | 475 | void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR]; |
476 | struct pdc_host_priv *hpriv = ap->host->private_data; | 476 | void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR]; |
477 | void __iomem *dimm_mmio = hpriv->dimm_mmio; | ||
478 | unsigned int portno = ap->port_no; | 477 | unsigned int portno = ap->port_no; |
479 | unsigned int i; | 478 | unsigned int i; |
480 | 479 | ||
@@ -524,7 +523,7 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc, | |||
524 | { | 523 | { |
525 | struct ata_port *ap = qc->ap; | 524 | struct ata_port *ap = qc->ap; |
526 | struct ata_host *host = ap->host; | 525 | struct ata_host *host = ap->host; |
527 | void __iomem *mmio = host->mmio_base; | 526 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; |
528 | 527 | ||
529 | /* hard-code chip #0 */ | 528 | /* hard-code chip #0 */ |
530 | mmio += PDC_CHIP0_OFS; | 529 | mmio += PDC_CHIP0_OFS; |
@@ -578,8 +577,7 @@ static void pdc20621_dump_hdma(struct ata_queued_cmd *qc) | |||
578 | { | 577 | { |
579 | struct ata_port *ap = qc->ap; | 578 | struct ata_port *ap = qc->ap; |
580 | unsigned int port_no = ap->port_no; | 579 | unsigned int port_no = ap->port_no; |
581 | struct pdc_host_priv *hpriv = ap->host->private_data; | 580 | void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR]; |
582 | void *dimm_mmio = hpriv->dimm_mmio; | ||
583 | 581 | ||
584 | dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP); | 582 | dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP); |
585 | dimm_mmio += PDC_DIMM_HOST_PKT; | 583 | dimm_mmio += PDC_DIMM_HOST_PKT; |
@@ -598,7 +596,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc) | |||
598 | struct ata_port *ap = qc->ap; | 596 | struct ata_port *ap = qc->ap; |
599 | struct ata_host *host = ap->host; | 597 | struct ata_host *host = ap->host; |
600 | unsigned int port_no = ap->port_no; | 598 | unsigned int port_no = ap->port_no; |
601 | void __iomem *mmio = host->mmio_base; | 599 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; |
602 | unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); | 600 | unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); |
603 | u8 seq = (u8) (port_no + 1); | 601 | u8 seq = (u8) (port_no + 1); |
604 | unsigned int port_ofs; | 602 | unsigned int port_ofs; |
@@ -627,8 +625,8 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc) | |||
627 | readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */ | 625 | readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */ |
628 | 626 | ||
629 | writel(port_ofs + PDC_DIMM_ATA_PKT, | 627 | writel(port_ofs + PDC_DIMM_ATA_PKT, |
630 | (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); | 628 | ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); |
631 | readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); | 629 | readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); |
632 | VPRINTK("submitted ofs 0x%x (%u), seq %u\n", | 630 | VPRINTK("submitted ofs 0x%x (%u), seq %u\n", |
633 | port_ofs + PDC_DIMM_ATA_PKT, | 631 | port_ofs + PDC_DIMM_ATA_PKT, |
634 | port_ofs + PDC_DIMM_ATA_PKT, | 632 | port_ofs + PDC_DIMM_ATA_PKT, |
@@ -706,8 +704,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
706 | writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4)); | 704 | writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4)); |
707 | readl(mmio + PDC_20621_SEQCTL + (seq * 4)); | 705 | readl(mmio + PDC_20621_SEQCTL + (seq * 4)); |
708 | writel(port_ofs + PDC_DIMM_ATA_PKT, | 706 | writel(port_ofs + PDC_DIMM_ATA_PKT, |
709 | (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); | 707 | ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); |
710 | readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); | 708 | readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); |
711 | } | 709 | } |
712 | 710 | ||
713 | /* step two - execute ATA command */ | 711 | /* step two - execute ATA command */ |
@@ -740,7 +738,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
740 | static void pdc20621_irq_clear(struct ata_port *ap) | 738 | static void pdc20621_irq_clear(struct ata_port *ap) |
741 | { | 739 | { |
742 | struct ata_host *host = ap->host; | 740 | struct ata_host *host = ap->host; |
743 | void __iomem *mmio = host->mmio_base; | 741 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; |
744 | 742 | ||
745 | mmio += PDC_CHIP0_OFS; | 743 | mmio += PDC_CHIP0_OFS; |
746 | 744 | ||
@@ -758,12 +756,12 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance) | |||
758 | 756 | ||
759 | VPRINTK("ENTER\n"); | 757 | VPRINTK("ENTER\n"); |
760 | 758 | ||
761 | if (!host || !host->mmio_base) { | 759 | if (!host || !host->iomap[PDC_MMIO_BAR]) { |
762 | VPRINTK("QUICK EXIT\n"); | 760 | VPRINTK("QUICK EXIT\n"); |
763 | return IRQ_NONE; | 761 | return IRQ_NONE; |
764 | } | 762 | } |
765 | 763 | ||
766 | mmio_base = host->mmio_base; | 764 | mmio_base = host->iomap[PDC_MMIO_BAR]; |
767 | 765 | ||
768 | /* reading should also clear interrupts */ | 766 | /* reading should also clear interrupts */ |
769 | mmio_base += PDC_CHIP0_OFS; | 767 | mmio_base += PDC_CHIP0_OFS; |
@@ -864,7 +862,7 @@ static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile | |||
864 | } | 862 | } |
865 | 863 | ||
866 | 864 | ||
867 | static void pdc_sata_setup_port(struct ata_ioports *port, unsigned long base) | 865 | static void pdc_sata_setup_port(struct ata_ioports *port, void __iomem *base) |
868 | { | 866 | { |
869 | port->cmd_addr = base; | 867 | port->cmd_addr = base; |
870 | port->data_addr = base; | 868 | port->data_addr = base; |
@@ -890,9 +888,8 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource, | |||
890 | u16 idx; | 888 | u16 idx; |
891 | u8 page_mask; | 889 | u8 page_mask; |
892 | long dist; | 890 | long dist; |
893 | void __iomem *mmio = pe->mmio_base; | 891 | void __iomem *mmio = pe->iomap[PDC_MMIO_BAR]; |
894 | struct pdc_host_priv *hpriv = pe->private_data; | 892 | void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR]; |
895 | void __iomem *dimm_mmio = hpriv->dimm_mmio; | ||
896 | 893 | ||
897 | /* hard-code chip #0 */ | 894 | /* hard-code chip #0 */ |
898 | mmio += PDC_CHIP0_OFS; | 895 | mmio += PDC_CHIP0_OFS; |
@@ -946,9 +943,8 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource, | |||
946 | u16 idx; | 943 | u16 idx; |
947 | u8 page_mask; | 944 | u8 page_mask; |
948 | long dist; | 945 | long dist; |
949 | void __iomem *mmio = pe->mmio_base; | 946 | void __iomem *mmio = pe->iomap[PDC_MMIO_BAR]; |
950 | struct pdc_host_priv *hpriv = pe->private_data; | 947 | void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR]; |
951 | void __iomem *dimm_mmio = hpriv->dimm_mmio; | ||
952 | 948 | ||
953 | /* hard-code chip #0 */ | 949 | /* hard-code chip #0 */ |
954 | mmio += PDC_CHIP0_OFS; | 950 | mmio += PDC_CHIP0_OFS; |
@@ -993,7 +989,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource, | |||
993 | static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device, | 989 | static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device, |
994 | u32 subaddr, u32 *pdata) | 990 | u32 subaddr, u32 *pdata) |
995 | { | 991 | { |
996 | void __iomem *mmio = pe->mmio_base; | 992 | void __iomem *mmio = pe->iomap[PDC_MMIO_BAR]; |
997 | u32 i2creg = 0; | 993 | u32 i2creg = 0; |
998 | u32 status; | 994 | u32 status; |
999 | u32 count =0; | 995 | u32 count =0; |
@@ -1052,7 +1048,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe) | |||
1052 | u32 data = 0; | 1048 | u32 data = 0; |
1053 | int size, i; | 1049 | int size, i; |
1054 | u8 bdimmsize; | 1050 | u8 bdimmsize; |
1055 | void __iomem *mmio = pe->mmio_base; | 1051 | void __iomem *mmio = pe->iomap[PDC_MMIO_BAR]; |
1056 | static const struct { | 1052 | static const struct { |
1057 | unsigned int reg; | 1053 | unsigned int reg; |
1058 | unsigned int ofs; | 1054 | unsigned int ofs; |
@@ -1114,8 +1110,8 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe) | |||
1114 | static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe) | 1110 | static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe) |
1115 | { | 1111 | { |
1116 | u32 data, spd0; | 1112 | u32 data, spd0; |
1117 | int error, i; | 1113 | int error, i; |
1118 | void __iomem *mmio = pe->mmio_base; | 1114 | void __iomem *mmio = pe->iomap[PDC_MMIO_BAR]; |
1119 | 1115 | ||
1120 | /* hard-code chip #0 */ | 1116 | /* hard-code chip #0 */ |
1121 | mmio += PDC_CHIP0_OFS; | 1117 | mmio += PDC_CHIP0_OFS; |
@@ -1169,7 +1165,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe) | |||
1169 | u32 ticks=0; | 1165 | u32 ticks=0; |
1170 | u32 clock=0; | 1166 | u32 clock=0; |
1171 | u32 fparam=0; | 1167 | u32 fparam=0; |
1172 | void __iomem *mmio = pe->mmio_base; | 1168 | void __iomem *mmio = pe->iomap[PDC_MMIO_BAR]; |
1173 | 1169 | ||
1174 | /* hard-code chip #0 */ | 1170 | /* hard-code chip #0 */ |
1175 | mmio += PDC_CHIP0_OFS; | 1171 | mmio += PDC_CHIP0_OFS; |
@@ -1293,7 +1289,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe) | |||
1293 | static void pdc_20621_init(struct ata_probe_ent *pe) | 1289 | static void pdc_20621_init(struct ata_probe_ent *pe) |
1294 | { | 1290 | { |
1295 | u32 tmp; | 1291 | u32 tmp; |
1296 | void __iomem *mmio = pe->mmio_base; | 1292 | void __iomem *mmio = pe->iomap[PDC_MMIO_BAR]; |
1297 | 1293 | ||
1298 | /* hard-code chip #0 */ | 1294 | /* hard-code chip #0 */ |
1299 | mmio += PDC_CHIP0_OFS; | 1295 | mmio += PDC_CHIP0_OFS; |
@@ -1325,9 +1321,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * | |||
1325 | { | 1321 | { |
1326 | static int printed_version; | 1322 | static int printed_version; |
1327 | struct ata_probe_ent *probe_ent; | 1323 | struct ata_probe_ent *probe_ent; |
1328 | unsigned long base; | 1324 | void __iomem *base; |
1329 | void __iomem *mmio_base; | ||
1330 | void __iomem *dimm_mmio; | ||
1331 | struct pdc_host_priv *hpriv; | 1325 | struct pdc_host_priv *hpriv; |
1332 | unsigned int board_idx = (unsigned int) ent->driver_data; | 1326 | unsigned int board_idx = (unsigned int) ent->driver_data; |
1333 | int rc; | 1327 | int rc; |
@@ -1339,11 +1333,12 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * | |||
1339 | if (rc) | 1333 | if (rc) |
1340 | return rc; | 1334 | return rc; |
1341 | 1335 | ||
1342 | rc = pci_request_regions(pdev, DRV_NAME); | 1336 | rc = pcim_iomap_regions(pdev, (1 << PDC_MMIO_BAR) | (1 << PDC_DIMM_BAR), |
1343 | if (rc) { | 1337 | DRV_NAME); |
1338 | if (rc == -EBUSY) | ||
1344 | pcim_pin_device(pdev); | 1339 | pcim_pin_device(pdev); |
1340 | if (rc) | ||
1345 | return rc; | 1341 | return rc; |
1346 | } | ||
1347 | 1342 | ||
1348 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 1343 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
1349 | if (rc) | 1344 | if (rc) |
@@ -1359,21 +1354,10 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * | |||
1359 | probe_ent->dev = pci_dev_to_dev(pdev); | 1354 | probe_ent->dev = pci_dev_to_dev(pdev); |
1360 | INIT_LIST_HEAD(&probe_ent->node); | 1355 | INIT_LIST_HEAD(&probe_ent->node); |
1361 | 1356 | ||
1362 | mmio_base = pcim_iomap(pdev, 3, 0); | ||
1363 | if (mmio_base == NULL) | ||
1364 | return -ENOMEM; | ||
1365 | base = (unsigned long) mmio_base; | ||
1366 | |||
1367 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); | 1357 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
1368 | if (!hpriv) | 1358 | if (!hpriv) |
1369 | return -ENOMEM; | 1359 | return -ENOMEM; |
1370 | 1360 | ||
1371 | dimm_mmio = pcim_iomap(pdev, 4, 0); | ||
1372 | if (!dimm_mmio) | ||
1373 | return -ENOMEM; | ||
1374 | |||
1375 | hpriv->dimm_mmio = dimm_mmio; | ||
1376 | |||
1377 | probe_ent->sht = pdc_port_info[board_idx].sht; | 1361 | probe_ent->sht = pdc_port_info[board_idx].sht; |
1378 | probe_ent->port_flags = pdc_port_info[board_idx].flags; | 1362 | probe_ent->port_flags = pdc_port_info[board_idx].flags; |
1379 | probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask; | 1363 | probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask; |
@@ -1383,10 +1367,10 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * | |||
1383 | 1367 | ||
1384 | probe_ent->irq = pdev->irq; | 1368 | probe_ent->irq = pdev->irq; |
1385 | probe_ent->irq_flags = IRQF_SHARED; | 1369 | probe_ent->irq_flags = IRQF_SHARED; |
1386 | probe_ent->mmio_base = mmio_base; | 1370 | probe_ent->iomap = pcim_iomap_table(pdev); |
1387 | 1371 | ||
1388 | probe_ent->private_data = hpriv; | 1372 | probe_ent->private_data = hpriv; |
1389 | base += PDC_CHIP0_OFS; | 1373 | base = probe_ent->iomap[PDC_MMIO_BAR] + PDC_CHIP0_OFS; |
1390 | 1374 | ||
1391 | probe_ent->n_ports = 4; | 1375 | probe_ent->n_ports = 4; |
1392 | pdc_sata_setup_port(&probe_ent->port[0], base + 0x200); | 1376 | pdc_sata_setup_port(&probe_ent->port[0], base + 0x200); |