Lines Matching +full:udma +full:- +full:c

1 // SPDX-License-Identifier: GPL-2.0-only
3 * pata_amd.c - AMD PATA for new ATA layer
4 * (C) 2005-2006 Red Hat Inc
6 * Based on pata-sil680. Errata information is taken from data sheets
7 * and the amd74xx.c driver by Vojtech Pavlik. Nvidia SATA devices are
8 * claimed by sata-nv.c.
30 * timing_setup - shared timing computation and load
49 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in timing_setup()
51 int dn = ap->port_no * 2 + adev->devno; in timing_setup()
63 dev_err(&pdev->dev, "unknown mode %d\n", speed); in timing_setup()
69 if (peer->dma_mode) { in timing_setup()
70 ata_timing_compute(peer, peer->dma_mode, &apeer, T, UT); in timing_setup()
73 ata_timing_compute(peer, peer->pio_mode, &apeer, T, UT); in timing_setup()
77 if (speed == XFER_UDMA_5 && amd_clock <= 33333) at.udma = 1; in timing_setup()
78 if (speed == XFER_UDMA_6 && amd_clock <= 33333) at.udma = 15; in timing_setup()
86 t = (t & ~(3 << ((3 - dn) << 1))) | ((clamp_val(at.setup, 1, 4) - 1) << ((3 - dn) << 1)); in timing_setup()
90 pci_write_config_byte(pdev, offset + 0x0E + (1 - (dn >> 1)), in timing_setup()
91 ((clamp_val(at.act8b, 1, 16) - 1) << 4) | (clamp_val(at.rec8b, 1, 16) - 1)); in timing_setup()
94 pci_write_config_byte(pdev, offset + 0x08 + (3 - dn), in timing_setup()
95 ((clamp_val(at.active, 1, 16) - 1) << 4) | (clamp_val(at.recover, 1, 16) - 1)); in timing_setup()
99 t = at.udma ? (0xc0 | (clamp_val(at.udma, 2, 5) - 2)) : 0x03; in timing_setup()
103 t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val(at.udma, 2, 10)]) : 0x03; in timing_setup()
107 t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val(at.udma, 1, 10)]) : 0x03; in timing_setup()
111 t = at.udma ? (0xc0 | amd_cyc2udma[clamp_val(at.udma, 1, 15)]) : 0x03; in timing_setup()
118 /* UDMA timing */ in timing_setup()
119 if (at.udma) in timing_setup()
120 pci_write_config_byte(pdev, offset + 0x10 + (3 - dn), t); in timing_setup()
124 * amd_pre_reset - perform reset handling
139 struct ata_port *ap = link->ap; in amd_pre_reset()
140 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in amd_pre_reset()
142 if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) in amd_pre_reset()
143 return -ENOENT; in amd_pre_reset()
149 * amd_cable_detect - report cable type
158 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in amd_cable_detect()
162 if (ata66 & bitmask[ap->port_no]) in amd_cable_detect()
168 * amd_fifo_setup - set the PIO FIFO for ATA/ATAPI
181 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in amd_fifo_setup()
183 u8 fifo = fifobit[ap->port_no]; in amd_fifo_setup()
187 ata_for_each_dev(adev, &ap->link, ENABLED) { in amd_fifo_setup()
188 if (adev->class == ATA_DEV_ATAPI) in amd_fifo_setup()
191 if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7411) /* FIFO is broken */ in amd_fifo_setup()
194 /* On the later chips the read prefetch bits become no-op bits */ in amd_fifo_setup()
196 r &= ~fifobit[ap->port_no]; in amd_fifo_setup()
202 * amd33_set_piomode - set initial PIO mode data
212 timing_setup(ap, adev, 0x40, adev->pio_mode, 1); in amd33_set_piomode()
218 timing_setup(ap, adev, 0x40, adev->pio_mode, 2); in amd66_set_piomode()
224 timing_setup(ap, adev, 0x40, adev->pio_mode, 3); in amd100_set_piomode()
230 timing_setup(ap, adev, 0x40, adev->pio_mode, 4); in amd133_set_piomode()
234 * amd33_set_dmamode - set initial DMA mode data
238 * Program the MWDMA/UDMA modes for the AMD and Nvidia
244 timing_setup(ap, adev, 0x40, adev->dma_mode, 1); in amd33_set_dmamode()
249 timing_setup(ap, adev, 0x40, adev->dma_mode, 2); in amd66_set_dmamode()
254 timing_setup(ap, adev, 0x40, adev->dma_mode, 3); in amd100_set_dmamode()
259 timing_setup(ap, adev, 0x40, adev->dma_mode, 4); in amd133_set_dmamode()
262 /* Both host-side and drive-side detection results are worthless on NV
274 struct ata_port *ap = dev->link->ap; in nv_mode_filter()
276 u32 saved_udma, udma; in nv_mode_filter() local
281 udma = saved_udma = (unsigned long)ap->host->private_data; in nv_mode_filter()
283 if (ap->port_no == 0) in nv_mode_filter()
284 udma >>= 16; in nv_mode_filter()
285 if (dev->devno == 0) in nv_mode_filter()
286 udma >>= 8; in nv_mode_filter()
288 if ((udma & 0xc0) == 0xc0) in nv_mode_filter()
289 bios_limit = ata_pack_xfermask(0, 0, udma_mask_map[udma & 0x7]); in nv_mode_filter()
297 gtm->drive[0].dma, gtm->drive[1].dma, gtm->flags); in nv_mode_filter()
314 ata_port_dbg(ap, "nv_mode_filter: 0x%lx&0x%lx->0x%lx, " in nv_mode_filter()
323 * nv_probe_init - cable detection
337 struct ata_port *ap = link->ap; in nv_pre_reset()
338 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in nv_pre_reset()
340 if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no])) in nv_pre_reset()
341 return -ENOENT; in nv_pre_reset()
347 * nv100_set_piomode - set initial PIO mode data
356 timing_setup(ap, adev, 0x50, adev->pio_mode, 3); in nv100_set_piomode()
361 timing_setup(ap, adev, 0x50, adev->pio_mode, 4); in nv133_set_piomode()
365 * nv100_set_dmamode - set initial DMA mode data
369 * Program the MWDMA/UDMA modes for the AMD and Nvidia
375 timing_setup(ap, adev, 0x50, adev->dma_mode, 3); in nv100_set_dmamode()
380 timing_setup(ap, adev, 0x50, adev->dma_mode, 4); in nv133_set_dmamode()
385 u32 udma = (unsigned long)host->private_data; in nv_host_stop() local
388 pci_write_config_dword(to_pci_dev(host->dev), 0x60, udma); in nv_host_stop()
451 /* Disable the FIFO, the FIFO logic will re-enable it as in amd_clear_fifo()
461 { /* 0: AMD 7401 - no swdma */ in amd_init_one()
468 { /* 1: Early AMD7409 - no swdma */ in amd_init_one()
496 { /* 5: AMD 8111 - no swdma */ in amd_init_one()
503 { /* 6: AMD 8111 UDMA 100 (Serenade) - no swdma */ in amd_init_one()
517 { /* 8: Nvidia Nforce2 and later - no swdma */ in amd_init_one()
533 int type = id->driver_data; in amd_init_one()
538 ata_print_version_once(&pdev->dev, DRV_VERSION); in amd_init_one()
547 if (type == 1 && pdev->revision > 0x7) in amd_init_one()
551 if (type == 5 && pdev->subsystem_vendor == PCI_VENDOR_ID_AMD && in amd_init_one()
552 pdev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) in amd_init_one()
553 type = 6; /* UDMA 100 only */ in amd_init_one()
556 * Okay, type is determined now. Apply type-specific workarounds. in amd_init_one()
562 if (pdev->vendor == PCI_VENDOR_ID_AMD) in amd_init_one()
565 * cache BIOS programmed UDMA mode. in amd_init_one()
568 u32 udma; in amd_init_one() local
570 pci_read_config_dword(pdev, 0x60, &udma); in amd_init_one()
571 hpriv = (void *)(unsigned long)udma; in amd_init_one()
588 if (pdev->vendor == PCI_VENDOR_ID_AMD) { in amd_reinit_one()
590 if (pdev->device == PCI_DEVICE_ID_AMD_VIPER_7409 || in amd_reinit_one()
591 pdev->device == PCI_DEVICE_ID_AMD_COBRA_7401) in amd_reinit_one()
639 MODULE_DESCRIPTION("low-level driver for AMD and Nvidia PATA IDE");