aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_pdc2027x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_pdc2027x.c')
-rw-r--r--drivers/ata/pata_pdc2027x.c63
1 files changed, 31 insertions, 32 deletions
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index 1c106b866c79..2ff91bbbab06 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -45,6 +45,8 @@
45#endif 45#endif
46 46
47enum { 47enum {
48 PDC_MMIO_BAR = 5,
49
48 PDC_UDMA_100 = 0, 50 PDC_UDMA_100 = 0,
49 PDC_UDMA_133 = 1, 51 PDC_UDMA_133 = 1,
50 52
@@ -158,7 +160,7 @@ static struct ata_port_operations pdc2027x_pata100_ops = {
158 .bmdma_status = ata_bmdma_status, 160 .bmdma_status = ata_bmdma_status,
159 .qc_prep = ata_qc_prep, 161 .qc_prep = ata_qc_prep,
160 .qc_issue = ata_qc_issue_prot, 162 .qc_issue = ata_qc_issue_prot,
161 .data_xfer = ata_mmio_data_xfer, 163 .data_xfer = ata_data_xfer,
162 164
163 .freeze = ata_bmdma_freeze, 165 .freeze = ata_bmdma_freeze,
164 .thaw = ata_bmdma_thaw, 166 .thaw = ata_bmdma_thaw,
@@ -190,7 +192,7 @@ static struct ata_port_operations pdc2027x_pata133_ops = {
190 .bmdma_status = ata_bmdma_status, 192 .bmdma_status = ata_bmdma_status,
191 .qc_prep = ata_qc_prep, 193 .qc_prep = ata_qc_prep,
192 .qc_issue = ata_qc_issue_prot, 194 .qc_issue = ata_qc_issue_prot,
193 .data_xfer = ata_mmio_data_xfer, 195 .data_xfer = ata_data_xfer,
194 196
195 .freeze = ata_bmdma_freeze, 197 .freeze = ata_bmdma_freeze,
196 .thaw = ata_bmdma_thaw, 198 .thaw = ata_bmdma_thaw,
@@ -239,7 +241,7 @@ MODULE_DEVICE_TABLE(pci, pdc2027x_pci_tbl);
239 */ 241 */
240static inline void __iomem *port_mmio(struct ata_port *ap, unsigned int offset) 242static inline void __iomem *port_mmio(struct ata_port *ap, unsigned int offset)
241{ 243{
242 return ap->host->mmio_base + ap->port_no * 0x100 + offset; 244 return ap->host->iomap[PDC_MMIO_BAR] + ap->port_no * 0x100 + offset;
243} 245}
244 246
245/** 247/**
@@ -520,18 +522,19 @@ static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc)
520 522
521static long pdc_read_counter(struct ata_probe_ent *probe_ent) 523static long pdc_read_counter(struct ata_probe_ent *probe_ent)
522{ 524{
525 void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
523 long counter; 526 long counter;
524 int retry = 1; 527 int retry = 1;
525 u32 bccrl, bccrh, bccrlv, bccrhv; 528 u32 bccrl, bccrh, bccrlv, bccrhv;
526 529
527retry: 530retry:
528 bccrl = readl(probe_ent->mmio_base + PDC_BYTE_COUNT) & 0xffff; 531 bccrl = readl(mmio_base + PDC_BYTE_COUNT) & 0xffff;
529 bccrh = readl(probe_ent->mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff; 532 bccrh = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff;
530 rmb(); 533 rmb();
531 534
532 /* Read the counter values again for verification */ 535 /* Read the counter values again for verification */
533 bccrlv = readl(probe_ent->mmio_base + PDC_BYTE_COUNT) & 0xffff; 536 bccrlv = readl(mmio_base + PDC_BYTE_COUNT) & 0xffff;
534 bccrhv = readl(probe_ent->mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff; 537 bccrhv = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff;
535 rmb(); 538 rmb();
536 539
537 counter = (bccrh << 15) | bccrl; 540 counter = (bccrh << 15) | bccrl;
@@ -562,7 +565,7 @@ retry:
562 */ 565 */
563static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsigned int board_idx) 566static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsigned int board_idx)
564{ 567{
565 568 void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
566 u16 pll_ctl; 569 u16 pll_ctl;
567 long pll_clock_khz = pll_clock / 1000; 570 long pll_clock_khz = pll_clock / 1000;
568 long pout_required = board_idx? PDC_133_MHZ:PDC_100_MHZ; 571 long pout_required = board_idx? PDC_133_MHZ:PDC_100_MHZ;
@@ -581,7 +584,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
581 /* Show the current clock value of PLL control register 584 /* Show the current clock value of PLL control register
582 * (maybe already configured by the firmware) 585 * (maybe already configured by the firmware)
583 */ 586 */
584 pll_ctl = readw(probe_ent->mmio_base + PDC_PLL_CTL); 587 pll_ctl = readw(mmio_base + PDC_PLL_CTL);
585 588
586 PDPRINTK("pll_ctl[%X]\n", pll_ctl); 589 PDPRINTK("pll_ctl[%X]\n", pll_ctl);
587#endif 590#endif
@@ -621,8 +624,8 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
621 624
622 PDPRINTK("Writing pll_ctl[%X]\n", pll_ctl); 625 PDPRINTK("Writing pll_ctl[%X]\n", pll_ctl);
623 626
624 writew(pll_ctl, probe_ent->mmio_base + PDC_PLL_CTL); 627 writew(pll_ctl, mmio_base + PDC_PLL_CTL);
625 readw(probe_ent->mmio_base + PDC_PLL_CTL); /* flush */ 628 readw(mmio_base + PDC_PLL_CTL); /* flush */
626 629
627 /* Wait the PLL circuit to be stable */ 630 /* Wait the PLL circuit to be stable */
628 mdelay(30); 631 mdelay(30);
@@ -632,7 +635,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
632 * Show the current clock value of PLL control register 635 * Show the current clock value of PLL control register
633 * (maybe configured by the firmware) 636 * (maybe configured by the firmware)
634 */ 637 */
635 pll_ctl = readw(probe_ent->mmio_base + PDC_PLL_CTL); 638 pll_ctl = readw(mmio_base + PDC_PLL_CTL);
636 639
637 PDPRINTK("pll_ctl[%X]\n", pll_ctl); 640 PDPRINTK("pll_ctl[%X]\n", pll_ctl);
638#endif 641#endif
@@ -648,6 +651,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
648 */ 651 */
649static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent) 652static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
650{ 653{
654 void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
651 u32 scr; 655 u32 scr;
652 long start_count, end_count; 656 long start_count, end_count;
653 long pll_clock; 657 long pll_clock;
@@ -656,10 +660,10 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
656 start_count = pdc_read_counter(probe_ent); 660 start_count = pdc_read_counter(probe_ent);
657 661
658 /* Start the test mode */ 662 /* Start the test mode */
659 scr = readl(probe_ent->mmio_base + PDC_SYS_CTL); 663 scr = readl(mmio_base + PDC_SYS_CTL);
660 PDPRINTK("scr[%X]\n", scr); 664 PDPRINTK("scr[%X]\n", scr);
661 writel(scr | (0x01 << 14), probe_ent->mmio_base + PDC_SYS_CTL); 665 writel(scr | (0x01 << 14), mmio_base + PDC_SYS_CTL);
662 readl(probe_ent->mmio_base + PDC_SYS_CTL); /* flush */ 666 readl(mmio_base + PDC_SYS_CTL); /* flush */
663 667
664 /* Let the counter run for 100 ms. */ 668 /* Let the counter run for 100 ms. */
665 mdelay(100); 669 mdelay(100);
@@ -668,10 +672,10 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
668 end_count = pdc_read_counter(probe_ent); 672 end_count = pdc_read_counter(probe_ent);
669 673
670 /* Stop the test mode */ 674 /* Stop the test mode */
671 scr = readl(probe_ent->mmio_base + PDC_SYS_CTL); 675 scr = readl(mmio_base + PDC_SYS_CTL);
672 PDPRINTK("scr[%X]\n", scr); 676 PDPRINTK("scr[%X]\n", scr);
673 writel(scr & ~(0x01 << 14), probe_ent->mmio_base + PDC_SYS_CTL); 677 writel(scr & ~(0x01 << 14), mmio_base + PDC_SYS_CTL);
674 readl(probe_ent->mmio_base + PDC_SYS_CTL); /* flush */ 678 readl(mmio_base + PDC_SYS_CTL); /* flush */
675 679
676 /* calculate the input clock in Hz */ 680 /* calculate the input clock in Hz */
677 pll_clock = (start_count - end_count) * 10; 681 pll_clock = (start_count - end_count) * 10;
@@ -716,7 +720,7 @@ static int pdc_hardware_init(struct pci_dev *pdev, struct ata_probe_ent *pe, uns
716 * @port: ata ioports to setup 720 * @port: ata ioports to setup
717 * @base: base address 721 * @base: base address
718 */ 722 */
719static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base) 723static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base)
720{ 724{
721 port->cmd_addr = 725 port->cmd_addr =
722 port->data_addr = base; 726 port->data_addr = base;
@@ -750,7 +754,6 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
750 unsigned int board_idx = (unsigned int) ent->driver_data; 754 unsigned int board_idx = (unsigned int) ent->driver_data;
751 755
752 struct ata_probe_ent *probe_ent; 756 struct ata_probe_ent *probe_ent;
753 unsigned long base;
754 void __iomem *mmio_base; 757 void __iomem *mmio_base;
755 int rc; 758 int rc;
756 759
@@ -761,7 +764,7 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
761 if (rc) 764 if (rc)
762 return rc; 765 return rc;
763 766
764 rc = pci_request_regions(pdev, DRV_NAME); 767 rc = pcim_iomap_regions(pdev, 1 << PDC_MMIO_BAR, DRV_NAME);
765 if (rc) 768 if (rc)
766 return rc; 769 return rc;
767 770
@@ -781,12 +784,6 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
781 probe_ent->dev = pci_dev_to_dev(pdev); 784 probe_ent->dev = pci_dev_to_dev(pdev);
782 INIT_LIST_HEAD(&probe_ent->node); 785 INIT_LIST_HEAD(&probe_ent->node);
783 786
784 mmio_base = pcim_iomap(pdev, 5, 0);
785 if (!mmio_base)
786 return -ENOMEM;
787
788 base = (unsigned long) mmio_base;
789
790 probe_ent->sht = pdc2027x_port_info[board_idx].sht; 787 probe_ent->sht = pdc2027x_port_info[board_idx].sht;
791 probe_ent->port_flags = pdc2027x_port_info[board_idx].flags; 788 probe_ent->port_flags = pdc2027x_port_info[board_idx].flags;
792 probe_ent->pio_mask = pdc2027x_port_info[board_idx].pio_mask; 789 probe_ent->pio_mask = pdc2027x_port_info[board_idx].pio_mask;
@@ -796,12 +793,14 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
796 793
797 probe_ent->irq = pdev->irq; 794 probe_ent->irq = pdev->irq;
798 probe_ent->irq_flags = SA_SHIRQ; 795 probe_ent->irq_flags = SA_SHIRQ;
799 probe_ent->mmio_base = mmio_base; 796 probe_ent->iomap = pcim_iomap_table(pdev);
797
798 mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
800 799
801 pdc_ata_setup_port(&probe_ent->port[0], base + 0x17c0); 800 pdc_ata_setup_port(&probe_ent->port[0], mmio_base + 0x17c0);
802 probe_ent->port[0].bmdma_addr = base + 0x1000; 801 probe_ent->port[0].bmdma_addr = mmio_base + 0x1000;
803 pdc_ata_setup_port(&probe_ent->port[1], base + 0x15c0); 802 pdc_ata_setup_port(&probe_ent->port[1], mmio_base + 0x15c0);
804 probe_ent->port[1].bmdma_addr = base + 0x1008; 803 probe_ent->port[1].bmdma_addr = mmio_base + 0x1008;
805 804
806 probe_ent->n_ports = 2; 805 probe_ent->n_ports = 2;
807 806