// SPDX-License-Identifier: GPL-2.0-only /* * pata_via.c - VIA PATA for new ATA layer * (C) 2005-2006 Red Hat Inc * * Documentation * Most chipset documentation available under NDA only * * VIA version guide * VIA VT82C561 - early design, uses ata_generic currently * VIA VT82C576 - MWDMA, 33Mhz * VIA VT82C586 - MWDMA, 33Mhz * VIA VT82C586a - Added UDMA to 33Mhz * VIA VT82C586b - UDMA33 * VIA VT82C596a - Nonfunctional UDMA66 * VIA VT82C596b - Working UDMA66 * VIA VT82C686 - Nonfunctional UDMA66 * VIA VT82C686a - Working UDMA66 * VIA VT82C686b - Updated to UDMA100 * VIA VT8231 - UDMA100 * VIA VT8233 - UDMA100 * VIA VT8233a - UDMA133 * VIA VT8233c - UDMA100 * VIA VT8235 - UDMA133 * VIA VT8237 - UDMA133 * VIA VT8237A - UDMA133 * VIA VT8237S - UDMA133 * VIA VT8251 - UDMA133 * * Most registers remain compatible across chips. Others start reserved * and acquire sensible semantics if set to 1 (eg cable detect). A few * exceptions exist, notably around the FIFO settings. * * One additional quirk of the VIA design is that like ALi they use few * PCI IDs for a lot of chips. * * Based heavily on: * * Version 3.38 * * VIA IDE driver for Linux. Supported southbridges: * * vt82c576, vt82c586, vt82c586a, vt82c586b, vt82c596a, vt82c596b, * vt82c686, vt82c686a, vt82c686b, vt8231, vt8233, vt8233c, vt8233a, * vt8235, vt8237 * * Copyright (c) 2000-2002 Vojtech Pavlik * * Based on the work of: * Michel Aubry * Jeff Garzik * Andre Hedrick
staticint via_cable_override(struct pci_dev *pdev)
{ /* Systems by DMI */ if (dmi_check_system(cable_dmi_table)) return 1; /* Arima W730-K8/Targa Visionary 811/... */ if (pdev->subsystem_vendor == 0x161F && pdev->subsystem_device == 0x2032) return 1; return 0;
}
/** * via_cable_detect - cable detection * @ap: ATA port * * Perform cable detection. Actually for the VIA case the BIOS * already did this for us. We read the values provided by the * BIOS. If you are using an 8235 in a non-PC configuration you * may need to update this code. * * Hotplug also impacts on this.
*/
if (via_cable_override(pdev)) return ATA_CBL_PATA40_SHORT;
if ((config->flags & VIA_SATA_PATA) && ap->port_no == 0) return ATA_CBL_SATA;
/* Early chips are 40 wire */ if (config->udma_mask < ATA_UDMA4) return ATA_CBL_PATA40; /* UDMA 66 chips have only drive side logic */ elseif (config->udma_mask < ATA_UDMA5) return ATA_CBL_PATA_UNK; /* UDMA 100 or later */
pci_read_config_dword(pdev, 0x50, &ata66); /* Check both the drive cable reporting bits, we might not have
two drives */ if (ata66 & (0x10100000 >> (16 * ap->port_no))) return ATA_CBL_PATA80;
/* Check with ACPI so we can spot BIOS reported SATA bridges */ return ata_acpi_cbl_pata_type(ap);
}
/** * via_do_set_mode - set transfer mode data * @ap: ATA interface * @adev: ATA device * @mode: ATA mode being programmed * @set_ast: Set to program address setup * @udma_type: UDMA mode/format of registers * * Program the VIA registers for DMA and PIO modes. Uses the ata timing * support in order to compute modes. * * FIXME: Hotplug will require we serialize multiple mode changes * on the two channels.
*/
staticvoid via_do_set_mode(struct ata_port *ap, struct ata_device *adev, int mode, int set_ast, int udma_type)
{ struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct ata_device *peer = ata_dev_pair(adev); struct ata_timing t, p; constint via_clock = 33333; /* Bus clock in kHz */ constint T = 1000000000 / via_clock; int UT = T; int ut; int offset = 3 - (2*ap->port_no) - adev->devno;
switch (udma_type) { case ATA_UDMA4:
UT = T / 2; break; case ATA_UDMA5:
UT = T / 3; break; case ATA_UDMA6:
UT = T / 4; break;
}
/* Calculate the timing values we require */
ata_timing_compute(adev, mode, &t, T, UT);
/* We share 8bit timing so we must merge the constraints */ if (peer) { if (peer->pio_mode) {
ata_timing_compute(peer, peer->pio_mode, &p, T, UT);
ata_timing_merge(&p, &t, &t, ATA_TIMING_8BIT);
}
}
/* Address setup is programmable but breaks on UDMA133 setups */ if (set_ast) {
u8 setup; /* 2 bits per drive */ int shift = 2 * offset;
/** * via_mode_filter - filter buggy device/mode pairs * @dev: ATA device * @mask: Mode bitmask * * We need to apply some minimal filtering for old controllers and at least * one breed of Transcend SSD. Return the updated mask.
*/
if (config->id == PCI_DEVICE_ID_VIA_82C586_0) {
ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); if (strcmp(model_num, "TS64GSSD25-M") == 0) {
ata_dev_warn(dev, "disabling UDMA mode due to reported lockups with this device\n");
mask &= ~ ATA_MASK_UDMA;
}
}
if (dev->class == ATA_DEV_ATAPI &&
(dmi_check_system(no_atapi_dma_dmi_table) ||
config->id == PCI_DEVICE_ID_VIA_6415)) {
ata_dev_warn(dev, "controller locks up on ATAPI DMA, forcing PIO\n");
mask &= ATA_MASK_PIO;
}
return mask;
}
/** * via_tf_load - send taskfile registers to host controller * @ap: Port to which output is sent * @tf: ATA taskfile register set * * Outputs ATA taskfile to standard ATA host controller. * * Note: This is to fix the internal bug of via chipsets, which * will reset the device register after changing the IEN bit on * ctl register
*/ staticvoid via_tf_load(struct ata_port *ap, conststruct ata_taskfile *tf)
{ struct ata_ioports *ioaddr = &ap->ioaddr; struct via_port *vp = ap->private_data; unsignedint is_addr = tf->flags & ATA_TFLAG_ISADDR; int newctl = 0;
/** * via_config_fifo - set up the FIFO * @pdev: PCI device * @flags: configuration flags * * Set the FIFO properties for this device if necessary. Used both on * set up and on and the resume path
*/
/* Initialise the FIFO for the enabled channels. */
via_config_fifo(pdev, config->flags);
if (config->udma_mask == ATA_UDMA4) { /* The 66 MHz devices require we enable the clock */
pci_read_config_dword(pdev, 0x50, &timing);
timing |= 0x80008;
pci_write_config_dword(pdev, 0x50, timing);
} if (config->flags & VIA_BAD_CLK66) { /* Disable the 66MHz clock on problem devices */
pci_read_config_dword(pdev, 0x50, &timing);
timing &= ~0x80008;
pci_write_config_dword(pdev, 0x50, timing);
}
}
/** * via_init_one - discovery callback * @pdev: PCI device * @id: PCI table info * * A VIA IDE interface has been discovered. Figure out what revision * and perform configuration work before handing it to the ATA layer
*/
if (flags & VIA_IDFLAG_SINGLE)
ppi[1] = &ata_dummy_port_info;
/* To find out how the IDE will behave and what features we
actually have to look at the bridge not the IDE controller */ for (config = via_isa_bridges; config->id != PCI_DEVICE_ID_VIA_ANON;
config++) if ((isa = pci_get_device(PCI_VENDOR_ID_VIA +
!!(config->flags & VIA_BAD_ID),
config->id, NULL))) {
u8 rev = isa->revision;
pci_dev_put(isa);
/* Clock set up */ switch (config->udma_mask) { case 0x00: if (config->flags & VIA_NO_UNMASK)
ppi[0] = &via_mwdma_info_borked; else
ppi[0] = &via_mwdma_info; break; case ATA_UDMA2:
ppi[0] = &via_udma33_info; break; case ATA_UDMA4:
ppi[0] = &via_udma66_info; break; case ATA_UDMA5:
ppi[0] = &via_udma100_info; break; case ATA_UDMA6:
ppi[0] = &via_udma133_info; break; default:
WARN_ON(1); return -ENODEV;
}
via_fixup(pdev, config);
/* We have established the device type, now fire it up */ return ata_pci_bmdma_init_one(pdev, ppi, &via_sht, (void *)config, 0);
}
#ifdef CONFIG_PM_SLEEP /** * via_reinit_one - reinit after resume * @pdev: PCI device * * Called when the VIA PATA device is resumed. We must then * reconfigure the fifo and other setup we may have altered. In * addition the kernel needs to have the resume methods on PCI * quirk supported.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.