// 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 * */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/blkdev.h> #include <linux/delay.h> #include <scsi/scsi_host.h> #include <linux/libata.h> #define DRV_NAME … #define DRV_VERSION … enum { … }; static int 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 */ static int optidma_pre_reset(struct ata_link *link, unsigned long 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. */ static void optidma_unlock(struct ata_port *ap) { … } /** * optidma_lock - issue temporary relock * @ap: ATA port * * Re-lock the configuration register settings. */ static void optidma_lock(struct ata_port *ap) { … } /** * 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. */ static void optidma_mode_setup(struct ata_port *ap, struct ata_device *adev, u8 mode) { … } /** * 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 */ static void optiplus_mode_setup(struct ata_port *ap, struct ata_device *adev, u8 mode) { … } /** * 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 */ static void optidma_set_pio_mode(struct ata_port *ap, struct ata_device *adev) { … } /** * 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 */ static void optidma_set_dma_mode(struct ata_port *ap, struct ata_device *adev) { … } /** * 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 */ static void optiplus_set_pio_mode(struct ata_port *ap, struct ata_device *adev) { … } /** * 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 */ static void optiplus_set_dma_mode(struct ata_port *ap, struct ata_device *adev) { … } /** * 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. */ static u8 optidma_make_bits43(struct ata_device *adev) { … } /** * 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. */ static int optidma_set_mode(struct ata_link *link, struct ata_device **r_failed) { … } static const struct scsi_host_template optidma_sht = …; static struct ata_port_operations optidma_port_ops = …; static struct ata_port_operations optiplus_port_ops = …; /** * optiplus_with_udma - Look for UDMA capable setup * @pdev: ATA controller */ static int optiplus_with_udma(struct pci_dev *pdev) { … } static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) { … } static const struct pci_device_id optidma[] = …; static struct pci_driver optidma_pci_driver = …; module_pci_driver(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; MODULE_DEVICE_TABLE(pci, optidma); MODULE_VERSION(…);