aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_ali.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_ali.c')
-rw-r--r--drivers/ata/pata_ali.c165
1 files changed, 29 insertions, 136 deletions
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 511a830b6256..fcabe46f262b 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -121,7 +121,7 @@ static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask)
121 ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num)); 121 ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
122 if (strstr(model_num, "WDC")) 122 if (strstr(model_num, "WDC"))
123 return mask &= ~ATA_MASK_UDMA; 123 return mask &= ~ATA_MASK_UDMA;
124 return ata_pci_default_filter(adev, mask); 124 return ata_bmdma_mode_filter(adev, mask);
125} 125}
126 126
127/** 127/**
@@ -339,21 +339,7 @@ static int ali_check_atapi_dma(struct ata_queued_cmd *qc)
339} 339}
340 340
341static struct scsi_host_template ali_sht = { 341static struct scsi_host_template ali_sht = {
342 .module = THIS_MODULE, 342 ATA_BMDMA_SHT(DRV_NAME),
343 .name = DRV_NAME,
344 .ioctl = ata_scsi_ioctl,
345 .queuecommand = ata_scsi_queuecmd,
346 .can_queue = ATA_DEF_QUEUE,
347 .this_id = ATA_SHT_THIS_ID,
348 .sg_tablesize = LIBATA_MAX_PRD,
349 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
350 .emulated = ATA_SHT_EMULATED,
351 .use_clustering = ATA_SHT_USE_CLUSTERING,
352 .proc_name = DRV_NAME,
353 .dma_boundary = ATA_DMA_BOUNDARY,
354 .slave_configure = ata_scsi_slave_config,
355 .slave_destroy = ata_scsi_slave_destroy,
356 .bios_param = ata_std_bios_param,
357}; 343};
358 344
359/* 345/*
@@ -361,29 +347,15 @@ static struct scsi_host_template ali_sht = {
361 */ 347 */
362 348
363static struct ata_port_operations ali_early_port_ops = { 349static struct ata_port_operations ali_early_port_ops = {
364 .set_piomode = ali_set_piomode, 350 .inherits = &ata_sff_port_ops,
365 .tf_load = ata_tf_load,
366 .tf_read = ata_tf_read,
367 .check_status = ata_check_status,
368 .exec_command = ata_exec_command,
369 .dev_select = ata_std_dev_select,
370
371 .freeze = ata_bmdma_freeze,
372 .thaw = ata_bmdma_thaw,
373 .error_handler = ata_bmdma_error_handler,
374 .post_internal_cmd = ata_bmdma_post_internal_cmd,
375 .cable_detect = ata_cable_40wire, 351 .cable_detect = ata_cable_40wire,
352 .set_piomode = ali_set_piomode,
353};
376 354
377 .qc_prep = ata_qc_prep, 355static const struct ata_port_operations ali_dma_base_ops = {
378 .qc_issue = ata_qc_issue_prot, 356 .inherits = &ata_bmdma_port_ops,
379 357 .set_piomode = ali_set_piomode,
380 .data_xfer = ata_data_xfer, 358 .set_dmamode = ali_set_dmamode,
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}; 359};
388 360
389/* 361/*
@@ -391,115 +363,31 @@ static struct ata_port_operations ali_early_port_ops = {
391 * detect 363 * detect
392 */ 364 */
393static struct ata_port_operations ali_20_port_ops = { 365static struct ata_port_operations ali_20_port_ops = {
394 .set_piomode = ali_set_piomode, 366 .inherits = &ali_dma_base_ops,
395 .set_dmamode = ali_set_dmamode, 367 .cable_detect = ata_cable_40wire,
396 .mode_filter = ali_20_filter, 368 .mode_filter = ali_20_filter,
397
398 .tf_load = ata_tf_load,
399 .tf_read = ata_tf_read,
400 .check_atapi_dma = ali_check_atapi_dma, 369 .check_atapi_dma = ali_check_atapi_dma,
401 .check_status = ata_check_status,
402 .exec_command = ata_exec_command,
403 .dev_select = ata_std_dev_select,
404 .dev_config = ali_lock_sectors, 370 .dev_config = ali_lock_sectors,
405
406 .freeze = ata_bmdma_freeze,
407 .thaw = ata_bmdma_thaw,
408 .error_handler = ata_bmdma_error_handler,
409 .post_internal_cmd = ata_bmdma_post_internal_cmd,
410 .cable_detect = ata_cable_40wire,
411
412 .bmdma_setup = ata_bmdma_setup,
413 .bmdma_start = ata_bmdma_start,
414 .bmdma_stop = ata_bmdma_stop,
415 .bmdma_status = ata_bmdma_status,
416
417 .qc_prep = ata_qc_prep,
418 .qc_issue = ata_qc_issue_prot,
419
420 .data_xfer = ata_data_xfer,
421
422 .irq_handler = ata_interrupt,
423 .irq_clear = ata_bmdma_irq_clear,
424 .irq_on = ata_irq_on,
425
426 .port_start = ata_sff_port_start,
427}; 371};
428 372
429/* 373/*
430 * Port operations for DMA capable ALi with cable detect 374 * Port operations for DMA capable ALi with cable detect
431 */ 375 */
432static struct ata_port_operations ali_c2_port_ops = { 376static struct ata_port_operations ali_c2_port_ops = {
433 .set_piomode = ali_set_piomode, 377 .inherits = &ali_dma_base_ops,
434 .set_dmamode = ali_set_dmamode,
435 .mode_filter = ata_pci_default_filter,
436 .tf_load = ata_tf_load,
437 .tf_read = ata_tf_read,
438 .check_atapi_dma = ali_check_atapi_dma, 378 .check_atapi_dma = ali_check_atapi_dma,
439 .check_status = ata_check_status,
440 .exec_command = ata_exec_command,
441 .dev_select = ata_std_dev_select,
442 .dev_config = ali_lock_sectors,
443
444 .freeze = ata_bmdma_freeze,
445 .thaw = ata_bmdma_thaw,
446 .error_handler = ata_bmdma_error_handler,
447 .post_internal_cmd = ata_bmdma_post_internal_cmd,
448 .cable_detect = ali_c2_cable_detect, 379 .cable_detect = ali_c2_cable_detect,
449 380 .dev_config = ali_lock_sectors,
450 .bmdma_setup = ata_bmdma_setup,
451 .bmdma_start = ata_bmdma_start,
452 .bmdma_stop = ata_bmdma_stop,
453 .bmdma_status = ata_bmdma_status,
454
455 .qc_prep = ata_qc_prep,
456 .qc_issue = ata_qc_issue_prot,
457
458 .data_xfer = ata_data_xfer,
459
460 .irq_handler = ata_interrupt,
461 .irq_clear = ata_bmdma_irq_clear,
462 .irq_on = ata_irq_on,
463
464 .port_start = ata_sff_port_start,
465}; 381};
466 382
467/* 383/*
468 * Port operations for DMA capable ALi with cable detect and LBA48 384 * Port operations for DMA capable ALi with cable detect and LBA48
469 */ 385 */
470static struct ata_port_operations ali_c5_port_ops = { 386static struct ata_port_operations ali_c5_port_ops = {
471 .set_piomode = ali_set_piomode, 387 .inherits = &ali_dma_base_ops,
472 .set_dmamode = ali_set_dmamode,
473 .mode_filter = ata_pci_default_filter,
474 .tf_load = ata_tf_load,
475 .tf_read = ata_tf_read,
476 .check_atapi_dma = ali_check_atapi_dma, 388 .check_atapi_dma = ali_check_atapi_dma,
477 .check_status = ata_check_status,
478 .exec_command = ata_exec_command,
479 .dev_select = ata_std_dev_select,
480 .dev_config = ali_warn_atapi_dma, 389 .dev_config = ali_warn_atapi_dma,
481
482 .freeze = ata_bmdma_freeze,
483 .thaw = ata_bmdma_thaw,
484 .error_handler = ata_bmdma_error_handler,
485 .post_internal_cmd = ata_bmdma_post_internal_cmd,
486 .cable_detect = ali_c2_cable_detect, 390 .cable_detect = ali_c2_cable_detect,
487
488 .bmdma_setup = ata_bmdma_setup,
489 .bmdma_start = ata_bmdma_start,
490 .bmdma_stop = ata_bmdma_stop,
491 .bmdma_status = ata_bmdma_status,
492
493 .qc_prep = ata_qc_prep,
494 .qc_issue = ata_qc_issue_prot,
495
496 .data_xfer = ata_data_xfer,
497
498 .irq_handler = ata_interrupt,
499 .irq_clear = ata_bmdma_irq_clear,
500 .irq_on = ata_irq_on,
501
502 .port_start = ata_sff_port_start,
503}; 391};
504 392
505 393
@@ -561,7 +449,7 @@ static void ali_init_chipset(struct pci_dev *pdev)
561 } 449 }
562 pci_dev_put(isa_bridge); 450 pci_dev_put(isa_bridge);
563 pci_dev_put(north); 451 pci_dev_put(north);
564 ata_pci_clear_simplex(pdev); 452 ata_pci_bmdma_clear_simplex(pdev);
565} 453}
566/** 454/**
567 * ali_init_one - discovery callback 455 * ali_init_one - discovery callback
@@ -575,14 +463,12 @@ static void ali_init_chipset(struct pci_dev *pdev)
575static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 463static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
576{ 464{
577 static const struct ata_port_info info_early = { 465 static const struct ata_port_info info_early = {
578 .sht = &ali_sht,
579 .flags = ATA_FLAG_SLAVE_POSS, 466 .flags = ATA_FLAG_SLAVE_POSS,
580 .pio_mask = 0x1f, 467 .pio_mask = 0x1f,
581 .port_ops = &ali_early_port_ops 468 .port_ops = &ali_early_port_ops
582 }; 469 };
583 /* Revision 0x20 added DMA */ 470 /* Revision 0x20 added DMA */
584 static const struct ata_port_info info_20 = { 471 static const struct ata_port_info info_20 = {
585 .sht = &ali_sht,
586 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 472 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
587 .pio_mask = 0x1f, 473 .pio_mask = 0x1f,
588 .mwdma_mask = 0x07, 474 .mwdma_mask = 0x07,
@@ -590,7 +476,6 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
590 }; 476 };
591 /* Revision 0x20 with support logic added UDMA */ 477 /* Revision 0x20 with support logic added UDMA */
592 static const struct ata_port_info info_20_udma = { 478 static const struct ata_port_info info_20_udma = {
593 .sht = &ali_sht,
594 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 479 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
595 .pio_mask = 0x1f, 480 .pio_mask = 0x1f,
596 .mwdma_mask = 0x07, 481 .mwdma_mask = 0x07,
@@ -599,7 +484,6 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
599 }; 484 };
600 /* Revision 0xC2 adds UDMA66 */ 485 /* Revision 0xC2 adds UDMA66 */
601 static const struct ata_port_info info_c2 = { 486 static const struct ata_port_info info_c2 = {
602 .sht = &ali_sht,
603 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 487 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
604 .pio_mask = 0x1f, 488 .pio_mask = 0x1f,
605 .mwdma_mask = 0x07, 489 .mwdma_mask = 0x07,
@@ -608,7 +492,6 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
608 }; 492 };
609 /* Revision 0xC3 is UDMA66 for now */ 493 /* Revision 0xC3 is UDMA66 for now */
610 static const struct ata_port_info info_c3 = { 494 static const struct ata_port_info info_c3 = {
611 .sht = &ali_sht,
612 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 495 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
613 .pio_mask = 0x1f, 496 .pio_mask = 0x1f,
614 .mwdma_mask = 0x07, 497 .mwdma_mask = 0x07,
@@ -617,7 +500,6 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
617 }; 500 };
618 /* Revision 0xC4 is UDMA100 */ 501 /* Revision 0xC4 is UDMA100 */
619 static const struct ata_port_info info_c4 = { 502 static const struct ata_port_info info_c4 = {
620 .sht = &ali_sht,
621 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48, 503 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_LBA48,
622 .pio_mask = 0x1f, 504 .pio_mask = 0x1f,
623 .mwdma_mask = 0x07, 505 .mwdma_mask = 0x07,
@@ -626,7 +508,6 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
626 }; 508 };
627 /* Revision 0xC5 is UDMA133 with LBA48 DMA */ 509 /* Revision 0xC5 is UDMA133 with LBA48 DMA */
628 static const struct ata_port_info info_c5 = { 510 static const struct ata_port_info info_c5 = {
629 .sht = &ali_sht,
630 .flags = ATA_FLAG_SLAVE_POSS, 511 .flags = ATA_FLAG_SLAVE_POSS,
631 .pio_mask = 0x1f, 512 .pio_mask = 0x1f,
632 .mwdma_mask = 0x07, 513 .mwdma_mask = 0x07,
@@ -637,6 +518,11 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
637 const struct ata_port_info *ppi[] = { NULL, NULL }; 518 const struct ata_port_info *ppi[] = { NULL, NULL };
638 u8 tmp; 519 u8 tmp;
639 struct pci_dev *isa_bridge; 520 struct pci_dev *isa_bridge;
521 int rc;
522
523 rc = pcim_enable_device(pdev);
524 if (rc)
525 return rc;
640 526
641 /* 527 /*
642 * The chipset revision selects the driver operations and 528 * The chipset revision selects the driver operations and
@@ -666,14 +552,21 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
666 ppi[0] = &info_20_udma; 552 ppi[0] = &info_20_udma;
667 pci_dev_put(isa_bridge); 553 pci_dev_put(isa_bridge);
668 } 554 }
669 return ata_pci_init_one(pdev, ppi); 555 return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL);
670} 556}
671 557
672#ifdef CONFIG_PM 558#ifdef CONFIG_PM
673static int ali_reinit_one(struct pci_dev *pdev) 559static int ali_reinit_one(struct pci_dev *pdev)
674{ 560{
561 struct ata_host *host = dev_get_drvdata(&pdev->dev);
562 int rc;
563
564 rc = ata_pci_device_do_resume(pdev);
565 if (rc)
566 return rc;
675 ali_init_chipset(pdev); 567 ali_init_chipset(pdev);
676 return ata_pci_device_resume(pdev); 568 ata_host_resume(host);
569 return 0;
677} 570}
678#endif 571#endif
679 572