// SPDX-License-Identifier: GPL-2.0-only /* * pata_optidma.c - Opti DMA PATA for new ATA layer * (C) 2006 Red Hat Inc * * The Opti DMA controllers are related to the older PIO PCI controllers * and indeed the VLB ones. The main differences are that the timing * numbers are now based off PCI clocks not VLB and differ, and that * MWDMA is supported. * * This driver should support Viper-N+, FireStar, FireStar Plus. * * These devices support virtual DMA for read (aka the CS5520). Later * chips support UDMA33, but only if the rest of the board logic does, * so you have to get this right. We don't support the virtual DMA * but we do handle UDMA. * * Bits that are worth knowing * Most control registers are shadowed into I/O registers * 0x1F5 bit 0 tells you if the PCI/VLB clock is 33 or 25Mhz * Virtual DMA registers *move* between rev 0x02 and rev 0x10 * UDMA requires a 66MHz FSB *
*/
enum {
READ_REG = 0, /* index of Read cycle timing register */
WRITE_REG = 1, /* index of Write cycle timing register */
CNTRL_REG = 3, /* index of Control register */
STRAP_REG = 5, /* index of Strap register */
MISC_REG = 6 /* index of Miscellaneous register */
};
staticint pci_clock; /* 0 = 33 1 = 25 */
/** * optidma_pre_reset - probe begin * @link: ATA link * @deadline: deadline jiffies for the operation * * Set up cable type and use generic probe init
*/
if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits)) return -ENOENT;
return ata_sff_prereset(link, deadline);
}
/** * optidma_unlock - unlock control registers * @ap: ATA port * * Unlock the control register block for this adapter. Registers must not * be unlocked in a situation where libata might look at them.
*/
/** * optidma_mode_setup - set mode data * @ap: ATA interface * @adev: ATA device * @mode: Mode to set * * Called to do the DMA or PIO mode setup. Timing numbers are all * pre computed to keep the code clean. There are two tables depending * on the hardware clock speed. * * WARNING: While we do this the IDE registers vanish. If we take an * IRQ here we depend on the host set locking to avoid catastrophe.
*/
/* Switch from IDE to control mode */
optidma_unlock(ap);
/* * As with many controllers the address setup time is shared * and must suit both devices if present. FIXME: Check if we * need to look at slowest of PIO/DMA mode of either device
*/
if (pair) {
u8 pair_addr; /* Hardware constraint */ if (ata_dma_enabled(pair))
pair_addr = 0; else
pair_addr = addr_timing[pci_clock][pair->pio_mode - XFER_PIO_0]; if (pair_addr > addr)
addr = pair_addr;
}
/* Commence primary programming sequence */ /* First we load the device number into the timing select */
iowrite8(adev->devno, regio + MISC_REG); /* Now we load the data timings into read data/write data */ if (mode < XFER_MW_DMA_0) {
iowrite8(data_rec_timing[pci_clock][pio], regio + READ_REG);
iowrite8(data_rec_timing[pci_clock][pio], regio + WRITE_REG);
} elseif (mode < XFER_UDMA_0) {
iowrite8(dma_data_rec_timing[pci_clock][dma], regio + READ_REG);
iowrite8(dma_data_rec_timing[pci_clock][dma], regio + WRITE_REG);
} /* Finally we load the address setup into the misc register */
iowrite8(addr | adev->devno, regio + MISC_REG);
/* Programming sequence complete, timing 0 dev 0, timing 1 dev 1 */
iowrite8(0x85, regio + CNTRL_REG);
/* Switch back to IDE mode */
optidma_lock(ap);
/* Note: at this point our programming is incomplete. We are not supposed to program PCI 0x43 "things we hacked onto the chip"
until we've done both sets of PIO/DMA timings */
}
/** * optiplus_mode_setup - DMA setup for Firestar Plus * @ap: ATA port * @adev: device * @mode: desired mode * * The Firestar plus has additional UDMA functionality for UDMA0-2 and * requires we do some additional work. Because the base work we must do * is mostly shared we wrap the Firestar setup functionality in this * one
*/
staticvoid optiplus_mode_setup(struct ata_port *ap, struct ata_device *adev, u8 mode)
{ struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 udcfg;
u8 udslave; int dev2 = 2 * adev->devno; int unit = 2 * ap->port_no + adev->devno; int udma = mode - XFER_UDMA_0;
/** * optidma_set_pio_mode - PIO setup callback * @ap: ATA port * @adev: Device * * The libata core provides separate functions for handling PIO and * DMA programming. The architecture of the Firestar makes it easier * for us to have a common function so we provide wrappers
*/
/** * optidma_set_dma_mode - DMA setup callback * @ap: ATA port * @adev: Device * * The libata core provides separate functions for handling PIO and * DMA programming. The architecture of the Firestar makes it easier * for us to have a common function so we provide wrappers
*/
/** * optiplus_set_pio_mode - PIO setup callback * @ap: ATA port * @adev: Device * * The libata core provides separate functions for handling PIO and * DMA programming. The architecture of the Firestar makes it easier * for us to have a common function so we provide wrappers
*/
/** * optiplus_set_dma_mode - DMA setup callback * @ap: ATA port * @adev: Device * * The libata core provides separate functions for handling PIO and * DMA programming. The architecture of the Firestar makes it easier * for us to have a common function so we provide wrappers
*/
/** * optidma_make_bits43 - PCI setup helper * @adev: ATA device * * Turn the ATA device setup into PCI configuration bits * for register 0x43 and return the two bits needed.
*/
/** * optidma_set_mode - mode setup * @link: link to set up * @r_failed: out parameter for failed device * * Use the standard setup to tune the chipset and then finalise the * configuration by writing the nibble of extra bits of data into * the chip.
*/
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.