aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_via.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_via.c')
-rw-r--r--drivers/ata/pata_via.c134
1 files changed, 28 insertions, 106 deletions
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index d119a68c388f..d4840748fb5c 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -210,23 +210,11 @@ static int via_pre_reset(struct ata_link *link, unsigned long deadline)
210 return -ENOENT; 210 return -ENOENT;
211 } 211 }
212 212
213 return ata_std_prereset(link, deadline); 213 return ata_sff_prereset(link, deadline);
214} 214}
215 215
216 216
217/** 217/**
218 * via_error_handler - reset for VIA chips
219 * @ap: ATA port
220 *
221 * Handle the reset callback for the later chips with cable detect
222 */
223
224static void via_error_handler(struct ata_port *ap)
225{
226 ata_bmdma_drive_eh(ap, via_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
227}
228
229/**
230 * via_do_set_mode - set initial PIO mode data 218 * via_do_set_mode - set initial PIO mode data
231 * @ap: ATA interface 219 * @ap: ATA interface
232 * @adev: ATA device 220 * @adev: ATA device
@@ -335,89 +323,20 @@ static void via_set_dmamode(struct ata_port *ap, struct ata_device *adev)
335} 323}
336 324
337static struct scsi_host_template via_sht = { 325static struct scsi_host_template via_sht = {
338 .module = THIS_MODULE, 326 ATA_BMDMA_SHT(DRV_NAME),
339 .name = DRV_NAME,
340 .ioctl = ata_scsi_ioctl,
341 .queuecommand = ata_scsi_queuecmd,
342 .can_queue = ATA_DEF_QUEUE,
343 .this_id = ATA_SHT_THIS_ID,
344 .sg_tablesize = LIBATA_MAX_PRD,
345 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
346 .emulated = ATA_SHT_EMULATED,
347 .use_clustering = ATA_SHT_USE_CLUSTERING,
348 .proc_name = DRV_NAME,
349 .dma_boundary = ATA_DMA_BOUNDARY,
350 .slave_configure = ata_scsi_slave_config,
351 .slave_destroy = ata_scsi_slave_destroy,
352 .bios_param = ata_std_bios_param,
353}; 327};
354 328
355static struct ata_port_operations via_port_ops = { 329static struct ata_port_operations via_port_ops = {
330 .inherits = &ata_bmdma_port_ops,
331 .cable_detect = via_cable_detect,
356 .set_piomode = via_set_piomode, 332 .set_piomode = via_set_piomode,
357 .set_dmamode = via_set_dmamode, 333 .set_dmamode = via_set_dmamode,
358 .mode_filter = ata_pci_default_filter, 334 .prereset = via_pre_reset,
359
360 .tf_load = ata_tf_load,
361 .tf_read = ata_tf_read,
362 .check_status = ata_check_status,
363 .exec_command = ata_exec_command,
364 .dev_select = ata_std_dev_select,
365
366 .freeze = ata_bmdma_freeze,
367 .thaw = ata_bmdma_thaw,
368 .error_handler = via_error_handler,
369 .post_internal_cmd = ata_bmdma_post_internal_cmd,
370 .cable_detect = via_cable_detect,
371
372 .bmdma_setup = ata_bmdma_setup,
373 .bmdma_start = ata_bmdma_start,
374 .bmdma_stop = ata_bmdma_stop,
375 .bmdma_status = ata_bmdma_status,
376
377 .qc_prep = ata_qc_prep,
378 .qc_issue = ata_qc_issue_prot,
379
380 .data_xfer = ata_data_xfer,
381
382 .irq_handler = ata_interrupt,
383 .irq_clear = ata_bmdma_irq_clear,
384 .irq_on = ata_irq_on,
385
386 .port_start = ata_sff_port_start,
387}; 335};
388 336
389static struct ata_port_operations via_port_ops_noirq = { 337static struct ata_port_operations via_port_ops_noirq = {
390 .set_piomode = via_set_piomode, 338 .inherits = &via_port_ops,
391 .set_dmamode = via_set_dmamode, 339 .sff_data_xfer = ata_sff_data_xfer_noirq,
392 .mode_filter = ata_pci_default_filter,
393
394 .tf_load = ata_tf_load,
395 .tf_read = ata_tf_read,
396 .check_status = ata_check_status,
397 .exec_command = ata_exec_command,
398 .dev_select = ata_std_dev_select,
399
400 .freeze = ata_bmdma_freeze,
401 .thaw = ata_bmdma_thaw,
402 .error_handler = via_error_handler,
403 .post_internal_cmd = ata_bmdma_post_internal_cmd,
404 .cable_detect = via_cable_detect,
405
406 .bmdma_setup = ata_bmdma_setup,
407 .bmdma_start = ata_bmdma_start,
408 .bmdma_stop = ata_bmdma_stop,
409 .bmdma_status = ata_bmdma_status,
410
411 .qc_prep = ata_qc_prep,
412 .qc_issue = ata_qc_issue_prot,
413
414 .data_xfer = ata_data_xfer_noirq,
415
416 .irq_handler = ata_interrupt,
417 .irq_clear = ata_bmdma_irq_clear,
418 .irq_on = ata_irq_on,
419
420 .port_start = ata_sff_port_start,
421}; 340};
422 341
423/** 342/**
@@ -467,7 +386,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
467{ 386{
468 /* Early VIA without UDMA support */ 387 /* Early VIA without UDMA support */
469 static const struct ata_port_info via_mwdma_info = { 388 static const struct ata_port_info via_mwdma_info = {
470 .sht = &via_sht,
471 .flags = ATA_FLAG_SLAVE_POSS, 389 .flags = ATA_FLAG_SLAVE_POSS,
472 .pio_mask = 0x1f, 390 .pio_mask = 0x1f,
473 .mwdma_mask = 0x07, 391 .mwdma_mask = 0x07,
@@ -475,7 +393,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
475 }; 393 };
476 /* Ditto with IRQ masking required */ 394 /* Ditto with IRQ masking required */
477 static const struct ata_port_info via_mwdma_info_borked = { 395 static const struct ata_port_info via_mwdma_info_borked = {
478 .sht = &via_sht,
479 .flags = ATA_FLAG_SLAVE_POSS, 396 .flags = ATA_FLAG_SLAVE_POSS,
480 .pio_mask = 0x1f, 397 .pio_mask = 0x1f,
481 .mwdma_mask = 0x07, 398 .mwdma_mask = 0x07,
@@ -483,7 +400,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
483 }; 400 };
484 /* VIA UDMA 33 devices (and borked 66) */ 401 /* VIA UDMA 33 devices (and borked 66) */
485 static const struct ata_port_info via_udma33_info = { 402 static const struct ata_port_info via_udma33_info = {
486 .sht = &via_sht,
487 .flags = ATA_FLAG_SLAVE_POSS, 403 .flags = ATA_FLAG_SLAVE_POSS,
488 .pio_mask = 0x1f, 404 .pio_mask = 0x1f,
489 .mwdma_mask = 0x07, 405 .mwdma_mask = 0x07,
@@ -492,7 +408,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
492 }; 408 };
493 /* VIA UDMA 66 devices */ 409 /* VIA UDMA 66 devices */
494 static const struct ata_port_info via_udma66_info = { 410 static const struct ata_port_info via_udma66_info = {
495 .sht = &via_sht,
496 .flags = ATA_FLAG_SLAVE_POSS, 411 .flags = ATA_FLAG_SLAVE_POSS,
497 .pio_mask = 0x1f, 412 .pio_mask = 0x1f,
498 .mwdma_mask = 0x07, 413 .mwdma_mask = 0x07,
@@ -501,7 +416,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
501 }; 416 };
502 /* VIA UDMA 100 devices */ 417 /* VIA UDMA 100 devices */
503 static const struct ata_port_info via_udma100_info = { 418 static const struct ata_port_info via_udma100_info = {
504 .sht = &via_sht,
505 .flags = ATA_FLAG_SLAVE_POSS, 419 .flags = ATA_FLAG_SLAVE_POSS,
506 .pio_mask = 0x1f, 420 .pio_mask = 0x1f,
507 .mwdma_mask = 0x07, 421 .mwdma_mask = 0x07,
@@ -510,24 +424,27 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
510 }; 424 };
511 /* UDMA133 with bad AST (All current 133) */ 425 /* UDMA133 with bad AST (All current 133) */
512 static const struct ata_port_info via_udma133_info = { 426 static const struct ata_port_info via_udma133_info = {
513 .sht = &via_sht,
514 .flags = ATA_FLAG_SLAVE_POSS, 427 .flags = ATA_FLAG_SLAVE_POSS,
515 .pio_mask = 0x1f, 428 .pio_mask = 0x1f,
516 .mwdma_mask = 0x07, 429 .mwdma_mask = 0x07,
517 .udma_mask = ATA_UDMA6, /* FIXME: should check north bridge */ 430 .udma_mask = ATA_UDMA6, /* FIXME: should check north bridge */
518 .port_ops = &via_port_ops 431 .port_ops = &via_port_ops
519 }; 432 };
520 struct ata_port_info type; 433 const struct ata_port_info *ppi[] = { NULL, NULL };
521 const struct ata_port_info *ppi[] = { &type, NULL };
522 struct pci_dev *isa = NULL; 434 struct pci_dev *isa = NULL;
523 const struct via_isa_bridge *config; 435 const struct via_isa_bridge *config;
524 static int printed_version; 436 static int printed_version;
525 u8 enable; 437 u8 enable;
526 u32 timing; 438 u32 timing;
439 int rc;
527 440
528 if (!printed_version++) 441 if (!printed_version++)
529 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 442 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
530 443
444 rc = pcim_enable_device(pdev);
445 if (rc)
446 return rc;
447
531 /* To find out how the IDE will behave and what features we 448 /* To find out how the IDE will behave and what features we
532 actually have to look at the bridge not the IDE controller */ 449 actually have to look at the bridge not the IDE controller */
533 for (config = via_isa_bridges; config->id; config++) 450 for (config = via_isa_bridges; config->id; config++)
@@ -561,25 +478,25 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
561 switch(config->flags & VIA_UDMA) { 478 switch(config->flags & VIA_UDMA) {
562 case VIA_UDMA_NONE: 479 case VIA_UDMA_NONE:
563 if (config->flags & VIA_NO_UNMASK) 480 if (config->flags & VIA_NO_UNMASK)
564 type = via_mwdma_info_borked; 481 ppi[0] = &via_mwdma_info_borked;
565 else 482 else
566 type = via_mwdma_info; 483 ppi[0] = &via_mwdma_info;
567 break; 484 break;
568 case VIA_UDMA_33: 485 case VIA_UDMA_33:
569 type = via_udma33_info; 486 ppi[0] = &via_udma33_info;
570 break; 487 break;
571 case VIA_UDMA_66: 488 case VIA_UDMA_66:
572 type = via_udma66_info; 489 ppi[0] = &via_udma66_info;
573 /* The 66 MHz devices require we enable the clock */ 490 /* The 66 MHz devices require we enable the clock */
574 pci_read_config_dword(pdev, 0x50, &timing); 491 pci_read_config_dword(pdev, 0x50, &timing);
575 timing |= 0x80008; 492 timing |= 0x80008;
576 pci_write_config_dword(pdev, 0x50, timing); 493 pci_write_config_dword(pdev, 0x50, timing);
577 break; 494 break;
578 case VIA_UDMA_100: 495 case VIA_UDMA_100:
579 type = via_udma100_info; 496 ppi[0] = &via_udma100_info;
580 break; 497 break;
581 case VIA_UDMA_133: 498 case VIA_UDMA_133:
582 type = via_udma133_info; 499 ppi[0] = &via_udma133_info;
583 break; 500 break;
584 default: 501 default:
585 WARN_ON(1); 502 WARN_ON(1);
@@ -594,9 +511,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
594 } 511 }
595 512
596 /* We have established the device type, now fire it up */ 513 /* We have established the device type, now fire it up */
597 type.private_data = (void *)config; 514 return ata_pci_sff_init_one(pdev, ppi, &via_sht, (void *)config);
598
599 return ata_pci_init_one(pdev, ppi);
600} 515}
601 516
602#ifdef CONFIG_PM 517#ifdef CONFIG_PM
@@ -615,6 +530,11 @@ static int via_reinit_one(struct pci_dev *pdev)
615 u32 timing; 530 u32 timing;
616 struct ata_host *host = dev_get_drvdata(&pdev->dev); 531 struct ata_host *host = dev_get_drvdata(&pdev->dev);
617 const struct via_isa_bridge *config = host->private_data; 532 const struct via_isa_bridge *config = host->private_data;
533 int rc;
534
535 rc = ata_pci_device_do_resume(pdev);
536 if (rc)
537 return rc;
618 538
619 via_config_fifo(pdev, config->flags); 539 via_config_fifo(pdev, config->flags);
620 540
@@ -630,7 +550,9 @@ static int via_reinit_one(struct pci_dev *pdev)
630 timing &= ~0x80008; 550 timing &= ~0x80008;
631 pci_write_config_dword(pdev, 0x50, timing); 551 pci_write_config_dword(pdev, 0x50, timing);
632 } 552 }
633 return ata_pci_device_resume(pdev); 553
554 ata_host_resume(host);
555 return 0;
634} 556}
635#endif 557#endif
636 558