diff options
Diffstat (limited to 'drivers/ide/ppc/pmac.c')
| -rw-r--r-- | drivers/ide/ppc/pmac.c | 86 | 
1 files changed, 54 insertions, 32 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 177961edc430..185faa0dce94 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c  | |||
| @@ -409,7 +409,7 @@ kauai_lookup_timing(struct kauai_timing* table, int cycle_time) | |||
| 409 | */ | 409 | */ | 
| 410 | #define IDE_WAKEUP_DELAY (1*HZ) | 410 | #define IDE_WAKEUP_DELAY (1*HZ) | 
| 411 | 411 | ||
| 412 | static int pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif); | 412 | static int pmac_ide_init_dma(ide_hwif_t *, const struct ide_port_info *); | 
| 413 | static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); | 413 | static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); | 
| 414 | static void pmac_ide_selectproc(ide_drive_t *drive); | 414 | static void pmac_ide_selectproc(ide_drive_t *drive); | 
| 415 | static void pmac_ide_kauai_selectproc(ide_drive_t *drive); | 415 | static void pmac_ide_kauai_selectproc(ide_drive_t *drive); | 
| @@ -918,11 +918,29 @@ pmac_ide_do_resume(ide_hwif_t *hwif) | |||
| 918 | return 0; | 918 | return 0; | 
| 919 | } | 919 | } | 
| 920 | 920 | ||
| 921 | static const struct ide_port_ops pmac_ide_ata6_port_ops = { | ||
| 922 | .set_pio_mode = pmac_ide_set_pio_mode, | ||
| 923 | .set_dma_mode = pmac_ide_set_dma_mode, | ||
| 924 | .selectproc = pmac_ide_kauai_selectproc, | ||
| 925 | }; | ||
| 926 | |||
| 927 | static const struct ide_port_ops pmac_ide_port_ops = { | ||
| 928 | .set_pio_mode = pmac_ide_set_pio_mode, | ||
| 929 | .set_dma_mode = pmac_ide_set_dma_mode, | ||
| 930 | .selectproc = pmac_ide_selectproc, | ||
| 931 | }; | ||
| 932 | |||
| 933 | static const struct ide_dma_ops pmac_dma_ops; | ||
| 934 | |||
| 921 | static const struct ide_port_info pmac_port_info = { | 935 | static const struct ide_port_info pmac_port_info = { | 
| 936 | .init_dma = pmac_ide_init_dma, | ||
| 922 | .chipset = ide_pmac, | 937 | .chipset = ide_pmac, | 
| 938 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | ||
| 939 | .dma_ops = &pmac_dma_ops, | ||
| 940 | #endif | ||
| 941 | .port_ops = &pmac_ide_port_ops, | ||
| 923 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | | 942 | .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | | 
| 924 | IDE_HFLAG_POST_SET_MODE | | 943 | IDE_HFLAG_POST_SET_MODE | | 
| 925 | IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ | ||
| 926 | IDE_HFLAG_UNMASK_IRQS, | 944 | IDE_HFLAG_UNMASK_IRQS, | 
| 927 | .pio_mask = ATA_PIO4, | 945 | .pio_mask = ATA_PIO4, | 
| 928 | .mwdma_mask = ATA_MWDMA2, | 946 | .mwdma_mask = ATA_MWDMA2, | 
| @@ -947,12 +965,15 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
| 947 | pmif->broken_dma = pmif->broken_dma_warn = 0; | 965 | pmif->broken_dma = pmif->broken_dma_warn = 0; | 
| 948 | if (of_device_is_compatible(np, "shasta-ata")) { | 966 | if (of_device_is_compatible(np, "shasta-ata")) { | 
| 949 | pmif->kind = controller_sh_ata6; | 967 | pmif->kind = controller_sh_ata6; | 
| 968 | d.port_ops = &pmac_ide_ata6_port_ops; | ||
| 950 | d.udma_mask = ATA_UDMA6; | 969 | d.udma_mask = ATA_UDMA6; | 
| 951 | } else if (of_device_is_compatible(np, "kauai-ata")) { | 970 | } else if (of_device_is_compatible(np, "kauai-ata")) { | 
| 952 | pmif->kind = controller_un_ata6; | 971 | pmif->kind = controller_un_ata6; | 
| 972 | d.port_ops = &pmac_ide_ata6_port_ops; | ||
| 953 | d.udma_mask = ATA_UDMA5; | 973 | d.udma_mask = ATA_UDMA5; | 
| 954 | } else if (of_device_is_compatible(np, "K2-UATA")) { | 974 | } else if (of_device_is_compatible(np, "K2-UATA")) { | 
| 955 | pmif->kind = controller_k2_ata6; | 975 | pmif->kind = controller_k2_ata6; | 
| 976 | d.port_ops = &pmac_ide_ata6_port_ops; | ||
| 956 | d.udma_mask = ATA_UDMA5; | 977 | d.udma_mask = ATA_UDMA5; | 
| 957 | } else if (of_device_is_compatible(np, "keylargo-ata")) { | 978 | } else if (of_device_is_compatible(np, "keylargo-ata")) { | 
| 958 | if (strcmp(np->name, "ata-4") == 0) { | 979 | if (strcmp(np->name, "ata-4") == 0) { | 
| @@ -1029,37 +1050,29 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) | |||
| 1029 | default_hwif_mmiops(hwif); | 1050 | default_hwif_mmiops(hwif); | 
| 1030 | hwif->OUTBSYNC = pmac_outbsync; | 1051 | hwif->OUTBSYNC = pmac_outbsync; | 
| 1031 | 1052 | ||
| 1032 | /* Tell common code _not_ to mess with resources */ | ||
| 1033 | hwif->mmio = 1; | ||
| 1034 | hwif->hwif_data = pmif; | 1053 | hwif->hwif_data = pmif; | 
| 1035 | ide_init_port_hw(hwif, hw); | 1054 | ide_init_port_hw(hwif, hw); | 
| 1036 | hwif->noprobe = pmif->mediabay; | ||
| 1037 | hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 1055 | hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; | 
| 1038 | hwif->set_pio_mode = pmac_ide_set_pio_mode; | ||
| 1039 | if (pmif->kind == controller_un_ata6 | ||
| 1040 | || pmif->kind == controller_k2_ata6 | ||
| 1041 | || pmif->kind == controller_sh_ata6) | ||
| 1042 | hwif->selectproc = pmac_ide_kauai_selectproc; | ||
| 1043 | else | ||
| 1044 | hwif->selectproc = pmac_ide_selectproc; | ||
| 1045 | hwif->set_dma_mode = pmac_ide_set_dma_mode; | ||
| 1046 | 1056 | ||
| 1047 | printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", | 1057 | printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", | 
| 1048 | hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, | 1058 | hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, | 
| 1049 | pmif->mediabay ? " (mediabay)" : "", hwif->irq); | 1059 | pmif->mediabay ? " (mediabay)" : "", hwif->irq); | 
| 1050 | 1060 | ||
| 1061 | if (pmif->mediabay) { | ||
| 1051 | #ifdef CONFIG_PMAC_MEDIABAY | 1062 | #ifdef CONFIG_PMAC_MEDIABAY | 
| 1052 | if (pmif->mediabay && check_media_bay_by_base(pmif->regbase, MB_CD) == 0) | 1063 | if (check_media_bay_by_base(pmif->regbase, MB_CD)) { | 
| 1053 | hwif->noprobe = 0; | 1064 | #else | 
| 1054 | #endif /* CONFIG_PMAC_MEDIABAY */ | 1065 | if (1) { | 
| 1066 | #endif | ||
| 1067 | hwif->drives[0].noprobe = 1; | ||
| 1068 | hwif->drives[1].noprobe = 1; | ||
| 1069 | } | ||
| 1070 | } | ||
| 1055 | 1071 | ||
| 1056 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | 1072 | #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC | 
| 1057 | if (pmif->cable_80 == 0) | 1073 | if (pmif->cable_80 == 0) | 
| 1058 | d.udma_mask &= ATA_UDMA2; | 1074 | d.udma_mask &= ATA_UDMA2; | 
| 1059 | /* has a DBDMA controller channel */ | ||
| 1060 | if (pmif->dma_regs == 0 || pmac_ide_setup_dma(pmif, hwif) < 0) | ||
| 1061 | #endif | 1075 | #endif | 
| 1062 | d.udma_mask = d.mwdma_mask = 0; | ||
| 1063 | 1076 | ||
| 1064 | idx[0] = hwif->index; | 1077 | idx[0] = hwif->index; | 
| 1065 | 1078 | ||
| @@ -1662,18 +1675,31 @@ pmac_ide_dma_lost_irq (ide_drive_t *drive) | |||
| 1662 | printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); | 1675 | printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); | 
| 1663 | } | 1676 | } | 
| 1664 | 1677 | ||
| 1678 | static const struct ide_dma_ops pmac_dma_ops = { | ||
| 1679 | .dma_host_set = pmac_ide_dma_host_set, | ||
| 1680 | .dma_setup = pmac_ide_dma_setup, | ||
| 1681 | .dma_exec_cmd = pmac_ide_dma_exec_cmd, | ||
| 1682 | .dma_start = pmac_ide_dma_start, | ||
| 1683 | .dma_end = pmac_ide_dma_end, | ||
| 1684 | .dma_test_irq = pmac_ide_dma_test_irq, | ||
| 1685 | .dma_timeout = ide_dma_timeout, | ||
| 1686 | .dma_lost_irq = pmac_ide_dma_lost_irq, | ||
| 1687 | }; | ||
| 1688 | |||
| 1665 | /* | 1689 | /* | 
| 1666 | * Allocate the data structures needed for using DMA with an interface | 1690 | * Allocate the data structures needed for using DMA with an interface | 
| 1667 | * and fill the proper list of functions pointers | 1691 | * and fill the proper list of functions pointers | 
| 1668 | */ | 1692 | */ | 
| 1669 | static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | 1693 | static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, | 
| 1694 | const struct ide_port_info *d) | ||
| 1670 | { | 1695 | { | 
| 1696 | pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; | ||
| 1671 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 1697 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 
| 1672 | 1698 | ||
| 1673 | /* We won't need pci_dev if we switch to generic consistent | 1699 | /* We won't need pci_dev if we switch to generic consistent | 
| 1674 | * DMA routines ... | 1700 | * DMA routines ... | 
| 1675 | */ | 1701 | */ | 
| 1676 | if (dev == NULL) | 1702 | if (dev == NULL || pmif->dma_regs == 0) | 
| 1677 | return -ENODEV; | 1703 | return -ENODEV; | 
| 1678 | /* | 1704 | /* | 
| 1679 | * Allocate space for the DBDMA commands. | 1705 | * Allocate space for the DBDMA commands. | 
| @@ -1692,18 +1718,14 @@ static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
| 1692 | 1718 | ||
| 1693 | hwif->sg_max_nents = MAX_DCMDS; | 1719 | hwif->sg_max_nents = MAX_DCMDS; | 
| 1694 | 1720 | ||
| 1695 | hwif->dma_host_set = &pmac_ide_dma_host_set; | ||
| 1696 | hwif->dma_setup = &pmac_ide_dma_setup; | ||
| 1697 | hwif->dma_exec_cmd = &pmac_ide_dma_exec_cmd; | ||
| 1698 | hwif->dma_start = &pmac_ide_dma_start; | ||
| 1699 | hwif->ide_dma_end = &pmac_ide_dma_end; | ||
| 1700 | hwif->ide_dma_test_irq = &pmac_ide_dma_test_irq; | ||
| 1701 | hwif->dma_timeout = &ide_dma_timeout; | ||
| 1702 | hwif->dma_lost_irq = &pmac_ide_dma_lost_irq; | ||
| 1703 | |||
| 1704 | return 0; | 1721 | return 0; | 
| 1705 | } | 1722 | } | 
| 1706 | 1723 | #else | |
| 1724 | static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, | ||
| 1725 | const struct ide_port_info *d) | ||
| 1726 | { | ||
| 1727 | return -EOPNOTSUPP; | ||
| 1728 | } | ||
| 1707 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ | 1729 | #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ | 
| 1708 | 1730 | ||
| 1709 | module_init(pmac_ide_probe); | 1731 | module_init(pmac_ide_probe); | 
