aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-24 16:53:16 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-24 16:53:16 -0400
commit4c674235d667d7ddc6b0c95a228a507eb94da2d6 (patch)
tree716b03d153081d04a87a5572fb6df1c19f57bf8e /drivers
parent96776f3b57eb7beb889a4368937cc9d74082a47e (diff)
siimage: convert to use ->host_priv
While at it: * Reserve PCI BAR 5 in siimage_init_one() and remove no longer needed setup_mmio_siimage(). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/pci/siimage.c114
1 files changed, 58 insertions, 56 deletions
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 48124133601a..1388ffa97644 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -127,9 +127,10 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r)
127 127
128static u8 sil_ioread8(struct pci_dev *dev, unsigned long addr) 128static u8 sil_ioread8(struct pci_dev *dev, unsigned long addr)
129{ 129{
130 struct ide_host *host = pci_get_drvdata(dev);
130 u8 tmp = 0; 131 u8 tmp = 0;
131 132
132 if (pci_get_drvdata(dev)) 133 if (host->host_priv)
133 tmp = readb((void __iomem *)addr); 134 tmp = readb((void __iomem *)addr);
134 else 135 else
135 pci_read_config_byte(dev, addr, &tmp); 136 pci_read_config_byte(dev, addr, &tmp);
@@ -139,9 +140,10 @@ static u8 sil_ioread8(struct pci_dev *dev, unsigned long addr)
139 140
140static u16 sil_ioread16(struct pci_dev *dev, unsigned long addr) 141static u16 sil_ioread16(struct pci_dev *dev, unsigned long addr)
141{ 142{
143 struct ide_host *host = pci_get_drvdata(dev);
142 u16 tmp = 0; 144 u16 tmp = 0;
143 145
144 if (pci_get_drvdata(dev)) 146 if (host->host_priv)
145 tmp = readw((void __iomem *)addr); 147 tmp = readw((void __iomem *)addr);
146 else 148 else
147 pci_read_config_word(dev, addr, &tmp); 149 pci_read_config_word(dev, addr, &tmp);
@@ -151,7 +153,9 @@ static u16 sil_ioread16(struct pci_dev *dev, unsigned long addr)
151 153
152static void sil_iowrite8(struct pci_dev *dev, u8 val, unsigned long addr) 154static void sil_iowrite8(struct pci_dev *dev, u8 val, unsigned long addr)
153{ 155{
154 if (pci_get_drvdata(dev)) 156 struct ide_host *host = pci_get_drvdata(dev);
157
158 if (host->host_priv)
155 writeb(val, (void __iomem *)addr); 159 writeb(val, (void __iomem *)addr);
156 else 160 else
157 pci_write_config_byte(dev, addr, val); 161 pci_write_config_byte(dev, addr, val);
@@ -159,7 +163,9 @@ static void sil_iowrite8(struct pci_dev *dev, u8 val, unsigned long addr)
159 163
160static void sil_iowrite16(struct pci_dev *dev, u16 val, unsigned long addr) 164static void sil_iowrite16(struct pci_dev *dev, u16 val, unsigned long addr)
161{ 165{
162 if (pci_get_drvdata(dev)) 166 struct ide_host *host = pci_get_drvdata(dev);
167
168 if (host->host_priv)
163 writew(val, (void __iomem *)addr); 169 writew(val, (void __iomem *)addr);
164 else 170 else
165 pci_write_config_word(dev, addr, val); 171 pci_write_config_word(dev, addr, val);
@@ -167,7 +173,9 @@ static void sil_iowrite16(struct pci_dev *dev, u16 val, unsigned long addr)
167 173
168static void sil_iowrite32(struct pci_dev *dev, u32 val, unsigned long addr) 174static void sil_iowrite32(struct pci_dev *dev, u32 val, unsigned long addr)
169{ 175{
170 if (pci_get_drvdata(dev)) 176 struct ide_host *host = pci_get_drvdata(dev);
177
178 if (host->host_priv)
171 writel(val, (void __iomem *)addr); 179 writel(val, (void __iomem *)addr);
172 else 180 else
173 pci_write_config_dword(dev, addr, val); 181 pci_write_config_dword(dev, addr, val);
@@ -445,44 +453,6 @@ static void sil_sata_pre_reset(ide_drive_t *drive)
445} 453}
446 454
447/** 455/**
448 * setup_mmio_siimage - switch controller into MMIO mode
449 * @dev: PCI device we are configuring
450 * @name: device name
451 *
452 * Attempt to put the device into MMIO mode. There are some slight
453 * complications here with certain systems where the MMIO BAR isn't
454 * mapped, so we have to be sure that we can fall back to I/O.
455 */
456
457static unsigned int setup_mmio_siimage(struct pci_dev *dev, const char *name)
458{
459 resource_size_t bar5 = pci_resource_start(dev, 5);
460 unsigned long barsize = pci_resource_len(dev, 5);
461 void __iomem *ioaddr;
462
463 /*
464 * Drop back to PIO if we can't map the MMIO. Some systems
465 * seem to get terminally confused in the PCI spaces.
466 */
467 if (!request_mem_region(bar5, barsize, name)) {
468 printk(KERN_WARNING "siimage: IDE controller MMIO ports not "
469 "available.\n");
470 return 0;
471 }
472
473 ioaddr = ioremap(bar5, barsize);
474 if (ioaddr == NULL) {
475 release_mem_region(bar5, barsize);
476 return 0;
477 }
478
479 pci_set_master(dev);
480 pci_set_drvdata(dev, (void *) ioaddr);
481
482 return 1;
483}
484
485/**
486 * init_chipset_siimage - set up an SI device 456 * init_chipset_siimage - set up an SI device
487 * @dev: PCI device 457 * @dev: PCI device
488 * @name: device name 458 * @name: device name
@@ -494,17 +464,15 @@ static unsigned int setup_mmio_siimage(struct pci_dev *dev, const char *name)
494static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev, 464static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev,
495 const char *name) 465 const char *name)
496{ 466{
467 struct ide_host *host = pci_get_drvdata(dev);
468 void __iomem *ioaddr = host->host_priv;
497 unsigned long base, scsc_addr; 469 unsigned long base, scsc_addr;
498 void __iomem *ioaddr = NULL; 470 u8 rev = dev->revision, tmp;
499 u8 rev = dev->revision, tmp, BA5_EN;
500 471
501 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, rev ? 1 : 255); 472 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, rev ? 1 : 255);
502 473
503 pci_read_config_byte(dev, 0x8A, &BA5_EN); 474 if (ioaddr)
504 475 pci_set_master(dev);
505 if ((BA5_EN & 0x01) || pci_resource_start(dev, 5))
506 if (setup_mmio_siimage(dev, name))
507 ioaddr = pci_get_drvdata(dev);
508 476
509 base = (unsigned long)ioaddr; 477 base = (unsigned long)ioaddr;
510 478
@@ -592,7 +560,8 @@ static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev,
592static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) 560static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
593{ 561{
594 struct pci_dev *dev = to_pci_dev(hwif->dev); 562 struct pci_dev *dev = to_pci_dev(hwif->dev);
595 void *addr = pci_get_drvdata(dev); 563 struct ide_host *host = pci_get_drvdata(dev);
564 void *addr = host->host_priv;
596 u8 ch = hwif->channel; 565 u8 ch = hwif->channel;
597 struct ide_io_ports *io_ports = &hwif->io_ports; 566 struct ide_io_ports *io_ports = &hwif->io_ports;
598 unsigned long base; 567 unsigned long base;
@@ -691,16 +660,15 @@ static void __devinit sil_quirkproc(ide_drive_t *drive)
691static void __devinit init_iops_siimage(ide_hwif_t *hwif) 660static void __devinit init_iops_siimage(ide_hwif_t *hwif)
692{ 661{
693 struct pci_dev *dev = to_pci_dev(hwif->dev); 662 struct pci_dev *dev = to_pci_dev(hwif->dev);
663 struct ide_host *host = pci_get_drvdata(dev);
694 664
695 hwif->hwif_data = NULL; 665 hwif->hwif_data = NULL;
696 666
697 /* Pessimal until we finish probing */ 667 /* Pessimal until we finish probing */
698 hwif->rqsize = 15; 668 hwif->rqsize = 15;
699 669
700 if (pci_get_drvdata(dev) == NULL) 670 if (host->host_priv)
701 return; 671 init_mmio_iops_siimage(hwif);
702
703 init_mmio_iops_siimage(hwif);
704} 672}
705 673
706/** 674/**
@@ -778,8 +746,13 @@ static const struct ide_port_info siimage_chipsets[] __devinitdata = {
778static int __devinit siimage_init_one(struct pci_dev *dev, 746static int __devinit siimage_init_one(struct pci_dev *dev,
779 const struct pci_device_id *id) 747 const struct pci_device_id *id)
780{ 748{
749 void __iomem *ioaddr = NULL;
750 resource_size_t bar5 = pci_resource_start(dev, 5);
751 unsigned long barsize = pci_resource_len(dev, 5);
752 int rc;
781 struct ide_port_info d; 753 struct ide_port_info d;
782 u8 idx = id->driver_data; 754 u8 idx = id->driver_data;
755 u8 BA5_EN;
783 756
784 d = siimage_chipsets[idx]; 757 d = siimage_chipsets[idx];
785 758
@@ -795,7 +768,36 @@ static int __devinit siimage_init_one(struct pci_dev *dev,
795 d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 768 d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
796 } 769 }
797 770
798 return ide_pci_init_one(dev, &d, NULL); 771 rc = pci_enable_device(dev);
772 if (rc)
773 return rc;
774
775 pci_read_config_byte(dev, 0x8A, &BA5_EN);
776 if ((BA5_EN & 0x01) || bar5) {
777 /*
778 * Drop back to PIO if we can't map the MMIO. Some systems
779 * seem to get terminally confused in the PCI spaces.
780 */
781 if (!request_mem_region(bar5, barsize, d.name)) {
782 printk(KERN_WARNING "siimage: IDE controller MMIO "
783 "ports not available.\n");
784 } else {
785 ioaddr = ioremap(bar5, barsize);
786 if (ioaddr == NULL)
787 release_mem_region(bar5, barsize);
788 }
789 }
790
791 rc = ide_pci_init_one(dev, &d, ioaddr);
792 if (rc) {
793 if (ioaddr) {
794 iounmap(ioaddr);
795 release_mem_region(bar5, barsize);
796 }
797 pci_disable_device(dev);
798 }
799
800 return rc;
799} 801}
800 802
801static const struct pci_device_id siimage_pci_tbl[] = { 803static const struct pci_device_id siimage_pci_tbl[] = {