diff options
Diffstat (limited to 'drivers/ata/sata_vsc.c')
-rw-r--r-- | drivers/ata/sata_vsc.c | 72 |
1 files changed, 28 insertions, 44 deletions
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c index 170bad1b415b..80126f835d32 100644 --- a/drivers/ata/sata_vsc.c +++ b/drivers/ata/sata_vsc.c | |||
@@ -333,7 +333,6 @@ static const struct ata_port_operations vsc_sata_ops = { | |||
333 | .thaw = vsc_thaw, | 333 | .thaw = vsc_thaw, |
334 | .error_handler = ata_bmdma_error_handler, | 334 | .error_handler = ata_bmdma_error_handler, |
335 | .post_internal_cmd = ata_bmdma_post_internal_cmd, | 335 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
336 | .irq_handler = vsc_sata_interrupt, | ||
337 | .irq_clear = ata_bmdma_irq_clear, | 336 | .irq_clear = ata_bmdma_irq_clear, |
338 | .irq_on = ata_irq_on, | 337 | .irq_on = ata_irq_on, |
339 | .irq_ack = ata_irq_ack, | 338 | .irq_ack = ata_irq_ack, |
@@ -367,30 +366,50 @@ static void __devinit vsc_sata_setup_port(struct ata_ioports *port, | |||
367 | 366 | ||
368 | static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 367 | static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
369 | { | 368 | { |
369 | static const struct ata_port_info pi = { | ||
370 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | ||
371 | ATA_FLAG_MMIO, | ||
372 | .pio_mask = 0x1f, | ||
373 | .mwdma_mask = 0x07, | ||
374 | .udma_mask = 0x7f, | ||
375 | .port_ops = &vsc_sata_ops, | ||
376 | }; | ||
377 | const struct ata_port_info *ppi[] = { &pi, NULL }; | ||
370 | static int printed_version; | 378 | static int printed_version; |
371 | struct ata_probe_ent *probe_ent; | 379 | struct ata_host *host; |
372 | void __iomem *mmio_base; | 380 | void __iomem *mmio_base; |
373 | int rc; | 381 | int i, rc; |
374 | u8 cls; | 382 | u8 cls; |
375 | 383 | ||
376 | if (!printed_version++) | 384 | if (!printed_version++) |
377 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 385 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
378 | 386 | ||
387 | /* allocate host */ | ||
388 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, 4); | ||
389 | if (!host) | ||
390 | return -ENOMEM; | ||
391 | |||
379 | rc = pcim_enable_device(pdev); | 392 | rc = pcim_enable_device(pdev); |
380 | if (rc) | 393 | if (rc) |
381 | return rc; | 394 | return rc; |
382 | 395 | ||
383 | /* | 396 | /* check if we have needed resource mapped */ |
384 | * Check if we have needed resource mapped. | ||
385 | */ | ||
386 | if (pci_resource_len(pdev, 0) == 0) | 397 | if (pci_resource_len(pdev, 0) == 0) |
387 | return -ENODEV; | 398 | return -ENODEV; |
388 | 399 | ||
400 | /* map IO regions and intialize host accordingly */ | ||
389 | rc = pcim_iomap_regions(pdev, 1 << VSC_MMIO_BAR, DRV_NAME); | 401 | rc = pcim_iomap_regions(pdev, 1 << VSC_MMIO_BAR, DRV_NAME); |
390 | if (rc == -EBUSY) | 402 | if (rc == -EBUSY) |
391 | pcim_pin_device(pdev); | 403 | pcim_pin_device(pdev); |
392 | if (rc) | 404 | if (rc) |
393 | return rc; | 405 | return rc; |
406 | host->iomap = pcim_iomap_table(pdev); | ||
407 | |||
408 | mmio_base = host->iomap[VSC_MMIO_BAR]; | ||
409 | |||
410 | for (i = 0; i < host->n_ports; i++) | ||
411 | vsc_sata_setup_port(&host->ports[i]->ioaddr, | ||
412 | mmio_base + (i + 1) * VSC_SATA_PORT_OFFSET); | ||
394 | 413 | ||
395 | /* | 414 | /* |
396 | * Use 32 bit DMA mask, because 64 bit address support is poor. | 415 | * Use 32 bit DMA mask, because 64 bit address support is poor. |
@@ -402,12 +421,6 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
402 | if (rc) | 421 | if (rc) |
403 | return rc; | 422 | return rc; |
404 | 423 | ||
405 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); | ||
406 | if (probe_ent == NULL) | ||
407 | return -ENOMEM; | ||
408 | probe_ent->dev = pci_dev_to_dev(pdev); | ||
409 | INIT_LIST_HEAD(&probe_ent->node); | ||
410 | |||
411 | /* | 424 | /* |
412 | * Due to a bug in the chip, the default cache line size can't be | 425 | * Due to a bug in the chip, the default cache line size can't be |
413 | * used (unless the default is non-zero). | 426 | * used (unless the default is non-zero). |
@@ -418,33 +431,6 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
418 | 431 | ||
419 | if (pci_enable_msi(pdev) == 0) | 432 | if (pci_enable_msi(pdev) == 0) |
420 | pci_intx(pdev, 0); | 433 | pci_intx(pdev, 0); |
421 | else | ||
422 | probe_ent->irq_flags = IRQF_SHARED; | ||
423 | |||
424 | probe_ent->sht = &vsc_sata_sht; | ||
425 | probe_ent->port_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | ||
426 | ATA_FLAG_MMIO; | ||
427 | probe_ent->port_ops = &vsc_sata_ops; | ||
428 | probe_ent->n_ports = 4; | ||
429 | probe_ent->irq = pdev->irq; | ||
430 | probe_ent->iomap = pcim_iomap_table(pdev); | ||
431 | |||
432 | /* We don't care much about the PIO/UDMA masks, but the core won't like us | ||
433 | * if we don't fill these | ||
434 | */ | ||
435 | probe_ent->pio_mask = 0x1f; | ||
436 | probe_ent->mwdma_mask = 0x07; | ||
437 | probe_ent->udma_mask = 0x7f; | ||
438 | |||
439 | mmio_base = probe_ent->iomap[VSC_MMIO_BAR]; | ||
440 | |||
441 | /* We have 4 ports per PCI function */ | ||
442 | vsc_sata_setup_port(&probe_ent->port[0], mmio_base + 1 * VSC_SATA_PORT_OFFSET); | ||
443 | vsc_sata_setup_port(&probe_ent->port[1], mmio_base + 2 * VSC_SATA_PORT_OFFSET); | ||
444 | vsc_sata_setup_port(&probe_ent->port[2], mmio_base + 3 * VSC_SATA_PORT_OFFSET); | ||
445 | vsc_sata_setup_port(&probe_ent->port[3], mmio_base + 4 * VSC_SATA_PORT_OFFSET); | ||
446 | |||
447 | pci_set_master(pdev); | ||
448 | 434 | ||
449 | /* | 435 | /* |
450 | * Config offset 0x98 is "Extended Control and Status Register 0" | 436 | * Config offset 0x98 is "Extended Control and Status Register 0" |
@@ -454,11 +440,9 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
454 | */ | 440 | */ |
455 | pci_write_config_dword(pdev, 0x98, 0); | 441 | pci_write_config_dword(pdev, 0x98, 0); |
456 | 442 | ||
457 | if (!ata_device_add(probe_ent)) | 443 | pci_set_master(pdev); |
458 | return -ENODEV; | 444 | return ata_host_activate(host, pdev->irq, vsc_sata_interrupt, |
459 | 445 | IRQF_SHARED, &vsc_sata_sht); | |
460 | devm_kfree(&pdev->dev, probe_ent); | ||
461 | return 0; | ||
462 | } | 446 | } |
463 | 447 | ||
464 | static const struct pci_device_id vsc_sata_pci_tbl[] = { | 448 | static const struct pci_device_id vsc_sata_pci_tbl[] = { |