Lines Matching +full:hw +full:- +full:settle +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * These IDE interfaces are memory-mapped and have a DBDMA channel
8 * Copyright (C) 1998-2003 Paul Mackerras & Ben. Herrenschmidt
9 * Copyright (C) 2007-2008 Bartlomiej Zolnierkiewicz
11 * Some code taken from drivers/ide/ide-dma.c:
13 * Copyright (c) 1995-1998 Mark Lord
15 * TODO: - Use pre-calculated (kauai) timing tables all the time and
44 #define DRV_NAME "ide-pmac"
75 controller_kl_ata3, /* KeyLargo ATA-3 */
76 controller_kl_ata4, /* KeyLargo ATA-4 */
77 controller_un_ata6, /* UniNorth2 ATA-6 */
78 controller_k2_ata6, /* K2 ATA-6 */
79 controller_sh_ata6, /* Shasta ATA-6 */
85 "KeyLargo ATA-3", /* KeyLargo ATA-3 (MDMA only) */
86 "KeyLargo ATA-4", /* KeyLargo ATA-4 (UDMA/66) */
87 "UniNorth ATA-6", /* UniNorth2 ATA-6 (UDMA/100) */
88 "K2 ATA-6", /* K2 ATA-6 (UDMA/100) */
89 "Shasta ATA-6", /* Shasta ATA-6 (UDMA/133) */
93 * Extra registers, both 32-bit little-endian
108 #define SYSCLK_TICKS(t) (((t) + IDE_SYSCLK_NS - 1) / IDE_SYSCLK_NS)
109 #define SYSCLK_TICKS_66(t) (((t) + IDE_SYSCLK_66_NS - 1) / IDE_SYSCLK_66_NS)
129 * So far, I'm using pre-calculated tables for this extracted from
135 * cycle time in units of 10ns. Bits 8..15 are used by I don't
149 * - Write data setup, which appears to match the cycle time. They
151 * - Ready to pause time (from spec)
152 * - Address setup. That one is weird. I don't see where exactly
157 * Apple also add 60ns to the write data setup (or cycle time ?) on
164 #define TR_66_UDMA_RDY2PAUS_MASK 0x1e000000 /* Ready 2 pause time */
166 #define TR_66_UDMA_WRDATASETUP_MASK 0x01e00000 /* Write data setup time */
182 * The access time and recovery time can be programmed. Some older
183 * Darwin code base limit OHare to 150ns cycle time. I decided to do
186 * time and removes one from recovery. It's not supported on KeyLargo
267 /* KeyLargo ATA-4 Ultra DMA timings (rounded) */
396 * from MacOS...) --BenH.
403 ((void __iomem *)((drive)->hwif->io_ports.data_addr + (x)))
412 ide_hwif_t *hwif = drive->hwif; in pmac_ide_apply_timings()
413 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_apply_timings()
415 if (drive->dn & 1) in pmac_ide_apply_timings()
416 writel(pmif->timings[1], PMAC_IDE_REG(IDE_TIMING_CONFIG)); in pmac_ide_apply_timings()
418 writel(pmif->timings[0], PMAC_IDE_REG(IDE_TIMING_CONFIG)); in pmac_ide_apply_timings()
429 ide_hwif_t *hwif = drive->hwif; in pmac_ide_kauai_apply_timings()
430 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_kauai_apply_timings()
432 if (drive->dn & 1) { in pmac_ide_kauai_apply_timings()
433 writel(pmif->timings[1], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG)); in pmac_ide_kauai_apply_timings()
434 writel(pmif->timings[3], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG)); in pmac_ide_kauai_apply_timings()
436 writel(pmif->timings[0], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG)); in pmac_ide_kauai_apply_timings()
437 writel(pmif->timings[2], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG)); in pmac_ide_kauai_apply_timings()
448 ide_hwif_t *hwif = drive->hwif; in pmac_ide_do_update_timings()
449 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_do_update_timings()
451 if (pmif->kind == controller_sh_ata6 || in pmac_ide_do_update_timings()
452 pmif->kind == controller_un_ata6 || in pmac_ide_do_update_timings()
453 pmif->kind == controller_k2_ata6) in pmac_ide_do_update_timings()
463 writeb(drive->select | ATA_DEVICE_OBS, in pmac_dev_select()
464 (void __iomem *)drive->hwif->io_ports.device_addr); in pmac_dev_select()
471 writeb(drive->select | ATA_DEVICE_OBS, in pmac_kauai_dev_select()
472 (void __iomem *)drive->hwif->io_ports.device_addr); in pmac_kauai_dev_select()
477 writeb(cmd, (void __iomem *)hwif->io_ports.command_addr); in pmac_exec_command()
478 (void)readl((void __iomem *)(hwif->io_ports.data_addr in pmac_exec_command()
484 writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr); in pmac_write_devctl()
485 (void)readl((void __iomem *)(hwif->io_ports.data_addr in pmac_write_devctl()
490 * Old tuning functions (called on hdparm -p), sets up drive PIO timings
494 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_set_pio_mode()
495 const u8 pio = drive->pio_mode - XFER_PIO_0; in pmac_ide_set_pio_mode()
503 timings = &pmif->timings[drive->dn & 1]; in pmac_ide_set_pio_mode()
508 switch (pmif->kind) { in pmac_ide_set_pio_mode()
524 recTime = cycle_time - tim->active - tim->setup; in pmac_ide_set_pio_mode()
526 accessTime = tim->active; in pmac_ide_set_pio_mode()
539 recTime = cycle_time - tim->active - tim->setup; in pmac_ide_set_pio_mode()
541 accessTime = tim->active; in pmac_ide_set_pio_mode()
548 recTicks = max(recTicks, 5U) - 4; in pmac_ide_set_pio_mode()
550 recTicks--; /* guess, but it's only for PIO0, so... */ in pmac_ide_set_pio_mode()
564 drive->name, pio, *timings); in pmac_ide_set_pio_mode()
610 tr = kauai_lookup_timing(kauai_udma_timings, (int)t->udma); in set_timings_udma_ata6()
628 tr = kauai_lookup_timing(shasta_udma133_timings, (int)t->udma); in set_timings_udma_shasta()
642 u16 *id = drive->id; in set_timings_mdma()
648 /* Get default cycle time for mode */ in set_timings_mdma()
658 /* Check if drive provides explicit DMA cycle time */ in set_timings_mdma()
683 i = -1; in set_timings_mdma()
695 drive->name, cycleTime, accessTime, recTime); in set_timings_mdma()
751 recTicks = max(recTicks, 2U) - 1; in set_timings_mdma()
755 ((accessTime - IDE_SYSCLK_NS/2) >= origAccessTime) && in set_timings_mdma()
756 ((recTime - IDE_SYSCLK_NS/2) >= origRecTime)) { in set_timings_mdma()
758 accessTicks--; in set_timings_mdma()
769 drive->name, speed & 0xf, *timings); in set_timings_mdma()
775 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_set_dma_mode()
778 u8 unit = drive->dn & 1; in pmac_ide_set_dma_mode()
779 const u8 speed = drive->dma_mode; in pmac_ide_set_dma_mode()
781 timings = &pmif->timings[unit]; in pmac_ide_set_dma_mode()
782 timings2 = &pmif->timings[unit+2]; in pmac_ide_set_dma_mode()
789 if (pmif->kind == controller_kl_ata4) in pmac_ide_set_dma_mode()
791 else if (pmif->kind == controller_un_ata6 in pmac_ide_set_dma_mode()
792 || pmif->kind == controller_k2_ata6) in pmac_ide_set_dma_mode()
794 else if (pmif->kind == controller_sh_ata6) in pmac_ide_set_dma_mode()
797 ret = -1; in pmac_ide_set_dma_mode()
799 set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed); in pmac_ide_set_dma_mode()
813 * wakeup from sleep time, before we do real calculation
820 switch(pmif->kind) { in sanitize_timings()
842 pmif->timings[0] = pmif->timings[1] = value; in sanitize_timings()
843 pmif->timings[2] = pmif->timings[3] = value2; in sanitize_timings()
848 return pmif->mdev && pmif->mdev->media_bay != NULL; in on_media_bay()
857 pmif->timings[0] = 0; in pmac_ide_do_suspend()
858 pmif->timings[1] = 0; in pmac_ide_do_suspend()
860 disable_irq(pmif->irq); in pmac_ide_do_suspend()
867 if (pmif->kauai_fcr) { in pmac_ide_do_suspend()
868 u32 fcr = readl(pmif->kauai_fcr); in pmac_ide_do_suspend()
870 writel(fcr, pmif->kauai_fcr); in pmac_ide_do_suspend()
874 ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, in pmac_ide_do_suspend()
885 /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */ in pmac_ide_do_resume()
887 ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1); in pmac_ide_do_resume()
888 ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1); in pmac_ide_do_resume()
890 ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0); in pmac_ide_do_resume()
893 if (pmif->kauai_fcr) { in pmac_ide_do_resume()
894 u32 fcr = readl(pmif->kauai_fcr); in pmac_ide_do_resume()
896 writel(fcr, pmif->kauai_fcr); in pmac_ide_do_resume()
905 enable_irq(pmif->irq); in pmac_ide_do_resume()
912 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_cable_detect()
913 struct device_node *np = pmif->node; in pmac_ide_cable_detect()
914 const char *cable = of_get_property(np, "cable-type", NULL); in pmac_ide_cable_detect()
919 /* Get cable type from device-tree. */ in pmac_ide_cable_detect()
920 if (cable && !strncmp(cable, "80-", 3)) { in pmac_ide_cable_detect()
930 * G5's seem to have incorrect cable type in device-tree. in pmac_ide_cable_detect()
934 if (of_device_is_compatible(np, "K2-UATA") || in pmac_ide_cable_detect()
935 of_device_is_compatible(np, "shasta-ata")) in pmac_ide_cable_detect()
943 ide_hwif_t *hwif = drive->hwif; in pmac_ide_init_dev()
944 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_init_dev()
947 if (check_media_bay(pmif->mdev->media_bay) == MB_CD) { in pmac_ide_init_dev()
948 drive->dev_flags &= ~IDE_DFLAG_NOPROBE; in pmac_ide_init_dev()
951 drive->dev_flags |= IDE_DFLAG_NOPROBE; in pmac_ide_init_dev()
1017 static int pmac_ide_setup_device(pmac_ide_hwif_t *pmif, struct ide_hw *hw) in pmac_ide_setup_device() argument
1019 struct device_node *np = pmif->node; in pmac_ide_setup_device()
1022 struct ide_hw *hws[] = { hw }; in pmac_ide_setup_device()
1026 pmif->broken_dma = pmif->broken_dma_warn = 0; in pmac_ide_setup_device()
1027 if (of_device_is_compatible(np, "shasta-ata")) { in pmac_ide_setup_device()
1028 pmif->kind = controller_sh_ata6; in pmac_ide_setup_device()
1032 } else if (of_device_is_compatible(np, "kauai-ata")) { in pmac_ide_setup_device()
1033 pmif->kind = controller_un_ata6; in pmac_ide_setup_device()
1037 } else if (of_device_is_compatible(np, "K2-UATA")) { in pmac_ide_setup_device()
1038 pmif->kind = controller_k2_ata6; in pmac_ide_setup_device()
1042 } else if (of_device_is_compatible(np, "keylargo-ata")) { in pmac_ide_setup_device()
1043 if (of_node_name_eq(np, "ata-4")) { in pmac_ide_setup_device()
1044 pmif->kind = controller_kl_ata4; in pmac_ide_setup_device()
1048 pmif->kind = controller_kl_ata3; in pmac_ide_setup_device()
1049 } else if (of_device_is_compatible(np, "heathrow-ata")) { in pmac_ide_setup_device()
1050 pmif->kind = controller_heathrow; in pmac_ide_setup_device()
1052 pmif->kind = controller_ohare; in pmac_ide_setup_device()
1053 pmif->broken_dma = 1; in pmac_ide_setup_device()
1056 bidp = of_get_property(np, "AAPL,bus-id", NULL); in pmac_ide_setup_device()
1057 pmif->aapl_bus_id = bidp ? *bidp : 0; in pmac_ide_setup_device()
1059 /* On Kauai-type controllers, we make sure the FCR is correct */ in pmac_ide_setup_device()
1060 if (pmif->kauai_fcr) in pmac_ide_setup_device()
1063 KAUAI_FCR_UATA_ENABLE, pmif->kauai_fcr); in pmac_ide_setup_device()
1068 /* If we are on a media bay, wait for it to settle and lock it */ in pmac_ide_setup_device()
1069 if (pmif->mdev) in pmac_ide_setup_device()
1070 lock_media_bay(pmif->mdev->media_bay); in pmac_ide_setup_device()
1074 rc = -ENOMEM; in pmac_ide_setup_device()
1077 pmif->hwif = host->ports[0]; in pmac_ide_setup_device()
1082 pmif->aapl_bus_id = 1; in pmac_ide_setup_device()
1083 } else if (pmif->kind == controller_ohare) { in pmac_ide_setup_device()
1090 /* This is necessary to enable IDE when net-booting */ in pmac_ide_setup_device()
1091 ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1); in pmac_ide_setup_device()
1092 ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1); in pmac_ide_setup_device()
1094 ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0); in pmac_ide_setup_device()
1099 "bus ID %d%s, irq %d\n", model_name[pmif->kind], in pmac_ide_setup_device()
1100 pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id, in pmac_ide_setup_device()
1101 on_media_bay(pmif) ? " (mediabay)" : "", hw->irq); in pmac_ide_setup_device()
1105 pmif->hwif = NULL; in pmac_ide_setup_device()
1107 if (pmif->mdev) in pmac_ide_setup_device()
1108 unlock_media_bay(pmif->mdev->media_bay); in pmac_ide_setup_device()
1116 static void pmac_ide_init_ports(struct ide_hw *hw, unsigned long base) in pmac_ide_init_ports() argument
1121 hw->io_ports_array[i] = base + i * 0x10; in pmac_ide_init_ports()
1123 hw->io_ports.ctl_addr = base + 0x160; in pmac_ide_init_ports()
1136 struct ide_hw hw; in pmac_ide_macio_attach() local
1140 return -ENOMEM; in pmac_ide_macio_attach()
1143 printk(KERN_WARNING "ide-pmac: no address for %pOF\n", in pmac_ide_macio_attach()
1144 mdev->ofdev.dev.of_node); in pmac_ide_macio_attach()
1145 rc = -ENXIO; in pmac_ide_macio_attach()
1150 if (macio_request_resource(mdev, 0, "ide-pmac (ports)")) { in pmac_ide_macio_attach()
1151 printk(KERN_ERR "ide-pmac: can't request MMIO resource for " in pmac_ide_macio_attach()
1152 "%pOF!\n", mdev->ofdev.dev.of_node); in pmac_ide_macio_attach()
1153 rc = -EBUSY; in pmac_ide_macio_attach()
1163 printk(KERN_WARNING "ide-pmac: no intrs for device %pOF, using " in pmac_ide_macio_attach()
1164 "13\n", mdev->ofdev.dev.of_node); in pmac_ide_macio_attach()
1172 pmif->mdev = mdev; in pmac_ide_macio_attach()
1173 pmif->node = mdev->ofdev.dev.of_node; in pmac_ide_macio_attach()
1174 pmif->regbase = regbase; in pmac_ide_macio_attach()
1175 pmif->irq = irq; in pmac_ide_macio_attach()
1176 pmif->kauai_fcr = NULL; in pmac_ide_macio_attach()
1179 if (macio_request_resource(mdev, 1, "ide-pmac (dma)")) in pmac_ide_macio_attach()
1180 printk(KERN_WARNING "ide-pmac: can't request DMA " in pmac_ide_macio_attach()
1182 mdev->ofdev.dev.of_node); in pmac_ide_macio_attach()
1184 pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000); in pmac_ide_macio_attach()
1186 pmif->dma_regs = NULL; in pmac_ide_macio_attach()
1188 dev_set_drvdata(&mdev->ofdev.dev, pmif); in pmac_ide_macio_attach()
1190 memset(&hw, 0, sizeof(hw)); in pmac_ide_macio_attach()
1191 pmac_ide_init_ports(&hw, pmif->regbase); in pmac_ide_macio_attach()
1192 hw.irq = irq; in pmac_ide_macio_attach()
1193 hw.dev = &mdev->bus->pdev->dev; in pmac_ide_macio_attach()
1194 hw.parent = &mdev->ofdev.dev; in pmac_ide_macio_attach()
1196 rc = pmac_ide_setup_device(pmif, &hw); in pmac_ide_macio_attach()
1199 dev_set_drvdata(&mdev->ofdev.dev, NULL); in pmac_ide_macio_attach()
1201 if (pmif->dma_regs) { in pmac_ide_macio_attach()
1202 iounmap(pmif->dma_regs); in pmac_ide_macio_attach()
1219 pmac_ide_hwif_t *pmif = dev_get_drvdata(&mdev->ofdev.dev); in pmac_ide_macio_suspend()
1222 if (mesg.event != mdev->ofdev.dev.power.power_state.event in pmac_ide_macio_suspend()
1226 mdev->ofdev.dev.power.power_state = mesg; in pmac_ide_macio_suspend()
1235 pmac_ide_hwif_t *pmif = dev_get_drvdata(&mdev->ofdev.dev); in pmac_ide_macio_resume()
1238 if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) { in pmac_ide_macio_resume()
1241 mdev->ofdev.dev.power.power_state = PMSG_ON; in pmac_ide_macio_resume()
1258 struct ide_hw hw; in pmac_ide_pci_attach() local
1262 printk(KERN_ERR "ide-pmac: cannot find MacIO node for Kauai ATA interface\n"); in pmac_ide_pci_attach()
1263 return -ENODEV; in pmac_ide_pci_attach()
1268 return -ENOMEM; in pmac_ide_pci_attach()
1271 printk(KERN_WARNING "ide-pmac: Can't enable PCI device for " in pmac_ide_pci_attach()
1273 rc = -ENXIO; in pmac_ide_pci_attach()
1279 printk(KERN_ERR "ide-pmac: Cannot obtain PCI resources for " in pmac_ide_pci_attach()
1281 rc = -ENXIO; in pmac_ide_pci_attach()
1285 pmif->mdev = NULL; in pmac_ide_pci_attach()
1286 pmif->node = np; in pmac_ide_pci_attach()
1292 pmif->regbase = (unsigned long) base + 0x2000; in pmac_ide_pci_attach()
1293 pmif->dma_regs = base + 0x1000; in pmac_ide_pci_attach()
1294 pmif->kauai_fcr = base; in pmac_ide_pci_attach()
1295 pmif->irq = pdev->irq; in pmac_ide_pci_attach()
1299 memset(&hw, 0, sizeof(hw)); in pmac_ide_pci_attach()
1300 pmac_ide_init_ports(&hw, pmif->regbase); in pmac_ide_pci_attach()
1301 hw.irq = pdev->irq; in pmac_ide_pci_attach()
1302 hw.dev = &pdev->dev; in pmac_ide_pci_attach()
1304 rc = pmac_ide_setup_device(pmif, &hw); in pmac_ide_pci_attach()
1325 if (mesg.event != pdev->dev.power.power_state.event in pmac_ide_pci_suspend()
1329 pdev->dev.power.power_state = mesg; in pmac_ide_pci_suspend()
1341 if (pdev->dev.power.power_state.event != PM_EVENT_ON) { in pmac_ide_pci_resume()
1344 pdev->dev.power.power_state = PMSG_ON; in pmac_ide_pci_resume()
1353 pmac_ide_hwif_t *pmif = dev_get_drvdata(&mdev->ofdev.dev); in pmac_ide_macio_mb_event()
1357 if (!pmif->hwif->present) in pmac_ide_macio_mb_event()
1358 ide_port_scan(pmif->hwif); in pmac_ide_macio_mb_event()
1361 if (pmif->hwif->present) in pmac_ide_macio_mb_event()
1362 ide_port_unregister_devices(pmif->hwif); in pmac_ide_macio_mb_event()
1388 .name = "ide-pmac",
1410 .name = "ide-pmac",
1423 return -ENODEV; in pmac_ide_probe()
1454 ide_hwif_t *hwif = drive->hwif; in pmac_ide_build_dmatable()
1455 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_build_dmatable()
1457 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; in pmac_ide_build_dmatable()
1459 int wr = !!(cmd->tf_flags & IDE_TFLAG_WRITE); in pmac_ide_build_dmatable()
1460 int i = cmd->sg_nents, count = 0; in pmac_ide_build_dmatable()
1463 table = (struct dbdma_cmd *) pmif->dma_table_cpu; in pmac_ide_build_dmatable()
1466 writel((RUN|PAUSE|FLUSH|WAKE|DEAD) << 16, &dma->control); in pmac_ide_build_dmatable()
1467 while (readl(&dma->status) & RUN) in pmac_ide_build_dmatable()
1471 sg = hwif->sg_table; in pmac_ide_build_dmatable()
1479 if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) { in pmac_ide_build_dmatable()
1480 if (pmif->broken_dma_warn == 0) { in pmac_ide_build_dmatable()
1482 "switching to PIO on Ohare chipset\n", drive->name); in pmac_ide_build_dmatable()
1483 pmif->broken_dma_warn = 1; in pmac_ide_build_dmatable()
1492 drive->name); in pmac_ide_build_dmatable()
1495 table->command = cpu_to_le16(wr? OUTPUT_MORE: INPUT_MORE); in pmac_ide_build_dmatable()
1496 table->req_count = cpu_to_le16(tc); in pmac_ide_build_dmatable()
1497 table->phy_addr = cpu_to_le32(cur_addr); in pmac_ide_build_dmatable()
1498 table->cmd_dep = 0; in pmac_ide_build_dmatable()
1499 table->xfer_status = 0; in pmac_ide_build_dmatable()
1500 table->res_count = 0; in pmac_ide_build_dmatable()
1502 cur_len -= tc; in pmac_ide_build_dmatable()
1506 i--; in pmac_ide_build_dmatable()
1511 table[-1].command = cpu_to_le16(wr? OUTPUT_LAST: INPUT_LAST); in pmac_ide_build_dmatable()
1514 table->command = cpu_to_le16(DBDMA_STOP); in pmac_ide_build_dmatable()
1516 writel(hwif->dmatable_dma, &dma->cmdptr); in pmac_ide_build_dmatable()
1520 printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name); in pmac_ide_build_dmatable()
1531 ide_hwif_t *hwif = drive->hwif; in pmac_ide_dma_setup()
1532 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_dma_setup()
1533 u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4); in pmac_ide_dma_setup()
1534 u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE); in pmac_ide_dma_setup()
1540 if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) { in pmac_ide_dma_setup()
1541 writel(pmif->timings[unit] + (write ? 0 : 0x00800000UL), in pmac_ide_dma_setup()
1556 ide_hwif_t *hwif = drive->hwif; in pmac_ide_dma_start()
1557 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_dma_start()
1560 dma = pmif->dma_regs; in pmac_ide_dma_start()
1562 writel((RUN << 16) | RUN, &dma->control); in pmac_ide_dma_start()
1564 (void)readl(&dma->control); in pmac_ide_dma_start()
1573 ide_hwif_t *hwif = drive->hwif; in pmac_ide_dma_end()
1574 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_dma_end()
1575 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; in pmac_ide_dma_end()
1578 dstat = readl(&dma->status); in pmac_ide_dma_end()
1579 writel(((RUN|WAKE|DEAD) << 16), &dma->control); in pmac_ide_dma_end()
1597 ide_hwif_t *hwif = drive->hwif; in pmac_ide_dma_test_irq()
1598 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_dma_test_irq()
1599 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; in pmac_ide_dma_test_irq()
1604 * - The dbdma won't stop if the command was started in pmac_ide_dma_test_irq()
1607 * a multi-block transfer. in pmac_ide_dma_test_irq()
1609 * - The dbdma fifo hasn't yet finished flushing to in pmac_ide_dma_test_irq()
1617 status = readl(&dma->status); in pmac_ide_dma_test_irq()
1628 writel((FLUSH << 16) | FLUSH, &dma->control); in pmac_ide_dma_test_irq()
1632 status = readl(&dma->status); in pmac_ide_dma_test_irq()
1637 hwif->index); in pmac_ide_dma_test_irq()
1651 ide_hwif_t *hwif = drive->hwif; in pmac_ide_dma_lost_irq()
1652 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_dma_lost_irq()
1653 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; in pmac_ide_dma_lost_irq()
1654 unsigned long status = readl(&dma->status); in pmac_ide_dma_lost_irq()
1656 printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); in pmac_ide_dma_lost_irq()
1674 pmac_ide_hwif_t *pmif = dev_get_drvdata(hwif->gendev.parent); in pmac_ide_init_dma()
1675 struct pci_dev *dev = to_pci_dev(hwif->dev); in pmac_ide_init_dma()
1680 if (dev == NULL || pmif->dma_regs == 0) in pmac_ide_init_dma()
1681 return -ENODEV; in pmac_ide_init_dma()
1687 pmif->dma_table_cpu = dma_alloc_coherent(&dev->dev, in pmac_ide_init_dma()
1689 &hwif->dmatable_dma, GFP_KERNEL); in pmac_ide_init_dma()
1690 if (pmif->dma_table_cpu == NULL) { in pmac_ide_init_dma()
1692 hwif->name); in pmac_ide_init_dma()
1693 return -ENOMEM; in pmac_ide_init_dma()
1696 hwif->sg_max_nents = MAX_DCMDS; in pmac_ide_init_dma()