Commit 0d5ff566 authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik

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: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 1a68ff13
This diff is collapsed.
...@@ -79,7 +79,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) ...@@ -79,7 +79,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused)
/* Bits 5 and 6 indicate if DMA is active on master/slave */ /* Bits 5 and 6 indicate if DMA is active on master/slave */
if (ap->ioaddr.bmdma_addr) if (ap->ioaddr.bmdma_addr)
dma_enabled = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD); dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
for (i = 0; i < ATA_MAX_DEVICES; i++) { for (i = 0; i < ATA_MAX_DEVICES; i++) {
struct ata_device *dev = &ap->device[i]; struct ata_device *dev = &ap->device[i];
...@@ -138,7 +138,7 @@ static struct ata_port_operations generic_port_ops = { ...@@ -138,7 +138,7 @@ static struct ata_port_operations generic_port_ops = {
.bmdma_stop = ata_bmdma_stop, .bmdma_stop = ata_bmdma_stop,
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
......
...@@ -299,7 +299,7 @@ static const struct ata_port_operations piix_pata_ops = { ...@@ -299,7 +299,7 @@ static const struct ata_port_operations piix_pata_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
...@@ -330,7 +330,7 @@ static const struct ata_port_operations ich_pata_ops = { ...@@ -330,7 +330,7 @@ static const struct ata_port_operations ich_pata_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
...@@ -358,7 +358,7 @@ static const struct ata_port_operations piix_sata_ops = { ...@@ -358,7 +358,7 @@ static const struct ata_port_operations piix_sata_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
......
This diff is collapsed.
This diff is collapsed.
...@@ -370,7 +370,7 @@ static struct ata_port_operations ali_early_port_ops = { ...@@ -370,7 +370,7 @@ static struct ata_port_operations ali_early_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -409,7 +409,7 @@ static struct ata_port_operations ali_20_port_ops = { ...@@ -409,7 +409,7 @@ static struct ata_port_operations ali_20_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -445,7 +445,7 @@ static struct ata_port_operations ali_c2_port_ops = { ...@@ -445,7 +445,7 @@ static struct ata_port_operations ali_c2_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -480,7 +480,7 @@ static struct ata_port_operations ali_c5_port_ops = { ...@@ -480,7 +480,7 @@ static struct ata_port_operations ali_c5_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -362,7 +362,7 @@ static struct ata_port_operations amd33_port_ops = { ...@@ -362,7 +362,7 @@ static struct ata_port_operations amd33_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -394,7 +394,7 @@ static struct ata_port_operations amd66_port_ops = { ...@@ -394,7 +394,7 @@ static struct ata_port_operations amd66_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -426,7 +426,7 @@ static struct ata_port_operations amd100_port_ops = { ...@@ -426,7 +426,7 @@ static struct ata_port_operations amd100_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -458,7 +458,7 @@ static struct ata_port_operations amd133_port_ops = { ...@@ -458,7 +458,7 @@ static struct ata_port_operations amd133_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -490,7 +490,7 @@ static struct ata_port_operations nv100_port_ops = { ...@@ -490,7 +490,7 @@ static struct ata_port_operations nv100_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -522,7 +522,7 @@ static struct ata_port_operations nv133_port_ops = { ...@@ -522,7 +522,7 @@ static struct ata_port_operations nv133_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -341,7 +341,7 @@ static const struct ata_port_operations artop6210_ops = { ...@@ -341,7 +341,7 @@ static const struct ata_port_operations artop6210_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -371,7 +371,7 @@ static const struct ata_port_operations artop6260_ops = { ...@@ -371,7 +371,7 @@ static const struct ata_port_operations artop6260_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -252,7 +252,7 @@ static struct ata_port_operations atiixp_port_ops = { ...@@ -252,7 +252,7 @@ static struct ata_port_operations atiixp_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -313,7 +313,7 @@ static struct ata_port_operations cmd64x_port_ops = { ...@@ -313,7 +313,7 @@ static struct ata_port_operations cmd64x_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -345,7 +345,7 @@ static struct ata_port_operations cmd646r1_port_ops = { ...@@ -345,7 +345,7 @@ static struct ata_port_operations cmd646r1_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -377,7 +377,7 @@ static struct ata_port_operations cmd648_port_ops = { ...@@ -377,7 +377,7 @@ static struct ata_port_operations cmd648_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -99,9 +99,9 @@ static void cs5520_set_timings(struct ata_port *ap, struct ata_device *adev, int ...@@ -99,9 +99,9 @@ static void cs5520_set_timings(struct ata_port *ap, struct ata_device *adev, int
static void cs5520_enable_dma(struct ata_port *ap, struct ata_device *adev) static void cs5520_enable_dma(struct ata_port *ap, struct ata_device *adev)
{ {
/* Set the DMA enable/disable flag */ /* Set the DMA enable/disable flag */
u8 reg = inb(ap->ioaddr.bmdma_addr + 0x02); u8 reg = ioread8(ap->ioaddr.bmdma_addr + 0x02);
reg |= 1<<(adev->devno + 5); reg |= 1<<(adev->devno + 5);
outb(reg, ap->ioaddr.bmdma_addr + 0x02); iowrite8(reg, ap->ioaddr.bmdma_addr + 0x02);
} }
/** /**
...@@ -193,7 +193,7 @@ static struct ata_port_operations cs5520_port_ops = { ...@@ -193,7 +193,7 @@ static struct ata_port_operations cs5520_port_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -204,6 +204,7 @@ static struct ata_port_operations cs5520_port_ops = { ...@@ -204,6 +204,7 @@ static struct ata_port_operations cs5520_port_ops = {
static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{ {
u8 pcicfg; u8 pcicfg;
void *iomap[5];
static struct ata_probe_ent probe[2]; static struct ata_probe_ent probe[2];
int ports = 0; int ports = 0;
...@@ -234,6 +235,16 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic ...@@ -234,6 +235,16 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
return -ENODEV; return -ENODEV;
} }
/* Map IO ports */
iomap[0] = devm_ioport_map(&dev->dev, 0x1F0, 8);
iomap[1] = devm_ioport_map(&dev->dev, 0x3F6, 1);
iomap[2] = devm_ioport_map(&dev->dev, 0x170, 8);
iomap[3] = devm_ioport_map(&dev->dev, 0x376, 1);
iomap[4] = pcim_iomap(dev, 2, 0);
if (!iomap[0] || !iomap[1] || !iomap[2] || !iomap[3] || !iomap[4])
return -ENOMEM;
/* We have to do our own plumbing as the PCI setup for this /* We have to do our own plumbing as the PCI setup for this
chipset is non-standard so we can't punt to the libata code */ chipset is non-standard so we can't punt to the libata code */
...@@ -247,10 +258,10 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic ...@@ -247,10 +258,10 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
probe[0].irq_flags = 0; probe[0].irq_flags = 0;
probe[0].port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST; probe[0].port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST;
probe[0].n_ports = 1; probe[0].n_ports = 1;
probe[0].port[0].cmd_addr = 0x1F0; probe[0].port[0].cmd_addr = iomap[0];
probe[0].port[0].ctl_addr = 0x3F6; probe[0].port[0].ctl_addr = iomap[1];
probe[0].port[0].altstatus_addr = 0x3F6; probe[0].port[0].altstatus_addr = iomap[1];
probe[0].port[0].bmdma_addr = pci_resource_start(dev, 2); probe[0].port[0].bmdma_addr = iomap[4];
/* The secondary lurks at different addresses but is otherwise /* The secondary lurks at different addresses but is otherwise
the same beastie */ the same beastie */
...@@ -258,10 +269,10 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic ...@@ -258,10 +269,10 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
probe[1] = probe[0]; probe[1] = probe[0];
INIT_LIST_HEAD(&probe[1].node); INIT_LIST_HEAD(&probe[1].node);
probe[1].irq = 15; probe[1].irq = 15;
probe[1].port[0].cmd_addr = 0x170; probe[1].port[0].cmd_addr = iomap[2];
probe[1].port[0].ctl_addr = 0x376; probe[1].port[0].ctl_addr = iomap[3];
probe[1].port[0].altstatus_addr = 0x376; probe[1].port[0].altstatus_addr = iomap[3];
probe[1].port[0].bmdma_addr = pci_resource_start(dev, 2) + 8; probe[1].port[0].bmdma_addr = iomap[4] + 8;
/* Let libata fill in the port details */ /* Let libata fill in the port details */
ata_std_ports(&probe[0].port[0]); ata_std_ports(&probe[0].port[0]);
......
...@@ -37,6 +37,13 @@ ...@@ -37,6 +37,13 @@
#define DRV_NAME "pata_cs5530" #define DRV_NAME "pata_cs5530"
#define DRV_VERSION "0.7.1" #define DRV_VERSION "0.7.1"
static void __iomem *cs5530_port_base(struct ata_port *ap)
{
unsigned long bmdma = (unsigned long)ap->ioaddr.bmdma_addr;
return (void __iomem *)((bmdma & ~0x0F) + 0x20 + 0x10 * ap->port_no);
}
/** /**
* cs5530_set_piomode - PIO setup * cs5530_set_piomode - PIO setup
* @ap: ATA interface * @ap: ATA interface
...@@ -52,19 +59,19 @@ static void cs5530_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -52,19 +59,19 @@ static void cs5530_set_piomode(struct ata_port *ap, struct ata_device *adev)
{0x00009172, 0x00012171, 0x00020080, 0x00032010, 0x00040010}, {0x00009172, 0x00012171, 0x00020080, 0x00032010, 0x00040010},
{0xd1329172, 0x71212171, 0x30200080, 0x20102010, 0x00100010} {0xd1329172, 0x71212171, 0x30200080, 0x20102010, 0x00100010}
}; };
unsigned long base = ( ap->ioaddr.bmdma_addr & ~0x0F) + 0x20 + 0x10 * ap->port_no; void __iomem *base = cs5530_port_base(ap);
u32 tuning; u32 tuning;
int format; int format;
/* Find out which table to use */ /* Find out which table to use */
tuning = inl(base + 0x04); tuning = ioread32(base + 0x04);
format = (tuning & 0x80000000UL) ? 1 : 0; format = (tuning & 0x80000000UL) ? 1 : 0;
/* Now load the right timing register */ /* Now load the right timing register */
if (adev->devno) if (adev->devno)
base += 0x08; base += 0x08;
outl(cs5530_pio_timings[format][adev->pio_mode - XFER_PIO_0], base); iowrite32(cs5530_pio_timings[format][adev->pio_mode - XFER_PIO_0], base);
} }
/** /**
...@@ -79,12 +86,12 @@ static void cs5530_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -79,12 +86,12 @@ static void cs5530_set_piomode(struct ata_port *ap, struct ata_device *adev)
static void cs5530_set_dmamode(struct ata_port *ap, struct ata_device *adev) static void cs5530_set_dmamode(struct ata_port *ap, struct ata_device *adev)
{ {
unsigned long base = ( ap->ioaddr.bmdma_addr & ~0x0F) + 0x20 + 0x10 * ap->port_no; void __iomem *base = cs5530_port_base(ap);
u32 tuning, timing = 0; u32 tuning, timing = 0;
u8 reg; u8 reg;
/* Find out which table to use */ /* Find out which table to use */
tuning = inl(base + 0x04); tuning = ioread32(base + 0x04);
switch(adev->dma_mode) { switch(adev->dma_mode) {
case XFER_UDMA_0: case XFER_UDMA_0:
...@@ -105,20 +112,20 @@ static void cs5530_set_dmamode(struct ata_port *ap, struct ata_device *adev) ...@@ -105,20 +112,20 @@ static void cs5530_set_dmamode(struct ata_port *ap, struct ata_device *adev)
/* Merge in the PIO format bit */ /* Merge in the PIO format bit */
timing |= (tuning & 0x80000000UL); timing |= (tuning & 0x80000000UL);
if (adev->devno == 0) /* Master */ if (adev->devno == 0) /* Master */
outl(timing, base + 0x04); iowrite32(timing, base + 0x04);
else { else {
if (timing & 0x00100000) if (timing & 0x00100000)
tuning |= 0x00100000; /* UDMA for both */ tuning |= 0x00100000; /* UDMA for both */
else else
tuning &= ~0x00100000; /* MWDMA for both */ tuning &= ~0x00100000; /* MWDMA for both */
outl(tuning, base + 0x04); iowrite32(tuning, base + 0x04);
outl(timing, base + 0x0C); iowrite32(timing, base + 0x0C);
} }
/* Set the DMA capable bit in the BMDMA area */ /* Set the DMA capable bit in the BMDMA area */
reg = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); reg = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
reg |= (1 << (5 + adev->devno)); reg |= (1 << (5 + adev->devno));
outb(reg, ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); iowrite8(reg, ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
/* Remember the last DMA setup we did */ /* Remember the last DMA setup we did */
...@@ -210,7 +217,7 @@ static struct ata_port_operations cs5530_port_ops = { ...@@ -210,7 +217,7 @@ static struct ata_port_operations cs5530_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = cs5530_qc_issue_prot, .qc_issue = cs5530_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -214,7 +214,7 @@ static struct ata_port_operations cs5535_port_ops = { ...@@ -214,7 +214,7 @@ static struct ata_port_operations cs5535_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -165,7 +165,7 @@ static struct ata_port_operations cy82c693_port_ops = { ...@@ -165,7 +165,7 @@ static struct ata_port_operations cy82c693_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -261,7 +261,7 @@ static const struct ata_port_operations efar_ops = { ...@@ -261,7 +261,7 @@ static const struct ata_port_operations efar_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -361,7 +361,7 @@ static struct ata_port_operations hpt366_port_ops = { ...@@ -361,7 +361,7 @@ static struct ata_port_operations hpt366_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -634,24 +634,24 @@ static void hpt370_bmdma_stop(struct ata_queued_cmd *qc) ...@@ -634,24 +634,24 @@ static void hpt370_bmdma_stop(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 dma_stat = inb(ap->ioaddr.bmdma_addr + 2); u8 dma_stat = ioread8(ap->ioaddr.bmdma_addr + 2);
u8 dma_cmd; u8 dma_cmd;
unsigned long bmdma = ap->ioaddr.bmdma_addr; void __iomem *bmdma = ap->ioaddr.bmdma_addr;
if (dma_stat & 0x01) { if (dma_stat & 0x01) {
udelay(20); udelay(20);
dma_stat = inb(bmdma + 2); dma_stat = ioread8(bmdma + 2);
} }
if (dma_stat & 0x01) { if (dma_stat & 0x01) {
/* Clear the engine */ /* Clear the engine */
pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
udelay(10); udelay(10);
/* Stop DMA */ /* Stop DMA */
dma_cmd = inb(bmdma ); dma_cmd = ioread8(bmdma );
outb(dma_cmd & 0xFE, bmdma); iowrite8(dma_cmd & 0xFE, bmdma);
/* Clear Error */ /* Clear Error */
dma_stat = inb(bmdma + 2); dma_stat = ioread8(bmdma + 2);
outb(dma_stat | 0x06 , bmdma + 2); iowrite8(dma_stat | 0x06 , bmdma + 2);
/* Clear the engine */ /* Clear the engine */
pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
udelay(10); udelay(10);
...@@ -796,7 +796,7 @@ static struct ata_port_operations hpt370_port_ops = { ...@@ -796,7 +796,7 @@ static struct ata_port_operations hpt370_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -833,7 +833,7 @@ static struct ata_port_operations hpt370a_port_ops = { ...@@ -833,7 +833,7 @@ static struct ata_port_operations hpt370a_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -871,7 +871,7 @@ static struct ata_port_operations hpt372_port_ops = { ...@@ -871,7 +871,7 @@ static struct ata_port_operations hpt372_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -909,7 +909,7 @@ static struct ata_port_operations hpt374_port_ops = { ...@@ -909,7 +909,7 @@ static struct ata_port_operations hpt374_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -263,26 +263,26 @@ static void hpt3x2n_bmdma_stop(struct ata_queued_cmd *qc) ...@@ -263,26 +263,26 @@ static void hpt3x2n_bmdma_stop(struct ata_queued_cmd *qc)
static void hpt3x2n_set_clock(struct ata_port *ap, int source) static void hpt3x2n_set_clock(struct ata_port *ap, int source)
{ {
unsigned long bmdma = ap->ioaddr.bmdma_addr; void __iomem *bmdma = ap->ioaddr.bmdma_addr;
/* Tristate the bus */ /* Tristate the bus */
outb(0x80, bmdma+0x73); iowrite8(0x80, bmdma+0x73);
outb(0x80, bmdma+0x77); iowrite8(0x80, bmdma+0x77);
/* Switch clock and reset channels */ /* Switch clock and reset channels */
outb(source, bmdma+0x7B); iowrite8(source, bmdma+0x7B);
outb(0xC0, bmdma+0x79); iowrite8(0xC0, bmdma+0x79);
/* Reset state machines */ /* Reset state machines */
outb(0x37, bmdma+0x70); iowrite8(0x37, bmdma+0x70);
outb(0x37, bmdma+0x74); iowrite8(0x37, bmdma+0x74);
/* Complete reset */ /* Complete reset */
outb(0x00, bmdma+0x79); iowrite8(0x00, bmdma+0x79);
/* Reconnect channels to bus */ /* Reconnect channels to bus */
outb(0x00, bmdma+0x73); iowrite8(0x00, bmdma+0x73);
outb(0x00, bmdma+0x77); iowrite8(0x00, bmdma+0x77);
} }
/* Check if our partner interface is busy */ /* Check if our partner interface is busy */
...@@ -373,7 +373,7 @@ static struct ata_port_operations hpt3x2n_port_ops = { ...@@ -373,7 +373,7 @@ static struct ata_port_operations hpt3x2n_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = hpt3x2n_qc_issue_prot, .qc_issue = hpt3x2n_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -148,7 +148,7 @@ static struct ata_port_operations hpt3x3_port_ops = { ...@@ -148,7 +148,7 @@ static struct ata_port_operations hpt3x3_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -53,7 +53,7 @@ static struct ata_port_operations isapnp_port_ops = { ...@@ -53,7 +53,7 @@ static struct ata_port_operations isapnp_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -73,6 +73,7 @@ static struct ata_port_operations isapnp_port_ops = { ...@@ -73,6 +73,7 @@ static struct ata_port_operations isapnp_port_ops = {
static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id) static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev_id)
{ {
struct ata_probe_ent ae; struct ata_probe_ent ae;
void __iomem *cmd_addr, *ctl_addr;
if (pnp_port_valid(idev, 0) == 0) if (pnp_port_valid(idev, 0) == 0)
return -ENODEV; return -ENODEV;
...@@ -81,6 +82,10 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev ...@@ -81,6 +82,10 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
if (pnp_irq_valid(idev, 0) == 0) if (pnp_irq_valid(idev, 0) == 0)
return -ENODEV; return -ENODEV;
cmd_addr = devm_ioport_map(&idev->dev, pnp_port_start(idev, 0), 8);
if (!cmd_addr)
return -ENOMEM;
memset(&ae, 0, sizeof(struct ata_probe_ent)); memset(&ae, 0, sizeof(struct ata_probe_ent));
INIT_LIST_HEAD(&ae.node); INIT_LIST_HEAD(&ae.node);
ae.dev = &idev->dev; ae.dev = &idev->dev;
...@@ -91,11 +96,13 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev ...@@ -91,11 +96,13 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
ae.irq = pnp_irq(idev, 0); ae.irq = pnp_irq(idev, 0);
ae.irq_flags = 0; ae.irq_flags = 0;
ae.port_flags = ATA_FLAG_SLAVE_POSS; ae.port_flags = ATA_FLAG_SLAVE_POSS;
ae.port[0].cmd_addr = pnp_port_start(idev, 0); ae.port[0].cmd_addr = cmd_addr;
if (pnp_port_valid(idev, 1) == 0) { if (pnp_port_valid(idev, 1) == 0) {
ae.port[0].altstatus_addr = pnp_port_start(idev, 1); ctl_addr = devm_ioport_map(&idev->dev,
ae.port[0].ctl_addr = pnp_port_start(idev, 1); pnp_port_start(idev, 1), 1);
ae.port[0].altstatus_addr = ctl_addr;
ae.port[0].ctl_addr = ctl_addr;
ae.port_flags |= ATA_FLAG_SRST; ae.port_flags |= ATA_FLAG_SRST;
} }
ata_std_ports(&ae.port[0]); ata_std_ports(&ae.port[0]);
......
...@@ -273,7 +273,7 @@ static const struct ata_port_operations it8213_ops = { ...@@ -273,7 +273,7 @@ static const struct ata_port_operations it8213_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -492,7 +492,7 @@ static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device **unused ...@@ -492,7 +492,7 @@ static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device **unused
/* Bits 5 and 6 indicate if DMA is active on master/slave */ /* Bits 5 and 6 indicate if DMA is active on master/slave */
/* It is possible that BMDMA isn't allocated */ /* It is possible that BMDMA isn't allocated */
if (ap->ioaddr.bmdma_addr) if (ap->ioaddr.bmdma_addr)
dma_enabled = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD); dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
for (i = 0; i < ATA_MAX_DEVICES; i++) { for (i = 0; i < ATA_MAX_DEVICES; i++) {
struct ata_device *dev = &ap->device[i]; struct ata_device *dev = &ap->device[i];
...@@ -674,7 +674,7 @@ static struct ata_port_operations it821x_smart_port_ops = { ...@@ -674,7 +674,7 @@ static struct ata_port_operations it821x_smart_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = it821x_smart_qc_issue_prot, .qc_issue = it821x_smart_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -708,7 +708,7 @@ static struct ata_port_operations it821x_passthru_port_ops = { ...@@ -708,7 +708,7 @@ static struct ata_port_operations it821x_passthru_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = it821x_passthru_qc_issue_prot, .qc_issue = it821x_passthru_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
......
...@@ -140,9 +140,9 @@ static struct ata_port_operations ixp4xx_port_ops = { ...@@ -140,9 +140,9 @@ static struct ata_port_operations ixp4xx_port_ops = {
static void ixp4xx_setup_port(struct ata_ioports *ioaddr, static void ixp4xx_setup_port(struct ata_ioports *ioaddr,
struct ixp4xx_pata_data *data) struct ixp4xx_pata_data *data)
{ {
ioaddr->cmd_addr = (unsigned long) data->cs0; ioaddr->cmd_addr = data->cs0;
ioaddr->altstatus_addr = (unsigned long) data->cs1 + 0x06; ioaddr->altstatus_addr = data->cs1 + 0x06;
ioaddr->ctl_addr = (unsigned long) data->cs1 + 0x06; ioaddr->ctl_addr = data->cs1 + 0x06;
ata_std_ports(ioaddr); ata_std_ports(ioaddr);
...@@ -152,19 +152,19 @@ static void ixp4xx_setup_port(struct ata_ioports *ioaddr, ...@@ -152,19 +152,19 @@ static void ixp4xx_setup_port(struct ata_ioports *ioaddr,
* ixp4xx in little endian mode. * ixp4xx in little endian mode.
*/ */
ioaddr->data_addr ^= 0x02; *(unsigned long *)&ioaddr->data_addr ^= 0x02;
ioaddr->cmd_addr ^= 0x03; *(unsigned long *)&ioaddr->cmd_addr ^= 0x03;
ioaddr->altstatus_addr ^= 0x03; *(unsigned long *)&ioaddr->altstatus_addr ^= 0x03;
ioaddr->ctl_addr ^= 0x03; *(unsigned long *)&ioaddr->ctl_addr ^= 0x03;
ioaddr->error_addr ^= 0x03; *(unsigned long *)&ioaddr->error_addr ^= 0x03;
ioaddr->feature_addr ^= 0x03; *(unsigned long *)&ioaddr->feature_addr ^= 0x03;
ioaddr->nsect_addr ^= 0x03; *(unsigned long *)&ioaddr->nsect_addr ^= 0x03;
ioaddr->lbal_addr ^= 0x03; *(unsigned long *)&ioaddr->lbal_addr ^= 0x03;
ioaddr->lbam_addr ^= 0x03; *(unsigned long *)&ioaddr->lbam_addr ^= 0x03;
ioaddr->lbah_addr ^= 0x03; *(unsigned long *)&ioaddr->lbah_addr ^= 0x03;
ioaddr->device_addr ^= 0x03; *(unsigned long *)&ioaddr->device_addr ^= 0x03;
ioaddr->status_addr ^= 0x03; *(unsigned long *)&ioaddr->status_addr ^= 0x03;
ioaddr->command_addr ^= 0x03; *(unsigned long *)&ioaddr->command_addr ^= 0x03;
#endif #endif
} }
......
...@@ -161,7 +161,7 @@ static const struct ata_port_operations jmicron_ops = { ...@@ -161,7 +161,7 @@ static const struct ata_port_operations jmicron_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
/* IRQ-related hooks */ /* IRQ-related hooks */
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
......
...@@ -164,7 +164,7 @@ static struct ata_port_operations simple_port_ops = { ...@@ -164,7 +164,7 @@ static struct ata_port_operations simple_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer_noirq, .data_xfer = ata_data_xfer_noirq,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -187,7 +187,7 @@ static struct ata_port_operations legacy_port_ops = { ...@@ -187,7 +187,7 @@ static struct ata_port_operations legacy_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer_noirq, .data_xfer = ata_data_xfer_noirq,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -253,31 +253,33 @@ static void pdc_data_xfer_vlb(struct ata_device *adev, unsigned char *buf, unsig ...@@ -253,31 +253,33 @@ static void pdc_data_xfer_vlb(struct ata_device *adev, unsigned char *buf, unsig
local_irq_save(flags); local_irq_save(flags);
/* Perform the 32bit I/O synchronization sequence */ /* Perform the 32bit I/O synchronization sequence */
inb(ap->ioaddr.nsect_addr); ioread8(ap->ioaddr.nsect_addr);
inb(ap->ioaddr.nsect_addr); ioread8(ap->ioaddr.nsect_addr);
inb(ap->ioaddr.nsect_addr); ioread8(ap->ioaddr.nsect_addr);
/* Now the data */ /* Now the data */
if (write_data) if (write_data)
outsl(ap->ioaddr.data_addr, buf, buflen >> 2); iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
else else
insl(ap->ioaddr.data_addr, buf, buflen >> 2); ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
if (unlikely(slop)) { if (unlikely(slop)) {
u32 pad; u32 pad;
if (write_data) { if (write_data) {
memcpy(&pad, buf + buflen - slop, slop); memcpy(&pad, buf + buflen - slop, slop);
outl(le32_to_cpu(pad), ap->ioaddr.data_addr); pad = le32_to_cpu(pad);
iowrite32(pad, ap->ioaddr.data_addr);
} else { } else {
pad = cpu_to_le16(inl(ap->ioaddr.data_addr)); pad = ioread32(ap->ioaddr.data_addr);
pad = cpu_to_le16(pad);
memcpy(buf + buflen - slop, &pad, slop); memcpy(buf + buflen - slop, &pad, slop);
} }
} }
local_irq_restore(flags); local_irq_restore(flags);
} }
else else
ata_pio_data_xfer_noirq(adev, buf, buflen, write_data); ata_data_xfer_noirq(adev, buf, buflen, write_data);
} }
static struct ata_port_operations pdc20230_port_ops = { static struct ata_port_operations pdc20230_port_ops = {
...@@ -326,8 +328,8 @@ static void ht6560a_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -326,8 +328,8 @@ static void ht6560a_set_piomode(struct ata_port *ap, struct ata_device *adev)
inb(0x3E6); inb(0x3E6);
inb(0x3E6); inb(0x3E6);
outb(recover << 4 | active, ap->ioaddr.device_addr); iowrite8(recover << 4 | active, ap->ioaddr.device_addr);
inb(ap->ioaddr.status_addr); ioread8(ap->ioaddr.status_addr);
} }
static struct ata_port_operations ht6560a_port_ops = { static struct ata_port_operations ht6560a_port_ops = {
...@@ -345,7 +347,7 @@ static struct ata_port_operations ht6560a_port_ops = { ...@@ -345,7 +347,7 @@ static struct ata_port_operations ht6560a_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, /* Check vlb/noirq */ .data_xfer = ata_data_xfer, /* Check vlb/noirq */
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -379,7 +381,7 @@ static void ht6560b_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -379,7 +381,7 @@ static void ht6560b_set_piomode(struct ata_port *ap, struct ata_device *adev)
inb(0x3E6); inb(0x3E6);
inb(0x3E6); inb(0x3E6);
outb(recover << 4 | active, ap->ioaddr.device_addr); iowrite8(recover << 4 | active, ap->ioaddr.device_addr);
if (adev->class != ATA_DEV_ATA) { if (adev->class != ATA_DEV_ATA) {
u8 rconf = inb(0x3E6); u8 rconf = inb(0x3E6);
...@@ -388,7 +390,7 @@ static void ht6560b_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -388,7 +390,7 @@ static void ht6560b_set_piomode(struct ata_port *ap, struct ata_device *adev)
outb(rconf, 0x3E6); outb(rconf, 0x3E6);
} }
} }
inb(ap->ioaddr.status_addr); ioread8(ap->ioaddr.status_addr);
} }
static struct ata_port_operations ht6560b_port_ops = { static struct ata_port_operations ht6560b_port_ops = {
...@@ -406,7 +408,7 @@ static struct ata_port_operations ht6560b_port_ops = { ...@@ -406,7 +408,7 @@ static struct ata_port_operations ht6560b_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, /* FIXME: Check 32bit and noirq */ .data_xfer = ata_data_xfer, /* FIXME: Check 32bit and noirq */
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -454,12 +456,12 @@ static void opti82c611a_set_piomode(struct ata_port *ap, struct ata_device *adev ...@@ -454,12 +456,12 @@ static void opti82c611a_set_piomode(struct ata_port *ap, struct ata_device *adev
u8 rc; u8 rc;
/* Enter configuration mode */ /* Enter configuration mode */
inw(ap->ioaddr.error_addr); ioread16(ap->ioaddr.error_addr);
inw(ap->ioaddr.error_addr); ioread16(ap->ioaddr.error_addr);
outb(3, ap->ioaddr.nsect_addr); iowrite8(3, ap->ioaddr.nsect_addr);
/* Read VLB clock strapping */ /* Read VLB clock strapping */
clock = 1000000000 / khz[inb(ap->ioaddr.lbah_addr) & 0x03]; clock = 1000000000 / khz[ioread8(ap->ioaddr.lbah_addr) & 0x03];
/* Get the timing data in cycles */ /* Get the timing data in cycles */
ata_timing_compute(adev, adev->pio_mode, &t, clock, 1000); ata_timing_compute(adev, adev->pio_mode, &t, clock, 1000);
...@@ -477,33 +479,33 @@ static void opti82c611a_set_piomode(struct ata_port *ap, struct ata_device *adev ...@@ -477,33 +479,33 @@ static void opti82c611a_set_piomode(struct ata_port *ap, struct ata_device *adev
setup = FIT(t.setup, 1, 4) - 1; setup = FIT(t.setup, 1, 4) - 1;
/* Select the right timing bank for write timing */ /* Select the right timing bank for write timing */
rc = inb(ap->ioaddr.lbal_addr); rc = ioread8(ap->ioaddr.lbal_addr);
rc &= 0x7F; rc &= 0x7F;
rc |= (adev->devno << 7); rc |= (adev->devno << 7);
outb(rc, ap->ioaddr.lbal_addr); iowrite8(rc, ap->ioaddr.lbal_addr);
/* Write the timings */ /* Write the timings */
outb(active << 4 | recover, ap->ioaddr.error_addr); iowrite8(active << 4 | recover, ap->ioaddr.error_addr);
/* Select the right bank for read timings, also /* Select the right bank for read timings, also
load the shared timings for address */ load the shared timings for address */
rc = inb(ap->ioaddr.device_addr); rc = ioread8(ap->ioaddr.device_addr);
rc &= 0xC0; rc &= 0xC0;
rc |= adev->devno; /* Index select */ rc |= adev->devno; /* Index select */
rc |= (setup << 4) | 0x04; rc |= (setup << 4) | 0x04;
outb(rc, ap->ioaddr.device_addr); iowrite8(rc, ap->ioaddr.device_addr);
/* Load the read timings */ /* Load the read timings */
outb(active << 4 | recover, ap->ioaddr.data_addr); iowrite8(active << 4 | recover, ap->ioaddr.data_addr);
/* Ensure the timing register mode is right */ /* Ensure the timing register mode is right */
rc = inb (ap->ioaddr.lbal_addr); rc = ioread8(ap->ioaddr.lbal_addr);
rc &= 0x73; rc &= 0x73;
rc |= 0x84; rc |= 0x84;
outb(rc, ap->ioaddr.lbal_addr); iowrite8(rc, ap->ioaddr.lbal_addr);
/* Exit command mode */ /* Exit command mode */
outb(0x83, ap->ioaddr.nsect_addr); iowrite8(0x83, ap->ioaddr.nsect_addr);
} }
...@@ -522,7 +524,7 @@ static struct ata_port_operations opti82c611a_port_ops = { ...@@ -522,7 +524,7 @@ static struct ata_port_operations opti82c611a_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -551,9 +553,9 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -551,9 +553,9 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev)
sysclk = opti_syscfg(0xAC) & 0xC0; /* BIOS set */ sysclk = opti_syscfg(0xAC) & 0xC0; /* BIOS set */
/* Enter configuration mode */ /* Enter configuration mode */
inw(ap->ioaddr.error_addr); ioread16(ap->ioaddr.error_addr);
inw(ap->ioaddr.error_addr); ioread16(ap->ioaddr.error_addr);
outb(3, ap->ioaddr.nsect_addr); iowrite8(3, ap->ioaddr.nsect_addr);
/* Read VLB clock strapping */ /* Read VLB clock strapping */
clock = 1000000000 / khz[sysclk]; clock = 1000000000 / khz[sysclk];
...@@ -574,33 +576,33 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -574,33 +576,33 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev)
setup = FIT(t.setup, 1, 4) - 1; setup = FIT(t.setup, 1, 4) - 1;
/* Select the right timing bank for write timing */ /* Select the right timing bank for write timing */
rc = inb(ap->ioaddr.lbal_addr); rc = ioread8(ap->ioaddr.lbal_addr);
rc &= 0x7F; rc &= 0x7F;
rc |= (adev->devno << 7); rc |= (adev->devno << 7);
outb(rc, ap->ioaddr.lbal_addr); iowrite8(rc, ap->ioaddr.lbal_addr);
/* Write the timings */ /* Write the timings */
outb(active << 4 | recover, ap->ioaddr.error_addr); iowrite8(active << 4 | recover, ap->ioaddr.error_addr);
/* Select the right bank for read timings, also /* Select the right bank for read timings, also
load the shared timings for address */ load the shared timings for address */
rc = inb(ap->ioaddr.device_addr); rc = ioread8(ap->ioaddr.device_addr);
rc &= 0xC0; rc &= 0xC0;
rc |= adev->devno; /* Index select */ rc |= adev->devno; /* Index select */
rc |= (setup << 4) | 0x04; rc |= (setup << 4) | 0x04;
outb(rc, ap->ioaddr.device_addr); iowrite8(rc, ap->ioaddr.device_addr);
/* Load the read timings */ /* Load the read timings */
outb(active << 4 | recover, ap->ioaddr.data_addr); iowrite8(active << 4 | recover, ap->ioaddr.data_addr);
/* Ensure the timing register mode is right */ /* Ensure the timing register mode is right */
rc = inb (ap->ioaddr.lbal_addr); rc = ioread8(ap->ioaddr.lbal_addr);
rc &= 0x73; rc &= 0x73;
rc |= 0x84; rc |= 0x84;
outb(rc, ap->ioaddr.lbal_addr); iowrite8(rc, ap->ioaddr.lbal_addr);
/* Exit command mode */ /* Exit command mode */
outb(0x83, ap->ioaddr.nsect_addr); iowrite8(0x83, ap->ioaddr.nsect_addr);
/* We need to know this for quad device on the MVB */ /* We need to know this for quad device on the MVB */
ap->host->private_data = ap; ap->host->private_data = ap;
...@@ -650,7 +652,7 @@ static struct ata_port_operations opti82c46x_port_ops = { ...@@ -650,7 +652,7 @@ static struct ata_port_operations opti82c46x_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = opti82c46x_qc_issue_prot, .qc_issue = opti82c46x_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -676,6 +678,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl ...@@ -676,6 +678,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
struct ata_probe_ent ae; struct ata_probe_ent ae;
struct platform_device *pdev; struct platform_device *pdev;
struct ata_port_operations *ops = &legacy_port_ops; struct ata_port_operations *ops = &legacy_port_ops;
void __iomem *io_addr, *ctrl_addr;
int pio_modes = pio_mask; int pio_modes = pio_mask;
u32 mask = (1 << port); u32 mask = (1 << port);
int ret; int ret;
...@@ -689,6 +692,12 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl ...@@ -689,6 +692,12 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
devm_request_region(&pdev->dev, ctrl, 1, "pata_legacy") == NULL) devm_request_region(&pdev->dev, ctrl, 1, "pata_legacy") == NULL)
goto fail; goto fail;
ret = -ENOMEM;
io_addr = devm_ioport_map(&pdev->dev, io, 8);
ctrl_addr = devm_ioport_map(&pdev->dev, ctrl, 1);
if (!io_addr || !ctrl_addr)
goto fail;
if (ht6560a & mask) { if (ht6560a & mask) {
ops = &ht6560a_port_ops; ops = &ht6560a_port_ops;
pio_modes = 0x07; pio_modes = 0x07;
...@@ -754,9 +763,9 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl ...@@ -754,9 +763,9 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
ae.irq = irq; ae.irq = irq;
ae.irq_flags = 0; ae.irq_flags = 0;
ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST; ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST;
ae.port[0].cmd_addr = io; ae.port[0].cmd_addr = io_addr;
ae.port[0].altstatus_addr = ctrl; ae.port[0].altstatus_addr = ctrl_addr;
ae.port[0].ctl_addr = ctrl; ae.port[0].ctl_addr = ctrl_addr;
ata_std_ports(&ae.port[0]); ata_std_ports(&ae.port[0]);
ae.private_data = ld; ae.private_data = ld;
......
...@@ -57,7 +57,7 @@ static int marvell_pre_reset(struct ata_port *ap) ...@@ -57,7 +57,7 @@ static int marvell_pre_reset(struct ata_port *ap)
switch(ap->port_no) switch(ap->port_no)
{ {
case 0: case 0:
if (inb(ap->ioaddr.bmdma_addr + 1) & 1) if (ioread8(ap->ioaddr.bmdma_addr + 1) & 1)
ap->cbl = ATA_CBL_PATA40; ap->cbl = ATA_CBL_PATA40;
else else
ap->cbl = ATA_CBL_PATA80; ap->cbl = ATA_CBL_PATA80;
...@@ -129,7 +129,7 @@ static const struct ata_port_operations marvell_ops = { ...@@ -129,7 +129,7 @@ static const struct ata_port_operations marvell_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
/* Timeout handling */ /* Timeout handling */
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
......
...@@ -295,7 +295,7 @@ static struct ata_port_operations mpc52xx_ata_port_ops = { ...@@ -295,7 +295,7 @@ static struct ata_port_operations mpc52xx_ata_port_ops = {
.error_handler = mpc52xx_ata_error_handler, .error_handler = mpc52xx_ata_error_handler,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
.port_start = ata_port_start, .port_start = ata_port_start,
...@@ -308,7 +308,7 @@ static struct ata_probe_ent mpc52xx_ata_probe_ent = { ...@@ -308,7 +308,7 @@ static struct ata_probe_ent mpc52xx_ata_probe_ent = {
.pio_mask = 0x1f, /* Up to PIO4 */ .pio_mask = 0x1f, /* Up to PIO4 */
.mwdma_mask = 0x00, /* No MWDMA */ .mwdma_mask = 0x00, /* No MWDMA */
.udma_mask = 0x00, /* No UDMA */ .udma_mask = 0x00, /* No UDMA */
.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_MMIO, .port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.irq_flags = 0, .irq_flags = 0,
}; };
...@@ -324,18 +324,18 @@ mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv) ...@@ -324,18 +324,18 @@ mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv)
ae->irq = priv->ata_irq; ae->irq = priv->ata_irq;
aio->cmd_addr = 0; /* Don't have a classic reg block */ aio->cmd_addr = 0; /* Don't have a classic reg block */
aio->altstatus_addr = (unsigned long)&priv->ata_regs->tf_control; aio->altstatus_addr = &priv->ata_regs->tf_control;
aio->ctl_addr = (unsigned long)&priv->ata_regs->tf_control; aio->ctl_addr = &priv->ata_regs->tf_control;
aio->data_addr = (unsigned long)&priv->ata_regs->tf_data; aio->data_addr = &priv->ata_regs->tf_data;
aio->error_addr = (unsigned long)&priv->ata_regs->tf_features; aio->error_addr = &priv->ata_regs->tf_features;
aio->feature_addr = (unsigned long)&priv->ata_regs->tf_features; aio->feature_addr = &priv->ata_regs->tf_features;
aio->nsect_addr = (unsigned long)&priv->ata_regs->tf_sec_count; aio->nsect_addr = &priv->ata_regs->tf_sec_count;
aio->lbal_addr = (unsigned long)&priv->ata_regs->tf_sec_num; aio->lbal_addr = &priv->ata_regs->tf_sec_num;
aio->lbam_addr = (unsigned long)&priv->ata_regs->tf_cyl_low; aio->lbam_addr = &priv->ata_regs->tf_cyl_low;
aio->lbah_addr = (unsigned long)&priv->ata_regs->tf_cyl_high; aio->lbah_addr = &priv->ata_regs->tf_cyl_high;
aio->device_addr = (unsigned long)&priv->ata_regs->tf_dev_head; aio->device_addr = &priv->ata_regs->tf_dev_head;
aio->status_addr = (unsigned long)&priv->ata_regs->tf_command; aio->status_addr = &priv->ata_regs->tf_command;
aio->command_addr = (unsigned long)&priv->ata_regs->tf_command; aio->command_addr = &priv->ata_regs->tf_command;
ae->private_data = priv; ae->private_data = priv;
......
...@@ -188,7 +188,7 @@ static struct ata_port_operations mpiix_port_ops = { ...@@ -188,7 +188,7 @@ static struct ata_port_operations mpiix_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = mpiix_qc_issue_prot, .qc_issue = mpiix_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -199,10 +199,11 @@ static struct ata_port_operations mpiix_port_ops = { ...@@ -199,10 +199,11 @@ static struct ata_port_operations mpiix_port_ops = {
static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id) static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{ {
/* Single threaded by the PCI probe logic */ /* Single threaded by the PCI probe logic */
static struct ata_probe_ent probe[2]; static struct ata_probe_ent probe;
static int printed_version; static int printed_version;
void __iomem *cmd_addr, *ctl_addr;
u16 idetim; u16 idetim;
int enabled; int irq;
if (!printed_version++) if (!printed_version++)
dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
...@@ -215,43 +216,43 @@ static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -215,43 +216,43 @@ static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
if (!(idetim & ENABLED)) if (!(idetim & ENABLED))
return -ENODEV; return -ENODEV;
if (!(idetim & SECONDARY)) {
irq = 14;
cmd_addr = devm_ioport_map(&dev->dev, 0x1F0, 8);
ctl_addr = devm_ioport_map(&dev->dev, 0x3F6, 1);
} else {
irq = 15;
cmd_addr = devm_ioport_map(&dev->dev, 0x170, 8);
ctl_addr = devm_ioport_map(&dev->dev, 0x376, 1);
}
if (!cmd_addr || !ctl_addr)
return -ENOMEM;
/* We do our own plumbing to avoid leaking special cases for whacko /* We do our own plumbing to avoid leaking special cases for whacko
ancient hardware into the core code. There are two issues to ancient hardware into the core code. There are two issues to
worry about. #1 The chip is a bridge so if in legacy mode and worry about. #1 The chip is a bridge so if in legacy mode and
without BARs set fools the setup. #2 If you pci_disable_device without BARs set fools the setup. #2 If you pci_disable_device
the MPIIX your box goes castors up */ the MPIIX your box goes castors up */
INIT_LIST_HEAD(&probe[0].node); INIT_LIST_HEAD(&probe.node);
probe[0].dev = pci_dev_to_dev(dev); probe.dev = pci_dev_to_dev(dev);
probe[0].port_ops = &mpiix_port_ops; probe.port_ops = &mpiix_port_ops;
probe[0].sht = &mpiix_sht; probe.sht = &mpiix_sht;
probe[0].pio_mask = 0x1F; probe.pio_mask = 0x1F;
probe[0].irq = 14; probe.irq = irq;
probe[0].irq_flags = SA_SHIRQ; probe.irq_flags = SA_SHIRQ;
probe[0].port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; probe.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
probe[0].n_ports = 1; probe.n_ports = 1;
probe[0].port[0].cmd_addr = 0x1F0; probe.port[0].cmd_addr = cmd_addr;
probe[0].port[0].ctl_addr = 0x3F6; probe.port[0].ctl_addr = ctl_addr;
probe[0].port[0].altstatus_addr = 0x3F6; probe.port[0].altstatus_addr = ctl_addr;
/* The secondary lurks at different addresses but is otherwise
the same beastie */
INIT_LIST_HEAD(&probe[1].node);
probe[1] = probe[0];
probe[1].irq = 15;
probe[1].port[0].cmd_addr = 0x170;
probe[1].port[0].ctl_addr = 0x376;
probe[1].port[0].altstatus_addr = 0x376;
/* Let libata fill in the port details */ /* Let libata fill in the port details */
ata_std_ports(&probe[0].port[0]); ata_std_ports(&probe.port[0]);
ata_std_ports(&probe[1].port[0]);
/* Now add the port that is active */ /* Now add the port that is active */
enabled = (idetim & SECONDARY) ? 1 : 0; if (ata_device_add(&probe))
if (ata_device_add(&probe[enabled]))
return 0; return 0;
return -ENODEV; return -ENODEV;
} }
......
...@@ -89,7 +89,7 @@ static const struct ata_port_operations netcell_ops = { ...@@ -89,7 +89,7 @@ static const struct ata_port_operations netcell_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
/* IRQ-related hooks */ /* IRQ-related hooks */
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
......
...@@ -179,7 +179,7 @@ static struct ata_port_operations ns87410_port_ops = { ...@@ -179,7 +179,7 @@ static struct ata_port_operations ns87410_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ns87410_qc_issue_prot, .qc_issue = ns87410_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -259,7 +259,7 @@ static const struct ata_port_operations oldpiix_pata_ops = { ...@@ -259,7 +259,7 @@ static const struct ata_port_operations oldpiix_pata_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = oldpiix_qc_issue_prot, .qc_issue = oldpiix_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -95,18 +95,18 @@ static void opti_error_handler(struct ata_port *ap) ...@@ -95,18 +95,18 @@ static void opti_error_handler(struct ata_port *ap)
static void opti_write_reg(struct ata_port *ap, u8 val, int reg) static void opti_write_reg(struct ata_port *ap, u8 val, int reg)
{ {
unsigned long regio = ap->ioaddr.cmd_addr; void __iomem *regio = ap->ioaddr.cmd_addr;
/* These 3 unlock the control register access */ /* These 3 unlock the control register access */
inw(regio + 1); ioread16(regio + 1);
inw(regio + 1); ioread16(regio + 1);
outb(3, regio + 2); iowrite8(3, regio + 2);
/* Do the I/O */ /* Do the I/O */
outb(val, regio + reg); iowrite8(val, regio + reg);
/* Relock */ /* Relock */
outb(0x83, regio + 2); iowrite8(0x83, regio + 2);
} }
/** /**
...@@ -124,7 +124,7 @@ static void opti_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -124,7 +124,7 @@ static void opti_set_piomode(struct ata_port *ap, struct ata_device *adev)
struct ata_device *pair = ata_dev_pair(adev); struct ata_device *pair = ata_dev_pair(adev);
int clock; int clock;
int pio = adev->pio_mode - XFER_PIO_0; int pio = adev->pio_mode - XFER_PIO_0;
unsigned long regio = ap->ioaddr.cmd_addr; void __iomem *regio = ap->ioaddr.cmd_addr;
u8 addr; u8 addr;
/* Address table precomputed with prefetch off and a DCLK of 2 */ /* Address table precomputed with prefetch off and a DCLK of 2 */
...@@ -137,8 +137,8 @@ static void opti_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -137,8 +137,8 @@ static void opti_set_piomode(struct ata_port *ap, struct ata_device *adev)
{ 0x58, 0x44, 0x32, 0x22, 0x21 } { 0x58, 0x44, 0x32, 0x22, 0x21 }
}; };
outb(0xff, regio + 5); iowrite8(0xff, regio + 5);
clock = inw(regio + 5) & 1; clock = ioread16(regio + 5) & 1;
/* /*
* As with many controllers the address setup time is shared * As with many controllers the address setup time is shared
...@@ -205,7 +205,7 @@ static struct ata_port_operations opti_port_ops = { ...@@ -205,7 +205,7 @@ static struct ata_port_operations opti_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -91,12 +91,12 @@ static void optidma_error_handler(struct ata_port *ap) ...@@ -91,12 +91,12 @@ static void optidma_error_handler(struct ata_port *ap)
static void optidma_unlock(struct ata_port *ap) static void optidma_unlock(struct ata_port *ap)
{ {
unsigned long regio = ap->ioaddr.cmd_addr; void __iomem *regio = ap->ioaddr.cmd_addr;
/* These 3 unlock the control register access */ /* These 3 unlock the control register access */
inw(regio + 1); ioread16(regio + 1);
inw(regio + 1); ioread16(regio + 1);
outb(3, regio + 2); iowrite8(3, regio + 2);
} }
/** /**
...@@ -108,10 +108,10 @@ static void optidma_unlock(struct ata_port *ap) ...@@ -108,10 +108,10 @@ static void optidma_unlock(struct ata_port *ap)
static void optidma_lock(struct ata_port *ap) static void optidma_lock(struct ata_port *ap)
{ {
unsigned long regio = ap->ioaddr.cmd_addr; void __iomem *regio = ap->ioaddr.cmd_addr;
/* Relock */ /* Relock */
outb(0x83, regio + 2); iowrite8(0x83, regio + 2);
} }
/** /**
...@@ -133,7 +133,7 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo ...@@ -133,7 +133,7 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
struct ata_device *pair = ata_dev_pair(adev); struct ata_device *pair = ata_dev_pair(adev);
int pio = adev->pio_mode - XFER_PIO_0; int pio = adev->pio_mode - XFER_PIO_0;
int dma = adev->dma_mode - XFER_MW_DMA_0; int dma = adev->dma_mode - XFER_MW_DMA_0;
unsigned long regio = ap->ioaddr.cmd_addr; void __iomem *regio = ap->ioaddr.cmd_addr;
u8 addr; u8 addr;
/* Address table precomputed with a DCLK of 2 */ /* Address table precomputed with a DCLK of 2 */
...@@ -178,20 +178,20 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo ...@@ -178,20 +178,20 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
/* Commence primary programming sequence */ /* Commence primary programming sequence */
/* First we load the device number into the timing select */ /* First we load the device number into the timing select */
outb(adev->devno, regio + MISC_REG); iowrite8(adev->devno, regio + MISC_REG);
/* Now we load the data timings into read data/write data */ /* Now we load the data timings into read data/write data */
if (mode < XFER_MW_DMA_0) { if (mode < XFER_MW_DMA_0) {
outb(data_rec_timing[pci_clock][pio], regio + READ_REG); iowrite8(data_rec_timing[pci_clock][pio], regio + READ_REG);
outb(data_rec_timing[pci_clock][pio], regio + WRITE_REG); iowrite8(data_rec_timing[pci_clock][pio], regio + WRITE_REG);
} else if (mode < XFER_UDMA_0) { } else if (mode < XFER_UDMA_0) {
outb(dma_data_rec_timing[pci_clock][dma], regio + READ_REG); iowrite8(dma_data_rec_timing[pci_clock][dma], regio + READ_REG);
outb(dma_data_rec_timing[pci_clock][dma], regio + WRITE_REG); iowrite8(dma_data_rec_timing[pci_clock][dma], regio + WRITE_REG);
} }
/* Finally we load the address setup into the misc register */ /* Finally we load the address setup into the misc register */
outb(addr | adev->devno, regio + MISC_REG); iowrite8(addr | adev->devno, regio + MISC_REG);
/* Programming sequence complete, timing 0 dev 0, timing 1 dev 1 */ /* Programming sequence complete, timing 0 dev 0, timing 1 dev 1 */
outb(0x85, regio + CNTRL_REG); iowrite8(0x85, regio + CNTRL_REG);
/* Switch back to IDE mode */ /* Switch back to IDE mode */
optidma_lock(ap); optidma_lock(ap);
...@@ -389,7 +389,7 @@ static struct ata_port_operations optidma_port_ops = { ...@@ -389,7 +389,7 @@ static struct ata_port_operations optidma_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -422,7 +422,7 @@ static struct ata_port_operations optiplus_port_ops = { ...@@ -422,7 +422,7 @@ static struct ata_port_operations optiplus_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -88,7 +88,7 @@ static struct ata_port_operations pcmcia_port_ops = { ...@@ -88,7 +88,7 @@ static struct ata_port_operations pcmcia_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer_noirq, .data_xfer = ata_data_xfer_noirq,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -121,6 +121,7 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) ...@@ -121,6 +121,7 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
cistpl_cftable_entry_t *cfg; cistpl_cftable_entry_t *cfg;
int pass, last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM; int pass, last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM;
unsigned long io_base, ctl_base; unsigned long io_base, ctl_base;
void __iomem *io_addr, *ctl_addr;
info = kzalloc(sizeof(*info), GFP_KERNEL); info = kzalloc(sizeof(*info), GFP_KERNEL);
if (info == NULL) if (info == NULL)
...@@ -231,10 +232,17 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) ...@@ -231,10 +232,17 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &pdev->irq)); CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &pdev->irq));
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &pdev->conf)); CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &pdev->conf));
/* iomap */
ret = -ENOMEM;
io_addr = devm_ioport_map(&pdev->dev, io_base, 8);
ctl_addr = devm_ioport_map(&pdev->dev, ctl_base, 1);
if (!io_addr || !ctl_addr)
goto failed;
/* Success. Disable the IRQ nIEN line, do quirks */ /* Success. Disable the IRQ nIEN line, do quirks */
outb(0x02, ctl_base); iowrite8(0x02, ctl_addr);
if (is_kme) if (is_kme)
outb(0x81, ctl_base + 0x01); iowrite8(0x81, ctl_addr + 0x01);
/* FIXME: Could be more ports at base + 0x10 but we only deal with /* FIXME: Could be more ports at base + 0x10 but we only deal with
one right now */ one right now */
...@@ -256,11 +264,12 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) ...@@ -256,11 +264,12 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
ae.irq = pdev->irq.AssignedIRQ; ae.irq = pdev->irq.AssignedIRQ;
ae.irq_flags = SA_SHIRQ; ae.irq_flags = SA_SHIRQ;
ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
ae.port[0].cmd_addr = io_base; ae.port[0].cmd_addr = io_addr;
ae.port[0].altstatus_addr = ctl_base; ae.port[0].altstatus_addr = ctl_addr;
ae.port[0].ctl_addr = ctl_base; ae.port[0].ctl_addr = ctl_addr;
ata_std_ports(&ae.port[0]); ata_std_ports(&ae.port[0]);
ret = -ENODEV;
if (ata_device_add(&ae) == 0) if (ata_device_add(&ae) == 0)
goto failed; goto failed;
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
#endif #endif
enum { enum {
PDC_MMIO_BAR = 5,
PDC_UDMA_100 = 0, PDC_UDMA_100 = 0,
PDC_UDMA_133 = 1, PDC_UDMA_133 = 1,
...@@ -158,7 +160,7 @@ static struct ata_port_operations pdc2027x_pata100_ops = { ...@@ -158,7 +160,7 @@ static struct ata_port_operations pdc2027x_pata100_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
...@@ -190,7 +192,7 @@ static struct ata_port_operations pdc2027x_pata133_ops = { ...@@ -190,7 +192,7 @@ static struct ata_port_operations pdc2027x_pata133_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
...@@ -239,7 +241,7 @@ MODULE_DEVICE_TABLE(pci, pdc2027x_pci_tbl); ...@@ -239,7 +241,7 @@ MODULE_DEVICE_TABLE(pci, pdc2027x_pci_tbl);
*/ */
static inline void __iomem *port_mmio(struct ata_port *ap, unsigned int offset) static inline void __iomem *port_mmio(struct ata_port *ap, unsigned int offset)
{ {
return ap->host->mmio_base + ap->port_no * 0x100 + offset; return ap->host->iomap[PDC_MMIO_BAR] + ap->port_no * 0x100 + offset;
} }
/** /**
...@@ -520,18 +522,19 @@ static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc) ...@@ -520,18 +522,19 @@ static int pdc2027x_check_atapi_dma(struct ata_queued_cmd *qc)
static long pdc_read_counter(struct ata_probe_ent *probe_ent) static long pdc_read_counter(struct ata_probe_ent *probe_ent)
{ {
void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
long counter; long counter;
int retry = 1; int retry = 1;
u32 bccrl, bccrh, bccrlv, bccrhv; u32 bccrl, bccrh, bccrlv, bccrhv;
retry: retry:
bccrl = readl(probe_ent->mmio_base + PDC_BYTE_COUNT) & 0xffff; bccrl = readl(mmio_base + PDC_BYTE_COUNT) & 0xffff;
bccrh = readl(probe_ent->mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff; bccrh = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff;
rmb(); rmb();
/* Read the counter values again for verification */ /* Read the counter values again for verification */
bccrlv = readl(probe_ent->mmio_base + PDC_BYTE_COUNT) & 0xffff; bccrlv = readl(mmio_base + PDC_BYTE_COUNT) & 0xffff;
bccrhv = readl(probe_ent->mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff; bccrhv = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff;
rmb(); rmb();
counter = (bccrh << 15) | bccrl; counter = (bccrh << 15) | bccrl;
...@@ -562,7 +565,7 @@ static long pdc_read_counter(struct ata_probe_ent *probe_ent) ...@@ -562,7 +565,7 @@ static long pdc_read_counter(struct ata_probe_ent *probe_ent)
*/ */
static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsigned int board_idx) static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsigned int board_idx)
{ {
void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
u16 pll_ctl; u16 pll_ctl;
long pll_clock_khz = pll_clock / 1000; long pll_clock_khz = pll_clock / 1000;
long pout_required = board_idx? PDC_133_MHZ:PDC_100_MHZ; 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,7 +584,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
/* Show the current clock value of PLL control register /* Show the current clock value of PLL control register
* (maybe already configured by the firmware) * (maybe already configured by the firmware)
*/ */
pll_ctl = readw(probe_ent->mmio_base + PDC_PLL_CTL); pll_ctl = readw(mmio_base + PDC_PLL_CTL);
PDPRINTK("pll_ctl[%X]\n", pll_ctl); PDPRINTK("pll_ctl[%X]\n", pll_ctl);
#endif #endif
...@@ -621,8 +624,8 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi ...@@ -621,8 +624,8 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
PDPRINTK("Writing pll_ctl[%X]\n", pll_ctl); PDPRINTK("Writing pll_ctl[%X]\n", pll_ctl);
writew(pll_ctl, probe_ent->mmio_base + PDC_PLL_CTL); writew(pll_ctl, mmio_base + PDC_PLL_CTL);
readw(probe_ent->mmio_base + PDC_PLL_CTL); /* flush */ readw(mmio_base + PDC_PLL_CTL); /* flush */
/* Wait the PLL circuit to be stable */ /* Wait the PLL circuit to be stable */
mdelay(30); mdelay(30);
...@@ -632,7 +635,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi ...@@ -632,7 +635,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
* Show the current clock value of PLL control register * Show the current clock value of PLL control register
* (maybe configured by the firmware) * (maybe configured by the firmware)
*/ */
pll_ctl = readw(probe_ent->mmio_base + PDC_PLL_CTL); pll_ctl = readw(mmio_base + PDC_PLL_CTL);
PDPRINTK("pll_ctl[%X]\n", pll_ctl); PDPRINTK("pll_ctl[%X]\n", pll_ctl);
#endif #endif
...@@ -648,6 +651,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi ...@@ -648,6 +651,7 @@ static void pdc_adjust_pll(struct ata_probe_ent *probe_ent, long pll_clock, unsi
*/ */
static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent) static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
{ {
void __iomem *mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
u32 scr; u32 scr;
long start_count, end_count; long start_count, end_count;
long pll_clock; long pll_clock;
...@@ -656,10 +660,10 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent) ...@@ -656,10 +660,10 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
start_count = pdc_read_counter(probe_ent); start_count = pdc_read_counter(probe_ent);
/* Start the test mode */ /* Start the test mode */
scr = readl(probe_ent->mmio_base + PDC_SYS_CTL); scr = readl(mmio_base + PDC_SYS_CTL);
PDPRINTK("scr[%X]\n", scr); PDPRINTK("scr[%X]\n", scr);
writel(scr | (0x01 << 14), probe_ent->mmio_base + PDC_SYS_CTL); writel(scr | (0x01 << 14), mmio_base + PDC_SYS_CTL);
readl(probe_ent->mmio_base + PDC_SYS_CTL); /* flush */ readl(mmio_base + PDC_SYS_CTL); /* flush */
/* Let the counter run for 100 ms. */ /* Let the counter run for 100 ms. */
mdelay(100); mdelay(100);
...@@ -668,10 +672,10 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent) ...@@ -668,10 +672,10 @@ static long pdc_detect_pll_input_clock(struct ata_probe_ent *probe_ent)
end_count = pdc_read_counter(probe_ent); end_count = pdc_read_counter(probe_ent);
/* Stop the test mode */ /* Stop the test mode */
scr = readl(probe_ent->mmio_base + PDC_SYS_CTL); scr = readl(mmio_base + PDC_SYS_CTL);
PDPRINTK("scr[%X]\n", scr); PDPRINTK("scr[%X]\n", scr);
writel(scr & ~(0x01 << 14), probe_ent->mmio_base + PDC_SYS_CTL); writel(scr & ~(0x01 << 14), mmio_base + PDC_SYS_CTL);
readl(probe_ent->mmio_base + PDC_SYS_CTL); /* flush */ readl(mmio_base + PDC_SYS_CTL); /* flush */
/* calculate the input clock in Hz */ /* calculate the input clock in Hz */
pll_clock = (start_count - end_count) * 10; 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,7 +720,7 @@ static int pdc_hardware_init(struct pci_dev *pdev, struct ata_probe_ent *pe, uns
* @port: ata ioports to setup * @port: ata ioports to setup
* @base: base address * @base: base address
*/ */
static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base) static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base)
{ {
port->cmd_addr = port->cmd_addr =
port->data_addr = base; port->data_addr = base;
...@@ -750,7 +754,6 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de ...@@ -750,7 +754,6 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
unsigned int board_idx = (unsigned int) ent->driver_data; unsigned int board_idx = (unsigned int) ent->driver_data;
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
unsigned long base;
void __iomem *mmio_base; void __iomem *mmio_base;
int rc; int rc;
...@@ -761,7 +764,7 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de ...@@ -761,7 +764,7 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
if (rc) if (rc)
return rc; return rc;
rc = pci_request_regions(pdev, DRV_NAME); rc = pcim_iomap_regions(pdev, 1 << PDC_MMIO_BAR, DRV_NAME);
if (rc) if (rc)
return rc; return rc;
...@@ -781,12 +784,6 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de ...@@ -781,12 +784,6 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
probe_ent->dev = pci_dev_to_dev(pdev); probe_ent->dev = pci_dev_to_dev(pdev);
INIT_LIST_HEAD(&probe_ent->node); INIT_LIST_HEAD(&probe_ent->node);
mmio_base = pcim_iomap(pdev, 5, 0);
if (!mmio_base)
return -ENOMEM;
base = (unsigned long) mmio_base;
probe_ent->sht = pdc2027x_port_info[board_idx].sht; probe_ent->sht = pdc2027x_port_info[board_idx].sht;
probe_ent->port_flags = pdc2027x_port_info[board_idx].flags; probe_ent->port_flags = pdc2027x_port_info[board_idx].flags;
probe_ent->pio_mask = pdc2027x_port_info[board_idx].pio_mask; 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,12 +793,14 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
probe_ent->irq = pdev->irq; probe_ent->irq = pdev->irq;
probe_ent->irq_flags = SA_SHIRQ; probe_ent->irq_flags = SA_SHIRQ;
probe_ent->mmio_base = mmio_base; probe_ent->iomap = pcim_iomap_table(pdev);
mmio_base = probe_ent->iomap[PDC_MMIO_BAR];
pdc_ata_setup_port(&probe_ent->port[0], base + 0x17c0); pdc_ata_setup_port(&probe_ent->port[0], mmio_base + 0x17c0);
probe_ent->port[0].bmdma_addr = base + 0x1000; probe_ent->port[0].bmdma_addr = mmio_base + 0x1000;
pdc_ata_setup_port(&probe_ent->port[1], base + 0x15c0); pdc_ata_setup_port(&probe_ent->port[1], mmio_base + 0x15c0);
probe_ent->port[1].bmdma_addr = base + 0x1008; probe_ent->port[1].bmdma_addr = mmio_base + 0x1008;
probe_ent->n_ports = 2; probe_ent->n_ports = 2;
......
...@@ -170,17 +170,17 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc) ...@@ -170,17 +170,17 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc)
struct ata_taskfile *tf = &qc->tf; struct ata_taskfile *tf = &qc->tf;
int sel66 = ap->port_no ? 0x08: 0x02; int sel66 = ap->port_no ? 0x08: 0x02;
unsigned long master = ap->host->ports[0]->ioaddr.bmdma_addr; void __iomem *master = ap->host->ports[0]->ioaddr.bmdma_addr;
unsigned long clock = master + 0x11; void __iomem *clock = master + 0x11;
unsigned long atapi_reg = master + 0x20 + (4 * ap->port_no); void __iomem *atapi_reg = master + 0x20 + (4 * ap->port_no);
u32 len; u32 len;
/* Check we keep host level locking here */ /* Check we keep host level locking here */
if (adev->dma_mode >= XFER_UDMA_2) if (adev->dma_mode >= XFER_UDMA_2)
outb(inb(clock) | sel66, clock); iowrite8(ioread8(clock) | sel66, clock);
else else
outb(inb(clock) & ~sel66, clock); iowrite8(ioread8(clock) & ~sel66, clock);
/* The DMA clocks may have been trashed by a reset. FIXME: make conditional /* The DMA clocks may have been trashed by a reset. FIXME: make conditional
and move to qc_issue ? */ and move to qc_issue ? */
...@@ -196,7 +196,7 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc) ...@@ -196,7 +196,7 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc)
else else
len |= 0x05000000; len |= 0x05000000;
outl(len, atapi_reg); iowrite32(len, atapi_reg);
} }
/* Activate DMA */ /* Activate DMA */
...@@ -219,19 +219,19 @@ static void pdc2026x_bmdma_stop(struct ata_queued_cmd *qc) ...@@ -219,19 +219,19 @@ static void pdc2026x_bmdma_stop(struct ata_queued_cmd *qc)
int sel66 = ap->port_no ? 0x08: 0x02; int sel66 = ap->port_no ? 0x08: 0x02;
/* The clock bits are in the same register for both channels */ /* The clock bits are in the same register for both channels */
unsigned long master = ap->host->ports[0]->ioaddr.bmdma_addr; void __iomem *master = ap->host->ports[0]->ioaddr.bmdma_addr;
unsigned long clock = master + 0x11; void __iomem *clock = master + 0x11;
unsigned long atapi_reg = master + 0x20 + (4 * ap->port_no); void __iomem *atapi_reg = master + 0x20 + (4 * ap->port_no);
/* Cases the state machine will not complete correctly */ /* Cases the state machine will not complete correctly */
if (tf->protocol == ATA_PROT_ATAPI_DMA || ( tf->flags & ATA_TFLAG_LBA48)) { if (tf->protocol == ATA_PROT_ATAPI_DMA || ( tf->flags & ATA_TFLAG_LBA48)) {
outl(0, atapi_reg); iowrite32(0, atapi_reg);
outb(inb(clock) & ~sel66, clock); iowrite8(ioread8(clock) & ~sel66, clock);
} }
/* Check we keep host level locking here */ /* Check we keep host level locking here */
/* Flip back to 33Mhz for PIO */ /* Flip back to 33Mhz for PIO */
if (adev->dma_mode >= XFER_UDMA_2) if (adev->dma_mode >= XFER_UDMA_2)
outb(inb(clock) & ~sel66, clock); iowrite8(ioread8(clock) & ~sel66, clock);
ata_bmdma_stop(qc); ata_bmdma_stop(qc);
} }
...@@ -294,7 +294,7 @@ static struct ata_port_operations pdc2024x_port_ops = { ...@@ -294,7 +294,7 @@ static struct ata_port_operations pdc2024x_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -326,7 +326,7 @@ static struct ata_port_operations pdc2026x_port_ops = { ...@@ -326,7 +326,7 @@ static struct ata_port_operations pdc2026x_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -83,7 +83,7 @@ static struct ata_port_operations pata_platform_port_ops = { ...@@ -83,7 +83,7 @@ static struct ata_port_operations pata_platform_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer_noirq, .data_xfer = ata_data_xfer_noirq,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -134,7 +134,6 @@ static int __devinit pata_platform_probe(struct platform_device *pdev) ...@@ -134,7 +134,6 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
struct resource *io_res, *ctl_res; struct resource *io_res, *ctl_res;
struct ata_probe_ent ae; struct ata_probe_ent ae;
unsigned int mmio; unsigned int mmio;
int ret;
/* /*
* Simple resource validation .. * Simple resource validation ..
...@@ -188,48 +187,29 @@ static int __devinit pata_platform_probe(struct platform_device *pdev) ...@@ -188,48 +187,29 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
* Handle the MMIO case * Handle the MMIO case
*/ */
if (mmio) { if (mmio) {
ae.port_flags |= ATA_FLAG_MMIO; ae.port[0].cmd_addr = devm_ioremap(&pdev->dev, io_res->start,
ae.port[0].cmd_addr = (unsigned long)
devm_ioremap(&pdev->dev, io_res->start,
io_res->end - io_res->start + 1); io_res->end - io_res->start + 1);
if (unlikely(!ae.port[0].cmd_addr)) { ae.port[0].ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start,
dev_err(&pdev->dev, "failed to remap IO base\n");
return -ENXIO;
}
ae.port[0].ctl_addr = (unsigned long)
devm_ioremap(&pdev->dev, ctl_res->start,
ctl_res->end - ctl_res->start + 1); ctl_res->end - ctl_res->start + 1);
if (unlikely(!ae.port[0].ctl_addr)) {
dev_err(&pdev->dev, "failed to remap CTL base\n");
ret = -ENXIO;
goto bad_remap;
}
} else { } else {
ae.port[0].cmd_addr = io_res->start; ae.port[0].cmd_addr = devm_ioport_map(&pdev->dev, io_res->start,
ae.port[0].ctl_addr = ctl_res->start; io_res->end - io_res->start + 1);
ae.port[0].ctl_addr = devm_ioport_map(&pdev->dev, ctl_res->start,
ctl_res->end - ctl_res->start + 1);
}
if (!ae.port[0].cmd_addr || !ae.port[0].ctl_addr) {
dev_err(&pdev->dev, "failed to map IO/CTL base\n");
return -ENOMEM;
} }
ae.port[0].altstatus_addr = ae.port[0].ctl_addr; ae.port[0].altstatus_addr = ae.port[0].ctl_addr;
pata_platform_setup_port(&ae.port[0], pdev->dev.platform_data); pata_platform_setup_port(&ae.port[0], pdev->dev.platform_data);
if (unlikely(ata_device_add(&ae) == 0)) { if (unlikely(ata_device_add(&ae) == 0))
ret = -ENODEV; return -ENODEV;
goto add_failed;
}
return 0; return 0;
add_failed:
if (ae.port[0].ctl_addr && mmio)
iounmap((void __iomem *)ae.port[0].ctl_addr);
bad_remap:
if (ae.port[0].cmd_addr && mmio)
iounmap((void __iomem *)ae.port[0].cmd_addr);
return ret;
} }
/** /**
......
...@@ -131,22 +131,24 @@ static void qdi_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned ...@@ -131,22 +131,24 @@ static void qdi_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned
if (ata_id_has_dword_io(adev->id)) { if (ata_id_has_dword_io(adev->id)) {
if (write_data) if (write_data)
outsl(ap->ioaddr.data_addr, buf, buflen >> 2); iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
else else
insl(ap->ioaddr.data_addr, buf, buflen >> 2); ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
if (unlikely(slop)) { if (unlikely(slop)) {
u32 pad; u32 pad;
if (write_data) { if (write_data) {
memcpy(&pad, buf + buflen - slop, slop); memcpy(&pad, buf + buflen - slop, slop);
outl(le32_to_cpu(pad), ap->ioaddr.data_addr); pad = le32_to_cpu(pad);
iowrite32(pad, ap->ioaddr.data_addr);
} else { } else {
pad = cpu_to_le32(inl(ap->ioaddr.data_addr)); pad = ioread32(ap->ioaddr.data_addr);
pad = cpu_to_le32(pad);
memcpy(buf + buflen - slop, &pad, slop); memcpy(buf + buflen - slop, &pad, slop);
} }
} }
} else } else
ata_pio_data_xfer(adev, buf, buflen, write_data); ata_data_xfer(adev, buf, buflen, write_data);
} }
static struct scsi_host_template qdi_sht = { static struct scsi_host_template qdi_sht = {
...@@ -234,10 +236,9 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i ...@@ -234,10 +236,9 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
{ {
struct ata_probe_ent ae; struct ata_probe_ent ae;
struct platform_device *pdev; struct platform_device *pdev;
void __iomem *io_addr, *ctl_addr;
int ret; int ret;
unsigned long ctrl = io + 0x206;
/* /*
* Fill in a probe structure first of all * Fill in a probe structure first of all
*/ */
...@@ -246,6 +247,12 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i ...@@ -246,6 +247,12 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
if (IS_ERR(pdev)) if (IS_ERR(pdev))
return PTR_ERR(pdev); return PTR_ERR(pdev);
ret = -ENOMEM;
io_addr = devm_ioport_map(&pdev->dev, io, 8);
ctl_addr = devm_ioport_map(&pdev->dev, io + 0x206, 1);
if (!io_addr || !ctl_addr)
goto fail;
memset(&ae, 0, sizeof(struct ata_probe_ent)); memset(&ae, 0, sizeof(struct ata_probe_ent));
INIT_LIST_HEAD(&ae.node); INIT_LIST_HEAD(&ae.node);
ae.dev = &pdev->dev; ae.dev = &pdev->dev;
...@@ -263,9 +270,9 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i ...@@ -263,9 +270,9 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
ae.irq = irq; ae.irq = irq;
ae.irq_flags = 0; ae.irq_flags = 0;
ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
ae.port[0].cmd_addr = io; ae.port[0].cmd_addr = io_addr;
ae.port[0].altstatus_addr = ctrl; ae.port[0].altstatus_addr = ctl_addr;
ae.port[0].ctl_addr = ctrl; ae.port[0].ctl_addr = ctl_addr;
ata_std_ports(&ae.port[0]); ata_std_ports(&ae.port[0]);
/* /*
...@@ -278,14 +285,17 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i ...@@ -278,14 +285,17 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i
qdi_data[nr_qdi_host].platform_dev = pdev; qdi_data[nr_qdi_host].platform_dev = pdev;
printk(KERN_INFO DRV_NAME": qd%d at 0x%lx.\n", type, io); printk(KERN_INFO DRV_NAME": qd%d at 0x%lx.\n", type, io);
ret = ata_device_add(&ae);
if (ret == 0) { ret = -ENODEV;
platform_device_unregister(pdev); if (!ata_device_add(&ae))
return -ENODEV; goto fail;
}
qdi_host[nr_qdi_host++] = dev_get_drvdata(&pdev->dev); qdi_host[nr_qdi_host++] = dev_get_drvdata(&pdev->dev);
return 0; return 0;
fail:
platform_device_unregister(pdev);
return ret;
} }
/** /**
......
...@@ -255,7 +255,7 @@ static const struct ata_port_operations radisys_pata_ops = { ...@@ -255,7 +255,7 @@ static const struct ata_port_operations radisys_pata_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = radisys_qc_issue_prot, .qc_issue = radisys_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -115,7 +115,7 @@ static struct ata_port_operations rz1000_port_ops = { ...@@ -115,7 +115,7 @@ static struct ata_port_operations rz1000_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
......
...@@ -220,7 +220,7 @@ static struct ata_port_operations sc1200_port_ops = { ...@@ -220,7 +220,7 @@ static struct ata_port_operations sc1200_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = sc1200_qc_issue_prot, .qc_issue = sc1200_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -348,7 +348,7 @@ static struct ata_port_operations serverworks_osb4_port_ops = { ...@@ -348,7 +348,7 @@ static struct ata_port_operations serverworks_osb4_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -381,7 +381,7 @@ static struct ata_port_operations serverworks_csb_port_ops = { ...@@ -381,7 +381,7 @@ static struct ata_port_operations serverworks_csb_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -252,7 +252,7 @@ static struct ata_port_operations sil680_port_ops = { ...@@ -252,7 +252,7 @@ static struct ata_port_operations sil680_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -603,7 +603,7 @@ static const struct ata_port_operations sis_133_ops = { ...@@ -603,7 +603,7 @@ static const struct ata_port_operations sis_133_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -634,7 +634,7 @@ static const struct ata_port_operations sis_133_early_ops = { ...@@ -634,7 +634,7 @@ static const struct ata_port_operations sis_133_early_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -666,7 +666,7 @@ static const struct ata_port_operations sis_100_ops = { ...@@ -666,7 +666,7 @@ static const struct ata_port_operations sis_100_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -697,7 +697,7 @@ static const struct ata_port_operations sis_66_ops = { ...@@ -697,7 +697,7 @@ static const struct ata_port_operations sis_66_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -728,7 +728,7 @@ static const struct ata_port_operations sis_old_ops = { ...@@ -728,7 +728,7 @@ static const struct ata_port_operations sis_old_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -262,7 +262,7 @@ static struct ata_port_operations sl82c105_port_ops = { ...@@ -262,7 +262,7 @@ static struct ata_port_operations sl82c105_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -221,7 +221,7 @@ static struct ata_port_operations triflex_port_ops = { ...@@ -221,7 +221,7 @@ static struct ata_port_operations triflex_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -334,7 +334,7 @@ static struct ata_port_operations via_port_ops = { ...@@ -334,7 +334,7 @@ static struct ata_port_operations via_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
...@@ -367,7 +367,7 @@ static struct ata_port_operations via_port_ops_noirq = { ...@@ -367,7 +367,7 @@ static struct ata_port_operations via_port_ops_noirq = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer_noirq, .data_xfer = ata_data_xfer_noirq,
.irq_handler = ata_interrupt, .irq_handler = ata_interrupt,
.irq_clear = ata_bmdma_irq_clear, .irq_clear = ata_bmdma_irq_clear,
......
...@@ -100,22 +100,24 @@ static void winbond_data_xfer(struct ata_device *adev, unsigned char *buf, unsig ...@@ -100,22 +100,24 @@ static void winbond_data_xfer(struct ata_device *adev, unsigned char *buf, unsig
if (ata_id_has_dword_io(adev->id)) { if (ata_id_has_dword_io(adev->id)) {
if (write_data) if (write_data)
outsl(ap->ioaddr.data_addr, buf, buflen >> 2); iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
else else
insl(ap->ioaddr.data_addr, buf, buflen >> 2); ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
if (unlikely(slop)) { if (unlikely(slop)) {
u32 pad; u32 pad;
if (write_data) { if (write_data) {
memcpy(&pad, buf + buflen - slop, slop); memcpy(&pad, buf + buflen - slop, slop);
outl(le32_to_cpu(pad), ap->ioaddr.data_addr); pad = le32_to_cpu(pad);
iowrite32(pad, ap->ioaddr.data_addr);
} else { } else {
pad = cpu_to_le16(inl(ap->ioaddr.data_addr)); pad = ioread32(ap->ioaddr.data_addr);
pad = cpu_to_le16(pad);
memcpy(buf + buflen - slop, &pad, slop); memcpy(buf + buflen - slop, &pad, slop);
} }
} }
} else } else
ata_pio_data_xfer(adev, buf, buflen, write_data); ata_data_xfer(adev, buf, buflen, write_data);
} }
static struct scsi_host_template winbond_sht = { static struct scsi_host_template winbond_sht = {
...@@ -197,6 +199,8 @@ static __init int winbond_init_one(unsigned long port) ...@@ -197,6 +199,8 @@ static __init int winbond_init_one(unsigned long port)
return 0; return 0;
for (i = 0; i < 2 ; i ++) { for (i = 0; i < 2 ; i ++) {
unsigned long cmd_port = 0x1F0 - (0x80 * i);
void __iomem *cmd_addr, *ctl_addr;
if (reg & (1 << i)) { if (reg & (1 << i)) {
/* /*
...@@ -207,6 +211,13 @@ static __init int winbond_init_one(unsigned long port) ...@@ -207,6 +211,13 @@ static __init int winbond_init_one(unsigned long port)
if (IS_ERR(pdev)) if (IS_ERR(pdev))
return PTR_ERR(pdev); return PTR_ERR(pdev);
cmd_addr = devm_ioport_map(&pdev->dev, cmd_port, 8);
ctl_addr = devm_ioport_map(&pdev->dev, cmd_port + 0x0206, 1);
if (!cmd_addr || !ctl_addr) {
platform_device_unregister(pdev);
return -ENOMEM;
}
memset(&ae, 0, sizeof(struct ata_probe_ent)); memset(&ae, 0, sizeof(struct ata_probe_ent));
INIT_LIST_HEAD(&ae.node); INIT_LIST_HEAD(&ae.node);
ae.dev = &pdev->dev; ae.dev = &pdev->dev;
...@@ -220,9 +231,9 @@ static __init int winbond_init_one(unsigned long port) ...@@ -220,9 +231,9 @@ static __init int winbond_init_one(unsigned long port)
ae.irq = 14 + i; ae.irq = 14 + i;
ae.irq_flags = 0; ae.irq_flags = 0;
ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
ae.port[0].cmd_addr = 0x1F0 - (0x80 * i); ae.port[0].cmd_addr = cmd_addr;
ae.port[0].altstatus_addr = ae.port[0].cmd_addr + 0x0206; ae.port[0].altstatus_addr = ctl_addr;
ae.port[0].ctl_addr = ae.port[0].altstatus_addr; ae.port[0].ctl_addr = ctl_addr;
ata_std_ports(&ae.port[0]); ata_std_ports(&ae.port[0]);
/* /*
* Hook in a private data structure per channel * Hook in a private data structure per channel
......
...@@ -53,7 +53,13 @@ ...@@ -53,7 +53,13 @@
/* macro to calculate base address for ADMA regs */ /* macro to calculate base address for ADMA regs */
#define ADMA_REGS(base,port_no) ((base) + 0x80 + ((port_no) * 0x20)) #define ADMA_REGS(base,port_no) ((base) + 0x80 + ((port_no) * 0x20))
/* macro to obtain addresses from ata_host */
#define ADMA_HOST_REGS(host,port_no) \
ADMA_REGS((host)->iomap[ADMA_MMIO_BAR], port_no)
enum { enum {
ADMA_MMIO_BAR = 4,
ADMA_PORTS = 2, ADMA_PORTS = 2,
ADMA_CPB_BYTES = 40, ADMA_CPB_BYTES = 40,
ADMA_PRD_BYTES = LIBATA_MAX_PRD * 16, ADMA_PRD_BYTES = LIBATA_MAX_PRD * 16,
...@@ -166,7 +172,7 @@ static const struct ata_port_operations adma_ata_ops = { ...@@ -166,7 +172,7 @@ static const struct ata_port_operations adma_ata_ops = {
.qc_prep = adma_qc_prep, .qc_prep = adma_qc_prep,
.qc_issue = adma_qc_issue, .qc_issue = adma_qc_issue,
.eng_timeout = adma_eng_timeout, .eng_timeout = adma_eng_timeout,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = adma_intr, .irq_handler = adma_intr,
.irq_clear = adma_irq_clear, .irq_clear = adma_irq_clear,
.port_start = adma_port_start, .port_start = adma_port_start,
...@@ -234,11 +240,10 @@ static void adma_reset_engine(void __iomem *chan) ...@@ -234,11 +240,10 @@ static void adma_reset_engine(void __iomem *chan)
static void adma_reinit_engine(struct ata_port *ap) static void adma_reinit_engine(struct ata_port *ap)
{ {
struct adma_port_priv *pp = ap->private_data; struct adma_port_priv *pp = ap->private_data;
void __iomem *mmio_base = ap->host->mmio_base; void __iomem *chan = ADMA_HOST_REGS(ap->host, ap->port_no);
void __iomem *chan = ADMA_REGS(mmio_base, ap->port_no);
/* mask/clear ATA interrupts */ /* mask/clear ATA interrupts */
writeb(ATA_NIEN, (void __iomem *)ap->ioaddr.ctl_addr); writeb(ATA_NIEN, ap->ioaddr.ctl_addr);
ata_check_status(ap); ata_check_status(ap);
/* reset the ADMA engine */ /* reset the ADMA engine */
...@@ -262,7 +267,7 @@ static void adma_reinit_engine(struct ata_port *ap) ...@@ -262,7 +267,7 @@ static void adma_reinit_engine(struct ata_port *ap)
static inline void adma_enter_reg_mode(struct ata_port *ap) static inline void adma_enter_reg_mode(struct ata_port *ap)
{ {
void __iomem *chan = ADMA_REGS(ap->host->mmio_base, ap->port_no); void __iomem *chan = ADMA_HOST_REGS(ap->host, ap->port_no);
writew(aPIOMD4, chan + ADMA_CONTROL); writew(aPIOMD4, chan + ADMA_CONTROL);
readb(chan + ADMA_STATUS); /* flush */ readb(chan + ADMA_STATUS); /* flush */
...@@ -409,7 +414,7 @@ static void adma_qc_prep(struct ata_queued_cmd *qc) ...@@ -409,7 +414,7 @@ static void adma_qc_prep(struct ata_queued_cmd *qc)
static inline void adma_packet_start(struct ata_queued_cmd *qc) static inline void adma_packet_start(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
void __iomem *chan = ADMA_REGS(ap->host->mmio_base, ap->port_no); void __iomem *chan = ADMA_HOST_REGS(ap->host, ap->port_no);
VPRINTK("ENTER, ap %p\n", ap); VPRINTK("ENTER, ap %p\n", ap);
...@@ -442,13 +447,12 @@ static unsigned int adma_qc_issue(struct ata_queued_cmd *qc) ...@@ -442,13 +447,12 @@ static unsigned int adma_qc_issue(struct ata_queued_cmd *qc)
static inline unsigned int adma_intr_pkt(struct ata_host *host) static inline unsigned int adma_intr_pkt(struct ata_host *host)
{ {
unsigned int handled = 0, port_no; unsigned int handled = 0, port_no;
u8 __iomem *mmio_base = host->mmio_base;
for (port_no = 0; port_no < host->n_ports; ++port_no) { for (port_no = 0; port_no < host->n_ports; ++port_no) {
struct ata_port *ap = host->ports[port_no]; struct ata_port *ap = host->ports[port_no];
struct adma_port_priv *pp; struct adma_port_priv *pp;
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
void __iomem *chan = ADMA_REGS(mmio_base, port_no); void __iomem *chan = ADMA_HOST_REGS(host, port_no);
u8 status = readb(chan + ADMA_STATUS); u8 status = readb(chan + ADMA_STATUS);
if (status == 0) if (status == 0)
...@@ -522,7 +526,7 @@ static irqreturn_t adma_intr(int irq, void *dev_instance) ...@@ -522,7 +526,7 @@ static irqreturn_t adma_intr(int irq, void *dev_instance)
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
static void adma_ata_setup_port(struct ata_ioports *port, unsigned long base) static void adma_ata_setup_port(struct ata_ioports *port, void __iomem *base)
{ {
port->cmd_addr = port->cmd_addr =
port->data_addr = base + 0x000; port->data_addr = base + 0x000;
...@@ -570,7 +574,7 @@ static int adma_port_start(struct ata_port *ap) ...@@ -570,7 +574,7 @@ static int adma_port_start(struct ata_port *ap)
static void adma_port_stop(struct ata_port *ap) static void adma_port_stop(struct ata_port *ap)
{ {
adma_reset_engine(ADMA_REGS(ap->host->mmio_base, ap->port_no)); adma_reset_engine(ADMA_HOST_REGS(ap->host, ap->port_no));
} }
static void adma_host_stop(struct ata_host *host) static void adma_host_stop(struct ata_host *host)
...@@ -578,14 +582,14 @@ static void adma_host_stop(struct ata_host *host) ...@@ -578,14 +582,14 @@ static void adma_host_stop(struct ata_host *host)
unsigned int port_no; unsigned int port_no;
for (port_no = 0; port_no < ADMA_PORTS; ++port_no) for (port_no = 0; port_no < ADMA_PORTS; ++port_no)
adma_reset_engine(ADMA_REGS(host->mmio_base, port_no)); adma_reset_engine(ADMA_HOST_REGS(host, port_no));
} }
static void adma_host_init(unsigned int chip_id, static void adma_host_init(unsigned int chip_id,
struct ata_probe_ent *probe_ent) struct ata_probe_ent *probe_ent)
{ {
unsigned int port_no; unsigned int port_no;
void __iomem *mmio_base = probe_ent->mmio_base; void __iomem *mmio_base = probe_ent->iomap[ADMA_MMIO_BAR];
/* enable/lock aGO operation */ /* enable/lock aGO operation */
writeb(7, mmio_base + ADMA_MODE_LOCK); writeb(7, mmio_base + ADMA_MODE_LOCK);
...@@ -630,16 +634,13 @@ static int adma_ata_init_one(struct pci_dev *pdev, ...@@ -630,16 +634,13 @@ static int adma_ata_init_one(struct pci_dev *pdev,
if (rc) if (rc)
return rc; return rc;
rc = pci_request_regions(pdev, DRV_NAME);
if (rc)
return rc;
if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0) if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0)
return -ENODEV; return -ENODEV;
mmio_base = pcim_iomap(pdev, 4, 0); rc = pcim_iomap_regions(pdev, 1 << ADMA_MMIO_BAR, DRV_NAME);
if (mmio_base == NULL) if (rc)
return -ENOMEM; return rc;
mmio_base = pcim_iomap_table(pdev)[ADMA_MMIO_BAR];
rc = adma_set_dma_masks(pdev, mmio_base); rc = adma_set_dma_masks(pdev, mmio_base);
if (rc) if (rc)
...@@ -661,12 +662,12 @@ static int adma_ata_init_one(struct pci_dev *pdev, ...@@ -661,12 +662,12 @@ static int adma_ata_init_one(struct pci_dev *pdev,
probe_ent->irq = pdev->irq; probe_ent->irq = pdev->irq;
probe_ent->irq_flags = IRQF_SHARED; probe_ent->irq_flags = IRQF_SHARED;
probe_ent->mmio_base = mmio_base;
probe_ent->n_ports = ADMA_PORTS; probe_ent->n_ports = ADMA_PORTS;
probe_ent->iomap = pcim_iomap_table(pdev);
for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) { for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) {
adma_ata_setup_port(&probe_ent->port[port_no], adma_ata_setup_port(&probe_ent->port[port_no],
ADMA_ATA_REGS((unsigned long)mmio_base, port_no)); ADMA_ATA_REGS(mmio_base, port_no));
} }
pci_set_master(pdev); pci_set_master(pdev);
......
...@@ -147,7 +147,7 @@ static const int scr_map[] = { ...@@ -147,7 +147,7 @@ static const int scr_map[] = {
static void __iomem * inic_port_base(struct ata_port *ap) static void __iomem * inic_port_base(struct ata_port *ap)
{ {
return ap->host->mmio_base + ap->port_no * PORT_SIZE; return ap->host->iomap[MMIO_BAR] + ap->port_no * PORT_SIZE;
} }
static void __inic_set_pirq_mask(struct ata_port *ap, u8 mask) static void __inic_set_pirq_mask(struct ata_port *ap, u8 mask)
...@@ -324,7 +324,7 @@ static void inic_host_intr(struct ata_port *ap) ...@@ -324,7 +324,7 @@ static void inic_host_intr(struct ata_port *ap)
static irqreturn_t inic_interrupt(int irq, void *dev_instance) static irqreturn_t inic_interrupt(int irq, void *dev_instance)
{ {
struct ata_host *host = dev_instance; struct ata_host *host = dev_instance;
void __iomem *mmio_base = host->mmio_base; void __iomem *mmio_base = host->iomap[MMIO_BAR];
u16 host_irq_stat; u16 host_irq_stat;
int i, handled = 0;; int i, handled = 0;;
...@@ -566,7 +566,7 @@ static struct ata_port_operations inic_port_ops = { ...@@ -566,7 +566,7 @@ static struct ata_port_operations inic_port_ops = {
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = inic_qc_issue, .qc_issue = inic_qc_issue,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = inic_freeze, .freeze = inic_freeze,
.thaw = inic_thaw, .thaw = inic_thaw,
...@@ -638,7 +638,7 @@ static int inic_pci_device_resume(struct pci_dev *pdev) ...@@ -638,7 +638,7 @@ static int inic_pci_device_resume(struct pci_dev *pdev)
{ {
struct ata_host *host = dev_get_drvdata(&pdev->dev); struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct inic_host_priv *hpriv = host->private_data; struct inic_host_priv *hpriv = host->private_data;
void __iomem *mmio_base = host->mmio_base; void __iomem *mmio_base = host->iomap[MMIO_BAR];
int rc; int rc;
ata_pci_device_do_resume(pdev); ata_pci_device_do_resume(pdev);
...@@ -661,7 +661,7 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -661,7 +661,7 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
struct ata_port_info *pinfo = &inic_port_info; struct ata_port_info *pinfo = &inic_port_info;
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
struct inic_host_priv *hpriv; struct inic_host_priv *hpriv;
void __iomem *mmio_base; void __iomem * const *iomap;
int i, rc; int i, rc;
if (!printed_version++) if (!printed_version++)
...@@ -675,9 +675,10 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -675,9 +675,10 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (rc) if (rc)
return rc; return rc;
mmio_base = pci_iomap(pdev, MMIO_BAR, 0); rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME);
if (!mmio_base) if (rc)
return -ENOMEM; return rc;
iomap = pcim_iomap_table(pdev);
/* Set dma_mask. This devices doesn't support 64bit addressing. */ /* Set dma_mask. This devices doesn't support 64bit addressing. */
rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
...@@ -713,26 +714,25 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -713,26 +714,25 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
probe_ent->irq = pdev->irq; probe_ent->irq = pdev->irq;
probe_ent->irq_flags = SA_SHIRQ; probe_ent->irq_flags = SA_SHIRQ;
probe_ent->mmio_base = mmio_base; probe_ent->iomap = iomap;
for (i = 0; i < NR_PORTS; i++) { for (i = 0; i < NR_PORTS; i++) {
struct ata_ioports *port = &probe_ent->port[i]; struct ata_ioports *port = &probe_ent->port[i];
unsigned long port_base = void __iomem *port_base = iomap[MMIO_BAR] + i * PORT_SIZE;
(unsigned long)mmio_base + i * PORT_SIZE;
port->cmd_addr = pci_resource_start(pdev, 2 * i); port->cmd_addr = iomap[2 * i];
port->altstatus_addr = port->altstatus_addr =
port->ctl_addr = port->ctl_addr = (void __iomem *)
pci_resource_start(pdev, 2 * i + 1) | ATA_PCI_CTL_OFS; ((unsigned long)iomap[2 * i + 1] | ATA_PCI_CTL_OFS);
port->scr_addr = port_base + PORT_SCR; port->scr_addr = port_base + PORT_SCR;
ata_std_ports(port); ata_std_ports(port);
} }
probe_ent->private_data = hpriv; probe_ent->private_data = hpriv;
hpriv->cached_hctl = readw(mmio_base + HOST_CTL); hpriv->cached_hctl = readw(iomap[MMIO_BAR] + HOST_CTL);
rc = init_controller(mmio_base, hpriv->cached_hctl); rc = init_controller(iomap[MMIO_BAR], hpriv->cached_hctl);
if (rc) { if (rc) {
dev_printk(KERN_ERR, &pdev->dev, dev_printk(KERN_ERR, &pdev->dev,
"failed to initialize controller\n"); "failed to initialize controller\n");
......
...@@ -404,7 +404,7 @@ static const struct ata_port_operations mv5_ops = { ...@@ -404,7 +404,7 @@ static const struct ata_port_operations mv5_ops = {
.qc_prep = mv_qc_prep, .qc_prep = mv_qc_prep,
.qc_issue = mv_qc_issue, .qc_issue = mv_qc_issue,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.eng_timeout = mv_eng_timeout, .eng_timeout = mv_eng_timeout,
...@@ -431,7 +431,7 @@ static const struct ata_port_operations mv6_ops = { ...@@ -431,7 +431,7 @@ static const struct ata_port_operations mv6_ops = {
.qc_prep = mv_qc_prep, .qc_prep = mv_qc_prep,
.qc_issue = mv_qc_issue, .qc_issue = mv_qc_issue,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.eng_timeout = mv_eng_timeout, .eng_timeout = mv_eng_timeout,
...@@ -458,7 +458,7 @@ static const struct ata_port_operations mv_iie_ops = { ...@@ -458,7 +458,7 @@ static const struct ata_port_operations mv_iie_ops = {
.qc_prep = mv_qc_prep_iie, .qc_prep = mv_qc_prep_iie,
.qc_issue = mv_qc_issue, .qc_issue = mv_qc_issue,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.eng_timeout = mv_eng_timeout, .eng_timeout = mv_eng_timeout,
...@@ -615,7 +615,7 @@ static inline void __iomem *mv_port_base(void __iomem *base, unsigned int port) ...@@ -615,7 +615,7 @@ static inline void __iomem *mv_port_base(void __iomem *base, unsigned int port)
static inline void __iomem *mv_ap_base(struct ata_port *ap) static inline void __iomem *mv_ap_base(struct ata_port *ap)
{ {
return mv_port_base(ap->host->mmio_base, ap->port_no); return mv_port_base(ap->host->iomap[MV_PRIMARY_BAR], ap->port_no);
} }
static inline int mv_get_hc_count(unsigned long port_flags) static 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,7 +1299,7 @@ static void mv_err_intr(struct ata_port *ap, int reset_allowed)
*/ */
static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc) static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc)
{ {
void __iomem *mmio = host->mmio_base; void __iomem *mmio = host->iomap[MV_PRIMARY_BAR];
void __iomem *hc_mmio = mv_hc_base(mmio, hc); void __iomem *hc_mmio = mv_hc_base(mmio, hc);
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
u32 hc_irq_cause; u32 hc_irq_cause;
...@@ -1342,8 +1342,7 @@ static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc) ...@@ -1342,8 +1342,7 @@ static void mv_host_intr(struct ata_host *host, u32 relevant, unsigned int hc)
} else { } else {
/* PIO: check for device (drive) interrupt */ /* PIO: check for device (drive) interrupt */
if ((DEV_IRQ << hard_port) & hc_irq_cause) { if ((DEV_IRQ << hard_port) & hc_irq_cause) {
ata_status = readb((void __iomem *) ata_status = readb(ap->ioaddr.status_addr);
ap->ioaddr.status_addr);
handled = 1; handled = 1;
/* ignore spurious intr if drive still BUSY */ /* ignore spurious intr if drive still BUSY */
if (ata_status & ATA_BUSY) { if (ata_status & ATA_BUSY) {
...@@ -1403,7 +1402,7 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance) ...@@ -1403,7 +1402,7 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance)
{ {
struct ata_host *host = dev_instance; struct ata_host *host = dev_instance;
unsigned int hc, handled = 0, n_hcs; unsigned int hc, handled = 0, n_hcs;
void __iomem *mmio = host->mmio_base; void __iomem *mmio = host->iomap[MV_PRIMARY_BAR];
struct mv_host_priv *hpriv; struct mv_host_priv *hpriv;
u32 irq_stat; u32 irq_stat;
...@@ -1479,22 +1478,24 @@ static unsigned int mv5_scr_offset(unsigned int sc_reg_in) ...@@ -1479,22 +1478,24 @@ static unsigned int mv5_scr_offset(unsigned int sc_reg_in)
static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in) static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in)
{ {
void __iomem *mmio = mv5_phy_base(ap->host->mmio_base, ap->port_no); void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
void __iomem *addr = mv5_phy_base(mmio, ap->port_no);
unsigned int ofs = mv5_scr_offset(sc_reg_in); unsigned int ofs = mv5_scr_offset(sc_reg_in);
if (ofs != 0xffffffffU) if (ofs != 0xffffffffU)
return readl(mmio + ofs); return readl(addr + ofs);
else else
return (u32) ofs; return (u32) ofs;
} }
static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
{ {
void __iomem *mmio = mv5_phy_base(ap->host->mmio_base, ap->port_no); void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
void __iomem *addr = mv5_phy_base(mmio, ap->port_no);
unsigned int ofs = mv5_scr_offset(sc_reg_in); unsigned int ofs = mv5_scr_offset(sc_reg_in);
if (ofs != 0xffffffffU) if (ofs != 0xffffffffU)
writelfl(val, mmio + ofs); writelfl(val, addr + ofs);
} }
static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio) static 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, ...@@ -1856,7 +1857,7 @@ static void mv_channel_reset(struct mv_host_priv *hpriv, void __iomem *mmio,
static void mv_stop_and_reset(struct ata_port *ap) static void mv_stop_and_reset(struct ata_port *ap)
{ {
struct mv_host_priv *hpriv = ap->host->private_data; struct mv_host_priv *hpriv = ap->host->private_data;
void __iomem *mmio = ap->host->mmio_base; void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
mv_stop_dma(ap); mv_stop_dma(ap);
...@@ -1954,10 +1955,10 @@ static void __mv_phy_reset(struct ata_port *ap, int can_sleep) ...@@ -1954,10 +1955,10 @@ static void __mv_phy_reset(struct ata_port *ap, int can_sleep)
break; break;
} }
tf.lbah = readb((void __iomem *) ap->ioaddr.lbah_addr); tf.lbah = readb(ap->ioaddr.lbah_addr);
tf.lbam = readb((void __iomem *) ap->ioaddr.lbam_addr); tf.lbam = readb(ap->ioaddr.lbam_addr);
tf.lbal = readb((void __iomem *) ap->ioaddr.lbal_addr); tf.lbal = readb(ap->ioaddr.lbal_addr);
tf.nsect = readb((void __iomem *) ap->ioaddr.nsect_addr); tf.nsect = readb(ap->ioaddr.nsect_addr);
dev->class = ata_dev_classify(&tf); dev->class = ata_dev_classify(&tf);
if (!ata_dev_enabled(dev)) { if (!ata_dev_enabled(dev)) {
...@@ -1989,17 +1990,17 @@ static void mv_phy_reset(struct ata_port *ap) ...@@ -1989,17 +1990,17 @@ static void mv_phy_reset(struct ata_port *ap)
*/ */
static void mv_eng_timeout(struct ata_port *ap) static void mv_eng_timeout(struct ata_port *ap)
{ {
void __iomem *mmio = ap->host->iomap[MV_PRIMARY_BAR];
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
unsigned long flags; unsigned long flags;
ata_port_printk(ap, KERN_ERR, "Entering mv_eng_timeout\n"); ata_port_printk(ap, KERN_ERR, "Entering mv_eng_timeout\n");
DPRINTK("All regs @ start of eng_timeout\n"); DPRINTK("All regs @ start of eng_timeout\n");
mv_dump_all_regs(ap->host->mmio_base, ap->port_no, mv_dump_all_regs(mmio, ap->port_no, to_pci_dev(ap->host->dev));
to_pci_dev(ap->host->dev));
qc = ata_qc_from_tag(ap, ap->active_tag); qc = ata_qc_from_tag(ap, ap->active_tag);
printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n", printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n",
ap->host->mmio_base, ap, qc, qc->scsicmd, &qc->scsicmd->cmnd); mmio, ap, qc, qc->scsicmd, &qc->scsicmd->cmnd);
spin_lock_irqsave(&ap->host->lock, flags); spin_lock_irqsave(&ap->host->lock, flags);
mv_err_intr(ap, 0); mv_err_intr(ap, 0);
...@@ -2027,7 +2028,7 @@ static void mv_eng_timeout(struct ata_port *ap) ...@@ -2027,7 +2028,7 @@ static void mv_eng_timeout(struct ata_port *ap)
*/ */
static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio) static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio)
{ {
unsigned long shd_base = (unsigned long) port_mmio + SHD_BLK_OFS; void __iomem *shd_base = port_mmio + SHD_BLK_OFS;
unsigned serr_ofs; unsigned serr_ofs;
/* PIO related setup /* PIO related setup
...@@ -2175,7 +2176,7 @@ static int mv_init_host(struct pci_dev *pdev, struct ata_probe_ent *probe_ent, ...@@ -2175,7 +2176,7 @@ static int mv_init_host(struct pci_dev *pdev, struct ata_probe_ent *probe_ent,
unsigned int board_idx) unsigned int board_idx)
{ {
int rc = 0, n_hc, port, hc; int rc = 0, n_hc, port, hc;
void __iomem *mmio = probe_ent->mmio_base; void __iomem *mmio = probe_ent->iomap[MV_PRIMARY_BAR];
struct mv_host_priv *hpriv = probe_ent->private_data; struct mv_host_priv *hpriv = probe_ent->private_data;
/* global interrupt mask */ /* global interrupt mask */
...@@ -2297,7 +2298,6 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2297,7 +2298,6 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
struct mv_host_priv *hpriv; struct mv_host_priv *hpriv;
unsigned int board_idx = (unsigned int)ent->driver_data; unsigned int board_idx = (unsigned int)ent->driver_data;
void __iomem *mmio_base;
int rc; int rc;
if (!printed_version++) if (!printed_version++)
...@@ -2308,11 +2308,11 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2308,11 +2308,11 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
return rc; return rc;
pci_set_master(pdev); pci_set_master(pdev);
rc = pci_request_regions(pdev, DRV_NAME); rc = pcim_iomap_regions(pdev, 1 << MV_PRIMARY_BAR, DRV_NAME);
if (rc) { if (rc == -EBUSY)
pcim_pin_device(pdev); pcim_pin_device(pdev);
if (rc)
return rc; return rc;
}
probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
if (probe_ent == NULL) if (probe_ent == NULL)
...@@ -2321,10 +2321,6 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2321,10 +2321,6 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
probe_ent->dev = pci_dev_to_dev(pdev); probe_ent->dev = pci_dev_to_dev(pdev);
INIT_LIST_HEAD(&probe_ent->node); INIT_LIST_HEAD(&probe_ent->node);
mmio_base = pcim_iomap(pdev, MV_PRIMARY_BAR, 0);
if (mmio_base == NULL)
return -ENOMEM;
hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
if (!hpriv) if (!hpriv)
return -ENOMEM; return -ENOMEM;
...@@ -2337,7 +2333,7 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2337,7 +2333,7 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
probe_ent->irq = pdev->irq; probe_ent->irq = pdev->irq;
probe_ent->irq_flags = IRQF_SHARED; probe_ent->irq_flags = IRQF_SHARED;
probe_ent->mmio_base = mmio_base; probe_ent->iomap = pcim_iomap_table(pdev);
probe_ent->private_data = hpriv; probe_ent->private_data = hpriv;
/* initialize adapter */ /* initialize adapter */
......
This diff is collapsed.
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
enum { enum {
PDC_MMIO_BAR = 3,
/* register offsets */ /* register offsets */
PDC_FEATURE = 0x04, /* Feature/Error reg (per port) */ PDC_FEATURE = 0x04, /* Feature/Error reg (per port) */
PDC_SECTOR_COUNT = 0x08, /* Sector count reg (per port) */ PDC_SECTOR_COUNT = 0x08, /* Sector count reg (per port) */
...@@ -167,7 +169,7 @@ static const struct ata_port_operations pdc_sata_ops = { ...@@ -167,7 +169,7 @@ static const struct ata_port_operations pdc_sata_ops = {
.thaw = pdc_thaw, .thaw = pdc_thaw,
.error_handler = pdc_error_handler, .error_handler = pdc_error_handler,
.post_internal_cmd = pdc_post_internal_cmd, .post_internal_cmd = pdc_post_internal_cmd,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = pdc_interrupt, .irq_handler = pdc_interrupt,
.irq_clear = pdc_irq_clear, .irq_clear = pdc_irq_clear,
...@@ -192,7 +194,7 @@ static const struct ata_port_operations pdc_old_sata_ops = { ...@@ -192,7 +194,7 @@ static const struct ata_port_operations pdc_old_sata_ops = {
.thaw = pdc_thaw, .thaw = pdc_thaw,
.error_handler = pdc_error_handler, .error_handler = pdc_error_handler,
.post_internal_cmd = pdc_post_internal_cmd, .post_internal_cmd = pdc_post_internal_cmd,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.irq_handler = pdc_interrupt, .irq_handler = pdc_interrupt,
.irq_clear = pdc_irq_clear, .irq_clear = pdc_irq_clear,
...@@ -214,7 +216,7 @@ static const struct ata_port_operations pdc_pata_ops = { ...@@ -214,7 +216,7 @@ static const struct ata_port_operations pdc_pata_ops = {
.qc_prep = pdc_qc_prep, .qc_prep = pdc_qc_prep,
.qc_issue = pdc_qc_issue_prot, .qc_issue = pdc_qc_issue_prot,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.eng_timeout = pdc_eng_timeout, .eng_timeout = pdc_eng_timeout,
.irq_handler = pdc_interrupt, .irq_handler = pdc_interrupt,
.irq_clear = pdc_irq_clear, .irq_clear = pdc_irq_clear,
...@@ -348,7 +350,7 @@ static int pdc_port_start(struct ata_port *ap) ...@@ -348,7 +350,7 @@ static int pdc_port_start(struct ata_port *ap)
static void pdc_reset_port(struct ata_port *ap) static void pdc_reset_port(struct ata_port *ap)
{ {
void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT; void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_CTLSTAT;
unsigned int i; unsigned int i;
u32 tmp; u32 tmp;
...@@ -394,7 +396,7 @@ static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) ...@@ -394,7 +396,7 @@ static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
{ {
if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA)
return 0xffffffffU; return 0xffffffffU;
return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); return readl(ap->ioaddr.scr_addr + (sc_reg * 4));
} }
...@@ -403,7 +405,7 @@ static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, ...@@ -403,7 +405,7 @@ static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
{ {
if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA)
return; return;
writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); writel(val, ap->ioaddr.scr_addr + (sc_reg * 4));
} }
static void pdc_atapi_pkt(struct ata_queued_cmd *qc) static void pdc_atapi_pkt(struct ata_queued_cmd *qc)
...@@ -627,7 +629,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap, ...@@ -627,7 +629,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
{ {
unsigned int handled = 0; unsigned int handled = 0;
u32 tmp; u32 tmp;
void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
tmp = readl(mmio); tmp = readl(mmio);
if (tmp & PDC_ERR_MASK) { if (tmp & PDC_ERR_MASK) {
...@@ -656,7 +658,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap, ...@@ -656,7 +658,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
static void pdc_irq_clear(struct ata_port *ap) static void pdc_irq_clear(struct ata_port *ap)
{ {
struct ata_host *host = ap->host; struct ata_host *host = ap->host;
void __iomem *mmio = host->mmio_base; void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
readl(mmio + PDC_INT_SEQMASK); readl(mmio + PDC_INT_SEQMASK);
} }
...@@ -672,12 +674,12 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance) ...@@ -672,12 +674,12 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance)
VPRINTK("ENTER\n"); VPRINTK("ENTER\n");
if (!host || !host->mmio_base) { if (!host || !host->iomap[PDC_MMIO_BAR]) {
VPRINTK("QUICK EXIT\n"); VPRINTK("QUICK EXIT\n");
return IRQ_NONE; return IRQ_NONE;
} }
mmio_base = host->mmio_base; mmio_base = host->iomap[PDC_MMIO_BAR];
/* reading should also clear interrupts */ /* reading should also clear interrupts */
mask = readl(mmio_base + PDC_INT_SEQMASK); mask = readl(mmio_base + PDC_INT_SEQMASK);
...@@ -722,18 +724,19 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc) ...@@ -722,18 +724,19 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct pdc_port_priv *pp = ap->private_data; struct pdc_port_priv *pp = ap->private_data;
void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
unsigned int port_no = ap->port_no; unsigned int port_no = ap->port_no;
u8 seq = (u8) (port_no + 1); u8 seq = (u8) (port_no + 1);
VPRINTK("ENTER, ap %p\n", ap); VPRINTK("ENTER, ap %p\n", ap);
writel(0x00000001, ap->host->mmio_base + (seq * 4)); writel(0x00000001, mmio + (seq * 4));
readl(ap->host->mmio_base + (seq * 4)); /* flush */ readl(mmio + (seq * 4)); /* flush */
pp->pkt[2] = seq; pp->pkt[2] = seq;
wmb(); /* flush PRD, pkt writes */ wmb(); /* flush PRD, pkt writes */
writel(pp->pkt_dma, (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); writel(pp->pkt_dma, ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */ readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */
} }
static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc) static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
...@@ -808,7 +811,7 @@ static int pdc_old_check_atapi_dma(struct ata_queued_cmd *qc) ...@@ -808,7 +811,7 @@ static int pdc_old_check_atapi_dma(struct ata_queued_cmd *qc)
return pdc_check_atapi_dma(qc); return pdc_check_atapi_dma(qc);
} }
static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base) static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base)
{ {
port->cmd_addr = base; port->cmd_addr = base;
port->data_addr = base; port->data_addr = base;
...@@ -828,7 +831,7 @@ static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base) ...@@ -828,7 +831,7 @@ static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base)
static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
{ {
void __iomem *mmio = pe->mmio_base; void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
struct pdc_host_priv *hp = pe->private_data; struct pdc_host_priv *hp = pe->private_data;
int hotplug_offset; int hotplug_offset;
u32 tmp; u32 tmp;
...@@ -884,8 +887,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -884,8 +887,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
static int printed_version; static int printed_version;
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
struct pdc_host_priv *hp; struct pdc_host_priv *hp;
unsigned long base; void __iomem *base;
void __iomem *mmio_base;
unsigned int board_idx = (unsigned int) ent->driver_data; unsigned int board_idx = (unsigned int) ent->driver_data;
int rc; int rc;
u8 tmp; u8 tmp;
...@@ -897,11 +899,11 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -897,11 +899,11 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
if (rc) if (rc)
return rc; return rc;
rc = pci_request_regions(pdev, DRV_NAME); rc = pcim_iomap_regions(pdev, 1 << PDC_MMIO_BAR, DRV_NAME);
if (rc) { if (rc == -EBUSY)
pcim_pin_device(pdev); pcim_pin_device(pdev);
if (rc)
return rc; return rc;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc) if (rc)
...@@ -917,11 +919,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -917,11 +919,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
probe_ent->dev = pci_dev_to_dev(pdev); probe_ent->dev = pci_dev_to_dev(pdev);
INIT_LIST_HEAD(&probe_ent->node); INIT_LIST_HEAD(&probe_ent->node);
mmio_base = pcim_iomap(pdev, 3, 0);
if (mmio_base == NULL)
return -ENOMEM;
base = (unsigned long) mmio_base;
hp = devm_kzalloc(&pdev->dev, sizeof(*hp), GFP_KERNEL); hp = devm_kzalloc(&pdev->dev, sizeof(*hp), GFP_KERNEL);
if (hp == NULL) if (hp == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -937,7 +934,9 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -937,7 +934,9 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
probe_ent->irq = pdev->irq; probe_ent->irq = pdev->irq;
probe_ent->irq_flags = IRQF_SHARED; probe_ent->irq_flags = IRQF_SHARED;
probe_ent->mmio_base = mmio_base; probe_ent->iomap = pcim_iomap_table(pdev);
base = probe_ent->iomap[PDC_MMIO_BAR];
pdc_ata_setup_port(&probe_ent->port[0], base + 0x200); pdc_ata_setup_port(&probe_ent->port[0], base + 0x200);
pdc_ata_setup_port(&probe_ent->port[1], base + 0x280); pdc_ata_setup_port(&probe_ent->port[1], base + 0x280);
...@@ -964,7 +963,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -964,7 +963,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
/* Fall through */ /* Fall through */
case board_2037x: case board_2037x:
/* TX2plus boards also have a PATA port */ /* TX2plus boards also have a PATA port */
tmp = readb(mmio_base + PDC_FLASH_CTL+1); tmp = readb(base + PDC_FLASH_CTL+1);
if (!(tmp & 0x80)) { if (!(tmp & 0x80)) {
probe_ent->n_ports = 3; probe_ent->n_ports = 3;
pdc_ata_setup_port(&probe_ent->port[2], base + 0x300); pdc_ata_setup_port(&probe_ent->port[2], base + 0x300);
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#define DRV_VERSION "0.06" #define DRV_VERSION "0.06"
enum { enum {
QS_MMIO_BAR = 4,
QS_PORTS = 4, QS_PORTS = 4,
QS_MAX_PRD = LIBATA_MAX_PRD, QS_MAX_PRD = LIBATA_MAX_PRD,
QS_CPB_ORDER = 6, QS_CPB_ORDER = 6,
...@@ -155,7 +157,7 @@ static const struct ata_port_operations qs_ata_ops = { ...@@ -155,7 +157,7 @@ static const struct ata_port_operations qs_ata_ops = {
.phy_reset = qs_phy_reset, .phy_reset = qs_phy_reset,
.qc_prep = qs_qc_prep, .qc_prep = qs_qc_prep,
.qc_issue = qs_qc_issue, .qc_issue = qs_qc_issue,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.eng_timeout = qs_eng_timeout, .eng_timeout = qs_eng_timeout,
.irq_handler = qs_intr, .irq_handler = qs_intr,
.irq_clear = qs_irq_clear, .irq_clear = qs_irq_clear,
...@@ -194,6 +196,11 @@ static struct pci_driver qs_ata_pci_driver = { ...@@ -194,6 +196,11 @@ static struct pci_driver qs_ata_pci_driver = {
.remove = ata_pci_remove_one, .remove = ata_pci_remove_one,
}; };
static void __iomem *qs_mmio_base(struct ata_host *host)
{
return host->iomap[QS_MMIO_BAR];
}
static int qs_check_atapi_dma(struct ata_queued_cmd *qc) static int qs_check_atapi_dma(struct ata_queued_cmd *qc)
{ {
return 1; /* ATAPI DMA not supported */ return 1; /* ATAPI DMA not supported */
...@@ -216,7 +223,7 @@ static void qs_irq_clear(struct ata_port *ap) ...@@ -216,7 +223,7 @@ static void qs_irq_clear(struct ata_port *ap)
static inline void qs_enter_reg_mode(struct ata_port *ap) static inline void qs_enter_reg_mode(struct ata_port *ap)
{ {
u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000); u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
writeb(QS_CTR0_REG, chan + QS_CCT_CTR0); writeb(QS_CTR0_REG, chan + QS_CCT_CTR0);
readb(chan + QS_CCT_CTR0); /* flush */ readb(chan + QS_CCT_CTR0); /* flush */
...@@ -224,7 +231,7 @@ static inline void qs_enter_reg_mode(struct ata_port *ap) ...@@ -224,7 +231,7 @@ static inline void qs_enter_reg_mode(struct ata_port *ap)
static inline void qs_reset_channel_logic(struct ata_port *ap) static inline void qs_reset_channel_logic(struct ata_port *ap)
{ {
u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000); u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
writeb(QS_CTR1_RCHN, chan + QS_CCT_CTR1); writeb(QS_CTR1_RCHN, chan + QS_CCT_CTR1);
readb(chan + QS_CCT_CTR0); /* flush */ readb(chan + QS_CCT_CTR0); /* flush */
...@@ -254,14 +261,14 @@ static u32 qs_scr_read (struct ata_port *ap, unsigned int sc_reg) ...@@ -254,14 +261,14 @@ static u32 qs_scr_read (struct ata_port *ap, unsigned int sc_reg)
{ {
if (sc_reg > SCR_CONTROL) if (sc_reg > SCR_CONTROL)
return ~0U; return ~0U;
return readl((void __iomem *)(ap->ioaddr.scr_addr + (sc_reg * 8))); return readl(ap->ioaddr.scr_addr + (sc_reg * 8));
} }
static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
{ {
if (sc_reg > SCR_CONTROL) if (sc_reg > SCR_CONTROL)
return; return;
writel(val, (void __iomem *)(ap->ioaddr.scr_addr + (sc_reg * 8))); writel(val, ap->ioaddr.scr_addr + (sc_reg * 8));
} }
static unsigned int qs_fill_sg(struct ata_queued_cmd *qc) static unsigned int qs_fill_sg(struct ata_queued_cmd *qc)
...@@ -338,7 +345,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc) ...@@ -338,7 +345,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
static inline void qs_packet_start(struct ata_queued_cmd *qc) static inline void qs_packet_start(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
u8 __iomem *chan = ap->host->mmio_base + (ap->port_no * 0x4000); u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
VPRINTK("ENTER, ap %p\n", ap); VPRINTK("ENTER, ap %p\n", ap);
...@@ -375,7 +382,7 @@ static inline unsigned int qs_intr_pkt(struct ata_host *host) ...@@ -375,7 +382,7 @@ static inline unsigned int qs_intr_pkt(struct ata_host *host)
{ {
unsigned int handled = 0; unsigned int handled = 0;
u8 sFFE; u8 sFFE;
u8 __iomem *mmio_base = host->mmio_base; u8 __iomem *mmio_base = qs_mmio_base(host);
do { do {
u32 sff0 = readl(mmio_base + QS_HST_SFF); u32 sff0 = readl(mmio_base + QS_HST_SFF);
...@@ -467,7 +474,7 @@ static irqreturn_t qs_intr(int irq, void *dev_instance) ...@@ -467,7 +474,7 @@ static irqreturn_t qs_intr(int irq, void *dev_instance)
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
static void qs_ata_setup_port(struct ata_ioports *port, unsigned long base) static void qs_ata_setup_port(struct ata_ioports *port, void __iomem *base)
{ {
port->cmd_addr = port->cmd_addr =
port->data_addr = base + 0x400; port->data_addr = base + 0x400;
...@@ -489,7 +496,7 @@ static int qs_port_start(struct ata_port *ap) ...@@ -489,7 +496,7 @@ static int qs_port_start(struct ata_port *ap)
{ {
struct device *dev = ap->host->dev; struct device *dev = ap->host->dev;
struct qs_port_priv *pp; struct qs_port_priv *pp;
void __iomem *mmio_base = ap->host->mmio_base; void __iomem *mmio_base = qs_mmio_base(ap->host);
void __iomem *chan = mmio_base + (ap->port_no * 0x4000); void __iomem *chan = mmio_base + (ap->port_no * 0x4000);
u64 addr; u64 addr;
int rc; int rc;
...@@ -516,7 +523,7 @@ static int qs_port_start(struct ata_port *ap) ...@@ -516,7 +523,7 @@ static int qs_port_start(struct ata_port *ap)
static void qs_host_stop(struct ata_host *host) static void qs_host_stop(struct ata_host *host)
{ {
void __iomem *mmio_base = host->mmio_base; void __iomem *mmio_base = qs_mmio_base(host);
writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */ 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,7 +531,7 @@ static void qs_host_stop(struct ata_host *host)
static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe) static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
{ {
void __iomem *mmio_base = pe->mmio_base; void __iomem *mmio_base = pe->iomap[QS_MMIO_BAR];
unsigned int port_no; unsigned int port_no;
writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ 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,8 +606,8 @@ static int qs_ata_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
static int printed_version; static int printed_version;
struct ata_probe_ent *probe_ent = NULL; struct ata_probe_ent *probe_ent;
void __iomem *mmio_base; void __iomem * const *iomap;
unsigned int board_idx = (unsigned int) ent->driver_data; unsigned int board_idx = (unsigned int) ent->driver_data;
int rc, port_no; int rc, port_no;
...@@ -611,18 +618,15 @@ static int qs_ata_init_one(struct pci_dev *pdev, ...@@ -611,18 +618,15 @@ static int qs_ata_init_one(struct pci_dev *pdev,
if (rc) if (rc)
return rc; return rc;
rc = pci_request_regions(pdev, DRV_NAME); if ((pci_resource_flags(pdev, QS_MMIO_BAR) & IORESOURCE_MEM) == 0)
if (rc)
return rc;
if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0)
return -ENODEV; return -ENODEV;
mmio_base = pcim_iomap(pdev, 4, 0); rc = pcim_iomap_regions(pdev, 1 << QS_MMIO_BAR, DRV_NAME);
if (mmio_base == NULL) if (rc)
return -ENOMEM; return rc;
iomap = pcim_iomap_table(pdev);
rc = qs_set_dma_masks(pdev, mmio_base); rc = qs_set_dma_masks(pdev, iomap[QS_MMIO_BAR]);
if (rc) if (rc)
return rc; return rc;
...@@ -642,12 +646,12 @@ static int qs_ata_init_one(struct pci_dev *pdev, ...@@ -642,12 +646,12 @@ static int qs_ata_init_one(struct pci_dev *pdev,
probe_ent->irq = pdev->irq; probe_ent->irq = pdev->irq;
probe_ent->irq_flags = IRQF_SHARED; probe_ent->irq_flags = IRQF_SHARED;
probe_ent->mmio_base = mmio_base; probe_ent->iomap = iomap;
probe_ent->n_ports = QS_PORTS; probe_ent->n_ports = QS_PORTS;
for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) { for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) {
unsigned long chan = (unsigned long)mmio_base + void __iomem *chan =
(port_no * 0x4000); probe_ent->iomap[QS_MMIO_BAR] + (port_no * 0x4000);
qs_ata_setup_port(&probe_ent->port[port_no], chan); qs_ata_setup_port(&probe_ent->port[port_no], chan);
} }
......
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
#define DRV_VERSION "2.0" #define DRV_VERSION "2.0"
enum { enum {
SIL_MMIO_BAR = 5,
/* /*
* host flags * host flags
*/ */
...@@ -200,7 +202,7 @@ static const struct ata_port_operations sil_ops = { ...@@ -200,7 +202,7 @@ static const struct ata_port_operations sil_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = sil_freeze, .freeze = sil_freeze,
.thaw = sil_thaw, .thaw = sil_thaw,
.error_handler = ata_bmdma_error_handler, .error_handler = ata_bmdma_error_handler,
...@@ -295,7 +297,8 @@ static void sil_post_set_mode (struct ata_port *ap) ...@@ -295,7 +297,8 @@ static void sil_post_set_mode (struct ata_port *ap)
{ {
struct ata_host *host = ap->host; struct ata_host *host = ap->host;
struct ata_device *dev; struct ata_device *dev;
void __iomem *addr = host->mmio_base + sil_port[ap->port_no].xfer_mode; void __iomem *mmio_base = host->iomap[SIL_MMIO_BAR];
void __iomem *addr = mmio_base + sil_port[ap->port_no].xfer_mode;
u32 tmp, dev_mode[2]; u32 tmp, dev_mode[2];
unsigned int i; unsigned int i;
...@@ -318,9 +321,9 @@ static void sil_post_set_mode (struct ata_port *ap) ...@@ -318,9 +321,9 @@ static void sil_post_set_mode (struct ata_port *ap)
readl(addr); /* flush */ readl(addr); /* flush */
} }
static inline unsigned long sil_scr_addr(struct ata_port *ap, unsigned int sc_reg) static inline void __iomem *sil_scr_addr(struct ata_port *ap, unsigned int sc_reg)
{ {
unsigned long offset = ap->ioaddr.scr_addr; void __iomem *offset = ap->ioaddr.scr_addr;
switch (sc_reg) { switch (sc_reg) {
case SCR_STATUS: case SCR_STATUS:
...@@ -339,7 +342,7 @@ static inline unsigned long sil_scr_addr(struct ata_port *ap, unsigned int sc_re ...@@ -339,7 +342,7 @@ static inline unsigned long sil_scr_addr(struct ata_port *ap, unsigned int sc_re
static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg) static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
{ {
void __iomem *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg); void __iomem *mmio = sil_scr_addr(ap, sc_reg);
if (mmio) if (mmio)
return readl(mmio); return readl(mmio);
return 0xffffffffU; return 0xffffffffU;
...@@ -347,7 +350,7 @@ static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg) ...@@ -347,7 +350,7 @@ static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
{ {
void __iomem *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg); void __iomem *mmio = sil_scr_addr(ap, sc_reg);
if (mmio) if (mmio)
writel(val, mmio); writel(val, mmio);
} }
...@@ -442,7 +445,7 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2) ...@@ -442,7 +445,7 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
static irqreturn_t sil_interrupt(int irq, void *dev_instance) static irqreturn_t sil_interrupt(int irq, void *dev_instance)
{ {
struct ata_host *host = dev_instance; struct ata_host *host = dev_instance;
void __iomem *mmio_base = host->mmio_base; void __iomem *mmio_base = host->iomap[SIL_MMIO_BAR];
int handled = 0; int handled = 0;
int i; int i;
...@@ -474,7 +477,7 @@ static irqreturn_t sil_interrupt(int irq, void *dev_instance) ...@@ -474,7 +477,7 @@ static irqreturn_t sil_interrupt(int irq, void *dev_instance)
static void sil_freeze(struct ata_port *ap) static void sil_freeze(struct ata_port *ap)
{ {
void __iomem *mmio_base = ap->host->mmio_base; void __iomem *mmio_base = ap->host->iomap[SIL_MMIO_BAR];
u32 tmp; u32 tmp;
/* global IRQ mask doesn't block SATA IRQ, turn off explicitly */ /* global IRQ mask doesn't block SATA IRQ, turn off explicitly */
...@@ -489,7 +492,7 @@ static void sil_freeze(struct ata_port *ap) ...@@ -489,7 +492,7 @@ static void sil_freeze(struct ata_port *ap)
static void sil_thaw(struct ata_port *ap) static void sil_thaw(struct ata_port *ap)
{ {
void __iomem *mmio_base = ap->host->mmio_base; void __iomem *mmio_base = ap->host->iomap[SIL_MMIO_BAR];
u32 tmp; u32 tmp;
/* clear IRQ */ /* clear IRQ */
...@@ -621,7 +624,6 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -621,7 +624,6 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
static int printed_version; static int printed_version;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
unsigned long base;
void __iomem *mmio_base; void __iomem *mmio_base;
int rc; int rc;
unsigned int i; unsigned int i;
...@@ -633,11 +635,11 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -633,11 +635,11 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
if (rc) if (rc)
return rc; return rc;
rc = pci_request_regions(pdev, DRV_NAME); rc = pcim_iomap_regions(pdev, 1 << SIL_MMIO_BAR, DRV_NAME);
if (rc) { if (rc == -EBUSY)
pcim_pin_device(pdev); pcim_pin_device(pdev);
if (rc)
return rc; return rc;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc) if (rc)
...@@ -662,20 +664,16 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -662,20 +664,16 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
probe_ent->irq_flags = IRQF_SHARED; probe_ent->irq_flags = IRQF_SHARED;
probe_ent->port_flags = sil_port_info[ent->driver_data].flags; probe_ent->port_flags = sil_port_info[ent->driver_data].flags;
mmio_base = pcim_iomap(pdev, 5, 0); probe_ent->iomap = pcim_iomap_table(pdev);
if (mmio_base == NULL)
return -ENOMEM;
probe_ent->mmio_base = mmio_base;
base = (unsigned long) mmio_base; mmio_base = probe_ent->iomap[SIL_MMIO_BAR];
for (i = 0; i < probe_ent->n_ports; i++) { for (i = 0; i < probe_ent->n_ports; i++) {
probe_ent->port[i].cmd_addr = base + sil_port[i].tf; probe_ent->port[i].cmd_addr = mmio_base + sil_port[i].tf;
probe_ent->port[i].altstatus_addr = probe_ent->port[i].altstatus_addr =
probe_ent->port[i].ctl_addr = base + sil_port[i].ctl; probe_ent->port[i].ctl_addr = mmio_base + sil_port[i].ctl;
probe_ent->port[i].bmdma_addr = base + sil_port[i].bmdma; probe_ent->port[i].bmdma_addr = mmio_base + sil_port[i].bmdma;
probe_ent->port[i].scr_addr = base + sil_port[i].scr; probe_ent->port[i].scr_addr = mmio_base + sil_port[i].scr;
ata_std_ports(&probe_ent->port[i]); ata_std_ports(&probe_ent->port[i]);
} }
...@@ -702,7 +700,7 @@ static int sil_pci_device_resume(struct pci_dev *pdev) ...@@ -702,7 +700,7 @@ static int sil_pci_device_resume(struct pci_dev *pdev)
return rc; return rc;
sil_init_controller(pdev, host->n_ports, host->ports[0]->flags, sil_init_controller(pdev, host->n_ports, host->ports[0]->flags,
host->mmio_base); host->iomap[SIL_MMIO_BAR]);
ata_host_resume(host); ata_host_resume(host);
return 0; return 0;
......
...@@ -60,6 +60,9 @@ struct sil24_port_multiplier { ...@@ -60,6 +60,9 @@ struct sil24_port_multiplier {
}; };
enum { enum {
SIL24_HOST_BAR = 0,
SIL24_PORT_BAR = 2,
/* /*
* Global controller registers (128 bytes @ BAR0) * Global controller registers (128 bytes @ BAR0)
*/ */
...@@ -320,12 +323,6 @@ struct sil24_port_priv { ...@@ -320,12 +323,6 @@ struct sil24_port_priv {
struct ata_taskfile tf; /* Cached taskfile registers */ struct ata_taskfile tf; /* Cached taskfile registers */
}; };
/* ap->host->private_data */
struct sil24_host_priv {
void __iomem *host_base; /* global controller control (128 bytes @BAR0) */
void __iomem *port_base; /* port registers (4 * 8192 bytes @BAR2) */
};
static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev); static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev);
static u8 sil24_check_status(struct ata_port *ap); static u8 sil24_check_status(struct ata_port *ap);
static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg);
...@@ -462,7 +459,7 @@ static int sil24_tag(int tag) ...@@ -462,7 +459,7 @@ static int sil24_tag(int tag)
static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev) static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev)
{ {
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
if (dev->cdb_len == 16) if (dev->cdb_len == 16)
writel(PORT_CS_CDB16, port + PORT_CTRL_STAT); writel(PORT_CS_CDB16, port + PORT_CTRL_STAT);
...@@ -473,7 +470,7 @@ static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev) ...@@ -473,7 +470,7 @@ static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev)
static inline void sil24_update_tf(struct ata_port *ap) static inline void sil24_update_tf(struct ata_port *ap)
{ {
struct sil24_port_priv *pp = ap->private_data; struct sil24_port_priv *pp = ap->private_data;
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
struct sil24_prb __iomem *prb = port; struct sil24_prb __iomem *prb = port;
u8 fis[6 * 4]; u8 fis[6 * 4];
...@@ -496,7 +493,7 @@ static int sil24_scr_map[] = { ...@@ -496,7 +493,7 @@ static int sil24_scr_map[] = {
static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg) static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg)
{ {
void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr; void __iomem *scr_addr = ap->ioaddr.scr_addr;
if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
void __iomem *addr; void __iomem *addr;
addr = scr_addr + sil24_scr_map[sc_reg] * 4; addr = scr_addr + sil24_scr_map[sc_reg] * 4;
...@@ -507,7 +504,7 @@ static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg) ...@@ -507,7 +504,7 @@ static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg)
static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
{ {
void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr; void __iomem *scr_addr = ap->ioaddr.scr_addr;
if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
void __iomem *addr; void __iomem *addr;
addr = scr_addr + sil24_scr_map[sc_reg] * 4; addr = scr_addr + sil24_scr_map[sc_reg] * 4;
...@@ -523,7 +520,7 @@ static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf) ...@@ -523,7 +520,7 @@ static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
static int sil24_init_port(struct ata_port *ap) static int sil24_init_port(struct ata_port *ap)
{ {
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
u32 tmp; u32 tmp;
writel(PORT_CS_INIT, port + PORT_CTRL_STAT); writel(PORT_CS_INIT, port + PORT_CTRL_STAT);
...@@ -539,7 +536,7 @@ static int sil24_init_port(struct ata_port *ap) ...@@ -539,7 +536,7 @@ static int sil24_init_port(struct ata_port *ap)
static int sil24_softreset(struct ata_port *ap, unsigned int *class) static int sil24_softreset(struct ata_port *ap, unsigned int *class)
{ {
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
struct sil24_port_priv *pp = ap->private_data; struct sil24_port_priv *pp = ap->private_data;
struct sil24_prb *prb = &pp->cmd_block[0].ata.prb; struct sil24_prb *prb = &pp->cmd_block[0].ata.prb;
dma_addr_t paddr = pp->cmd_block_dma; dma_addr_t paddr = pp->cmd_block_dma;
...@@ -599,7 +596,7 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class) ...@@ -599,7 +596,7 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class)
static int sil24_hardreset(struct ata_port *ap, unsigned int *class) static int sil24_hardreset(struct ata_port *ap, unsigned int *class)
{ {
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
const char *reason; const char *reason;
int tout_msec, rc; int tout_msec, rc;
u32 tmp; u32 tmp;
...@@ -716,7 +713,7 @@ static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc) ...@@ -716,7 +713,7 @@ static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct sil24_port_priv *pp = ap->private_data; struct sil24_port_priv *pp = ap->private_data;
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
unsigned int tag = sil24_tag(qc->tag); unsigned int tag = sil24_tag(qc->tag);
dma_addr_t paddr; dma_addr_t paddr;
void __iomem *activate; void __iomem *activate;
...@@ -737,7 +734,7 @@ static void sil24_irq_clear(struct ata_port *ap) ...@@ -737,7 +734,7 @@ static void sil24_irq_clear(struct ata_port *ap)
static void sil24_freeze(struct ata_port *ap) static void sil24_freeze(struct ata_port *ap)
{ {
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
/* Port-wide IRQ mask in HOST_CTRL doesn't really work, clear /* Port-wide IRQ mask in HOST_CTRL doesn't really work, clear
* PORT_IRQ_ENABLE instead. * PORT_IRQ_ENABLE instead.
...@@ -747,7 +744,7 @@ static void sil24_freeze(struct ata_port *ap) ...@@ -747,7 +744,7 @@ static void sil24_freeze(struct ata_port *ap)
static void sil24_thaw(struct ata_port *ap) static void sil24_thaw(struct ata_port *ap)
{ {
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
u32 tmp; u32 tmp;
/* clear IRQ */ /* clear IRQ */
...@@ -760,7 +757,7 @@ static void sil24_thaw(struct ata_port *ap) ...@@ -760,7 +757,7 @@ static void sil24_thaw(struct ata_port *ap)
static void sil24_error_intr(struct ata_port *ap) static void sil24_error_intr(struct ata_port *ap)
{ {
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
struct ata_eh_info *ehi = &ap->eh_info; struct ata_eh_info *ehi = &ap->eh_info;
int freeze = 0; int freeze = 0;
u32 irq_stat; u32 irq_stat;
...@@ -838,7 +835,7 @@ static void sil24_finish_qc(struct ata_queued_cmd *qc) ...@@ -838,7 +835,7 @@ static void sil24_finish_qc(struct ata_queued_cmd *qc)
static inline void sil24_host_intr(struct ata_port *ap) static inline void sil24_host_intr(struct ata_port *ap)
{ {
void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
u32 slot_stat, qc_active; u32 slot_stat, qc_active;
int rc; int rc;
...@@ -873,12 +870,12 @@ static inline void sil24_host_intr(struct ata_port *ap) ...@@ -873,12 +870,12 @@ static inline void sil24_host_intr(struct ata_port *ap)
static irqreturn_t sil24_interrupt(int irq, void *dev_instance) static irqreturn_t sil24_interrupt(int irq, void *dev_instance)
{ {
struct ata_host *host = dev_instance; struct ata_host *host = dev_instance;
struct sil24_host_priv *hpriv = host->private_data; void __iomem *host_base = host->iomap[SIL24_HOST_BAR];
unsigned handled = 0; unsigned handled = 0;
u32 status; u32 status;
int i; int i;
status = readl(hpriv->host_base + HOST_IRQ_STAT); status = readl(host_base + HOST_IRQ_STAT);
if (status == 0xffffffff) { if (status == 0xffffffff) {
printk(KERN_ERR DRV_NAME ": IRQ status == 0xffffffff, " printk(KERN_ERR DRV_NAME ": IRQ status == 0xffffffff, "
...@@ -1031,7 +1028,6 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1031,7 +1028,6 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
unsigned int board_id = (unsigned int)ent->driver_data; unsigned int board_id = (unsigned int)ent->driver_data;
struct ata_port_info *pinfo = &sil24_port_info[board_id]; struct ata_port_info *pinfo = &sil24_port_info[board_id];
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
struct sil24_host_priv *hpriv;
void __iomem *host_base; void __iomem *host_base;
void __iomem *port_base; void __iomem *port_base;
int i, rc; int i, rc;
...@@ -1044,20 +1040,15 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1044,20 +1040,15 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (rc) if (rc)
return rc; return rc;
rc = pci_request_regions(pdev, DRV_NAME); rc = pcim_iomap_regions(pdev,
(1 << SIL24_HOST_BAR) | (1 << SIL24_PORT_BAR),
DRV_NAME);
if (rc) if (rc)
return rc; return rc;
/* map mmio registers */ /* allocate & init probe_ent */
host_base = pcim_iomap(pdev, 0, 0);
port_base = pcim_iomap(pdev, 2, 0);
if (!host_base || !port_base)
return -ENOMEM;
/* allocate & init probe_ent and hpriv */
probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); if (!probe_ent)
if (!probe_ent || !hpriv)
return -ENOMEM; return -ENOMEM;
probe_ent->dev = pci_dev_to_dev(pdev); probe_ent->dev = pci_dev_to_dev(pdev);
...@@ -1073,10 +1064,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1073,10 +1064,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
probe_ent->irq = pdev->irq; probe_ent->irq = pdev->irq;
probe_ent->irq_flags = IRQF_SHARED; probe_ent->irq_flags = IRQF_SHARED;
probe_ent->private_data = hpriv; probe_ent->iomap = pcim_iomap_table(pdev);
hpriv->host_base = host_base; host_base = probe_ent->iomap[SIL24_HOST_BAR];
hpriv->port_base = port_base; port_base = probe_ent->iomap[SIL24_PORT_BAR];
/* /*
* Configure the device * Configure the device
...@@ -1118,11 +1109,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1118,11 +1109,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
for (i = 0; i < probe_ent->n_ports; i++) { for (i = 0; i < probe_ent->n_ports; i++) {
unsigned long portu = void __iomem *port = port_base + i * PORT_REGS_SIZE;
(unsigned long)port_base + i * PORT_REGS_SIZE;
probe_ent->port[i].cmd_addr = portu; probe_ent->port[i].cmd_addr = port;
probe_ent->port[i].scr_addr = portu + PORT_SCONTROL; probe_ent->port[i].scr_addr = port + PORT_SCONTROL;
ata_std_ports(&probe_ent->port[i]); ata_std_ports(&probe_ent->port[i]);
} }
...@@ -1143,7 +1133,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1143,7 +1133,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
static int sil24_pci_device_resume(struct pci_dev *pdev) static int sil24_pci_device_resume(struct pci_dev *pdev)
{ {
struct ata_host *host = dev_get_drvdata(&pdev->dev); struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct sil24_host_priv *hpriv = host->private_data; void __iomem *host_base = host->iomap[SIL24_HOST_BAR];
void __iomem *port_base = host->iomap[SIL24_PORT_BAR];
int rc; int rc;
rc = ata_pci_device_do_resume(pdev); rc = ata_pci_device_do_resume(pdev);
...@@ -1151,10 +1142,10 @@ static int sil24_pci_device_resume(struct pci_dev *pdev) ...@@ -1151,10 +1142,10 @@ static int sil24_pci_device_resume(struct pci_dev *pdev)
return rc; return rc;
if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND)
writel(HOST_CTRL_GLOBAL_RST, hpriv->host_base + HOST_CTRL); writel(HOST_CTRL_GLOBAL_RST, host_base + HOST_CTRL);
sil24_init_controller(pdev, host->n_ports, host->ports[0]->flags, sil24_init_controller(pdev, host->n_ports, host->ports[0]->flags,
hpriv->host_base, hpriv->port_base); host_base, port_base);
ata_host_resume(host); ata_host_resume(host);
......
...@@ -117,7 +117,7 @@ static const struct ata_port_operations sis_ops = { ...@@ -117,7 +117,7 @@ static const struct ata_port_operations sis_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_pio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = ata_bmdma_error_handler, .error_handler = ata_bmdma_error_handler,
...@@ -223,11 +223,11 @@ static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg) ...@@ -223,11 +223,11 @@ static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg)
pci_read_config_byte(pdev, SIS_PMR, &pmr); pci_read_config_byte(pdev, SIS_PMR, &pmr);
val = inl(ap->ioaddr.scr_addr + (sc_reg * 4)); val = ioread32(ap->ioaddr.scr_addr + (sc_reg * 4));
if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || (pdev->device == 0x1182) || if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || (pdev->device == 0x1182) ||
(pdev->device == 0x1183) || (pmr & SIS_PMR_COMBINED)) (pdev->device == 0x1183) || (pmr & SIS_PMR_COMBINED))
val2 = inl(ap->ioaddr.scr_addr + (sc_reg * 4) + 0x10); val2 = ioread32(ap->ioaddr.scr_addr + (sc_reg * 4) + 0x10);
return (val | val2) & 0xfffffffb; return (val | val2) & 0xfffffffb;
} }
...@@ -245,10 +245,10 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) ...@@ -245,10 +245,10 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
if (ap->flags & SIS_FLAG_CFGSCR) if (ap->flags & SIS_FLAG_CFGSCR)
sis_scr_cfg_write(ap, sc_reg, val); sis_scr_cfg_write(ap, sc_reg, val);
else { else {
outl(val, ap->ioaddr.scr_addr + (sc_reg * 4)); iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4));
if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || (pdev->device == 0x1182) || if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || (pdev->device == 0x1182) ||
(pdev->device == 0x1183) || (pmr & SIS_PMR_COMBINED)) (pdev->device == 0x1183) || (pmr & SIS_PMR_COMBINED))
outl(val, ap->ioaddr.scr_addr + (sc_reg * 4)+0x10); iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)+0x10);
} }
} }
...@@ -353,10 +353,14 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -353,10 +353,14 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
return -ENOMEM; return -ENOMEM;
if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) { if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) {
probe_ent->port[0].scr_addr = void *mmio;
pci_resource_start(pdev, SIS_SCR_PCI_BAR);
probe_ent->port[1].scr_addr = mmio = pcim_iomap(pdev, SIS_SCR_PCI_BAR, 0);
pci_resource_start(pdev, SIS_SCR_PCI_BAR) + port2_start; if (!mmio)
return -ENOMEM;
probe_ent->port[0].scr_addr = mmio;
probe_ent->port[1].scr_addr = mmio + port2_start;
} }
pci_set_master(pdev); pci_set_master(pdev);
......
...@@ -135,31 +135,31 @@ static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) ...@@ -135,31 +135,31 @@ static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
if (tf->ctl != ap->last_ctl) { if (tf->ctl != ap->last_ctl) {
writeb(tf->ctl, (void __iomem *) ioaddr->ctl_addr); writeb(tf->ctl, ioaddr->ctl_addr);
ap->last_ctl = tf->ctl; ap->last_ctl = tf->ctl;
ata_wait_idle(ap); ata_wait_idle(ap);
} }
if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
writew(tf->feature | (((u16)tf->hob_feature) << 8), writew(tf->feature | (((u16)tf->hob_feature) << 8),
(void __iomem *) ioaddr->feature_addr); ioaddr->feature_addr);
writew(tf->nsect | (((u16)tf->hob_nsect) << 8), writew(tf->nsect | (((u16)tf->hob_nsect) << 8),
(void __iomem *) ioaddr->nsect_addr); ioaddr->nsect_addr);
writew(tf->lbal | (((u16)tf->hob_lbal) << 8), writew(tf->lbal | (((u16)tf->hob_lbal) << 8),
(void __iomem *) ioaddr->lbal_addr); ioaddr->lbal_addr);
writew(tf->lbam | (((u16)tf->hob_lbam) << 8), writew(tf->lbam | (((u16)tf->hob_lbam) << 8),
(void __iomem *) ioaddr->lbam_addr); ioaddr->lbam_addr);
writew(tf->lbah | (((u16)tf->hob_lbah) << 8), writew(tf->lbah | (((u16)tf->hob_lbah) << 8),
(void __iomem *) ioaddr->lbah_addr); ioaddr->lbah_addr);
} else if (is_addr) { } else if (is_addr) {
writew(tf->feature, (void __iomem *) ioaddr->feature_addr); writew(tf->feature, ioaddr->feature_addr);
writew(tf->nsect, (void __iomem *) ioaddr->nsect_addr); writew(tf->nsect, ioaddr->nsect_addr);
writew(tf->lbal, (void __iomem *) ioaddr->lbal_addr); writew(tf->lbal, ioaddr->lbal_addr);
writew(tf->lbam, (void __iomem *) ioaddr->lbam_addr); writew(tf->lbam, ioaddr->lbam_addr);
writew(tf->lbah, (void __iomem *) ioaddr->lbah_addr); writew(tf->lbah, ioaddr->lbah_addr);
} }
if (tf->flags & ATA_TFLAG_DEVICE) if (tf->flags & ATA_TFLAG_DEVICE)
writeb(tf->device, (void __iomem *) ioaddr->device_addr); writeb(tf->device, ioaddr->device_addr);
ata_wait_idle(ap); ata_wait_idle(ap);
} }
...@@ -171,12 +171,12 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) ...@@ -171,12 +171,12 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
u16 nsect, lbal, lbam, lbah, feature; u16 nsect, lbal, lbam, lbah, feature;
tf->command = k2_stat_check_status(ap); tf->command = k2_stat_check_status(ap);
tf->device = readw((void __iomem *)ioaddr->device_addr); tf->device = readw(ioaddr->device_addr);
feature = readw((void __iomem *)ioaddr->error_addr); feature = readw(ioaddr->error_addr);
nsect = readw((void __iomem *)ioaddr->nsect_addr); nsect = readw(ioaddr->nsect_addr);
lbal = readw((void __iomem *)ioaddr->lbal_addr); lbal = readw(ioaddr->lbal_addr);
lbam = readw((void __iomem *)ioaddr->lbam_addr); lbam = readw(ioaddr->lbam_addr);
lbah = readw((void __iomem *)ioaddr->lbah_addr); lbah = readw(ioaddr->lbah_addr);
tf->feature = feature; tf->feature = feature;
tf->nsect = nsect; tf->nsect = nsect;
...@@ -349,7 +349,7 @@ static const struct ata_port_operations k2_sata_ops = { ...@@ -349,7 +349,7 @@ static const struct ata_port_operations k2_sata_ops = {
.bmdma_status = ata_bmdma_status, .bmdma_status = ata_bmdma_status,
.qc_prep = ata_qc_prep, .qc_prep = ata_qc_prep,
.qc_issue = ata_qc_issue_prot, .qc_issue = ata_qc_issue_prot,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.freeze = ata_bmdma_freeze, .freeze = ata_bmdma_freeze,
.thaw = ata_bmdma_thaw, .thaw = ata_bmdma_thaw,
.error_handler = ata_bmdma_error_handler, .error_handler = ata_bmdma_error_handler,
...@@ -361,7 +361,7 @@ static const struct ata_port_operations k2_sata_ops = { ...@@ -361,7 +361,7 @@ static const struct ata_port_operations k2_sata_ops = {
.port_start = ata_port_start, .port_start = ata_port_start,
}; };
static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base) static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base)
{ {
port->cmd_addr = base + K2_SATA_TF_CMD_OFFSET; port->cmd_addr = base + K2_SATA_TF_CMD_OFFSET;
port->data_addr = base + K2_SATA_TF_DATA_OFFSET; port->data_addr = base + K2_SATA_TF_DATA_OFFSET;
...@@ -386,7 +386,6 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -386,7 +386,6 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
static int printed_version; static int printed_version;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
unsigned long base;
void __iomem *mmio_base; void __iomem *mmio_base;
const struct k2_board_info *board_info = const struct k2_board_info *board_info =
&k2_board_info[ent->driver_data]; &k2_board_info[ent->driver_data];
...@@ -410,12 +409,12 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -410,12 +409,12 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
if (pci_resource_len(pdev, 5) == 0) if (pci_resource_len(pdev, 5) == 0)
return -ENODEV; return -ENODEV;
/* Request PCI regions */ /* Request and iomap PCI regions */
rc = pci_request_regions(pdev, DRV_NAME); rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME);
if (rc) { if (rc == -EBUSY)
pcim_pin_device(pdev); pcim_pin_device(pdev);
if (rc)
return rc; return rc;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc) if (rc)
...@@ -431,22 +430,6 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -431,22 +430,6 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
probe_ent->dev = pci_dev_to_dev(pdev); probe_ent->dev = pci_dev_to_dev(pdev);
INIT_LIST_HEAD(&probe_ent->node); INIT_LIST_HEAD(&probe_ent->node);
mmio_base = pcim_iomap(pdev, 5, 0);
if (mmio_base == NULL)
return -ENOMEM;
base = (unsigned long) mmio_base;
/* Clear a magic bit in SCR1 according to Darwin, those help
* some funky seagate drives (though so far, those were already
* set by the firmware on the machines I had access to)
*/
writel(readl(mmio_base + K2_SATA_SICR1_OFFSET) & ~0x00040000,
mmio_base + K2_SATA_SICR1_OFFSET);
/* Clear SATA error & interrupts we don't use */
writel(0xffffffff, mmio_base + K2_SATA_SCR_ERROR_OFFSET);
writel(0x0, mmio_base + K2_SATA_SIM_OFFSET);
probe_ent->sht = &k2_sata_sht; probe_ent->sht = &k2_sata_sht;
probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
ATA_FLAG_MMIO | board_info->port_flags; ATA_FLAG_MMIO | board_info->port_flags;
...@@ -454,7 +437,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -454,7 +437,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
probe_ent->n_ports = 4; probe_ent->n_ports = 4;
probe_ent->irq = pdev->irq; probe_ent->irq = pdev->irq;
probe_ent->irq_flags = IRQF_SHARED; probe_ent->irq_flags = IRQF_SHARED;
probe_ent->mmio_base = mmio_base; probe_ent->iomap = pcim_iomap_table(pdev);
/* We don't care much about the PIO/UDMA masks, but the core won't like us /* We don't care much about the PIO/UDMA masks, but the core won't like us
* if we don't fill these * if we don't fill these
...@@ -463,11 +446,25 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e ...@@ -463,11 +446,25 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
probe_ent->mwdma_mask = 0x7; probe_ent->mwdma_mask = 0x7;
probe_ent->udma_mask = 0x7f; probe_ent->udma_mask = 0x7f;
mmio_base = probe_ent->iomap[5];
/* different controllers have different number of ports - currently 4 or 8 */ /* different controllers have different number of ports - currently 4 or 8 */
/* All ports are on the same function. Multi-function device is no /* All ports are on the same function. Multi-function device is no
* longer available. This should not be seen in any system. */ * longer available. This should not be seen in any system. */
for (i = 0; i < board_info->n_ports; i++) for (i = 0; i < board_info->n_ports; i++)
k2_sata_setup_port(&probe_ent->port[i], base + i * K2_SATA_PORT_OFFSET); k2_sata_setup_port(&probe_ent->port[i],
mmio_base + i * K2_SATA_PORT_OFFSET);
/* Clear a magic bit in SCR1 according to Darwin, those help
* some funky seagate drives (though so far, those were already
* set by the firmware on the machines I had access to)
*/
writel(readl(mmio_base + K2_SATA_SICR1_OFFSET) & ~0x00040000,
mmio_base + K2_SATA_SICR1_OFFSET);
/* Clear SATA error & interrupts we don't use */
writel(0xffffffff, mmio_base + K2_SATA_SCR_ERROR_OFFSET);
writel(0x0, mmio_base + K2_SATA_SIM_OFFSET);
pci_set_master(pdev); pci_set_master(pdev);
......
...@@ -49,6 +49,9 @@ ...@@ -49,6 +49,9 @@
enum { enum {
PDC_MMIO_BAR = 3,
PDC_DIMM_BAR = 4,
PDC_PRD_TBL = 0x44, /* Direct command DMA table addr */ PDC_PRD_TBL = 0x44, /* Direct command DMA table addr */
PDC_PKT_SUBMIT = 0x40, /* Command packet pointer addr */ PDC_PKT_SUBMIT = 0x40, /* Command packet pointer addr */
...@@ -137,8 +140,6 @@ struct pdc_port_priv { ...@@ -137,8 +140,6 @@ struct pdc_port_priv {
}; };
struct pdc_host_priv { struct pdc_host_priv {
void __iomem *dimm_mmio;
unsigned int doing_hdma; unsigned int doing_hdma;
unsigned int hdma_prod; unsigned int hdma_prod;
unsigned int hdma_cons; unsigned int hdma_cons;
...@@ -202,7 +203,7 @@ static const struct ata_port_operations pdc_20621_ops = { ...@@ -202,7 +203,7 @@ static const struct ata_port_operations pdc_20621_ops = {
.phy_reset = pdc_20621_phy_reset, .phy_reset = pdc_20621_phy_reset,
.qc_prep = pdc20621_qc_prep, .qc_prep = pdc20621_qc_prep,
.qc_issue = pdc20621_qc_issue_prot, .qc_issue = pdc20621_qc_issue_prot,
.data_xfer = ata_mmio_data_xfer, .data_xfer = ata_data_xfer,
.eng_timeout = pdc_eng_timeout, .eng_timeout = pdc_eng_timeout,
.irq_handler = pdc20621_interrupt, .irq_handler = pdc20621_interrupt,
.irq_clear = pdc20621_irq_clear, .irq_clear = pdc20621_irq_clear,
...@@ -411,9 +412,8 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc) ...@@ -411,9 +412,8 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
struct scatterlist *sg; struct scatterlist *sg;
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct pdc_port_priv *pp = ap->private_data; struct pdc_port_priv *pp = ap->private_data;
void __iomem *mmio = ap->host->mmio_base; void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
struct pdc_host_priv *hpriv = ap->host->private_data; void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
void __iomem *dimm_mmio = hpriv->dimm_mmio;
unsigned int portno = ap->port_no; unsigned int portno = ap->port_no;
unsigned int i, idx, total_len = 0, sgt_len; unsigned int i, idx, total_len = 0, sgt_len;
u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ]; 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,9 +472,8 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct pdc_port_priv *pp = ap->private_data; struct pdc_port_priv *pp = ap->private_data;
void __iomem *mmio = ap->host->mmio_base; void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
struct pdc_host_priv *hpriv = ap->host->private_data; void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
void __iomem *dimm_mmio = hpriv->dimm_mmio;
unsigned int portno = ap->port_no; unsigned int portno = ap->port_no;
unsigned int i; unsigned int i;
...@@ -524,7 +523,7 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc, ...@@ -524,7 +523,7 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc,
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct ata_host *host = ap->host; struct ata_host *host = ap->host;
void __iomem *mmio = host->mmio_base; void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
/* hard-code chip #0 */ /* hard-code chip #0 */
mmio += PDC_CHIP0_OFS; mmio += PDC_CHIP0_OFS;
...@@ -578,8 +577,7 @@ static void pdc20621_dump_hdma(struct ata_queued_cmd *qc) ...@@ -578,8 +577,7 @@ static void pdc20621_dump_hdma(struct ata_queued_cmd *qc)
{ {
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
unsigned int port_no = ap->port_no; unsigned int port_no = ap->port_no;
struct pdc_host_priv *hpriv = ap->host->private_data; void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
void *dimm_mmio = hpriv->dimm_mmio;
dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP); dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP);
dimm_mmio += PDC_DIMM_HOST_PKT; dimm_mmio += PDC_DIMM_HOST_PKT;
...@@ -598,7 +596,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc) ...@@ -598,7 +596,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
struct ata_port *ap = qc->ap; struct ata_port *ap = qc->ap;
struct ata_host *host = ap->host; struct ata_host *host = ap->host;
unsigned int port_no = ap->port_no; unsigned int port_no = ap->port_no;
void __iomem *mmio = host->mmio_base; void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
u8 seq = (u8) (port_no + 1); u8 seq = (u8) (port_no + 1);
unsigned int port_ofs; unsigned int port_ofs;
...@@ -627,8 +625,8 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc) ...@@ -627,8 +625,8 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */ readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */
writel(port_ofs + PDC_DIMM_ATA_PKT, writel(port_ofs + PDC_DIMM_ATA_PKT,
(void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
VPRINTK("submitted ofs 0x%x (%u), seq %u\n", VPRINTK("submitted ofs 0x%x (%u), seq %u\n",
port_ofs + PDC_DIMM_ATA_PKT, port_ofs + PDC_DIMM_ATA_PKT,
port_ofs + PDC_DIMM_ATA_PKT, port_ofs + PDC_DIMM_ATA_PKT,
...@@ -706,8 +704,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, ...@@ -706,8 +704,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4)); writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4));
readl(mmio + PDC_20621_SEQCTL + (seq * 4)); readl(mmio + PDC_20621_SEQCTL + (seq * 4));
writel(port_ofs + PDC_DIMM_ATA_PKT, writel(port_ofs + PDC_DIMM_ATA_PKT,
(void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
} }
/* step two - execute ATA command */ /* step two - execute ATA command */
...@@ -740,7 +738,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, ...@@ -740,7 +738,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
static void pdc20621_irq_clear(struct ata_port *ap) static void pdc20621_irq_clear(struct ata_port *ap)
{ {
struct ata_host *host = ap->host; struct ata_host *host = ap->host;
void __iomem *mmio = host->mmio_base; void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
mmio += PDC_CHIP0_OFS; mmio += PDC_CHIP0_OFS;
...@@ -758,12 +756,12 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance) ...@@ -758,12 +756,12 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance)
VPRINTK("ENTER\n"); VPRINTK("ENTER\n");
if (!host || !host->mmio_base) { if (!host || !host->iomap[PDC_MMIO_BAR]) {
VPRINTK("QUICK EXIT\n"); VPRINTK("QUICK EXIT\n");
return IRQ_NONE; return IRQ_NONE;
} }
mmio_base = host->mmio_base; mmio_base = host->iomap[PDC_MMIO_BAR];
/* reading should also clear interrupts */ /* reading should also clear interrupts */
mmio_base += PDC_CHIP0_OFS; mmio_base += PDC_CHIP0_OFS;
...@@ -864,7 +862,7 @@ static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile ...@@ -864,7 +862,7 @@ static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile
} }
static void pdc_sata_setup_port(struct ata_ioports *port, unsigned long base) static void pdc_sata_setup_port(struct ata_ioports *port, void __iomem *base)
{ {
port->cmd_addr = base; port->cmd_addr = base;
port->data_addr = base; port->data_addr = base;
...@@ -890,9 +888,8 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource, ...@@ -890,9 +888,8 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource,
u16 idx; u16 idx;
u8 page_mask; u8 page_mask;
long dist; long dist;
void __iomem *mmio = pe->mmio_base; void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
struct pdc_host_priv *hpriv = pe->private_data; void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR];
void __iomem *dimm_mmio = hpriv->dimm_mmio;
/* hard-code chip #0 */ /* hard-code chip #0 */
mmio += PDC_CHIP0_OFS; mmio += PDC_CHIP0_OFS;
...@@ -946,9 +943,8 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource, ...@@ -946,9 +943,8 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
u16 idx; u16 idx;
u8 page_mask; u8 page_mask;
long dist; long dist;
void __iomem *mmio = pe->mmio_base; void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
struct pdc_host_priv *hpriv = pe->private_data; void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR];
void __iomem *dimm_mmio = hpriv->dimm_mmio;
/* hard-code chip #0 */ /* hard-code chip #0 */
mmio += PDC_CHIP0_OFS; mmio += PDC_CHIP0_OFS;
...@@ -993,7 +989,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource, ...@@ -993,7 +989,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device, static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device,
u32 subaddr, u32 *pdata) u32 subaddr, u32 *pdata)
{ {
void __iomem *mmio = pe->mmio_base; void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
u32 i2creg = 0; u32 i2creg = 0;
u32 status; u32 status;
u32 count =0; u32 count =0;
...@@ -1052,7 +1048,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe) ...@@ -1052,7 +1048,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
u32 data = 0; u32 data = 0;
int size, i; int size, i;
u8 bdimmsize; u8 bdimmsize;
void __iomem *mmio = pe->mmio_base; void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
static const struct { static const struct {
unsigned int reg; unsigned int reg;
unsigned int ofs; unsigned int ofs;
...@@ -1115,7 +1111,7 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe) ...@@ -1115,7 +1111,7 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe)
{ {
u32 data, spd0; u32 data, spd0;
int error, i; int error, i;
void __iomem *mmio = pe->mmio_base; void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
/* hard-code chip #0 */ /* hard-code chip #0 */
mmio += PDC_CHIP0_OFS; mmio += PDC_CHIP0_OFS;
...@@ -1169,7 +1165,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe) ...@@ -1169,7 +1165,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
u32 ticks=0; u32 ticks=0;
u32 clock=0; u32 clock=0;
u32 fparam=0; u32 fparam=0;
void __iomem *mmio = pe->mmio_base; void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
/* hard-code chip #0 */ /* hard-code chip #0 */
mmio += PDC_CHIP0_OFS; mmio += PDC_CHIP0_OFS;
...@@ -1293,7 +1289,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe) ...@@ -1293,7 +1289,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
static void pdc_20621_init(struct ata_probe_ent *pe) static void pdc_20621_init(struct ata_probe_ent *pe)
{ {
u32 tmp; u32 tmp;
void __iomem *mmio = pe->mmio_base; void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
/* hard-code chip #0 */ /* hard-code chip #0 */
mmio += PDC_CHIP0_OFS; mmio += PDC_CHIP0_OFS;
...@@ -1325,9 +1321,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * ...@@ -1325,9 +1321,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
{ {
static int printed_version; static int printed_version;
struct ata_probe_ent *probe_ent; struct ata_probe_ent *probe_ent;
unsigned long base; void __iomem *base;
void __iomem *mmio_base;
void __iomem *dimm_mmio;
struct pdc_host_priv *hpriv; struct pdc_host_priv *hpriv;
unsigned int board_idx = (unsigned int) ent->driver_data; unsigned int board_idx = (unsigned int) ent->driver_data;
int rc; int rc;
...@@ -1339,11 +1333,12 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * ...@@ -1339,11 +1333,12 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
if (rc) if (rc)
return rc; return rc;
rc = pci_request_regions(pdev, DRV_NAME); rc = pcim_iomap_regions(pdev, (1 << PDC_MMIO_BAR) | (1 << PDC_DIMM_BAR),
if (rc) { DRV_NAME);
if (rc == -EBUSY)
pcim_pin_device(pdev); pcim_pin_device(pdev);
if (rc)
return rc; return rc;
}
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc) if (rc)
...@@ -1359,21 +1354,10 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * ...@@ -1359,21 +1354,10 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
probe_ent->dev = pci_dev_to_dev(pdev); probe_ent->dev = pci_dev_to_dev(pdev);
INIT_LIST_HEAD(&probe_ent->node); INIT_LIST_HEAD(&probe_ent->node);
mmio_base = pcim_iomap(pdev, 3, 0);
if (mmio_base == NULL)
return -ENOMEM;
base = (unsigned long) mmio_base;
hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
if (!hpriv) if (!hpriv)
return -ENOMEM; return -ENOMEM;
dimm_mmio = pcim_iomap(pdev, 4, 0);
if (!dimm_mmio)
return -ENOMEM;
hpriv->dimm_mmio = dimm_mmio;
probe_ent->sht = pdc_port_info[board_idx].sht; probe_ent->sht = pdc_port_info[board_idx].sht;
probe_ent->port_flags = pdc_port_info[board_idx].flags; probe_ent->port_flags = pdc_port_info[board_idx].flags;
probe_ent->pio_mask = pdc_port_info[board_idx].pio_mask; 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,10 +1367,10 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
probe_ent->irq = pdev->irq; probe_ent->irq = pdev->irq;
probe_ent->irq_flags = IRQF_SHARED; probe_ent->irq_flags = IRQF_SHARED;
probe_ent->mmio_base = mmio_base; probe_ent->iomap = pcim_iomap_table(pdev);
probe_ent->private_data = hpriv; probe_ent->private_data = hpriv;
base += PDC_CHIP0_OFS; base = probe_ent->iomap[PDC_MMIO_BAR] + PDC_CHIP0_OFS;
probe_ent->n_ports = 4; probe_ent->n_ports = 4;
pdc_sata_setup_port(&probe_ent->port[0], base + 0x200); pdc_sata_setup_port(&probe_ent->port[0], base + 0x200);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment