Lines Matching +full:udma +full:- +full:p

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ata_piix.c - Intel PATA/SATA controllers
6 * Please ALWAYS copy linux-ide@vger.kernel.org
9 * Copyright 2003-2005 Red Hat Inc
10 * Copyright 2003-2005 Jeff Garzik
14 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
15 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
19 * as Documentation/driver-api/libata.rst
40 * PIIX4 errata #9 - Only on ultra obscure hw
41 * ICH3 errata #13 - Not observed to affect real hw
45 * PIIX4 errata #10 - BM IDE hang with non UDMA
47 * 440MX errata #15 - As PIIX4 errata #10
48 * PIIX4 errata #15 - Must not read control registers
50 * 440MX errata #13 - As PIIX4 errata #15
51 * ICH2 errata #21 - DMA mode 0 doesn't work right
52 * ICH0/1 errata #55 - As ICH2 errata #21
53 * ICH2 spec c #9 - Extra operations needed to handle
55 * ICH2 spec c #20 - IDE PRD must not cross a 64K boundary
57 * ICH2 spec c #24 - UDMA mode 4,5 t85/86 should be 6ns not 3.3
58 * ICH7 errata #16 - MWDMA1 timings are incorrect
61 * 450NX: errata #19 - DMA hangs on old 450NX
62 * 450NX: errata #20 - DMA hangs on old 450NX
63 * 450NX: errata #25 - Corruption with DMA on old 450NX
64 * ICH3 errata #15 - IDE deadlock under high load
66 * ICH3 errata #18 - Don't use native mode
110 IDE = -1, /* IDE */
111 NA = -2, /* not available */
112 RV = -3, /* reserved */
116 /* host->flags bits */
124 ich_pata_33, /* ICH up to UDMA 33 only */
126 ich_pata_100, /* ICH up to UDMA 100 */
127 ich_pata_100_nomwdma1, /* ICH up to UDMA 100 but with no MWDMA1*/
160 /* Intel PIIX4 for the 430TX/440BX/MX chipset: UDMA 33 */
169 /* Intel ICH (i810, i815, i840) UDMA 66*/
171 /* Intel ICH0 : UDMA 33*/
175 /* Intel ICH2 (i810E2, i845, 850, 860) UDMA 100 */
179 /* Intel ICH3 (E7500/1) UDMA 100 */
181 /* Intel ICH4-L */
183 /* Intel ICH4 (i845GV, i845E, i852, i855) UDMA 100 */
188 /* C-ICH (i810E2) */
190 /* ESB (855GME/875P + 6300ESB) UDMA 100 */
192 /* ICH6 (and 6) (i915) UDMA 100 */
194 /* ICH7/7-R (i945, i975) UDMA 100*/
296 /* SATA Controller IDE (Lynx Point-LP) */
298 /* SATA Controller IDE (Lynx Point-LP) */
300 /* SATA Controller IDE (Lynx Point-LP) */
302 /* SATA Controller IDE (Lynx Point-LP) */
451 MODULE_DESCRIPTION("SCSI low-level driver for Intel PIIX/ICH ATA controllers");
475 { 0x27DF, 0x1071, 0xD221 }, /* ICH7 on Hercules EC-900 */
479 { 0x24CA, 0x10CF, 0x11AB }, /* ICH4M on Fujitsu-Siemens Lifebook S6120 */
482 { 0x27df, 0x104d, 0x900e }, /* ICH7 on Sony TZ-90 */
489 if (!(ap->flags & PIIX_FLAG_PIO16)) in piix_port_start()
490 ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE; in piix_port_start()
496 * ich_pata_cable_detect - Probe host controller cable detect info
508 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in ich_pata_cable_detect()
509 struct piix_host_priv *hpriv = ap->host->private_data; in ich_pata_cable_detect()
514 while (lap->device) { in ich_pata_cable_detect()
515 if (lap->device == pdev->device && in ich_pata_cable_detect()
516 lap->subvendor == pdev->subsystem_vendor && in ich_pata_cable_detect()
517 lap->subdevice == pdev->subsystem_device) in ich_pata_cable_detect()
524 mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC; in ich_pata_cable_detect()
525 if ((hpriv->saved_iocfg & mask) == 0) in ich_pata_cable_detect()
531 * piix_pata_prereset - prereset for PATA host controller
540 struct ata_port *ap = link->ap; in piix_pata_prereset()
541 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in piix_pata_prereset()
543 if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) in piix_pata_prereset()
544 return -ENOENT; in piix_pata_prereset()
553 struct pci_dev *dev = to_pci_dev(ap->host->dev); in piix_set_timings()
555 unsigned int is_slave = (adev->devno != 0); in piix_set_timings()
556 unsigned int master_port= ap->port_no ? 0x42 : 0x40; in piix_set_timings()
564 * See Intel Document 298600-004 for the timing programing rules in piix_set_timings()
580 if (adev->class == ATA_DEV_ATA) in piix_set_timings()
586 if (adev->pio_mode < XFER_PIO_0 + pio) in piix_set_timings()
603 slave_data &= (ap->port_no ? 0x0f : 0xf0); in piix_set_timings()
606 << (ap->port_no ? 4 : 0); in piix_set_timings()
624 /* Ensure the UDMA bit is off - it will be turned back on if in piix_set_timings()
625 UDMA is selected */ in piix_set_timings()
627 if (ap->udma_mask) { in piix_set_timings()
629 udma_enable &= ~(1 << (2 * ap->port_no + adev->devno)); in piix_set_timings()
637 * piix_set_piomode - Initialize host controller PATA PIO timings
649 piix_set_timings(ap, adev, adev->pio_mode - XFER_PIO_0); in piix_set_piomode()
653 * do_pata_set_dmamode - Initialize host controller PATA PIO timings
658 * Set UDMA mode for device, in host controller PCI config space.
666 struct pci_dev *dev = to_pci_dev(ap->host->dev); in do_pata_set_dmamode()
668 u8 speed = adev->dma_mode; in do_pata_set_dmamode()
669 int devid = adev->devno + 2 * ap->port_no; in do_pata_set_dmamode()
673 unsigned int udma = speed - XFER_UDMA_0; in do_pata_set_dmamode() local
683 * UDMA is handled by a combination of clock switching and in do_pata_set_dmamode()
689 u_speed = min(2 - (udma & 1), udma); in do_pata_set_dmamode()
690 if (udma == 5) in do_pata_set_dmamode()
692 else if (udma > 2) in do_pata_set_dmamode()
720 unsigned int mwdma = speed - XFER_MW_DMA_0; in do_pata_set_dmamode()
724 int pio = needed_pio[mwdma] - XFER_PIO_0; in do_pata_set_dmamode()
732 * piix_set_dmamode - Initialize host controller PATA DMA timings
736 * Set MW/UDMA mode for device, in host controller PCI config space.
748 * ich_set_dmamode - Initialize host controller PATA DMA timings
752 * Set MW/UDMA mode for device, in host controller PCI config space.
779 struct ata_port *ap = link->ap; in piix_sidpr_sel()
780 struct piix_host_priv *hpriv = ap->host->private_data; in piix_sidpr_sel()
782 iowrite32(((ap->port_no * 2 + link->pmp) << 8) | piix_sidx_map[reg], in piix_sidpr_sel()
783 hpriv->sidpr + PIIX_SIDPR_IDX); in piix_sidpr_sel()
789 struct piix_host_priv *hpriv = link->ap->host->private_data; in piix_sidpr_scr_read()
792 return -EINVAL; in piix_sidpr_scr_read()
795 *val = ioread32(hpriv->sidpr + PIIX_SIDPR_DATA); in piix_sidpr_scr_read()
802 struct piix_host_priv *hpriv = link->ap->host->private_data; in piix_sidpr_scr_write()
805 return -EINVAL; in piix_sidpr_scr_write()
808 iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA); in piix_sidpr_scr_write()
822 if (unlikely(!ap->ioaddr.bmdma_addr)) in piix_irq_check()
825 host_stat = ap->ops->bmdma_status(ap); in piix_irq_check()
961 .ident = "VGN-BX297XP", in piix_broken_suspend()
964 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-BX297XP"), in piix_broken_suspend()
1011 if (pdev->current_state == PCI_D0) in piix_pci_device_suspend()
1012 pdev->current_state = PCI_UNKNOWN; in piix_pci_device_suspend()
1015 spin_lock_irqsave(&host->lock, flags); in piix_pci_device_suspend()
1016 host->flags |= PIIX_HOST_BROKEN_SUSPEND; in piix_pci_device_suspend()
1017 spin_unlock_irqrestore(&host->lock, flags); in piix_pci_device_suspend()
1030 if (host->flags & PIIX_HOST_BROKEN_SUSPEND) { in piix_pci_device_resume()
1031 spin_lock_irqsave(&host->lock, flags); in piix_pci_device_resume()
1032 host->flags &= ~PIIX_HOST_BROKEN_SUSPEND; in piix_pci_device_resume()
1033 spin_unlock_irqrestore(&host->lock, flags); in piix_pci_device_resume()
1044 dev_err(&pdev->dev, in piix_pci_device_resume()
1116 .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
1124 .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
1129 [ich_pata_33] = /* ICH0 - ICH at 33Mhz*/
1232 .mwdma_mask = ATA_MWDMA12_ONLY, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
1290 return -ENOMEM; in piix_disable_ahci()
1299 rc = -EIO; in piix_disable_ahci()
1307 * piix_check_450nx_errata - Check for problem 450NX setup
1325 if (pdev->revision == 0x00) in piix_check_450nx_errata()
1328 else if (cfg & (1<<14) && pdev->revision < 5) in piix_check_450nx_errata()
1332 dev_warn(&ata_dev->dev, in piix_check_450nx_errata()
1334 no_piix_dma == 2 ? " - a BIOS update may resolve this" in piix_check_450nx_errata()
1343 struct pci_dev *pdev = to_pci_dev(host->dev); in piix_init_pcs()
1348 new_pcs = pcs | map_db->port_enable; in piix_init_pcs()
1364 char *p = buf, *end = buf + sizeof(buf); in piix_init_sata_map() local
1368 map = map_db->map[map_value & map_db->mask]; in piix_init_sata_map()
1374 p += scnprintf(p, end - p, " XX"); in piix_init_sata_map()
1378 p += scnprintf(p, end - p, " --"); in piix_init_sata_map()
1385 p += scnprintf(p, end - p, " IDE IDE"); in piix_init_sata_map()
1389 p += scnprintf(p, end - p, " P%d", map[i]); in piix_init_sata_map()
1395 dev_info(&pdev->dev, "MAP [%s ]\n", buf); in piix_init_sata_map()
1398 dev_err(&pdev->dev, "invalid MAP value %u\n", map_value); in piix_init_sata_map()
1405 struct pci_dev *pdev = to_pci_dev(host->dev); in piix_no_sidpr()
1408 * Samsung DB-P70 only has three ATA ports exposed and in piix_no_sidpr()
1425 if (pdev->vendor == PCI_VENDOR_ID_INTEL && pdev->device == 0x2920 && in piix_no_sidpr()
1426 pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG && in piix_no_sidpr()
1427 pdev->subsystem_device == 0xb049) { in piix_no_sidpr()
1428 dev_warn(host->dev, in piix_no_sidpr()
1429 "Samsung DB-P70 detected, disabling SIDPR\n"); in piix_no_sidpr()
1438 struct pci_dev *pdev = to_pci_dev(host->dev); in piix_init_sidpr()
1439 struct piix_host_priv *hpriv = host->private_data; in piix_init_sidpr()
1440 struct ata_link *link0 = &host->ports[0]->link; in piix_init_sidpr()
1446 if (hpriv->map[i] == IDE) in piix_init_sidpr()
1452 if (!(host->ports[0]->flags & PIIX_FLAG_SIDPR)) in piix_init_sidpr()
1462 hpriv->sidpr = pcim_iomap_table(pdev)[PIIX_SIDPR_BAR]; in piix_init_sidpr()
1471 * un-inhibit power save modes as BIOS might have inhibited in piix_init_sidpr()
1480 dev_info(host->dev, in piix_init_sidpr()
1488 struct ata_port *ap = host->ports[i]; in piix_init_sidpr()
1490 ap->ops = &piix_sidpr_sata_ops; in piix_init_sidpr()
1492 if (ap->flags & ATA_FLAG_SLAVE_POSS) { in piix_init_sidpr()
1519 struct pci_dev *pdev = to_pci_dev(host->dev); in piix_iocfg_bit18_quirk()
1520 struct piix_host_priv *hpriv = host->private_data; in piix_iocfg_bit18_quirk()
1529 if (hpriv->saved_iocfg & (1 << 18)) { in piix_iocfg_bit18_quirk()
1530 dev_info(&pdev->dev, "applying IOCFG bit18 quirk\n"); in piix_iocfg_bit18_quirk()
1532 hpriv->saved_iocfg & ~(1 << 18)); in piix_iocfg_bit18_quirk()
1540 .ident = "HP Compaq 2510p", in piix_broken_system_poweroff()
1542 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), in piix_broken_system_poweroff()
1543 DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq 2510p"), in piix_broken_system_poweroff()
1551 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), in piix_broken_system_poweroff()
1563 unsigned long slot = (unsigned long)dmi->driver_data; in piix_broken_system_poweroff()
1564 /* apply the quirk only to on-board controllers */ in piix_broken_system_poweroff()
1565 return slot == PCI_SLOT(pdev->devfn); in piix_broken_system_poweroff()
1574 "Prefer Hyper-V paravirtualization drivers instead of ATA, "
1575 "0 - Use ATA drivers, "
1576 "1 (Default) - Use the paravirtualization drivers.");
1583 /* On Hyper-V hypervisors the disks are exposed on in piix_ignore_devices_quirk()
1589 .ident = "Hyper-V Virtual Machine", in piix_ignore_devices_quirk()
1601 * identical to a Hyper-V guest. One difference is the in piix_ignore_devices_quirk()
1620 host->flags |= ATA_HOST_IGNORE_ATA; in piix_ignore_devices_quirk()
1621 dev_info(host->dev, "%s detected, ATA device ignore set\n", in piix_ignore_devices_quirk()
1622 ignore->ident); in piix_ignore_devices_quirk()
1628 * piix_init_one - Register PIIX ATA PCI device with kernel services
1639 * Zero on success, or -ERRNO value.
1644 struct device *dev = &pdev->dev; in piix_init_one()
1653 ata_print_version_once(&pdev->dev, DRV_VERSION); in piix_init_one()
1656 if (!in_module_init && ent->driver_data >= ich5_sata) in piix_init_one()
1657 return -ENODEV; in piix_init_one()
1660 piix_port_info[ent->driver_data].flags |= in piix_init_one()
1663 dev_info(&pdev->dev, "quirky BIOS, skipping spindown " in piix_init_one()
1667 port_info[0] = piix_port_info[ent->driver_data]; in piix_init_one()
1668 port_info[1] = piix_port_info[ent->driver_data]; in piix_init_one()
1679 return -ENOMEM; in piix_init_one()
1686 pci_read_config_dword(pdev, PIIX_IOCFG, &hpriv->saved_iocfg); in piix_init_one()
1692 if (pdev->vendor == PCI_VENDOR_ID_INTEL && pdev->device == 0x2652) { in piix_init_one()
1700 hpriv->map = piix_init_sata_map(pdev, port_info, in piix_init_one()
1701 piix_map_db_table[ent->driver_data]); in piix_init_one()
1706 host->private_data = hpriv; in piix_init_one()
1710 piix_init_pcs(host, piix_map_db_table[ent->driver_data]); in piix_init_one()
1714 if (host->ports[0]->ops == &piix_sidpr_sata_ops) in piix_init_one()
1725 * message-signalled interrupts currently). in piix_init_one()
1734 host->ports[0]->mwdma_mask = 0; in piix_init_one()
1735 host->ports[0]->udma_mask = 0; in piix_init_one()
1736 host->ports[1]->mwdma_mask = 0; in piix_init_one()
1737 host->ports[1]->udma_mask = 0; in piix_init_one()
1739 host->flags |= ATA_HOST_PARALLEL_SCAN; in piix_init_one()
1751 struct piix_host_priv *hpriv = host->private_data; in piix_remove_one()
1753 pci_write_config_dword(pdev, PIIX_IOCFG, hpriv->saved_iocfg); in piix_remove_one()