diff options
Diffstat (limited to 'drivers/ata/sata_svw.c')
-rw-r--r-- | drivers/ata/sata_svw.c | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index 9c48b418ad7f..5ce4f593687d 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c | |||
@@ -135,31 +135,31 @@ static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | |||
135 | unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; | 135 | unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; |
136 | 136 | ||
137 | if (tf->ctl != ap->last_ctl) { | 137 | if (tf->ctl != ap->last_ctl) { |
138 | writeb(tf->ctl, (void __iomem *) ioaddr->ctl_addr); | 138 | writeb(tf->ctl, ioaddr->ctl_addr); |
139 | ap->last_ctl = tf->ctl; | 139 | ap->last_ctl = tf->ctl; |
140 | ata_wait_idle(ap); | 140 | ata_wait_idle(ap); |
141 | } | 141 | } |
142 | if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { | 142 | if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { |
143 | writew(tf->feature | (((u16)tf->hob_feature) << 8), | 143 | writew(tf->feature | (((u16)tf->hob_feature) << 8), |
144 | (void __iomem *) ioaddr->feature_addr); | 144 | ioaddr->feature_addr); |
145 | writew(tf->nsect | (((u16)tf->hob_nsect) << 8), | 145 | writew(tf->nsect | (((u16)tf->hob_nsect) << 8), |
146 | (void __iomem *) ioaddr->nsect_addr); | 146 | ioaddr->nsect_addr); |
147 | writew(tf->lbal | (((u16)tf->hob_lbal) << 8), | 147 | writew(tf->lbal | (((u16)tf->hob_lbal) << 8), |
148 | (void __iomem *) ioaddr->lbal_addr); | 148 | ioaddr->lbal_addr); |
149 | writew(tf->lbam | (((u16)tf->hob_lbam) << 8), | 149 | writew(tf->lbam | (((u16)tf->hob_lbam) << 8), |
150 | (void __iomem *) ioaddr->lbam_addr); | 150 | ioaddr->lbam_addr); |
151 | writew(tf->lbah | (((u16)tf->hob_lbah) << 8), | 151 | writew(tf->lbah | (((u16)tf->hob_lbah) << 8), |
152 | (void __iomem *) ioaddr->lbah_addr); | 152 | ioaddr->lbah_addr); |
153 | } else if (is_addr) { | 153 | } else if (is_addr) { |
154 | writew(tf->feature, (void __iomem *) ioaddr->feature_addr); | 154 | writew(tf->feature, ioaddr->feature_addr); |
155 | writew(tf->nsect, (void __iomem *) ioaddr->nsect_addr); | 155 | writew(tf->nsect, ioaddr->nsect_addr); |
156 | writew(tf->lbal, (void __iomem *) ioaddr->lbal_addr); | 156 | writew(tf->lbal, ioaddr->lbal_addr); |
157 | writew(tf->lbam, (void __iomem *) ioaddr->lbam_addr); | 157 | writew(tf->lbam, ioaddr->lbam_addr); |
158 | writew(tf->lbah, (void __iomem *) ioaddr->lbah_addr); | 158 | writew(tf->lbah, ioaddr->lbah_addr); |
159 | } | 159 | } |
160 | 160 | ||
161 | if (tf->flags & ATA_TFLAG_DEVICE) | 161 | if (tf->flags & ATA_TFLAG_DEVICE) |
162 | writeb(tf->device, (void __iomem *) ioaddr->device_addr); | 162 | writeb(tf->device, ioaddr->device_addr); |
163 | 163 | ||
164 | ata_wait_idle(ap); | 164 | ata_wait_idle(ap); |
165 | } | 165 | } |
@@ -171,12 +171,12 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
171 | u16 nsect, lbal, lbam, lbah, feature; | 171 | u16 nsect, lbal, lbam, lbah, feature; |
172 | 172 | ||
173 | tf->command = k2_stat_check_status(ap); | 173 | tf->command = k2_stat_check_status(ap); |
174 | tf->device = readw((void __iomem *)ioaddr->device_addr); | 174 | tf->device = readw(ioaddr->device_addr); |
175 | feature = readw((void __iomem *)ioaddr->error_addr); | 175 | feature = readw(ioaddr->error_addr); |
176 | nsect = readw((void __iomem *)ioaddr->nsect_addr); | 176 | nsect = readw(ioaddr->nsect_addr); |
177 | lbal = readw((void __iomem *)ioaddr->lbal_addr); | 177 | lbal = readw(ioaddr->lbal_addr); |
178 | lbam = readw((void __iomem *)ioaddr->lbam_addr); | 178 | lbam = readw(ioaddr->lbam_addr); |
179 | lbah = readw((void __iomem *)ioaddr->lbah_addr); | 179 | lbah = readw(ioaddr->lbah_addr); |
180 | 180 | ||
181 | tf->feature = feature; | 181 | tf->feature = feature; |
182 | tf->nsect = nsect; | 182 | tf->nsect = nsect; |
@@ -349,7 +349,7 @@ static const struct ata_port_operations k2_sata_ops = { | |||
349 | .bmdma_status = ata_bmdma_status, | 349 | .bmdma_status = ata_bmdma_status, |
350 | .qc_prep = ata_qc_prep, | 350 | .qc_prep = ata_qc_prep, |
351 | .qc_issue = ata_qc_issue_prot, | 351 | .qc_issue = ata_qc_issue_prot, |
352 | .data_xfer = ata_mmio_data_xfer, | 352 | .data_xfer = ata_data_xfer, |
353 | .freeze = ata_bmdma_freeze, | 353 | .freeze = ata_bmdma_freeze, |
354 | .thaw = ata_bmdma_thaw, | 354 | .thaw = ata_bmdma_thaw, |
355 | .error_handler = ata_bmdma_error_handler, | 355 | .error_handler = ata_bmdma_error_handler, |
@@ -361,7 +361,7 @@ static const struct ata_port_operations k2_sata_ops = { | |||
361 | .port_start = ata_port_start, | 361 | .port_start = ata_port_start, |
362 | }; | 362 | }; |
363 | 363 | ||
364 | static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base) | 364 | static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base) |
365 | { | 365 | { |
366 | port->cmd_addr = base + K2_SATA_TF_CMD_OFFSET; | 366 | port->cmd_addr = base + K2_SATA_TF_CMD_OFFSET; |
367 | port->data_addr = base + K2_SATA_TF_DATA_OFFSET; | 367 | 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 | static int printed_version; | 386 | static int printed_version; |
387 | struct device *dev = &pdev->dev; | 387 | struct device *dev = &pdev->dev; |
388 | struct ata_probe_ent *probe_ent; | 388 | struct ata_probe_ent *probe_ent; |
389 | unsigned long base; | ||
390 | void __iomem *mmio_base; | 389 | void __iomem *mmio_base; |
391 | const struct k2_board_info *board_info = | 390 | const struct k2_board_info *board_info = |
392 | &k2_board_info[ent->driver_data]; | 391 | &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 | if (pci_resource_len(pdev, 5) == 0) | 409 | if (pci_resource_len(pdev, 5) == 0) |
411 | return -ENODEV; | 410 | return -ENODEV; |
412 | 411 | ||
413 | /* Request PCI regions */ | 412 | /* Request and iomap PCI regions */ |
414 | rc = pci_request_regions(pdev, DRV_NAME); | 413 | rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME); |
415 | if (rc) { | 414 | if (rc == -EBUSY) |
416 | pcim_pin_device(pdev); | 415 | pcim_pin_device(pdev); |
416 | if (rc) | ||
417 | return rc; | 417 | return rc; |
418 | } | ||
419 | 418 | ||
420 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 419 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
421 | if (rc) | 420 | if (rc) |
@@ -431,22 +430,6 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
431 | probe_ent->dev = pci_dev_to_dev(pdev); | 430 | probe_ent->dev = pci_dev_to_dev(pdev); |
432 | INIT_LIST_HEAD(&probe_ent->node); | 431 | INIT_LIST_HEAD(&probe_ent->node); |
433 | 432 | ||
434 | mmio_base = pcim_iomap(pdev, 5, 0); | ||
435 | if (mmio_base == NULL) | ||
436 | return -ENOMEM; | ||
437 | base = (unsigned long) mmio_base; | ||
438 | |||
439 | /* Clear a magic bit in SCR1 according to Darwin, those help | ||
440 | * some funky seagate drives (though so far, those were already | ||
441 | * set by the firmware on the machines I had access to) | ||
442 | */ | ||
443 | writel(readl(mmio_base + K2_SATA_SICR1_OFFSET) & ~0x00040000, | ||
444 | mmio_base + K2_SATA_SICR1_OFFSET); | ||
445 | |||
446 | /* Clear SATA error & interrupts we don't use */ | ||
447 | writel(0xffffffff, mmio_base + K2_SATA_SCR_ERROR_OFFSET); | ||
448 | writel(0x0, mmio_base + K2_SATA_SIM_OFFSET); | ||
449 | |||
450 | probe_ent->sht = &k2_sata_sht; | 433 | probe_ent->sht = &k2_sata_sht; |
451 | probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 434 | probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
452 | ATA_FLAG_MMIO | board_info->port_flags; | 435 | 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 | probe_ent->n_ports = 4; | 437 | probe_ent->n_ports = 4; |
455 | probe_ent->irq = pdev->irq; | 438 | probe_ent->irq = pdev->irq; |
456 | probe_ent->irq_flags = IRQF_SHARED; | 439 | probe_ent->irq_flags = IRQF_SHARED; |
457 | probe_ent->mmio_base = mmio_base; | 440 | probe_ent->iomap = pcim_iomap_table(pdev); |
458 | 441 | ||
459 | /* We don't care much about the PIO/UDMA masks, but the core won't like us | 442 | /* We don't care much about the PIO/UDMA masks, but the core won't like us |
460 | * if we don't fill these | 443 | * 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 | probe_ent->mwdma_mask = 0x7; | 446 | probe_ent->mwdma_mask = 0x7; |
464 | probe_ent->udma_mask = 0x7f; | 447 | probe_ent->udma_mask = 0x7f; |
465 | 448 | ||
449 | mmio_base = probe_ent->iomap[5]; | ||
450 | |||
466 | /* different controllers have different number of ports - currently 4 or 8 */ | 451 | /* different controllers have different number of ports - currently 4 or 8 */ |
467 | /* All ports are on the same function. Multi-function device is no | 452 | /* All ports are on the same function. Multi-function device is no |
468 | * longer available. This should not be seen in any system. */ | 453 | * longer available. This should not be seen in any system. */ |
469 | for (i = 0; i < board_info->n_ports; i++) | 454 | for (i = 0; i < board_info->n_ports; i++) |
470 | k2_sata_setup_port(&probe_ent->port[i], base + i * K2_SATA_PORT_OFFSET); | 455 | k2_sata_setup_port(&probe_ent->port[i], |
456 | mmio_base + i * K2_SATA_PORT_OFFSET); | ||
457 | |||
458 | /* Clear a magic bit in SCR1 according to Darwin, those help | ||
459 | * some funky seagate drives (though so far, those were already | ||
460 | * set by the firmware on the machines I had access to) | ||
461 | */ | ||
462 | writel(readl(mmio_base + K2_SATA_SICR1_OFFSET) & ~0x00040000, | ||
463 | mmio_base + K2_SATA_SICR1_OFFSET); | ||
464 | |||
465 | /* Clear SATA error & interrupts we don't use */ | ||
466 | writel(0xffffffff, mmio_base + K2_SATA_SCR_ERROR_OFFSET); | ||
467 | writel(0x0, mmio_base + K2_SATA_SIM_OFFSET); | ||
471 | 468 | ||
472 | pci_set_master(pdev); | 469 | pci_set_master(pdev); |
473 | 470 | ||